Incorrectly formatted external disk on QNAP TS-210
After using QNAP’s web-panel to format external disk, it suddenly turned out that formatting to any partition type ends with extremely small free disk size. For example, completely empty (as should be after format) 1,5 TB disk, formatted to any Windows type (FAT32 / NTFS) has only 1,9 GB free space. Formatting it to any Linux type (Ext3, Ext4) ends with 1,84 GB free space and formatting to HPS+ with 1,89 GB. In all attempts disk has less then 0,2% free space right after format. Here is the solution, that I came up with after a lot of digging.
Warning! This solution assumes that you CAN delete all your partitions and lost all your data on an external disk. As in most cases, when talking about disk formatting. If you have similar problems, but on a disk, that you can’t format, then STOP READING THIS NOW. This solution is not for you!
Login to your QNAP via SSH (i.e. Putty) and type
df. Look into
Mounted on columns to determine device name of your disk.
For example, in case of TS-210 with two external USB disks it was:
filesystem: "/dev/sdt", mounted on "/share/external/sdt" and corresponding to "/share/USBDisk1",
filesystem: "/dev/sds", mounted on "/share/external/sds" and corresponding to "/share/USBDisk2".
Make sure, you’re referencing to a DISK, not one of its partitions! As I figured out, Linux is treating both whole disks and partitions the very same way, mounting them as similar looking shares. You can actually partition a partition under Linux (for example incorrectly using fdisk — pointing it to a mounted partition, not a disk), which would rather be hard under Windows. So, make sure, what mounted device you’re using in following console commands.
For example, a mounted device with a number at its end is most likely a partition, not a whole disk. In above example,
/dev/sds references whole (second) external disk, while
/dev/sds4 corresponds to four partitions on that disk.
fdisk -p /dev/sds
putting your located disk filesystem for “/dev/sds”.
You will probably see a lot of messages suggesting, that partition table is gone, is incorrect or something else has gone wrong. For example:
This doesn’t look like a partition table. Probably you selected the wrong device
Partition X has different physical/logical beginnings / endings (non-Linux?)
Partition table entries are not in disk order
Now we know, that during format using web-panel something gone really wrong.
Again, the disclaimer. This solution assumes that you CAN delete all your partitions and lost all your data on an external disk!
fdisk -d all /dev/sds
to use fdisk to DELETE ALL PARTITIONS on that disk. Again put your disk in place of
fdisk -n 1 /dev/sds
to create one partition (Linux type – ID: 82) covering area of whole disk. Most often used solution for external disks used with QNAP. If you want to create one partition formatted to NTFS type (to be able, for example, to take disk off QNAP and use it with Windows), then type instead:
fdisk -n 1 -z 7 /dev/sds
As NTFS/HPFS partition ID is 7. Look here for detailed list of other partition IDs. And, if you need more partitions or use more flexible options, type
fdisk without parameters, to see available options list.
Then you can (but don’t have to) type:
fdisk -p /dev/sds
again, to see how now your partition table looks like?
During above steps fdisk may report:
Re-reading the partition table failed with error 22: Invalid argument. The kernel still uses the old table. The new table will be used at the next reboot.
Which seems to be self-explanatory. Reboot NAS to complete process.
Notice, that this solution will not always work. I got replies, that it do fixes partition table, but in some cases, disk size still remains incorrect.
This solution is for people, who wants to try to solve mentioned problem using Linux only or if they need to fix Linux-type partition. If you’re dealing with NTFS-type (or FAT32) partition, the fastest way to fix the problem is to plug your external hard drive to any computer running Windows and use Computer Management > Disk Management tool to delete unnecessary partitions and create one, with correct size.