Inode numbers in the partition are blocks 0 and 1. inodeblock

Source: Internet
Author: User

Inode numbers in the partition are blocks 0 and 1. inodeblock
Inode numbers in the partition are block numbers 0 and 1.

 

I believe that when you use Linux, you have encountered accidental deletion of file system data, whether it is accidental deletion or recovery of accidental deletion.

Currently, many recovery tools are usually ext3grep and extundelete.

Of course, this article does not talk about the use of these two tools, but describes what the inode block in each partition is 0 or 1.

 

When using ext3grep and extundelete, there is basically such a step

In Linux, you can run the "ls-id" command to view the inode value of a partition directory. You can enter:

[root@localhost /]#ls –id /2 /[root@steven ~]# ls -id /boot2 /boot

 

We can see that no matter which partition it is, its inode value is 2, not 0, not 1

And when you use the find command to search for inode 0 or 1, nothing can be found.

 find /  -inum 0find: `/proc/1461/task/1461/fd/5': No such file or directoryfind: `/proc/1461/task/1461/fdinfo/5': No such file or directoryfind: `/proc/1461/fd/5': No such file or directoryfind: `/proc/1461/fdinfo/5': No such file or directory

So where is the block where inode is 0 or 1?

 

 

Relationship between boot sector and superblock

When the block is 1024 bytes (1 K:

If the block size is exactly 1024, The boot sector and superblock will each occupy a block, indicating that the boot sector is independent from the superblock.

[Root @ www ~] # Dumpe2fs/dev/hdc1dumpe2fs 1.39 (29-May-2006) Filesystem volume name:/boot ...... (omitted in the middle )....First block:1Block size: 1024 ...... (omitted in the middle )....Group0: (Blocks 1-8192)Primary superblock at 1, Group descriptors at 2-2 Reserved GDT blocks at 3-258 Block bitmap at 259 (+ 258), Inode bitmap at 260 (+ 259) inode table at 261-511 (+ 260) 511 free blocks, 1991 free inodes, 2 directories Free blocks: 5619-6129 Free inodes: 18-2008

Do you see the last special font? The superblock of Group0 starts with block 1.

The above results show that block 0 is reserved for boot sector.

 

When the block is larger than 1024 bytes (2 K, 4 K:

If the block size is greater than 1024, the superblock value is 0!

[Root @ www ~] # Dumpe2fs/dev/hdc2dumpe2fs 1.39 (29-May-2006 ).... (omitted in the middle ).... filesystem volume name:/1 .... (omitted in the middle ).... block size: 4096 .... (omitted in the middle )....Group0: (Blocks 0-32767)PRimary superblock0, Group descriptors at 1-1Reserved GDT blocks at 2-626Block bitmap at 627 (+ 627), Inode bitmap at 628 (+ 628) Inode table at 629-1641 (+ 629) 0 free blocks, 32405 free inodes, 2 directoriesFree blocks: Free inodes: 12-32416

It can be found that the superblock is on the first block (No. 0th), but the superblock actually only has 1024 bytes.

To avoid wasting more space, the first block contains the boot sector and superblock

The above results show that each block occupies 4 K, but the superblock actually only has 1024 bytes.

Therefore, the superblock In the first block only occupies 1024-2047 (if calculated from 0), and 0-1023 is reserved for the boot sector.

The space of the subsequent 2048 bytes is retained.

 

 

Now I understand why the df command is so fast. It reads the information in the superblock where inode of each partition is 0,

Superblock stores the partition file system type, size, used size, and available size.

 

 

 

 

We can use the tune2fs command to view the block size and other information of a partition.

tune2fs -l /dev/sdb1tune2fs 1.41.12 (17-May-2010)Filesystem volume name:   <none>Last mounted on:          <not available>Filesystem UUID:          4814e6f2-6550-4ac5-bf2d-33109fc53061Filesystem magic number:  0xEF53Filesystem revision #:    1 (dynamic)Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isizeFilesystem flags:         signed_directory_hash Default mount options:    (none)Filesystem state:         cleanErrors behavior:          ContinueFilesystem OS type:       LinuxInode count:              65280Block count:              261048Reserved block count:     13052Free blocks:              252525Free inodes:              65269First block:              0Block size:               4096Fragment size:            4096Reserved GDT blocks:      63Blocks per group:         32768Fragments per group:      32768Inodes per group:         8160Inode blocks per group:   510Flex block group size:    16Filesystem created:       Thu Jun  2 12:23:23 2016Last mount time:          Thu Jun  2 12:24:06 2016Last write time:          Thu Jun  2 12:24:06 2016Mount count:              1Maximum mount count:      20Last checked:             Thu Jun  2 12:23:23 2016Check interval:           15552000 (6 months)Next check after:         Tue Nov 29 12:23:23 2016Lifetime writes:          32 MBReserved blocks uid:      0 (user root)Reserved blocks gid:      0 (group root)First inode:              11Inode size:              256Required extra isize:     28Desired extra isize:      28Journal inode:            8Default directory hash:   half_md4Directory Hash Seed:      fad5ad24-52ef-482c-a54b-367a5bb4f122Journal backup:           inode blocks

 

Through the above information, we can know whether superblock is in block 0 or block 1.

Where can the above information be read?

The answer is: superblock.

 

Superblock is so important that the system has also implemented some protection measures for superblock.

The file system has some backup Super blocks. The backup Super blocks are generally created in blocks 8193, 16384, or 32768.

The ext file system manages block partitions in A group. You can see that Blocks per group contains 32768 Blocks.

Each group has a backup superblock. Therefore, the backup super block is generally created on blocks 8193, 16384, or 32768, depending on the block size during formatting.

Tune2fs-l/dev/sda4 | grep group
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Flex block group size: 16
Reserved blocks gid: 0 (group root)

 

 

Note: The tune2fs command cannot be used in non-ext file systems, and the principle and internal format are different from those in ext file systems !!

tune2fs -l /dev/sdb1tune2fs 1.41.12 (17-May-2010)tune2fs: Bad magic number in super-block while trying to open /dev/sdb1Couldn't find valid filesystem superblock.

 

 

 

The above content is applicable to ext file systems. If you are not interested, you are welcome to make a brick.

Part of the reference of laruence article: http://vbird.dic.ksu.edu.tw/linux_basic/0230filesystem_6.php

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.