如何根据文件的inode号查找inode数据

来源:互联网 发布:linux 查询用户权限 编辑:程序博客网 时间:2024/04/29 08:40

1. 根据ls -i 查看文件的inode号

2. 使用debugfs命令查看文件所在磁盘分区的超级块信息

#debugfs /dev/sda2

debugfs: stats

...

Inode count:   5152768

Block count:   20590080

Block size:     4096

Inode size:     256

Inodes per group: 8192

...

Group 11: block bitmap at 360448, inode bitmap at 360449, inode table at 360450

     11878 free blocks, 7687 free inodes, 0 used directories

...


3. 计算特定inode号的inode数据偏移

例如:以90612为例

90612 = 11*8192 + 500           --->  位于11 block group(从0开始编码)

        500 = (4096 / 256 ) * 31 + 4    ---->  block group内的31block的第3个(4-1)inode项


inode数据位置:(360450 + 31 = 360481) 块,偏移为(4-1)*256 = 768


4. 打印inode数据

dd if=/dev/sda2 bs=4096 skip=360481 count=1 2>/dev/null | awk 'BEGIN { LINE=0 } { if (LINE>=(768/16)) print; LINE=LINE+1 }' | xxd


注意:

debugfs的logdump -i <90612>也是用来计算本数据的,但是貌似它默认是按照inode size为128计算的,而本例中inode size为256,所以logdump得出的数据是错误的。


参考资料:

1. http://dengqi.blog.51cto.com/5685776/1351708


0 0
原创粉丝点击