Talking about the inode index node

Abstract: The inode inode is an area in the Unix/Linux file system used to store file meta information, which contains the meta information: file byte number User ID, Group ID file permission, file timestamp, ctime inode last change Time and mtime The time when the contents of the file were last changed.

The inode index node is the file meta information contained in the area used to store the file meta information in the Unix/Linux file system: the

number of bytes in the file, the
user ID , the
group ID
, the permissions of the
file , the timestamp of the file, the ctime the last time the inode changed, and the mtime The last time the file content was changed, the last time the atime file was opened, the number of
links , and how many file names point to
the block location where the inode is stored. To
view inode information, you can use the stat command to view stat +filename
7ad1a4e22e7835c1212a1b1ebd3c4112c5153edf



If the file is abnormal, such as a website being planted Enter advertisements, etc., you can use this command to view the timestamp of the file to determine whether the file has been abnormally tampered with recently. Each inode has a number, which is the unique identifier of the inode. When the system reads the file, the system does not pass "File name" is used to read the file data. The file name is just an alias of "inode". The system finds the corresponding inode number through the file name, then obtains the inode information and finds the corresponding block to read the file data.

To view the inode number, you can use the ls -i command to view it. When the file is abnormal or the file name has special characters that cannot be deleted, you can delete the inode node through the inode number to achieve the purpose of deleting the file. Because each file needs to have an inode, so Sometimes when there is remaining disk storage space, the prompt "No space left on device" is displayed when writing data to the disk. At this time, it is likely that the number of inodes is used up.





To check the inode usage of the disk, you can use the -i parameter of the df command to

specify



the number of inodes in the disk. It is automatically calculated according to the blocksize and bytes/inode of the file.

For example : mkfs.ext3 /dev/xvdb -N 100000 # Format /dev/xvdb The specified number of inodes is



a server running online with 100000. If the number of inodes is not planned for the initial disk , if the above problem occurs, you need to find the problem of consuming inodes. You can

use command find */ ! -type l | cut -d / -f 1 | uniq -c |sort -nr

to list the directories with many files in the current disk

10622ad3c2bb57e1238156e3a04107cb79e9ebbc



Combine the actual business to delete unnecessary files, release a certain inode, and continue to write data

Generally, there is a one-to-one correspondence between file names and inode numbers, but in Unix/Linux systems, multiple file names are allowed to point to the same inode number, that is, hard links (hard links can be understood as different file names point to the same inode number) , The same storage data is modified for hard link files and source files. Modifying data affects all file names. Deleting one file name does not affect other file names. Reading file data can be created by the ln command. In the inode information If there are links, the number will increase by 1 when creating a hard link, otherwise, it will decrease by 1 if the hard link is deleted. The default number of links in a directory file is 2. When a directory is created, two directory entries will be created. "." The inode number is The inode number of the current directory. The ".." inode number is the inode number of the parent directory.



d4e44d91f998ed8c6a3a03d06c86196bae87fce2

9eb7e3ad706c4dee660f2cb01ae397244561af5c





is a relative hard link and a soft link. The inode number of the soft link file is different from that of the source file, but the content of the file is the path of the source file. When accessing the soft link file, the system will lead to the source file. The soft link depends on the source file. If the source file is deleted, the soft link cannot be read. Due to the different inode numbers, if there are a large number of soft links, the number of indoes will be consumed, but the storage space will not be consumed. When a large number of soft links occupy inodes, the file cannot be written, and it is inconvenient to format the disk to adjust the inodes. You can use the following Method to get some inode count:



dd if=/dev/zero of=disk.img count=1024 bs=1024 (create an empty file)

mkfs.ext2 -N 1000000 -b 1024 -I 128 disk.img (format the specified inode )

mount -o loop disk.img /data/dd4inde/ (mount to an empty directory)

f1a6e57d6a8b853a851edb6bb393bd8ba619a22d

af585ca44244d021b75ef9b2512d9d818a9432a3

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326217447&siteId=291194637