# Linux【6】-硬盘管理3-5-报错No space left on device

1. The block usage on the disk reaches 100%.
2. The inode usage on the disk reaches 100%.
3. Certain disk space is not freed up because there are unreleased file handles.
4. The value of fs.inotify.max_user_watches has been reached.

## 一、100% Block Usage

df -h


If information similar to the following is displayed, the blocks have been used up.

Solution: Expand the capacity of the disk.

## 二、100% Inode Usage

df -i


If information similar to the following is displayed, the inodes have been used up.

Solution: Expand the capacity of the disk.

## 三、Space Occupied by Deleted Files

Run the df -h command to check whether the block usage reaches 100%.

Run the df -i command to check whether the inode usage is relatively low, for example 1%, as shown in the following figure.

Run the du -sh command to view the total disk space used by files. You may notice that there is a significant difference between the usage space and available space.

Solution

Run the following command to list deleted files whose handles are still held open by processes:

lsof |grep delete


Run the following command to stop these processes one by one:

kill -9 Process ID


## 四、inotify Watch Limit Reached

If inotify watches are used up, “No space left on device” will be displayed.

Solution

1.Run the following command to edit the /etc/sysctl.conf file:

vi /etc/sysctl.conf


2.Add the following content to the file:

fs.inotify.max_user_watches = 524288


3.Run the following command for the modification to take effect:

sysctl -p


4.inotify is used to monitor file system events. By default, a maximum of 8192 files can be watched for each real user ID. You can run the following command to obtain the current limit:

cat /proc/sys/fs/inotify/max_user_watches


If the limit is too low to watch all files, increase the limit.