Linux SSD – Resolve Disk Usage Confusion on Home Partition

disk-usagelinuxssd

Linux Mint tells me, I only have 622 MB free disk space but there should be some gigabytes left.

Looking at the partitions I am told that there are about ten gigabytes unused. I googled the problem and didn't find a solution but I did find the hint that I should check the disk usage with df -h.

sudo df -h /home
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p8  189G  178G  622M 100% /home

The output doesn't make any sense to me: The difference between Size and Used is 11GB, but it only shows 622M as Available.

The SSD isn't old, so I wouldn't expect such a discrepancy.

What should I do?

Best Answer

If the filesystem is ext4, there are reserved blocks, mostly to help handling and help avoid fragmentation and available only to the root user. For this setting, it can be changed live using tune2fs (not all settings can be handled like this when the filesystem is mounted):

-m reserved-blocks-percentage

Set the percentage of the filesystem which may only be allocated by privileged processes. Reserving some number of filesystem blocks for use by privileged processes is done to avoid filesystem fragmentation, and to allow system daemons, such as syslogd(8), to continue to function correctly after non-privileged processes are prevented from writing to the filesystem. Normally, the default percentage of reserved blocks is 5%.

So if you want to lower the reservation to 1% (~ 2GB) thus getting access to ~ 8GB of no more reserved space, you can do this:

sudo tune2fs -m 1 /dev/nvme0n1p8

Note: the -m option actually accepts a decimal number as parameter. You can use -m 0.1 to reserve only about ~200MB (and access most of those previously unavailable 10GB). You can also use the -r option instead to reserve directly by blocks. It's probably not advised to have 0 reserved blocks.

Related Question