I'm doing some research on ext4 filesystem low-level details. Specifically on how block-level data is stored and addressed by inodes.
Getting the information on block sequence addressed by some inode this way:
$ sudo debugfs /dev/nvme0n1p5
$ stat <inode_num>
It looks like directories and regular files has some difference on how blocks are stored:
Directories ( eg /var/log
in my case) has single block entry:
Inode: 6029320 Type: directory Mode: 0775 Flags: 0x80000
Generation: 2262719563 Version: 0x00000000:000021d1
User: 0 Group: 108 Size: 4096
File ACL: 0 Directory ACL: 0
Links: 18 Blockcount: 8
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x5dcc233c:99352690 -- Wed Nov 13 17:37:32 2019
atime: 0x5dcc23c9:7adfbb20 -- Wed Nov 13 17:39:53 2019
mtime: 0x5dcc233c:99352690 -- Wed Nov 13 17:37:32 2019
crtime: 0x5b2ac0de:4e871810 -- Thu Jun 21 00:02:22 2018
Size of extra inode fields: 32
EXTENTS:
(0):24125478
Regular file (/var/log/syslog
) has multiple entries:
Inode: 6029451 Type: regular Mode: 0640 Flags: 0x80000
Generation: 3263261578 Version: 0x00000000:00000001
User: 104 Group: 4 Size: 32009262
File ACL: 0 Directory ACL: 0
Links: 1 Blockcount: 62528
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x5dcc2482:6eb68abc -- Wed Nov 13 17:42:58 2019
atime: 0x5dcc1ce5:1c3a8e0c -- Wed Nov 13 17:10:29 2019
mtime: 0x5dcc2482:6eb68abc -- Wed Nov 13 17:42:58 2019
crtime: 0x5dc28c65:36d636f4 -- Wed Nov 6 11:03:33 2019
Size of extra inode fields: 32
EXTENTS:
(ETB0):24176616, (0):876526, (1-2):894872-894873, (3):894879, (4):894446, (5):893947, (6-7):102005-102006, (8-9):620027-620028, (10):602618, (11):620029, (12-13):626677-626678, (14-15):102036-102037, (16-31):12846176-12846191, (32-63):14649408-14649439, (64-255):13046208-13046399, (256-511):13244672-13244927, (512-1023):13309440-13309951, (1024-2047):1545216-1546239, (2048-4095):14821376-14823423, (4096-6143):9828352-9830399, (6144-7814):15056896-15058566
I could suppose the directory is storing relatively small amount of data (filenames and inodes entries only) so it may benefit a single non-divided block space which is hardly possible with regular file with a lot of data.
What I would like to know is how blocks are addressed in the case of regular file. Isn't it should start from 0
index?
Why block with ETB0
index appears first in the listing? And what is ETB0
meaning in regular file and why it absent in the directory?
User contributions licensed under CC BY-SA 3.0