Issue when viewing the super block in ext3 file system

1

I tried to view the superblock by command "dd" in ext3 file system.

dd if=/dev/sda3 bs=4096 skip=1 count=1 of=superblock

But the result in superblock file is not correct(I compare the value of Inodes count I got from dumpe2fs). The device file /dev/sda3 is started at the boot block and then the superblock of the group0? And another question is the boot block and superblock's size are both BLOCKSIZE(here is 4096)? The disk format of ext2/ext3(I think they are the same) are shown below:

alt text

user29218

Posted 2010-02-23T09:51:54.220

Reputation: 11

Answers

2

Boot block of the ext2/ext3 filesystem is 1024 bytes long, not 4096. Use

  $ sudo tune2fs -l /dev/sda3

to see filesystem parameters as block size, and

  $ sudo dumpe2fs -hx /dev/sda3

to get the superblock. Also

  $ sudo dd if=/dev/sda3 bs=1k skip=1 count=4

will get the superblock.

Diego Torres Milano

Posted 2010-02-23T09:51:54.220

Reputation: 223

0

Thanks for dtmilano's answer. I had already tried it before asking the question. But I think the result is wrong. The problem is I forget to convert the little endian!!

Below I write down my steps for your reference:

$ sudo dd if=/dev/sda3 bs=1k skip=1 count=4

The first line in the superblock is: 0000000: 0000 3a04 fdc4 3904 a616 3600 45f6 fc00 ..:...9...6.E...

So according to the struct ext3_super_block declarision in ext3_fs.h: /00/ __le32 s_inodes_count; /* Inodes count / __le32 s_blocks_count; / Blocks count */

The inodes count is 043a0000 = 70909952 (0000 3a04 should be convert to 043a0000) The blocks count is 0439c4fd = 70894845

It's same as the output from dumpe2fs: Inode count: 70909952 Block count: 70894845

user29218

Posted 2010-02-23T09:51:54.220

Reputation: 11