How to solve the problem of "insufficient disk space" in Linux
Obviously there is a lot of space available, but the Linux system still prompts that there is no space available. Why? Occasionally, some frustrating and fuzzy error messages appear in Linux, which is one of them. However, such errors are usually caused by several factors.
Check disk space through du and df
Before you start, check whether there is space available on the disk. Although the tools in the desktop environment are also good, the tools on the command line are more direct and better.
Linux Filesystem du
First, let's take a lookdu
Command. Use it to check the mount point directory of the problematic disk. This document assumes that the mount point of the partition is the root directory.
sudodu-sh /
Linux Filesystem df
It takes a little time to traverse all files on the disk. Now let's try again.df
.
sudodf-h
Add the root directory and the mounted file system to the end of this command. For example, if you have an independent disk attached/home
In addition to the root directory, you also need to add it. The total space used should bedu
The command returns a close result. Otherwise, the deleted files may be occupied by the process.
Of course, the main focus here is whether the results of these commands are smaller than the disk size. If it is indeed smaller than the disk size, it is obvious that there are many problems.
Related: Use Agedu to analyze disk space usage
Possible causes
The main reasons for this situation are listed here. If you finddu
Anddf
There are differences between the results, you can directly check the first reason. Otherwise, check from the second reason.
Deleted files are occupied by processes
Sometimes, the file may have been deleted, but some processes are still using it. During a process running, Linux does not release the storage space of the file. You need to find the process and restart it.
Check processes for deleted files
Run the following command to locate the process.
sudolsof/|grep deleted
This should list the problematic process and restart it.
sudosystemctl restart service_name
I node is insufficient
Linux check filesystem inodes
The file system contains metadata called "I node inode", which is used to save information about the file. The number of I nodes in many file systems is fixed, so it is likely that I nodes are exhausted and the file system is not used up yet. You can usedf
To check.
sudodf-i /
Compare the number of I nodes used and the total number of I nodes. If no I node is available, unfortunately, you cannot expand the I node. Delete useless and expired files to release some I nodes.
Ring Block
The last common problem is bad file system blocks. Unless otherwise marked, the operating system may think that these blocks are available, which may cause damage to the file system or hard disk necrosis. It is best to use a tape-cc
Flagfsck
Search and mark these blocks. Remember, you cannot usefsck
Command. You should use live CD.
sudofsck-vcck /dev/sda2
Obviously, you need to replace the disk location in the command with the disk path you want to check. In addition, it may take a long time.
Related: Use fsck to check and fix your file system [Linux]
We hope these solutions can solve your problem. This problem is not so easy to diagnose under any circumstances. However, if you are lucky, you can clean up the file system and make your hard disk work again normally.
Via: https://www.maketecheasier.com/fix-linux-no-space-left-on-device-error/
Author: Nick Congleton Translator: lujun9972 proofreaders: wxy
This article was originally compiled by LCTT and launched with the honor of Linux in China