How would you diagnose a situation where disk space is running out?
Asked at
AI answer
First, I’ll check exactly where the space is running out and how urgent the situation is: df -h shows filesystem usage, while df -i shows inode usage. Then I’ll find large directories, for example du -xhd1 /var 2>/dev/null | sort -h, and check logs, temporary files, container images, and other likely sources of growth. If space is not freed after deleting files, I’ll check for processes that are holding deleted files open (lsof +L1). I’ll free space safely: first, I’ll determine the files’ purpose and owner, then use rotation or cleanup according to the service’s rules. After that, I’ll check the metrics, configure alerts, and address the cause of the growth.
Also asked at RWB
- Why did you decide to change jobs / leave your current company?
- What is the key difference between TCP and UDP?
- What is the difference between git merge and git rebase? When should each approach be used?
- What is an inode in Linux?
- Which command is used to determine the route of a packet from your device to the target host?
Similar questions
- A virtual machine’s mounted partition is 100% full, and an alert has been triggered. What would you do, where would you look, and which commands would you use?
- A 20 GB log file was deleted with rm, but the disk space wasn’t freed. Why did that happen?
- A service generates logs. Monitoring shows 50 GB of free disk space, but the application crashes with a “no space left” error. What’s the problem?
- What is LVM used for, and how can you extend a filesystem online?
- How do you check a disk’s SMART status on a Linux server?