How to solve the problem of "insufficient disk space" in Linux

Source: Internet
Author: User

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

  1. sudodu-sh /

Linux Filesystem df

It takes a little time to traverse all files on the disk. Now let's try again.df.

  1. 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/homeIn addition to the root directory, you also need to add it. The total space used should beduThe 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 findduAnddfThere 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.

  1. sudolsof/|grep deleted

This should list the problematic process and restart it.

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

  1. 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-ccFlagfsckSearch and mark these blocks. Remember, you cannot usefsckCommand. You should use live CD.

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.