Why empty drive size differs from available space

Welcome to Programming Tutorial official website. Today - we are going to cover how to solve / find the solution of this error Why empty drive size differs from available space on this date .

I’ve just formatted a 500G disk and mounted it to /data folder.

~ :) df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           795M  748K  795M   1% /run
/dev/xvda2       25G  1.2G   22G   6% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/xvdc1      492G   73M  467G   1% /data
/dev/xvda1      240M   40M  188M  18% /boot
tmpfs           795M     0  795M   0% /run/user/0

As you can see, the available size seems 467G, while the actual disk size is 492G.

Only 73MB is used, but I’ve lost 25GB.

The filesystem is ext4.

Where is my 25G now?


If the filesystem is from the ext family then this fragment of man 8 mke2fs applies:

-m reserved-blocks-percentage

Specify the percentage of the filesystem blocks reserved for the super-user. This avoids fragmentation, and allows root-owned daemons, such as syslogd(8), to continue to function correctly after non-privileged processes are prevented from writing to the filesystem. The default percentage is 5%.

Note 5% of 500G is 25G, everything fits.

The following command will give you two relevant numbers:

tune2fs -l /dev/xvdc1 | grep -E 'Reserved block count|Block size'

Their product is the exact space you “lost” (in bytes).

For rationale see answers to this question: Reserved space for root on a filesystem – why?

To adjust the setting for an existing filesystem use tune2fs -m or tune2fs -r (and possibly tune2fs -u). See man 8 tune2fs. For general data storage filesystem there’s no need to leave any space for root. You can disable the functionality completely by running:

tune2fs -r 0 /dev/xvdc1

After this the output of df -h should be about what you expected.

Leave a Reply

Your email address will not be published. Required fields are marked *