Check disk space in linux using df command


Linux Version & distribution used for this article
[root@localhost workspace]# uname -sr
Linux 2.6.32-279.el6.x86_64

[root@localhost workspace]# cat /etc/redhat-release
CentOS release 6.3 (Final)



1. df  -- It display available file system details like device name, total size, used space and available space

[root@localhost workspace]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_fedo-lv_root
                      18133780   3579124  14370472  20% /
tmpfs                   247288       420    246868   1% /dev/shm
/dev/sda1               495844     33920    436324   8% /boot


2. a  -- include dummy filesystem

[root@localhost workspace]# df -a
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_fedo-lv_root
                      18133780   3591168  14358428  21% /
proc                         0         0         0   -  /proc
sysfs                        0         0         0   -  /sys
devpts                       0         0         0   -  /dev/pts
tmpfs                   247288       420    246868   1% /dev/shm
/dev/sda1               495844     33920    436324   8% /boot
none                         0         0         0   -  /proc/sys/fs/binfmt_misc
vmware-vmblock               0         0         0   -  /var/run/vmblock-fuse
sunrpc                       0         0         0   -  /var/lib/nfs/rpc_pipefs


3. h  -- human readable format. It will display size format as GB, MB, KB

[root@localhost workspace]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_fedo-lv_root
                       18G  3.5G   14G  21% /
tmpfs                 242M  420K  242M   1% /dev/shm
/dev/sda1             485M   34M  427M   8% /boot


4. df -h /  -- Display only certain mount point

[root@localhost workspace]# df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_fedo-lv_root
                       18G  3.7G   14G  22% /

[root@localhost workspace]# df -h /boot
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             485M   34M  427M   8% /boot


5. df -B 512  -- we can change the size of block its displaying. Below example each block has 512 bytes

[root@localhost workspace]# df -B 512
Filesystem         512B-blocks      Used Available Use% Mounted on
/dev/mapper/vg_fedo-lv_root
                      36267560   7636832  28262360  22% /
tmpfs                   494576       864    493712   1% /dev/shm
/dev/sda1               991688     67840    872648   8% /boot


6. df --block-size=512k  -- display block in KB format. here it will show each block is 512kb

[root@localhost workspace]# df --block-size=512k
Filesystem         512K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_fedo-lv_root
                         35418      7458     27600  22% /
tmpfs                      483         1       483   1% /dev/shm
/dev/sda1                  969        67       853   8% /boot


7. m  -- display block size in MB

[root@localhost workspace]# df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/vg_fedo-lv_root
                         17709      3729     13800  22% /
tmpfs                      242         1       242   1% /dev/shm
/dev/sda1                  485        34       427   8% /boot


8. --total -- display the grand total

[root@localhost workspace]# df --total
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_fedo-lv_root
                      18133780   3818416  14131180  22% /
tmpfs                   247288       432    246856   1% /dev/shm
/dev/sda1               495844     33920    436324   8% /boot
total                 18876912   3852768  14814360  21%


9. i  --  list inode information instead of block usage

[root@localhost workspace]# df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/mapper/vg_fedo-lv_root
                     1155072  138135 1016937   12% /
tmpfs                  61822       7   61815    1% /dev/shm
/dev/sda1             128016      40  127976    1% /boot


10. T  -- It will display additionaly filesystem type like ext3, ext4.

[root@localhost workspace]# df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_fedo-lv_root
              ext4    18133780   3818420  14131176  22% /
tmpfs        tmpfs      247288       432    246856   1% /dev/shm
/dev/sda1     ext4      495844     33920    436324   8% /boot


11. t  --  helps to display specific type of file system

[root@localhost workspace]# df -Tt ext4
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_fedo-lv_root
              ext4    18133780   3818412  14131184  22% /
/dev/sda1     ext4      495844     33920    436324   8% /boot


12. x  -- exclude specific type of file system

[root@localhost workspace]# df -Tx ext4
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
tmpfs        tmpfs      247288       432    246856   1% /dev/shm


13. df --help  -- to get df command help information


ENJOY & HAVE FUN WITH LINUX!!!!





No comments:

Post a Comment