Product SiteDocumentation Site

3.2. Exercises

3.2.1. Exercise 1

This exercise demonstrates how many bits an inode requires to be located anywhere in a filesystem.
  1. Use dd(1) to write a single (count=1) 4kB block of data (bs=4K) to an offset that's 256 * 1024 blocks (seek=256K) from the start of the file named loop. An offset of 256 * 1024 * 4kB = 1GB, so the resulting file is 1GB plus 4kB in length.
    # dd if=/dev/zero of=loop bs=4K seek=256K count=1 > /dev/null 2>&1
  2. The ls command confirms this, rounded up to the nearest 0.1 of a GB.
    # ls -lh loop
  3. mkfs.xfs is used to write a file system to the loop file and shows that the geometry is using
    • inodes that are 256 bytes in size
    • there are 8 allocation groups
    • block size is 4kB
    # mkfs.xfs -d file=loop loop
  4. Running xfs_db(8) to examine the superblock gives three relevant values for the formatting of inode numbers on this file system.
    • agcount' value of 8 or 23 means that three bits will be needed to specify the AG number.
    • inopblog' value of 4 means that there are 24 or 16 inodes per filesystem block. This makes sense since 16 256 byte inodes can fit in a 4kB filesystem block.
    • agblklog' value of 15 indicates that each AG has 215 filesystem blocks in it. This is expected since the mkfs.xfs output reported an agsize value of 32768 blocks.
    # xfs_db -f -c "sb 0" -c "p" ./loop | egrep 'agcount|inopblog|agblklog'
  5. 1.3 + 4 + 15 = 22 bits of data are required to address an inode placed anywhere in this filesystem