-->
Previous Table of Contents Next


device is the physical device that you want to mount; mountpoint is the point in the file system tree where you want it to appear.


NOTE:  The mount command can be used only by superusers. This is to help ensure system security. Several software packages are available that allow users to mount specific file systems, especially floppy disks.

mount accepts several command-line arguments in addition to the two mentioned above (see Table 14.3). If a needed command isn’t given, mount attempts to figure it out from the /etc/fstab file.

Table 14.3 Command-Line Arguments for the mount Command

Argument Description

-f Causes everything to be done except for the actual mount system call. This “fakes” mounting the file system.
-v Verbose mode; provides additional information about what mount is trying to do.
-w Mounts the file system with read and write permissions.
-r Mounts the file system with read-only permission.
-n Mounts without writing an entry in the /etc/mtab file.
-t type Specifies the type of the file system being mounted. Valid types are minux, ext, ext2, xiafs, msdos, hpfs, proc, nfs, umsdos, sysv, and iso9660 (the default).
-a Causes mount to try to mount all file systems in /etc/fstab.
-o list_of_options When followed by a comma-separated list of options, causes mount to apply the options specified to the file system being mounted. Many options are available here; for a complete list, refer to the mount man page.


NOTE:  Several forms of the mount command are very common. For example, the command mount /dev/hdb3 /mnt will mount the hard disk partition /dev/hdb3 under the directory /mnt. Similarly, mount -r -t iso9660/dev/sr0 /mnt mounts the SCSI CD-ROM drive /dev/sr0, which is read-only and of the ISO 9660 file format, under the directory /mnt. And the command mount -vat nfs mounts all the NFS file systems listed in the /etc/fstab file.


TIP:  If a file system doesn’t mount correctly, use the command mount -vf device mountpointv to see what mount is doing. This gives a verbose listing and tells mount to do everything except mount the file system. This way, you can fake out the mount command and get a lot of information about what it’s trying to do.

Mounting File Systems at Boot Time

Under most circumstances, the file systems that your Linux system uses won’t change frequently. For this reason, you can easily specify a list of file systems that Linux mounts when it boots and that it unmounts when it shuts down. These file systems are listed in a special configuration file named /etc/fstab, for file system table.

The /etc/fstab file lists the file systems to be mounted, one file system per line. The fields in each line are separated by spaces or tabs. Table 14.4 lists the different fields in the /etc/fstab file.

Table 14.4 Fields in the /etc/fstab File

Field Description

File system specifier Specifies the block special device or the remote file system to be mounted.
Mount point Specifies the mount point for the file system. For special file systems such as swap files, use the word none, which makes swap files active but not visible within the file tree.
Type Gives the file system type of the specified file system. The following types of file systems are supported:
minix: a local file system supporting filenames of 14 or 30 characters
ext: a local file system with longer filenames and larger inodes (this file system has been replaced by the ext2 file system and should no longer be used)
ext2: a local file system with longer filenames, larger inodes, and other features
xiafs: a local file system
msdos: a local file system for MS-DOS partitions
hpfs: a local file system for OS/2 High Performance File System partitions
iso9660: a local file system used for CD-ROM drives
nfs: a file system for mounting partitions from remote systems
swap: a disk partition or special file used for swapping
umsdos: a UMSDOS file system
sysv: a System V file system
Mount Options A comma-separated list of mount options for the file system. At a minimum, it must contain the type of mount for the file system. See the mount man page for more information on mount options.
Dump Frequency Specifies how often the file system should be backed up by the dump command. If this field isn’t present, dump assumes that the file system doesn’t need to be backed up.
Pass Number Specifies in what order the file systems should be checked by the fsck command when the system is booted. The root file system should have a value of 1. All other file systems should have a value of 2. If a value isn’t specified, the file system won’t be checked for consistency at boot time.


TIP:  It’s recommended that you mount your file systems at boot time via the /etc/fstab file instead of by using the mount command. Remember, only superusers can use mount.

The following is a sample fstab file:


# device       directory     type     options

/dev/hda1      /             ext2     defaults

/dev/hda2      /usr          ext2     defaults

/dev/hda3      none          swap     sw

/dev/sda1      /dosc         msdos    defaults

/proc          /proc         proc     none


Previous Table of Contents Next