Inode/hard link/soft link

Source: Internet
Author: User
Tags disk usage inode usage

Different partitions of the following two servers are displayed with different "inode size", one is 128 bytes, and the other is 256 bytes.

CH-HOV-FTP is using ext3 partition format, while WWW server is using ext4 partition format

Bytes --------------------------------------------------------------------------------------------------------------------

CH-HOV-FTP1:/home # DF-k/dev/sda8

Filesystem 1k-blocks used available use % mounted on

/Dev/sda8208784084900 1897716 5%/boot

CH-HOV-FTP1:/home # tune2fs-L/dev/sda8 | grep inode

Inode count: 131648

Inodes per group: 7744

Inode blocks per group: 242

Inode size: 128

CH-HOV-FTP1:/home # DF-I/dev/sda8

Filesystem inodes iused ifree iuse % mounted on

/Dev/sda8 131648 41 131607 1%/boot

CH-HOV-FTP1:/home # tune2fs-L/dev/sda8 | grep "block size"

Block Size: 4096

Bytes ---------------------------------------------------------------------------------------------------------------------

[[Email protected] huxiaoming] # DF-k/dev/sdb1

Filesystem 1k-blocks used available use % mounted on

/Dev/sdb1 2071384 73408 1892752 4%/var/log

[[Email protected] huxiaoming] # tune2fs-L/dev/sdb1 | grep inode

Inode count: 131648

Inodes per group: 7744

Inode blocks per group: 484

Inode size: 256

[[Email protected] huxiaoming] # DF-I/dev/sdb1

Filesystem inodes iused ifree iuse % mounted on

/Dev/sdb1 131648 37 131611 1%/var/log

[[Email protected] huxiaoming] # tune2fs-L/dev/sdb1 | grep "block size"

Block Size: 4096

Bytes ----------------------------------------------------------------------------------------------------------------------

The minimum disk storage unit is "Sector ). Each slice stores 512 bytes. So how can inode be smaller than the smallest sector?

This is a confusing concept: "inode size" and "bytes-per-inode". The inode size here refers to the number of bytes that each inode can contain. For example, photo taking information, modification time, and so on.

The inode-size (-I) Is something different than the bytes-per-inode (-i) Setting. the inode-size determines the size of a single inode, larger inodes can contain in more pointers to blocks, crawling the need for indirect blocks at the cost or increased disk usage. the bytes-per-inode setting sets a ratio that will be used to determine the maximum number of inodes. none of these two values can be changed after the filesystem had been created.

Assume that the size of each inode node in a 1 GB hard disk is 128 bytes, and an inode is set every 1 kb, the size of the inode table will reach 128 MB, accounts for 12.8% of the total disk. if an inode is set for 2 kb in Linux, 2048 bytes may not be used for one inode. This does not mean that the minimum unit of files allocation is 2048 bytes, it only indicates that the percentage of inode table/data area space allocated in ext3 filesystem is 128/2048, that is, 1/16, and that in ext4 is 1/8.

Inode number (Quantity) is the most commonly associated with work. If the design is poor and inode is used up in a partition, a partition may fail to create a new file.

Inode COUNT = file system size/bnpi

1024*1024/8 = 131072 is a 1 GB file system. When inode is divided by 1/8, the default inode quantity is 131072.

Nbpi: the number of bytes per inode. The number of bytes occupied by each inode determines the number of inode in the file system.

In a Linux File System, files with the same inode value are hard-linked files, that is, different file names may have the same inode, and one inode value may correspond to multiple files.

[[Email protected] huxiaoming] # DF-IView inode usage

Filesystem inodes iused ifree iuse % mounted on

/Dev/sda2 640848 7154 633694 2%/

Tmpfs 489727 8 489719 1%/dev/SHM

/Dev/sda1 51200 39 51161 1%/boot

/Dev/sda3 512064 153 511911 1%/home

/Dev/sda5 320000 124 319876 1%/tmp

/Dev/sda6 320000 88238 231762 28%/usr

/Dev/sda7 320000 3509 316491 2%/var

/Dev/sdb1 131648 37 131611 1%/var/log

[[Email protected] huxiaoming] # DF-H

Filesystem size used avail use % mounted on

/Dev/sda2 9.7 GB 398 m 8.8g 5%/

Tmpfs 1.9g 156 K 1.9g 1%/dev/SHM

/Dev/sda1 194 m 34 m 151 m 19%/boot

/Dev/sda3 7.7g 147 M 7.2g 2%/home

/Dev/sda5 4.9g 138 m 4.5g 3%/tmp

/Dev/sda6 4.9g 2.9g 1.7g 64%/usr

/Dev/sda7 4.9g 454 M 4.2g 10%/var

/Dev/sdb1 2.0g 72 m 1.9g 4%/var/log

Bytes ---------------------------------------------------------------------------------------------------------------------

Hard connection: (completed in a single file system-partition)

For example, I create a new/backup folder and make a hard link to/backup/passwd.

We can see that inode is the same

650) This. width = 650; "Title =" Clipboard "style =" border-top: 0px; border-Right: 0px; Background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; padding-Right: 0px; "Border =" 0 "alt =" Clipboard "src =" http://img1.51cto.com/attachment/201408/11/8976580_140777252405Vd.png "Height =" 60 "/>


Here, we delete the important file "ETC/paswd". In fact, only one link is deleted, and the actual block is still there, so we can copy the file back from it.

Is it like snapshot of netapp!

650) This. width = 650; "Title =" Clipboard [1] "style =" border-top: 0px; border-Right: 0px; Background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; padding-Right: 0px; "Border =" 0 "alt =" Clipboard [1] "src =" http://img1.51cto.com/attachment/201408/11/8976580_1407772525J0li.png "Height =" 68 "/>

Bytes ----------------------------------------------------------------------------------------------------------------------

The soft connection is also called symbolic link, which can be understood as a windows shortcut. The shortcut is useless if the source file is deleted.

[[Email protected] ~] # Ln [-SF] source file target file option and parameter:-S: If no parameter is added, the link is hard link. As for-s, it is symbolic link-F: if the target file exists, remove the target file and create it again!

[[Email protected]/] # ln-S/test.txt/backup/

[[Email protected]/] # Cat/backup/test.txt

It's a test file

[[Email protected]/] # Cat/test.txt

It's a test file

650) This. width = 650; "Title =" Clipboard [2] "style =" border-top: 0px; border-Right: 0px; Background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; padding-Right: 0px; "Border =" 0 "alt =" Clipboard [2] "src =" http://img1.51cto.com/attachment/201408/11/8976580_1407772525lVEP.png "Height =" 23 "/>

[[Email protected]/] # rm-F/test.txt

650) This. width = 650; "Title =" Clipboard [3] "style =" border-top: 0px; border-Right: 0px; Background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-Right: 0px; "Border =" 0 "alt =" Clipboard [3] "src =" http://img1.51cto.com/attachment/201408/11/8976580_1407772525ah0c.png "Height =" 31 "/>

[[Email protected]/] # Cat/backup/test.txt

Cat:/backup/test.txt: no such file or directory

The soft connection becomes invalid.

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.