Low diskspace

From NixTheWorld

Jump to: navigation, search

Definition

Low diskspace occurs when your disks are running out of space on which to store more data. This happens rather often on many reseller production machines as they are often oversold to make more profit.

Diagnosis

You may find that a disk is low on space when you have troubling creating new files. However, the best way to tell is using the df tool:

[root@server ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              99M   15M   80M  16% /boot
/dev/sda2             2.9G   43M  2.7G   2% /tmp
/dev/sda5             284G   271G  0G  100% /
/dev/sdb1             289G   97M  274G   1% /backup

So, why are we seeing 100% disk-usage when there should still be 13GB free? This is because GNU/Linux by default sets aside a portion of the filesystem to be retained for the root user. By default (at least on CentOS), the amount reserved is set to 5%. You will notice that 271/284=95.4%, thus meaning that there is 4.6% (rounds to 5%) space not used yet.

Solution

So, my explanation about disk-reserve leads us to our last-step, first. The following should only be done if the disk-space-clearing methods mentioned here fail to bring about enough free space. Since modern disks are rather large, and the 5% safety space was instituted back when disks were rarely larger than a few measly GB. As newer drives are generally 80-500GB in size, reserving 4-25GB for root is rather excessive. We can safely reduce this # to ~1% on most modern drives/machine setups.

# tune2fs -m 1 /dev/sda5

Now you will see:

[root@server ~]# df -h /dev/sda5
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5             284G   271G  10G  96% /
Personal tools