The /etc/fstab file makes it possible to automate the mounting of certain file systems, especially at system startup. It contains a series of lines describing the file systems, their mount points and other options. Here is an example of an /etc/fstab file:
/dev/hda1 / ext2 defaults 1 1 /dev/hda5 /home ext2 defaults 1 2 /dev/hda6 swap swap defaults 0 0 /dev/fd0 /mnt/floppy auto sync,user,noauto,nosuid,nodev,unhide 0 0 /dev/cdrom /mnt/cdrom auto user,noauto,nosuid,exec,nodev,ro 0 0 none /proc proc defaults 0 0 none /dev/pts devpts mode=0622 0 0 |
the device hosting the filesystem,
the mount point,
the type of file system,
the mounting options,
the dump utility backup flag,
the order of checking by fsck (FileSystem ChecK).
There is always an entry for the root filesystem. The swap partitions are special since they are not visible in the tree structure, and the mount point field for these partitions contains the keyword swap. As to /proc, we will return to it in greater detail in "The /proc filesystem". An other special filesystem is /dev/pts.
Let's get back to the subject. You moved the whole /usr hierarchy to /dev/hdb1 and so you want this partition to be mounted as /usr at boot time. In that case you need to add an entry to the file:
/dev/hdb1 /usr ext2 defaults 1 2 |
There are two special options: noauto and user. The noauto option specifies that the file system should not be mounted at startup but is to be mounted only when you tell it to. The user option specifies that any user can mount and unmount the filesystem. These two options are typically used for the CD-ROM drive and floppy drive. There are other options, and /etc/fstab even has its own man page (fstab(5)).
Not least of the advantages of this file is that it simplifies the mount command syntax. To mount a file system referenced in it, you can either reference the mount point or the device. To mount a floppy disk, you can type:
$ mount /mnt/floppy |
$ mount /dev/fd0 |
delete all files in the /usr directory (i.e. the "old" one, since the "new" one is not yet mounted): rm -Rf /usr/*;
mount the "new" /usr: mount /usr/
and that's it. Now, go back to multiuser mode (telinit 3 or telinit 5), and if there is no further administrative work left, you should now log off the root account.