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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • inode是什么 理解inode,要从文件储存说起。文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"(Sector...
    狗尾巴草败了阅读 3,923评论 0 0
  • 硬盘是由一个个圆形的盘片组全起来的,从物理特性上看,硬盘盘片的转速越快,它的性能就越好,而且我们的磁道越靠外部,它...
    zejin阅读 3,935评论 0 1
  • 一个基本的计算机系统由“硬件”和“软件”组成,一台Linux设备,主要的组成如下图所示: 一般情况下,我们所说的L...
    时待吾阅读 5,609评论 0 16
  • Linux系统一般有4个主要部分:内核、shell、文件系统和应用程序。 内核、shell和文件系统一起形成了基本...
    请爱护小动物阅读 8,032评论 0 22
  • 8.1 认识 ET2文件系统 8.1.1硬盘组成与分区的复习 磁盘的物理组成 (3个物理组成 3个盘片组成 两种磁...
    Leathy阅读 4,631评论 0 0