top of page

Posts

How to Check Disk Space




The df command is a command to see how much free disk space is left and manage disk space.

Since a lot of data remains in the disk day by day, if you leave it as it is, the disk will be filled up one day.

Therefore, the df command is useful and important.


df command


Check the disk usage.


# df
Filesystem 	1K-blocks	Used Available Use% Mounted on
devtmpfs      	485716   	0	485716   0% /dev
tmpfs         	503624   	0	503624   0% /dev/shm
tmpfs         	503624 	392	503232   1% /run
tmpfs         	503624   	0	503624   0% /sys/fs/cgroup
/dev/xvda1   	8376300 2864700   5511600  35% /
tmpfs         	100728   	0	100728   0% /run/user/1000


Without any options, the output looks like this.

  • -h option

# df -h
Filesystem  	Size  Used Avail Use% Mounted on
devtmpfs    	475M 	0  475M   0% /dev
tmpfs       	492M 	0  492M   0% /dev/shm
tmpfs       	492M  392K  492M   1% /run
tmpfs       	492M 	0  492M   0% /sys/fs/cgroup
/dev/xvda1  	8.0G  2.8G  5.3G  35% /
tmpfs        	99M 	0   99M   0% /run/user/1000

It displays the details in units of K(KB), M(MB), and G(GB), which makes it easier to find out what is using the data the most.

  • -a option

# df -ah
Filesystem  	Size  Used Avail Use% Mounted on
sysfs          	0 	0 	0	- /sys
proc           	0 	0 	0	- /proc
devtmpfs    	475M 	0  475M   0% /dev
securityfs     	0 	0 	0	- /sys/kernel/security
tmpfs       	492M 	0  492M   0% /dev/shm
devpts         	0 	0 	0	- /dev/pts
tmpfs       	492M  392K  492M   1% /run
tmpfs       	492M 	0  492M   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/devices
cgroup         	0 	0 	0	- /sys/fs/cgroup/net_cls,net_prio
cgroup         	0 	0 	0	- /sys/fs/cgroup/freezer
cgroup         	0 	0 	0	- /sys/fs/cgroup/cpu,cpuacct
cgroup         	0 	0 	0	- /sys/fs/cgroup/memory
cgroup         	0 	0 	0	- /sys/fs/cgroup/pids
cgroup         	0 	0 	0	- /sys/fs/cgroup/perf_event
cgroup         	0 	0 	0	- /sys/fs/cgroup/blkio
cgroup         	0 	0 	0	- /sys/fs/cgroup/hugetlb
cgroup         	0 	0 	0	- /sys/fs/cgroup/cpuset
/dev/xvda1  	8.0G  2.8G  5.3G  35% /
systemd-1      	- 	- 	-	- /proc/sys/fs/binfmt_misc
debugfs        	0 	0 	0	- /sys/kernel/debug
mqueue         	0 	0 	0	- /dev/mqueue
hugetlbfs      	0 	0 	0	- /dev/hugepages
sunrpc         	0 	0 	0	- /var/lib/nfs/rpc_pipefs
tmpfs        	99M 	0   99M   0% /run/user/1000
binfmt_misc    	0 	0 	0	- /proc/sys/fs/binfmt_misc

Displays all the file systems.

  • -T option

# df -Th
Filesystem 	Type  	Size  Used Avail Use% Mounted on
devtmpfs   	devtmpfs  475M 	0  475M   0% /dev
tmpfs      	tmpfs 	492M 	0  492M   0% /dev/shm
tmpfs      	tmpfs 	492M  392K  492M   1% /run
tmpfs      	tmpfs 	492M 	0  492M   0% /sys/fs/cgroup
/dev/xvda1 	xfs   	8.0G  2.8G  5.3G  35% /
tmpfs      	tmpfs  	99M 	0   99M   0% /run/user/1000

Displays file system types.

  • -i option

# df -i
Filesystem  	Inodes IUsed   IFree IUse% Mounted on
devtmpfs    	121429   281  121148	1% /dev
tmpfs       	125906 	1  125905	1% /dev/shm
tmpfs       	125906   346  125560	1% /run
tmpfs       	125906	16  125890	1% /sys/fs/cgroup
/dev/xvda1 	4193216 46429 4146787	2% /
tmpfs       	125906 	1  125905	1% /run/user/1000

Displays inode usages.

  • Specifying a directory

# df TestDir
Filesystem 	1K-blocks	Used Available Use% Mounted on
/dev/xvda1   	8376300 2881132   5495168  35% /

Displays a capacity of “xvda1” inside the specified directory(TestDir).


Summary


I introduced options for the “df” command.

It’s important to keep your eyes on the disk space regularly because if the disk is full, it causes problems with updating or keeping the logs.

So, make sure you check the disk space and organize it before the incidents happen!



This blog post is translated from a blog post written by Asuka Inoue on our Japanese website Beyond Co.

Recent Posts

See All

Comentarios


bottom of page