How to solve the problem that inode indexing nodes in Linux are full

Source: Internet
Author: User

Today, a Web site for login server found no session after login. According to past experience, generally the space is full cause session file generation failed.

The code is as follows:

Df-h

The code is as follows:

FileSystem Size Used Avail use% mounted on
/dev/mapper/dev01-root 75G 58G 14G 82%/
Udev 2.0G 4.0K 2.0G 1%/dev
Tmpfs 396M 292K 396M 1%/run
None 5.0M 0 5.0M 0%/run/lock
None 2.0G 4.0K 2.0G 1%/RUN/SHM
/DEV/SDA1 228M 149M 68M 69%/boot

Space remaining 14G, you can exclude the space full situation. Another reason for file generation failure is that the file index node Inode is full.

The code is as follows:

Df-i

The code is as follows:

FileSystem                    inodes   iused  ifree iuse% M ounted on
/dev/mapper/dev01-root       4964352 4964352      0  100%/
Udev &nbs P                        503779     440 503339    1%/dev
tmpfs                         506183     353 505830    1%/run
None                     &NBS P    506183       5 506178    1%/run/lock
None           &N Bsp              506183       2 506181    1%/RUN/SHM
/dev/sda 1                     124496     255 124241    1%/b Oot

Inodes occupies 100%, it is the problem.

WORKAROUND: Delete unwanted temporary files and release the Inode.
Find the session temp file with many sess_xxxxx found in the/tmp directory.

The code is as follows:

ls-lt/tmp | Wc-l
4011517

Enter/tmp directory, execute find-exec command

The code is as follows:

sudo find/tmp-type f-exec rm {} \;

If you use RM *, there may be a argument list too long error because there are too many files. In addition to/tmp temporary files, 0-byte files will also occupy the inode and should also be released.
Traverse the search for 0-byte files and delete them.

The code is as follows:

sudo find/home-type f-size 0-exec rm {} \;

After deletion, the usage of inode is reduced to 19%, it can be used normally.

The code is as follows:

Df-i

The code is as follows:

FileSystem inodes iused ifree iuse% mounted on
/dev/mapper/dev01-root 4964352 940835 4023517 19%/
Udev 503779 440 503339 1%/dev
Tmpfs 506183 353 505830 1%/run
None 506183 5 506178 1%/run/lock
None 506183 2 506181 1%/RUN/SHM
/DEV/SDA1 124496 255 124241 1%/boot

PS: What is an inode
In Linux, file lookups are not found by file names. In fact, it is through the inode to achieve the location of the file lookup. We can visualize the inode as a pointer fip. When the file is stored on disk, the file will certainly be stored on a disk location, so imagine, since the file data is stored on disk, if we know the address of the file data, when we want to read and write files, we are not directly using this address to find files on it?
Yes, under Linux, an inode is actually the way to think of an inode as an address that points to the file store on disk. Only this address we generally can not use directly, but through the file name to use indirectly. In fact, the Inode not only contains the address of the file data store, but also contains a lot of information, such as data size, and so on file information. However, the inode does not save the filename. The file name is saved in a directory entry. The file name and Inode are included in each directory entry.

We can look at the relationship between the catalog item, the Inode, and the file data by a graph.

As you can see from the figure above, the directory entry contains the file name and Inode.

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.