linux inode 学习,Linux 文件系统之inode

老师推荐的书是《The Design of the UNIX Operating System》,有压力,每天都觉得自己在欠技术债。

引用阮一峰写的一篇日志,他将对inode的理解写的通俗易懂,点个赞。

inode的内容

[root@chances126 product]# stat hn_dcms.sql

File: "hn_dcms.sql"

Size: 6375968 Blocks: 12456 IO Block: 4096 普通文件

Device: 808h/2056d Inode: 9459975 Links: 1

Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)

Access: 2016-01-29 14:27:19.618772319 +0800

Modify: 2016-01-29 14:26:34.897772357 +0800

Change: 2016-01-29 14:26:34.897772357 +0800

Blocks 占用数目的单位 是什么? Block 还是 sector?

block size 512,分配时4个block 一起分配 一个整数

12456/4=3114

[root@chances126 product]# fdisk -lu /dev/sda8

Disk /dev/sda8: 221.0 GB, 220971663360 bytes

255 heads, 63 sectors/track, 26864 cylinders, total 431585280 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk identifier: 0x00000000

每个sector为512,IO block 为4096

[root@chances126 product]# stat hn_dcms.sql

File: "hn_dcms.sql"

Size: 6375968 Blocks: 12456 IO Block: 4096 普通文件

Device: 808h/2056d Inode: 9459975 Links: 1

Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)

Access: 2016-01-29 14:27:19.618772319 +0800

Modify: 2016-01-29 14:26:34.897772357 +0800

Change: 2016-01-29 14:26:34.897772357 +0800

获取文件对应的inode信息

File sizes/ Sector = 共需多少个Sector

6375968 / 512 = 12453.0625 = 12454

8个sector 为一个block ,因此所需Block为=12454/8=1556.75

虽有偏差,但能大致能对应上,但有个问题:

计算出的 Sector是 12454,查询出的Blocks: 12456 ,还有2个Sector 也就是1024字节 是什么呢?

[root@chances126 product]# debugfs /dev/sda8

debugfs: stat hn_dcms.sql

Inode: 9459975 Type: regular Mode: 0644 Flags: 0x80000

Generation: 2744091751 Version: 0x00000000:00000001

User: 0 Group: 0 Size: 6375968

File ACL: 0 Directory ACL: 0

Links: 1 Blockcount: 12456

Fragment: Address: 0 Number: 0 Size: 0

ctime: 0x56ab061a:d60bad14 -- Fri Jan 29 14:26:34 2016

atime: 0x56ab0647:9386dd7c -- Fri Jan 29 14:27:19 2016

mtime: 0x56ab061a:d60bad14 -- Fri Jan 29 14:26:34 2016

crtime: 0x56ab061a:05e7fc20 -- Fri Jan 29 14:26:34 2016

Size of extra inode fields: 28

EXTENTS:

(0-1556): 38119424-38120980

(0-1556): 38119424-38120980 为文件数据具体在磁盘上的位置

inode 大小

[root@chances126 product]# sudo dumpe2fs -h /dev/sda8 | grep "Inode size"

dumpe2fs 1.41.12 (17-May-2010)

Inode size: 256

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值