Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


medium (thanks to the quality of today’s hard disks, it is almost always empty). This involves the
following steps:



  1. An inode and a data block are reserved and initialized for the root directory. The data block
    contains a file list with three entries:.,..,andlost+found. As this is the root directory, both
    .and..point back to the root inode that represents the root directory.

  2. An inode and a data block are also reserved for thelost+founddirectory, which has only
    two entries:..points back to the root inode and., as usual, points to the inode of the direc-
    tory itself.


Althoughmke2fsis designed for use with block special files, it is possible to use a regular file on a data
medium to create a filesystem. This is because of the ‘‘everything is just a file philosophy‘‘ ofUnixaccord-
ing to which the same routines can be used to handle regular files and block special devices, at least from
the userspace perspective. Using regular files instead of block special files is a very good way of experi-
menting with filesystem structures without having to access existing filesystems with possibly important
data or without having to bother with slow floppy disk drives. For this reason, I briefly discuss the steps
involved below.


First, a file of arbitrary size is created using theddstandard utility.


wolfgang@meitner>dd if=/dev/zero of=img.1440 bs=1k count=1440
1550+0 records in
1440+0 records out

This creates a file with a size of 1.4 MiB, the same capacity as a 3.5-inch floppy disk. The file contains only
zero bytes (with ASCII value 0) generated by/dev/zero.


mke2fsnow creates a filesystem on the file:


wolfgang@meitner>/sbin/mke2fs img.1440
mke2fs 1.40.2 (12-Jul-2007)
img.1440 is not a block special device.
Proceed anyway? (y,n) y
File System label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
184 inodes, 1440 blocks
72 blocks (5.00%) reserved for the super user
First data block=1
Maximum file system blocks=1572864
1 block group
8192 blocks per group, 8192 fragments per group
184 inodes per group
...

The data inimg.1440can be viewed using a hex editor to draw conclusions on the filesystem structure.
odandhexeditare classic examples of such editors, but all distributions include numerous alternatives
ranging from Spartan text-mode tools to sophisticated, user-friendly graphic applications.

Free download pdf