1 2This is a little C-program that can be used to print out the list 3of blocks used by a requested list of inodes. 4 5For example, to list the blocks referenced by your kernel: 6 7guest_12 % df / 8Filesystem 1K-blocks Used Avail Capacity Mounted on 9/dev/gpt/rootfs 20307196 10707336 7975288 57% / 10 11guest_12 % ls -i /boot/kernel/kernel 12160603 /boot/kernel/kernel 13 14guest_12 % ./prtblknos /dev/gpt/rootfs 160603 15160603: lbn 0-7 blkno 3217584-3217647 16 lbn 8-11 blkno 3217864-3217895 distance 216 17First-level indirect, blkno 3217896-3217903 distance 0 18 lbn 12-19 blkno 3217904-3217967 distance 8 19 lbn 20-75 blkno 3251816-3252263 distance 33848 20 lbn 76-83 blkno 3252368-3252431 distance 104 21 lbn 84-91 blkno 3252464-3252527 distance 32 22 lbn 92-852 blkno 3252896-3258983 distance 368 23 24Each contiguous range of blocks is printed on a line. 25The distance metric is the size of the gap from the end of the 26previous set of blocks to the beginning of the next set of blocks. 27Short distances are desirable. 28 29The logical block numbers (lbn above) describe filesystem-block 30size blocks which by today's default is 32Kb. 31 32The physical block numbers (blkno above) describe the smallest piece 33of disk space that an inode can reference which is a filesystem 34fragment. Since the default size for fragments today is 4Kb, the 35physical block numbers reference 4Kb blocks. The distances listed 36above are also in physical block size units. Thus a distance of 8 37means a separation of just one 32Kb block. For example lbn 11, ends 38at 3217895, the 32Kb first level indirect immediately follows it at 393217896-3217903, and lbn 12 starts distance 8 after lbn 11 immediately 40after the indirect block at 3217904. 41 42If you were to create a filesystem with the fragment size equal to 43half the block size (say 32Kb blocks with 16Kb fragments) then the 44physical block numbers listed would be 16Kb in size. 45 46 Marshall Kirk McKusick 47 January 19, 2018 48