Next: , Up: Scripts



4.1 File System Setup and Cleanup

Auto-pilot includes a file system setup script, fs-setup.sh, that formats and mounts a file system, and a corresponding script fs-cleanup.sh that later unmounts it. By default, Ext2, Ext3, and Reiserfs are supported, but the scripts are sufficiently extensible to allow other types of file systems to be mounted. The special file system type none bypasses file system setup and cleanup (this can be used if you mount your file system outside of Auto-pilot, but do not want to modify the default scripts).

fs-setup.sh

The file system setup script takes a single argument on the command line, which is the file system type to mount (e.g., ext2 or reiserfs).

Aside from the command line argument, the file system setup script is controlled by several environment variables:

FORMAT
If FORMAT is 1, then the file system is formatted.


FSSIZE
If FSSIZE is set, then the file system is formatted to be FSSIZE bytes. If FSSIZE is not set, then the file system fills the partition. For more reproducible results, you should attempt to set the file-system size to the smallest value that contains your data set (to eliminate large seeks).


TESTDEV
TESTDEV is the device that is used.


TESTDIR
TESTDEV is the directory that the test runs in. This should be a subdirectory of TESTROOT.


TESTROOT
TESTROOT is the directory that the file system is mounted on.

First, TESTROOT and TESTDEV are unmounted using the ap_unmount function. This is designed to prevent previous failed iterations of a test from impacting this iteration. Next, if FORMAT is 1, ap_initfs is called to format the file system. The ap_initfs function takes the file system type as its only argument. It formats TESTDEV with the specified file system time, and uses FSSIZE to determine how many megabytes the file system is. Before executing mkfs, it calls the "mkfsopts" hook. This hook takes four arguments, the file system time, the device, the block size, and the file system size. It prints any additional options to pass to mkfs on stdout. Next, for ext2, ext3, and reiserfs the file system is formatted using mkfs. For other file system types, a mkfs hook is called. The mkfs hook takes the same arguments as mkfsopts, and formats the file system according to the arguments and environment variables. If a mkfs hook is not defined, then ap_initfs fails. After the file system is formatted, a tunefs hook is called with two arguments: the file system type and the device. The tunefs hook can modify file system properties. For example, a tunefs hook can toggle directory indexing on an Ext2 or Ext3 partition.

After the file system is formatted, it is mounted. First, a mount hook is called with arguments of $FSTYPE $TESTDEV $TESTROOT. This hook can perform pre-mount operations, or mount the file system itself. To suppress fs-setup.sh from mounting the file system, the hook can set DOMOUNT to zero. After the mount is completed, a postmount hook is called with the same arguments as the mount hook. Finally, TESTDIR is created if it does not already exist.

fs-cleanup.sh

The file system cleanup script, fs-cleanup.sh, is simpler than the setup script. After loading commonsettings, the unmount hook is called with arguments of $TESTDEV $TESTROOT, and then ap_unmount is called with an argument of TESTROOT.