Monday, July 23, 2007

the df command

In linux, one GNU tool that displays information more about partition. It also supports human readable option, which enhance output readability.

The df command only displays information about active non-swap partitions. These can include partitions from other networked systems, mounted devices, and more. Linux version of df cannot show the space available on unmounted filesystems, because on most kinds of systems doing so requires very nonportable intimate knowledge of filesystem structures.


A sample output of df command

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 8.8G 7.6G 54% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
/dev/sda5 9.6G 6.2G 2.9G 69% /dload
/dev/sda1 45G 33G 9.8G 77% /data
/dev/sda2 99M 22M 73M 24% /boot
tmpfs 498M 0 498M 0% /dev/shm
none 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Sample LVM enabled LFS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p2 22G 12G 9.2G 56% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
/dev/cciss/c0d0p3 43G 32G 8.5G 80% /backup
/dev/cciss/c0d0p1 99M 20M 75M 21% /boot
/dev/mapper/VolGroup00_home-LogVol00_home
67G 14G 49G 23% /home
/dev/mapper/VolGroup00_var-LogVol00_var
67G 18G 45G 29% /var
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sample that supports human readable output

# df -ah
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 261M 4.4G 6% /
none 0 0 0 - /proc
none 0 0 0 - /sys
none 0 0 0 - /dev/pts
/dev/sda1 99M 19M 76M 20% /boot
none 505M 0 505M 0% /dev/shm
/dev/sda5 20G 7.4G 11G 41% /home
/dev/sda6 4.9G 1.3G 3.4G 27% /usr
/dev/sda7 37G 8.9G 26G 26% /var
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Issuing the command without any parameters will likely give you similar output:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 17958380 9166384 7865048 54% /
/dev/sda5 9974924 6441384 3018660 69% /dload
/dev/sda1 46362180 33767420 10239636 77% /data
/dev/sda2 101105 22133 73751 24% /boot
tmpfs 509412 0 509412 0% /dev/shm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The output is simple but useful. You can incorporate this command from shell. Or you can issue this command from MRTG/Nagios as well for graphical needs without using additional plugins.

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy