我已安装为/ext2
单独的分区 ( /dev/sda2
),其格式为 ext2,块大小为 1024。debugfs
显示如下:
[root@ /]# ls -ild /ext2
2 drwxr-xr-x. 3 root root 1024 Dec 14 12:33 /ext2
[root@ /]# echo "stat <2>" | debugfs /dev/sda2
debugfs 1.42.9 (28-Dec-2013)
debugfs: stat <2>
Inode: 2 Type: directory Mode: 0755 Flags: 0x0
Generation: 0 Version: 0x00000000
User: 0 Group: 0 Size: 1024
File ACL: 522 Directory ACL: 0
Links: 3 Blockcount: 4
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x5a31ff1f -- Thu Dec 14 12:33:35 2017
atime: 0x5a36657c -- Sun Dec 17 20:39:24 2017
mtime: 0x5a31ff1e -- Thu Dec 14 12:33:34 2017
BLOCKS:
(0):508
TOTAL: 1
在此输出中,我注意到块计数为 4。但目录大小仅为 1024 字节。为什么保留用于包含该 inode 数据的 512 字节块总数等于 4?为什么不是2?
我研究了一些例子,我发现块计数总是要设置为添加 2*块和 2。所以问题是:为什么添加 2?
[root@ ext2]# ls -ilh
total 382K
11 drwx------. 2 root root 12K Dec 14 12:33 lost+found
15 -rw-r--r--. 1 root root 341K Dec 18 20:22 sqlite3.h
14 -rw-r--r--. 1 root root 679 Dec 18 20:08 ulockmgr.h
12 -rw-r--r--. 1 root root 2.0K Dec 18 16:04 values.h
13 -rw-r--r--. 1 root root 17K Dec 18 16:29 xtables.h
[root@ ext2]# echo "stat <15>" | debugfs /dev/sda2
debugfs 1.42.9 (28-Dec-2013)
debugfs: stat <15>
Inode: 15 Type: regular Mode: 0644 Flags: 0x0
Generation: 2356632954 Version: 0x00000001
User: 0 Group: 0 Size: 348618
File ACL: 524 Directory ACL: 0
Links: 1 Blockcount: 690
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x5a37b313 -- Mon Dec 18 20:22:43 2017
atime: 0x5a37b313 -- Mon Dec 18 20:22:43 2017
mtime: 0x5a37b313 -- Mon Dec 18 20:22:43 2017
BLOCKS:
(0-11):1538-1549, (IND):526, (12-15):1550-1553, (16-63):593-640, (64-127):673-736, (128-2
55):769-896, (256-267):2177-2188, (DIND):562, (IND):527, (268-340):2189-2261
TOTAL: 344
区块数 = BLCOCKS*2 + 2 = 344*2 + 2 = 690