You need to check a current disk space usage (or enough free disk space) on your Linux system before you performing any patch update or installing a new application or downloading a large file.
It’s a prerequisites to perform the above tasks, that will help you in many ways. It can be done easily by using df command on Linux.
What’s df Command?
df command stands for Disk Filesystem. It shows detailed report of disk space usage on the Linux system.
It displays the amount of total disk space, available disk space, used disk space, disk used percentage and mounted filesystem on the Linux system.
- du (Disk Usage) Command To Check Disk Usage Of Files and Directories/Folders In Linux
- 3 Easy Ways To Get A Summary Of Disk Usage (Directory & Folders Size) In Linux
- Linux Shell Script To Monitor Disk Space Usage And Send Email
The df command doesn’t show the space available on unmounted file systems.
df command output comes with six fields and each field contains the different information. The details are below.
How to Check File System Disk Space Usage in Linux?
By default, df command displays all mounted filesystems except dummy file systems. This output comes with 1 kilobyte blocks for partition size, which is very difficult to read by users.
# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/vda1 83874816 80545500 3329316 97% / devtmpfs 1929456 0 1929456 0% /dev tmpfs 1940200 0 1940200 0% /dev/shm tmpfs 1940200 197464 1742736 11% /run tmpfs 1940200 0 1940200 0% /sys/fs/cgroup /dev/loop0 3728256 7764 3527776 1% /tmp tmpfs 388040 0 388040 0% /run/user/0
How to Check All Available File System Disk Space Usage in Linux?
It’s same as above but includes dummy filesystems in the output, to do so, add -a
option with df command. These are virtual filesystems, which is used by kernel for different purpose (it’s like proc, sys, etc)
# df -a Filesystem 1K-blocks Used Available Use% Mounted on rootfs - - - - / sysfs 0 0 0 - /sys proc 0 0 0 - /proc devtmpfs 1929456 0 1929456 0% /dev securityfs 0 0 0 - /sys/kernel/security tmpfs 1940200 0 1940200 0% /dev/shm devpts 0 0 0 - /dev/pts tmpfs 1940200 197464 1742736 11% /run tmpfs 1940200 0 1940200 0% /sys/fs/cgroup cgroup 0 0 0 - /sys/fs/cgroup/systemd pstore 0 0 0 - /sys/fs/pstore cgroup 0 0 0 - /sys/fs/cgroup/net_cls,net_prio cgroup 0 0 0 - /sys/fs/cgroup/devices cgroup 0 0 0 - /sys/fs/cgroup/blkio cgroup 0 0 0 - /sys/fs/cgroup/pids cgroup 0 0 0 - /sys/fs/cgroup/cpuset cgroup 0 0 0 - /sys/fs/cgroup/perf_event cgroup 0 0 0 - /sys/fs/cgroup/freezer cgroup 0 0 0 - /sys/fs/cgroup/memory cgroup 0 0 0 - /sys/fs/cgroup/cpu,cpuacct cgroup 0 0 0 - /sys/fs/cgroup/hugetlb configfs 0 0 0 - /sys/kernel/config /dev/vda1 83874816 80545500 3329316 97% / systemd-1 0 0 0 - /proc/sys/fs/binfmt_misc hugetlbfs 0 0 0 - /dev/hugepages debugfs 0 0 0 - /sys/kernel/debug mqueue 0 0 0 - /dev/mqueue /dev/loop0 3728256 7764 3527776 1% /tmp /dev/loop0 3728256 7764 3527776 1% /var/tmp tmpfs 388040 0 388040 0% /run/user/0
How to Check File System Disk Space Usage in Human Readable Format in Linux?
Add -h
option with df command to print the output with human readable format.
# df -h or # df -H Filesystem Size Used Avail Use% Mounted on /dev/vda1 80G 77G 3.2G 97% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 193M 1.7G 11% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/loop0 3.6G 7.6M 3.4G 1% /tmp tmpfs 379M 0 379M 0% /run/user/0
How to Check File System Disk Space Usage with Inode Information in Linux?
To view the filesystem inode usage, use -i
option that will show you inodes usage (used & available) of the filesystem.
How this output help you? Inode usage output can help you when you are getting an error “No space left on device”.
Say for example, you are having enough disk space on your mount point, however, you are getting an above error message. What would be the reason?
You might have used all the allocated inodes in the filesystem.
# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/vda1 15486384 1829165 13657219 12% / devtmpfs 482364 331 482033 1% /dev tmpfs 485050 1 485049 1% /dev/shm tmpfs 485050 594 484456 1% /run tmpfs 485050 16 485034 1% /sys/fs/cgroup /dev/loop0 240960 56 240904 1% /tmp tmpfs 485050 1 485049 1% /run/user/0
How to Check File System Disk Space Usage with Mounted Filesystem Type in Linux?
If you would like to print filesystem types in the df command output, use -T
option.
# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/vda1 xfs 80G 77G 3.2G 97% / devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs tmpfs 1.9G 193M 1.7G 11% /run tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/loop0 ext3 3.6G 7.6M 3.4G 1% /tmp tmpfs tmpfs 379M 0 379M 0% /run/user/0
How to View File System Usage in POSIX Output Format in Linux?
Some times you might get the df command output in the wrong format due to filesystems characters length. I had found this issue in RHEL 6 systems and the details are added below.
To overcome this issue, add -P
option with df command.
# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_2g-lv_root 10G 6.7G 3.4G 67% / tmpfs 7.8G 0 7.8G 0% /dev/shm /dev/sda1 976M 95M 830M 11% /boot /dev/mapper/vg_2g-lv_home 5.0G 4.3G 784M 85% /home /dev/mapper/vg_2g-lv_tmp 4.8G 14M 4.6G 1% /tmp
df command with POSIX Output Format.
# df -hP Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_2g-lv_root 10G 6.7G 3.4G 67% / tmpfs 7.8G 0 7.8G 0% /dev/shm /dev/sda1 976M 95M 830M 11% /boot /dev/mapper/vg_2g-lv_home 5.0G 4.3G 784M 85% /home /dev/mapper/vg_2g-lv_tmp 4.8G 14M 4.6G 1% /tmp
How to Check File System Disk Space Usage Of a Particular Filesystem in Linux?
If you want to print particular filesystem details in the df command output, use the following format.
# df -h / or # df -h /dev/vda1 Filesystem Size Used Avail Use% Mounted on /dev/vda1 80G 77G 3.2G 97% /
How to Check File System Usage Of a Particular Filesystem Type in Linux?
If you want to print particular filesystems type in the df command output, use -t
option with df command.
# df -ht tmpfs or # df -h --type=tmpfs Filesystem Size Used Avail Use% Mounted on tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 193M 1.7G 11% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup tmpfs 379M 0 379M 0% /run/user/0
How to Check File System Disk Space Usage with a Grand Total in Linux?
This option is very helpful when you have larger filesystems in the system. This option gives a grand total of all filesystems. To do so, use --total
option with df command.
# df -h --total Filesystem Size Used Avail Use% Mounted on /dev/vda1 80G 77G 3.2G 97% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 193M 1.7G 11% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/loop0 3.6G 7.6M 3.4G 1% /tmp tmpfs 379M 0 379M 0% /run/user/0 total 92G 78G 15G 85% -
How to Check Only Local File System Disk Space Usage in Linux?
By default, df command print all the mounted filesystems, which includes remote filesystems like nfs, samba, etc. If you would like to display only local filesystem in the df command output, use -l
option.
# df -l Filesystem Size Used Avail Use% Mounted on /dev/vda1 80G 77G 3.2G 97% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 193M 1.7G 11% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/loop0 3.6G 7.6M 3.4G 1% /tmp tmpfs 379M 0 379M 0% /run/user/0