Linux Mounting Facts

Mounting is the process of making a device accessible to users through the directory tree. The directory to which the device or partition is attached is called the mount point.

  • Volumes are represented by files located in the /dev directory; however, volumes must be mounted before use.
  • A volume is mounted to a directory. When accessing the directory in the file system, you are actually accessing the volume mounted to that directory.
  • Always mount volumes and other storage devices to empty directories. Mounting a volume to a directory that contains data makes the data inaccessible.
  • The /mnt and /media directories (depending on the system configuration) are directories that contain mount points specifically for external storage devices (e.g., CD-ROM drives, floppy drives, magnetic tape drives).

The following files manage and monitor the mounting of file systems:

File Description
/etc/fstab The /etc/fstab file identifies volumes to mount each time the system boots. When the system boots, it automatically mounts the volumes identified in the file. The file contains entries with six fields that control how a device is mounted. A common entry is shown below:

/dev/hda3 /mnt/disk1 ext3 auto,ro,nosuid,users 0 1

The fields in entry are as follows:

  • Device to mount is the path to the device file or the label that describes the volume.
  • Mount point specifies where to mount the device. This is the directory to which the device is attached.
  • file system type specifies the device’s file system type.
  • Options specifies the additional options accepted when mounting the device. Options can be strung together in a comma-separated list. Be aware of the following options:
    • sync reads all I/O files synchronously. (async disables this function.)
    • atime updates the timestamp on file’s inode. (noatime disables this function.)
    • auto allows the volume to be mounted automatically. Use the auto parameter typically with floppy devices.
    • noauto prevents the volume from being mounted automatically. Use this option for removable media.
    • dev allows block files to be read from the volume. (nodev disables this function.)
    • exec allows programs and script files to run from the volume. (noexec disables this function.)
    • owner identifies that only the device owner can mount the volume.
    • ro mounts the volume read only.
    • rw mounts the volume read/write.
    • suid allows the SUID bit to be set on files in the volume. (nosuid disables this function.)
    • user identifies a specific user who can mount the volume.
    • nouser allows only the root user to mount the volume.
    • users allows any user to mount the volume.
    • defaults uses the following default settings: rw, suid, dev, exec, auto, nouser, and async.
  • Dump## is used by the dump command when backing up the file system.
  • Fsck# indicates when to run fsck (file system check) during boot up.
    • 0 = never
    • 1 = only if not unmounted cleanly (Always set for the root partition.)
    • 2 = always
/etc/mtab The /etc/mtab file tracks the currently-mounted volumes on the system.
/procs/mounts The /procs/mounts file contains entries for all currently-mounted volumes on the system. The /proc file system is a virtual file system that contains current system information, including the mounted file systems.

Use the following commands to manage the mounting of file systems:

Use… To… Example
mount /dev/device /mountpoint Mount a volume or device. Common mount options:

  • -a mounts all file systems listed in the /etc/fstab file
  • -r, ro mounts the volume as read only
  • -w, rw mounts the volume as read/write
  • -t specifies the volume type (If you mount an ext3 file system without the -t, the system recognizes it as an ext2 file system)
  • -o loop mounts an ISO file.
mount -a reads the /etc/fstab file and mounts all volumes listed (except those with the noauto parameter)
mount -rt reiserfs /dev/hdc1 /mnt/reis
mounts the hdc1 device with the reiser file system as read only to the /mnt/reis mount point.
mount -t iso9660 /dev/cdrom /media/cdrom mounts the CD-ROM device to the /media/cdrom mount point.
mount -wt vfat /dev/fd0 /mnt/floppy mounts the fd0 device with the vfat file system as read/write to the floppy mount point.
mount View the currently-mounted volumes on the system. This will display the contents of the /etc/mtab file.
df View which file systems are mounted to specific mount points.
umount /device
umount /mountpoint
Unmount a volume or device from the system. If disk is busy is displayed when unmounting a device:

  • Make sure the current working directory is not in that file system.
  • Close any open files located on that file system.
umount /dev/hdc1 unmounts the hdc1 device.
umount /mnt/reis unmounts the device on the /mnt/reis mount point.
umount /dev/cdrom unmounts the CD-ROM device.
umount /mnt/cdrom unmounts the device on the /mnt/cdrom mount point (most likely a CD-ROM device).