In Linux systems, including CentOS 7 distribution, users may encounter a "disk full" warning even though the df
command indicates there is enough free space on the disk. This situation can be perplexing and requires a specific approach to diagnose and resolve. This article provides a comprehensive guide on how to address this issue.
Causes of the Problem
The problem can arise due to several reasons:
-
Exhausted inodes: Linux file systems use inodes to identify files. If all inodes are consumed, the system won't be able to create new files even though there is sufficient free space on the disk.
-
Open-held files: Deleting a file that is still being used by some process will not free up space on the disk until that process is terminated or the file is explicitly closed.
-
Reserved space for root: Ext4 and some other file systems inherently reserve a certain percentage of storage space for the superuser (root), which may lead to a situation where regular users perceive the disk as full while root still has available space.
Diagnosing the Problem
-
Check inode usage: Use the
df -i
command to display inode usage. If theIUse%
column is close to 100%, you will need to delete some files or increase the number of inodes (which usually requires reformatting the disk). -
Find open-held files: To identify files that have been deleted but are still open, you can use the
lsof | grep deleted
command. This will identify the processes holding these files open, and you can restart or terminate them. -
Check reserved space: You can check and adjust reserved space for the root user using the
tune2fs
command. For example,tune2fs -l /dev/sda1 | grep 'Reserved block count'
will show the count of blocks reserved for root. To change this setting, usetune2fs -m 1 /dev/sda1
, where1
is the percentage of disk space reserved.
-
Cleanup: Remove unnecessary files and applications. Use tools like
du
andncdu
to identify large files and directories. -
Adjust inode size: If the problem lies with inodes and you cannot remove any more files, you may need to consider resizing the file system or adding a new partition.
-
Restart services or system: If open-held files are causing issues, restarting the affected services or the entire system may help.
-
Adjust reserved space: If the issue is with reserved space, reducing the percentage of space reserved for root can free up space for other users.
In conclusion, while the "disk full" problem can be confusing, especially when tools indicate sufficient available space, it is usually possible to resolve it through careful diagnosis and using the right tools to address the specific cause.