The /etc/fstab file makes it possible to automate the mounting of certain filesystems, especially at system start-up. It contains a series of lines describing the filesystems, 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 filesystem;
the mounting options;
the dump utility backup flag;
fsck's (FileSystem ChecK) checking order.
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 those partitions contain the swap keyword. As for the /proc filesystem, we will get back 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 filesystem should not be mounted at start-up 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 and floppy drives. There are other options, and /etc/fstab even has its own man page (fstab(5)).
One of its great advantages is that it simplifies the mount command syntax. To mount a filesystem 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.