How to troubleshoot disk space issues - linux?
This blog post aims to to discuss how one can get started on identifying disk utilization on a system.
You might have run into situations where some services or applications will not work due to a disk space issue. This is fairly common and the best way to get started is as follows.
Use the command shown below to identify which partition is filled up.
mukul@test_machine:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 7.7G 0 7.7G 0% /dev
tmpfs 1.6G 523M 1.1G 34% /run
/dev/nvme0n1p1 97G 94G 3.4G 97% /
tmpfs 7.7G 4.0K 7.7G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
tmpfs 256M 4.4M 252M 2% /var/lib/sss/db
/dev/nvme1n1 985G 103G 882G 11% /mnt/data
tmpfs 1.6G 0 1.6G 0% /run/user/1432
/dev/loop2 33M 33M 0 100% /snap/amazon-ssm-agent/2996
/dev/loop6 34M 34M 0 100% /snap/amazon-ssm-agent/3552
/dev/loop1 56M 56M 0 100% /snap/core18/2066
/dev/loop3 100M 100M 0 100% /snap/core/11167
/dev/loop4 100M 100M 0 100% /snap/core/11187
/dev/loop5 56M 56M 0 100% /snap/core18/2074
tmpfs 1.6G 0 1.6G 0% /run/user/1833
tmpfs 1.6G 0 1.6G 0% /run/user/1698
tmpfs 1.6G 0 1.6G 0% /run/user/1513
tmpfs 1.6G 0 1.6G 0% /run/user/1650
tmpfs 1.6G 0 1.6G 0% /run/user/1965
tmpfs 1.6G 0 1.6G 0% /run/user/1181
Next, you can change directory to the partition that is taking up the most space, and use the following command.
mukul@test_machine:/$ sudo du -sh *
17M bin
823M boot
4.0K dev
20M etc
669M home
0 initrd.img
0 initrd.img.old
1.7G lib
304K lib64
16K lost+found
4.0K media
103G mnt
2.9G opt
du: cannot access 'proc/25280/task/25283/fdinfo/5': No such file or directory
du: cannot access 'proc/50983/task/50983/fd/4': No such file or directory
du: cannot access 'proc/50983/task/50983/fdinfo/4': No such file or directory
du: cannot access 'proc/50983/fd/4': No such file or directory
du: cannot access 'proc/50983/fdinfo/4': No such file or directory
0 proc
353M root
517M run
14M sbin
0 service
1.3G snap
4.0K srv
0 sys
41M tmp
8.4G usr
79G var
0 vmlinuz
0 vmlinuz.old
14M /
Keep navigating into the biggest directory and use the command above so that you can identify what is eating up all the space. Once you have identified that, you can delete them or discuss with your team on extending partition sizes for your machine. Hope this helps!