7.4. The /etc/fstab File

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
A line contains, in 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
Now the partition will be mounted at each boot. It will also be checked if necessary.

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
or:
$ mount /dev/fd0
To finish with our partition moving example: we copied the /usr hierarchy and completed /etc/fstab, in order for the new partition to be mounted at start-up. But for the moment, the old /usr files are still there! We therefore need to delete them to free up space (which was, after all, our initial goal). To do so, you first need to go to single user mode (by issuing the telinit 1 command on the command line), and then:

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.


Tux on Star from MandrakeSoft Linux is a registered trademark of Linus Torvalds. All other trademarks and copyrights are the property of their respective owners.
Unless otherwise stated, all the content of these pages and all images are Copyright MandrakeSoft S.A. and MandrakeSoft Inc. 2002.
http://www.mandrakelinux.com/