Linux System Administration

Slightly more tedious and complex than adding a disk drive to other microcomputer systems.
The Filesystem Configuration File: /etc/fstab

Here are some sample entries from /etc/fstab from a Linux system:

# device   mount  type  options   dump fsck
/dev/hda2  /      ext2  defaults    1    1
/dev/hdb1  /aux   msdos noauto      1    2
/dev/hda1  none   swap  sw          0    0
/dev/sda1  /chem  ext2  defaults    1    1

The general format for an entry is:

special-file loc type opts
dump-freq pass-number

The fields have the following meanings:

  • special-file: The name of the special file on which the filesystem resides. This must be a block device name.

  • loc: The directory at which to mount the filesystem. If the partition will be used for swapping, use none for this field.

  • type: The kind of partition the entry refers to. The value for local filesystems under Linux is ext2. Other common type values are nfs for volumes mounted remotely via NFS, and swap for swap partitions and ignore, which tells mount to ignore the entry.

  • opts: This field consists of one or more options, separated by commas. The type field, above, determines which options are allowed for any given kind of filesystem. For ignore type entries, this field is ignored. For local filesystems, the options field may include the following keywords, separated by commas:


Read-write filesystem


Read-only filesystem


The SUID access mode is permitted (default)


The SUID access mode is not permitted


Don't automatically mount this filesystem


User quotas may be placed in effect


Group quotas may be placed in effect

  • Multiple options are separated by commas, without intervening spaces. On many systems, the keyword defaults may be placed into this field if no options are needed.

  • If the filesystem type is nfs, many more options are supported (see Chapter 13).

  • dump-freq: A decimal number indicating the frequency with which this filesystem should be backed up by the dump utility. The dump utility is in alpha testing and is not available on most Linux systems, so unless you use dump, you can ignore this field.

  • pass-number: A decimal number indicating the order in which fsck should check the filesystems. A pass-number of 1 indicates that the filesystem should be checked first, 2 indicates that the filesystem should be checked second, and so on. The root filesystem must have a pass-number of 1. All other filesystems should have the same or higher pass numbers. For optimal performance, two filesystems that are on the same disk drive should have different pass numbers; however, filesystems on different drives may have the same pass number, letting fsck check the two filesystems in parallel. fsck will usually be fastest if all filesystems checked on the same pass have roughly the same size. This field should be 0 for swap devices (0 disables checking by fsck).

Viewing and Modifying the Superblock

The tune2fs command may be used to list and alter fields within the superblock of an ext2 filesystem. Here is an example of its display-mode output:

# tune2fs -l /dev/hdb1
Filesystem magic number: 0xEF53
Filesystem state:        clean
Errors behavior:         Continue
Inode count:             13104
Block count:             52208
Reserved block count:    2610
Free blocks:             50528
Free inodes:             13093
First block:             1
Block size:              1024
Fragment size:           1024
Blocks per group:        8192
Fragments per group:     8192
Inodes per group:        1872
Last mount time:         Wed Dec 31 19:00:00 1969
Last write time:         Thu Mar  2 04:19:16 1995
Mount count:             6
Maximum mount count:     20
Last checked:            Thu Mar  7 15:27:34 1996
Check interval:          2592000
Next check after:        Fri Apr  5 16:27:34 1996

The final items in the list concern when fsck will check the filesystem, even if it is clean. The Linux version of fsck for ext2 filesystems will check the filesystem if either the maximum number of mounts without a check has been exceeded or the maximum time interval between checks has expired (20 times and 30 days in the preceding output; the check interval is given in seconds).

tune2fs's -i option may be used to specify the maximum time interval between checks in days, and the -c option may be used to specify the maximum number of mounts between checks. For example, the following command disables the time-between-checks function and sets the maximum number of mounts to 25:

# tune2fs -i 0 -c 25 /dev/hdb1
Setting maximal mount count to 25
Setting interval between check 0 seconds

Another useful option to tune2fs is -m, which allows you to change the percentage of filesystem space held in reserve dynamically.