The cart is empty

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:

  1. 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.

  2. 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.

  3. 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

  1. Check inode usage: Use the df -i command to display inode usage. If the IUse% column is close to 100%, you will need to delete some files or increase the number of inodes (which usually requires reformatting the disk).

  2. 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.

  3. 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, use tune2fs -m 1 /dev/sda1, where 1 is the percentage of disk space reserved.

 

  1. Cleanup: Remove unnecessary files and applications. Use tools like du and ncdu to identify large files and directories.

  2. 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.

  3. Restart services or system: If open-held files are causing issues, restarting the affected services or the entire system may help.

  4. 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.