In addition to containing loose files, a storage medium may be used to store a whole filesystem, with its own root directory and subdirectories. A filesystem stored in this way can be mounted onto the main filesystem using the mnt(C) command.
Once a filesystem has been mounted on another filesystem, its root directory appears as a subdirectory of the parent filesystem. You can enter the mounted filesystem by using cd, and it looks just like another subdirectory hierarchy, even though it resides on another physical device.
Mounting a filesystem
To mount a CD-ROM filesystem, for example, you must first place the disk in a CD-ROM drive installed on your computer, then use the mnt command. For example:
$ mnt /mntThe /mnt directory is a mount point; when a device is mounted on it that device's root directory appears in the filesystem instead of /mnt. Any files that existed in /mnt before the new filesystem was mounted on it are obscured, although they will be accessible again when the filesystem is unmounted.
Once the CD-ROM is mounted, it appears on the system as a tree of subdirectories, with the root directory of the CD-ROM located in the mount directory /mnt.
The mnt command reads a file called
which contains a list of mountable filesystems. This file also
specifies the name of the device associated with the filesystem (the
bdev keyword) and the absolute pathname of the
filesystem's mount point within the parent filesystem (the
Your system administrator must have added an entry to this file before you can use mnt to mount a CD-ROM. You can examine the contents of /etc/default/filesys with the mnt -t option, as follows:
$Otherwise, use cat(C) to show the contents of /etc/default/filesys, as follows:
mnt -tMount Directory: /apps Block Device: /dev/apps Character Device: /dev/rapps Password required: No Mount if requested: No Fsck if requested: Only if filesystem is dirty Fsck flags: -y Mount at system startup: Yes Fsck at system startup: Only if filesystem is dirty Fsck options: -y Run command before mounting: No Run command after mounting: No
Mount Directory: /private Block Device: /dev/private Character Device: /dev/rprivate Password required: No Mount if requested: Yes Fsck if requested: Only if filesystem is dirty Fsck flags: -y Mount at system startup: Yes Fsck at system startup: Only if filesystem is dirty Fsck options: -y Run command before mounting: No Run command after mounting: No
$For a filesystem to be mountable by a user other than the root user, its /etc/default/filesys entry must contain the command
cat /etc/default/filesys. . . bdev=/dev/apps cdev=/dev/rapps \ mountdir=/apps rcmount=yes \ mount=no fsckflags=-y bdev=/dev/private cdev=/dev/rprivate \
mountdir=/private rcmount=yes \ mount=yes fsckflags=-y
mount=yes. In the example, the filesystem /dev/private is mountable by users while /dev/apps is not.
To unmount a filesystem, use either the umnt(C) command, as follows, or the mnt -u option.
$ umnt /mntYou can also mount a DOS filesystem, allowing the use of DOS files without first copying them into the UNIX filesystem. For details, see ``Using mounted DOS filesystems''.