Linux df command - Monitor Linux hard disk usage

It is important for system administrator to monitor hard disk usage from time to time. This will allow earlier action to be taken if hard disk is going out of space. In Linux, there are two commands that we can use to monitor and check hard disk usage, df command and fdisk command.

Linux df command

The Linux df command reports the amount of disk space used and available on mounted file systems. That means, df command can't show unmounted usb drive such as thumb drive or external hard disk.

With no arguments, df command reports the space used and available on all currently mounted file systems (of all types). Otherwise, df command reports on the file system containing each file name argument.

Here is an example of Linux df command with no option:

luzar@hitam:~$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root             76904380   5329876  67667900   8% /
/dev/sda3             19236340    725080  17534108   4% /usr/local
/dev/sda4             55716572   8929648  43956676  17% /home
/dev/sdb1             40957684  16202484  24755200  40% /fat-d
/dev/sdb5             30716248  10799096  19917152  36% /fat-e
/dev/sdb6             51199120  41318108   9881012  81% /fat-f
/dev/sdb7             51199120  35078560  16120560  69% /fat-g
/dev/sdb8             70115660  30306508  39809152  44% /fat-h
tmpfs                  1034776         0   1034776   0% /dev/shm
luzar@hitam:~$

Here is an example of Linux df command with -a option:

luzar@hitam:~$ df -a
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root             76904380   5329876  67667900   8% /
/proc                        0         0         0   -  /proc
sysfs                        0         0         0   -  /sys
usbfs                        0         0         0   -  /proc/bus/usb
/dev/sda3             19236340    725080  17534108   4% /usr/local
/dev/sda4             55716572   8933312  43953012  17% /home
/dev/sdb1             40957684  16202484  24755200  40% /fat-d
/dev/sdb5             30716248  10799096  19917152  36% /fat-e
/dev/sdb6             51199120  41318108   9881012  81% /fat-f
/dev/sdb7             51199120  35078560  16120560  69% /fat-g
/dev/sdb8             70115660  30306508  39809152  44% /fat-h
tmpfs                  1034776         0   1034776   0% /dev/shm
luzar@hitam:~$

The -a option prints all including dummy file system. Let's try another option, -h.

luzar@hitam:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/root              74G  5.1G   65G   8% /
/dev/sda3              19G  709M   17G   4% /usr/local
/dev/sda4              54G  8.6G   42G  17% /home
/dev/sdb1              40G   16G   24G  40% /fat-d
/dev/sdb5              30G   11G   19G  36% /fat-e
/dev/sdb6              49G   40G  9.5G  81% /fat-f
/dev/sdb7              49G   34G   16G  69% /fat-g
/dev/sdb8              67G   29G   38G  44% /fat-h
tmpfs                1011M     0 1011M   0% /dev/shm
luzar@hitam:~$ 

The df -h command will give output in human readable format. As you can see in the example above, df command prints output in M and G after the size, which represents MB and GB (also K for KB but they are not in my output).

Another option that we can use with df command is -l, which prints only local file system. If you want to check file system type, use df command with -T option like the example below:

luzar@hitam:~$ df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/root     ext3    76904380   5329880  67667896   8% /
/dev/sda3     ext3    19236340    725080  17534108   4% /usr/local
/dev/sda4     ext3    55716572   8951748  43934576  17% /home
/dev/sdb1  fuseblk    40957684  16202484  24755200  40% /fat-d
/dev/sdb5  fuseblk    30716248  10799096  19917152  36% /fat-e
/dev/sdb6  fuseblk    51199120  41318108   9881012  81% /fat-f
/dev/sdb7  fuseblk    51199120  35078560  16120560  69% /fat-g
/dev/sdb8  fuseblk    70115660  30306508  39809152  44% /fat-h
tmpfs        tmpfs     1034776         0   1034776   0% /dev/shm
luzar@hitam:~$  

You probably noticed that the ntfs-3g file system has been detected as fuseblk file system. You must have read about fuse file system before. Fuse is a file system in userspace. The fuseblk file system features including device locking and unlocking, allow sharing file system for multiple mounts, and other extra features.

You can also make df prints only a certain file system type, such as ext3. The right option to use is -t or --type=ext3. See the example below:

luzar@hitam:~$ df --type=ext3
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root             76904380   5329908  67667868   8% /
/dev/sda3             19236340    725080  17534108   4% /usr/local
/dev/sda4             55716572   9114888  43771436  18% /home
luzar@hitam:~$ df -t fuseblk
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdb1             40957684  16202484  24755200  40% /fat-d
/dev/sdb5             30716248  10799096  19917152  36% /fat-e
/dev/sdb6             51199120  41318108   9881012  81% /fat-f
/dev/sdb7             51199120  35078560  16120560  69% /fat-g
/dev/sdb8             70115660  30306508  39809152  44% /fat-h
luzar@hitam:~$

You can use df -x option to exclude a file system type. The -x does the opposite of what -t did. See the example below:

luzar@hitam:~$ df -x fuseblk
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root             76904380   5329924  67667852   8% /
/dev/sda3             19236340    725080  17534108   4% /usr/local
/dev/sda4             55716572   9130472  43755852  18% /home
tmpfs                  1034776         0   1034776   0% /dev/shm
luzar@hitam:~$   

Back to Linux basic commands main page.


Post new comment

The content of this field is kept private and will not be shown publicly.
This blog uses the CommentLuv Drupal plugin which will try and parse your sites feed and display a link to your last post, please be patient while it tries to find it for you.

Custom Search