Linux – is size on disk so large for a single file

hard drivelinuxwindows 8.1

I've read a couple posts explaining that when you have many small files, the "size on disk" reported by windows can be much larger than the reported "size". This makes good sense to me, but from what I can tell, the "cluster size" or "allocation unit" is typically 4 kB, which (if I understand the argument right) means that a single file should not be more than 4 kB bigger in the "size on disk" metric.

I have a tiff image that is reportedly 65 kB in "size", but 1.00 MB when measured as "size on disk". What could the cause of this big discrepancy be?

Update: I realize now that the file is on a NAS drive that runs Linux. I checked the allocation unit size and it is just 4 kB, not 1 MB, for example:

bash-3.2# /sbin/blockdev --getbsz /dev/sda1


I also checked a file that has "size" 1 kB and it shows up as 1.00 MB under "size on disk".

Best Answer

  • Data (files are binary data) on disks are saved in clusters. That's the way hard disk drives work. In this example clusters that are 4kb in length. There are options to format disks in smaller allocation units.

    To be rough, think of clusters as 4kb slots that are ready to store binary data. If a file is bigger than 4kb it will take extra slots. If it is smaller, it would take exactly one slot.

    For example, consider a file that is 5kb. Since it won't fit into a single cluster, an extra one will be used. Thus disk size would be 8kb, even if the file is actually 5kb in size.

    Try creating a small file (less than 4kb) and see that its disk size is exactly 4kb.