Why are partition size and df output different?

I have a partition /dev/sda1.
Disk utility shows it has the capacity of 154 GB.
df -h shows

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             123G  104G   14G  89% /
devtmpfs             1006M  280K 1006M   1% /dev
none                 1007M  276K 1006M   1% /dev/shm
none                 1007M  216K 1006M   1% /var/run
none                 1007M     0 1007M   0% /var/lock
none                 1007M     0 1007M   0% /lib/init/rw

Why are the results different? Where are the missing 31 GB?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

One reason the partition capacities can differ is that some space is reserved for root, in the event the partitions become full. If there is no space reserved for root, and the partitions become full, the system cannot function. However, this difference is usually of the order of 1%, so that does not explain the difference in your case. From the man page for df

If an argument is the absolute file
name of a disk device node containing
a mounted file system, df shows the
space available on that file system
rather than on the file system
containing the device node (which is
always the root file system).

So df is really showing the size of your filesystem, which is usually the size of the device, but this may not be true in your case. Does your filesystem extend over the whole of your partition?

Does

resize2fs /dev/sda1

make any difference? This command tries to increase your filesystem to cover the entire partition. But make sure you have a backup if you try this.

Method 2

The main difference is because some things say 1 kilobyte is 1000 bytes, and others say 1 kilobyte is 1024 bytes.

Gnome Disk Utility shows the capacity using 1 kilobyte = 1000 bytes, because disk manufacturers describe disk sizes this way. This means your disk capacity is close to 154,000,000,000 bytes.

On the other hand, most operating systems say 1 kilobyte = 1024 bytes. All the tools like df and fdisk use this convention. So 154,000,000,000 bytes / 1024 / 1024 / 1024 = 143.4 GB.

As jlliagre rightly points out (and Gilles implies when asking for your fdisk output), disk utility is telling you the size of your whole hard disk. But /dev/sda1 is a single partition on your hard disk. For example, your hard disk probably has some other partitions on it such as a 4-8 GB partition for swap (also known as virtual memory), and a boot partition which is usually around 100 MB.

You didn’t post the output of fdisk -l /dev/sda, so let’s assume your swap partition is 8 GB. Now we’re down to 135 GB.

Then, there are some other things that contribute to the difference.

For example, the file system uses some of the disk partition for metadata. Metadata is things like file names, file permissions, which parts of the partition belong to which files, and which parts of the partition are free. On my system, about 2% of the partition is used for this. Assuming yours is similar, it would bring the free space down to about 132 GB.

The file system can also reserve some space that can only be used by the root user. On my system, it’s 5% of the partition, so in your case, it would mean a total capacity of about 125 GB.

The exact numbers depend on whether you are using ext2, ext3, ext4, fat, ntfs, btrfs, etc, and what settings were used when formatting the partition.

If you are using ext2 or ext3, sudo tune2fs -l /dev/sda1 can help understand where the space is going.

Method 3

Probably they are used by inodes. Some amount may be used up by MBR.

Method 4

sda1 isn’t your whole disk but its first primary partition. You might have created other unmounted partitions that do not show up in df output or simply have sda1 not filling all usable space for some reason or having the filesystem not using all available space in its partition.

fdisk -l will tell you what your partition table looks like.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments