The mount command mounts a storage device or filesystem, making it accessible and attaching it to an existing directory structure.

The umount command “unmounts” a mounted filesystem, informing the system to complete any pending read or write operations, and safely detaching it.

Syntax

mount [-lhV]

mount -a [-fFnrsvw] [-t vfstype] [-O optlist]

mount [-fnrsvw] [-o option[,option]…] device|dir

mount [-fnrsvw] [-t vfstype] [-o options] device|dir

umount syntax

umount [-hV]

umount -a [-dflnrv] [-t vfstype] [-O options]

umount [-dflnrv] {dir|device}…

Description: mount

All files accessible in Unix, or a Unix-style system such as Linux, are arranged in one big tree: the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command attaches a filesystem, on some device or other, to the file tree. Conversely, the umount command detaches it again.

  • Syntax
  • Examples
  • Related commands
  • Linux commands help

The standard form of the mount command is:

mount -t type device dir

This tells the kernel to attach the filesystem found on device (which is of type type) at the directory dir. The previous contents (if any), owner, and mode of dir become invisible, and as long as this filesystem remains mounted, the pathname dir refers to the root of the filesystem on device.

If only directory or device is given, for example:

mount /dir

then mount looks for a corresponding mountpoint (and then, if not found, for a corresponding device) entry in the /etc/fstab file, and attempts to mount it.

Description: umount

The umount command detaches the specified file system(s) from the file hierarchy. A file system is specified by giving the directory where it was mounted. Giving the special device on which the file system lives may also work, but is an obsolete method, mainly because it fails in case this device was mounted on more than one directory.

Note that a file system cannot be unmounted when it is busy - for example, when there are open files on it, or when some process has its working directory there, or when a swap file on it’s in use. The offending process could even be umount itself - for example, umount opens the common C libraries, which in turn may open (for example) locale files, which, if they are on the device in question, prevents it from being unmounted. A “lazy” unmount (see -l in the umount options section, below) attempts to unmount even if this conflict arises.

Listing Mounts And Getting Help

Three forms of the mount command do not actually mount anything:

mount -h

prints a help message, and exits;

mount -V

prints mount’s version information, and exits;

mount [-l] [-t type]

lists all mounted filesystems (of type type). The option -l adds labels to this listing.

Device Indication

Most devices are indicated by a file name (of a block special device) like /dev/sda1, but there are other possibilities. For example, in the case of an NFS mount, the device name may look like hostname:/dir. It is possible to indicate a block special device using its volume LABEL or UUID (see the -L and -U options below).

The recommended setup is to use “LABEL=

Note that mount uses UUIDs as strings. The UUIDs from command line or fstab are not converted to internal binary representation. The string representation of the UUID should be based on lowercase characters.

The proc filesystem is not associated with a special device, and when mounting it, an arbitrary keyword such as proc can be used instead of a device specification. The customary choice none is less fortunate: the error message “none busy” from umount can be confusing since something is indeed busy.

The Files /etc/fstab, /etc/mtab And /proc/mounts

The file /etc/fstab may contain lines describing what devices are usually mounted where, using which options.

The command

mount -a [-t type] [-O optlist]

causes all filesystems mentioned in fstab (of the proper type and/or having or not having the proper options) to be mounted as indicated, except for those whose line contains the noauto keyword. This command is often included in a boot script. Adding the -F option makes mount fork, so that the filesystems are mounted simultaneously.

When mounting a filesystem mentioned in fstab or mtab, it suffices to give only the device, or only the mount point. The programs mount and umount maintain a list of currently mounted filesystems in the file /etc/mtab. If no arguments are given to mount, this list is printed.

The mount program does not read the /etc/fstab file if both device (or LABEL/UUID) and dir are specified. For example:

mount /dev/foo /dir

If you want to override mount options from /etc/fstab, you have to use:

mount device|dir -o options

and then the mount options from command line is appended to the list of options from /etc/fstab. If there are duplicate options, the usual behavior is that the one occurring last in the command is used.

When the proc filesystem is mounted (at /proc, for instance), the files /etc/mtab and /proc/mounts have very similar contents. The former has somewhat more information, such as the mount options used, but is not necessarily up-to-date (compare with the -n option below). It is possible to replace /etc/mtab by a symbolic link to /proc/mounts. When you have very large numbers of mounts things are much faster with the symlink, but some information is lost that way; in particular, the “user” option fails.

Non-Superuser Mounts

Normally, only the superuser can mount filesystems. However, when fstab contains the user option on a line, anybody can mount the corresponding system.

Thus, given an fstab line

/dev/cdrom /cd iso9660 ro,user,noauto,unhide

any user can mount the iso9660 filesystem found on a CD-ROM, using the command

mount /dev/cdrom

or

mount /cd

By default, only the user that mounted a filesystem can unmount it. If you’d like to allow any user to be able to unmount a user-mount filesystem, use “users” instead of “user” in the fstab line. The “owner” option is similar to the “user” option, with the restriction that the user must be the owner of the special file. This may be useful, for example, for /dev/fd if a login script makes the console user owner of this device. The “group” option is similar, with the restriction that the user must be member of the special file’s owning group.

Bind Mounts

Since Linux 2.4.0, it is possible to remount part of the file hierarchy somewhere else. The call is as follows:

mount –bind olddir newdir

or, using the short option:

mount -B olddir newdir

or as an fstab entry:

/olddir /newdir none bind

After this call the same contents is accessible in two places. One can also remount a single file (on a single file). It’s also possible to use the bind mount to create a mountpoint from a regular directory, for example:

mount –bind foo foo

The bind mount call attaches only (part of) a single filesystem, not possible submounts. The entire file hierarchy including submounts is attached a second place using

mount –rbind olddir newdir

mount -R olddir newdir

Note that the filesystem mount options remains the same as those on the original mount point, and cannot be changed by passing the -o option with –bind/–rbind. The mount options can be changed by a separate remount command, for example:

mount -o remount,ro newdir

Note that behavior of the remount operation depends on the /etc/mtab file. The first command stores the ‘bind’ flag to the /etc/mtab file and the second command reads the flag from the file. If you have a system without the /etc/mtab file or if you explicitly define source and target for the remount command (then mount does not read /etc/mtab), then you have to use bind flag (or option) for the remount command too. For example:

mount -o remount,ro,bind olddir newdir

The Move Operation

Since Linux 2.5.1, it is possible to atomically move a mounted tree to another place. The call is:

mount –move olddir newdir

or shortoption

mount -M olddir newdir

This causes the contents which previously appeared under olddir to be accessed under newdir. The physical location of the files is not changed. Note that the olddir has to be a mountpoint.

Shared Subtree Options

Since Linux 2.6.15 it is possible to mark a mount and its submounts as shared, private, secondary or unbindable. A shared mount provides ability to create mirrors of that mount such that mounts and umounts within any of the mirrors propagate to the other mirror. A secondary mount receives propagation from its primary, but any not vice-versa. A private mount carries no propagation abilities. A unbindable mount is a private mount which cannot be cloned through a bind operation. Detailed semantics is documented in Documentation/filesystems/sharedsubtree.txt file in the kernel source tree.

mount –make-shared mountpoint

mount –make-slave mountpoint

mount –make-private mountpoint

mount –make-unbindable mountpoint

The following commands allows one to recursively change the type of all the mounts under a given mountpoint.

mount –make-rshared mountpoint

mount –make-rslave mountpoint

mount –make-rprivate mountpoint

mount –make-runbindable mountpoint

mount: Command Line Options

The full set of mount options used by an invocation of mount is determined by first extracting the mount options for the filesystem from the fstab table, then applying any options specified by the -o argument, and finally applying a -r or -w option, when present.

Options are as follows:

Options

Some of these options are only useful when they appear in the /etc/fstab file.

  • adfsaffsautofscifscodacoherentcramfsdebugfsdevptsefsextext2ext3ext4fathfshfsplushpfsiso9660jfsminixmsdosncpfsnfsnfs4ntfsprocqnx4ramfsreiserfsromfssquashfssmbfssysvtmpfsubifsudfufsumsdosusbfsvfatxenixxfsxiafs

mount -a -t nomsdos,ext

mount -a -O no_netdev

mount -a -t ext2 -O _netdev

mount LABEL=mydisk -o noatime,nouser

Some of these options could be enabled or disabled by default in the system kernel. To check the current setting see the options in /proc/mounts.

The following options apply to any filesystem that is being mounted (but not every filesystem actually honors them - e.g., the sync option today has effect only for ext2, ext3, fat, vfat and ufs):

The following options apply only to certain filesystems. Here, they are sorted by filesystem. They all follow the -o flag.

mount -o remount,rw /dev/foo /dir

mount -o remount,rw /dir

What options are supported depends on the running kernel. More info is found in the kernel source subdirectory Documentation/filesystems.

Filesystem-Specific mount Options: adfs

Advanced Disc Filing System (“adfs”) is specific to certain RISC operating systems, such as those on the Acorn MOS line of computers.

Mount Options for adfs:

Filesystem-Specific mount Options: affs

Amiga Fast File System (“affs”) is a filesystem used on the Amiga personal computer.

Mount options for affs:

Filesystem-Specific mount Options: devpts

The devpts filesystem is a pseudo-filesystem, traditionally mounted on /dev/pts. To acquire a pseudo terminal, a process opens /dev/ptmx; the number of the pseudo terminal is then made available to the process and the pseudo terminal secondary can be accessed as /dev/pts/.

Mount options for devpts:

Filesystem-Specific mount Options: ext2

ext2, the “second extended file system”, was once the default filesystem of many distributions of Linux, including Debian and Red Hat Linux. It has since largely been replaced by ext3 (see below), but is still widely used, especially on flash-based solid-state media.

Mount options for ext2:

Filesystem-Specific mount Options: ext3

The ext3 filesystem is a version of ext2 that is enhanced with journalling features. It supports all the ext2 mount options listed above, and the following options.

mount /k -o minixdf; df /k; umount /k

Filesystem 1024-blocks Used Available Capacity Mounted on /dev/sda6 2630655 86954 2412169 3% /k

% mount /k -o bsddf; df /k; umount /k

Filesystem 1024-blocks Used Available Capacity Mounted on /dev/sda6 2543714 13 2412169 0% /k

Mount Options for ext3:

Filesystem-Specific mount Options: ext4

The ext4 filesystem is an advanced level of the ext3 filesystem which incorporates scalability and reliability enhancements for supporting large filesystem.

The options journal_dev, noload, data, commit, orlov, oldalloc, [no]user_xattr [no]acl, bsddf, minixdf, debug, errors, data_err, grpid, bsdgroups, nogrpid, sysvgroups, resgid, resuid, sb, quota, noquota, grpquota, and usrquota are backward compatible with ext3 or ext2.

Mount options for ext4:

Filesystem-Specific mount Options: fat

File Allocation Table (“fat”) is a legacy filesystem. Originally designed for use on floppy disks, it is simple and robust, but lacks the advanced features, performance, reliability and scalability of modern filesystems.

fd = open(“foo.new”)write(fd,..)close(fd)rename(“foo.new”, “foo”)

fd = open(“foo”, O_TRUNC)write(fd,..)close(fd).

For many years it was the standard filesystem of Microsoft’s MS-DOS and Windows 9x line of operating systems.

Mount options for fat:

Filesystem-Specific mount Options: hfs

Hierarchical File System (“hfs”) is a proprietary file system for MacOS. As of MacOS X version 10.6, Apple no longer supports writing to HFS volumes, although they can still be mounted as read-only.

Mount options for hfs:

Filesystem-Specific mount Options: hpfs

High Performance File System (“hpfs”) is a filesystem developed by Microsoft and IBM specifically for the OS/2 operating system. It was designed to improve upon the FAT filesystem.

Mount options for hpfs:

Filesystem-Specific mount Options: iso9660

ISO 9660 is a standard describing a filesystem structure to be used on CD-ROMs, and on some DVDs.

Normal iso9660 file names appear in a 8.3 format (i.e., DOS-like restrictions on file name length, where the file name has a maximum of eight characters, a dot, and then a maximum three-character extension), and in addition all characters are in uppercase. Also, there is no field for file ownership, protection, number of links, provision for block/character devices, etc.

“Rock Ridge” is an extension to iso9660 that provides all these Unix-like features. Basically, in iso9660 there are extensions to each directory record that supply all the additional information, and when Rock Ridge is in use, the filesystem is indistinguishable from a normal UNIX filesystem (except that it is read-only).

Mount options for iso9660:

The following options are the same as for vfat and specifying them only makes sense when using discs encoded using Microsoft’s Joliet extensions:

Filesystem-Specific mount Options: jfs

Journaled File System (“jfs”) is a journaled 64-bit file system created by IBM. There are versions for Linux, AIX, and OS/2, among other operating systems.

Mount options for jfs are as follows:

Filesystem-Specific mount Options: ntfs

NTFS is a file system developed by Microsoft for its Windows NT operating system.

Mount options for ntfs:

Filesystem-Specific mount Options: proc

proc (or “procfs”) is a special filesystem on Unix-like operating systems which presents running processes in a hierarchical file-like structure. It is often mounted at the location /proc at boot time.

Mount options for proc:

Filesystem-Specific mount Options: reiserfs

Reiserfs is a general-purpose journaled filesystem. It was the first journaled filesystem supported by the Linux kernel, and was once the default filesystem on SUSE Linux, before ext3 became the default.

Mount options for reiserfs:

Filesystem-Specific mount Options: tmpfs

tmpfs is the name of a temporary file system used on many Unix-like filesystems. It is mounted and structured like a disk-based filesystem, but resides in volatile memory space, similar to a RAM disk. Mount options for tmpfs:

The tmpfs mount options for sizing (size, nr_blocks, and nr_inodes) accept a suffix k, m or g for Ki, Mi, Gi (binary kilo, mega and giga) and can be changed on remount.

Filesystem-Specific mount Options: ubifs

UBIFS is a flash file system which works on top of UBI volumes. Note that atime is not supported and is always turned off.

The device name may be specified as:

An alternative “!” separator may be used instead of “:”.

Mount options for ubifs:

Filesystem-Specific mount Options: udf

udf is the “Universal Disk Format” filesystem defined by the Optical Storage Technology Association, and is often used for DVD-ROM. See also iso9660, above.

Mount options for udf:

Filesystem-Specific mount Options: ufs

ufs is the Unix File System. It is used in many Unix and Unix-like filesystems, and is a descendent of the filesystem used in Version 7 Unix.

Filesystem-Specific mount Options: usbfs

The usbfs filesystem is dynamically generated, similar to proc (see The Loop Device, below). It is used primarily for USB devices on Linux and other Unix-like filesystems.

Mount options for usbfs:

Filesystem-Specific mount Options: vfat

Virtual FAT, or vfat, is closely related to the FAT file system. Options that are valid for fat (see above) are also valid for vfat, except for the “dot” options. Additional options are as follows. Mount options for vfat:

Filesystem-Specific mount Options: xfs

xfs is a 64-bit, journaled filesystem developed by Silicon Graphics, Inc. It was the default filesystem in IRIX for many years, and has also been ported to the Linux kernel. xfs excels at parallel I/O, data consistency, and overall filesystem performance. It is well suited for real-time applications, due to a unique feature that allows it to maintain guaranteed data I/O bandwidth.

Mount options for xfs:

The Loop Device

One further possible type is a mount via the loop device. A loop device is a “pseudo device” which allows a file to be mounted as a filesystem. For example, the command:

mount /tmp/disk.img /mnt -t vfat -o loop=/dev/loop

sets up the loop device /dev/loop3 to correspond to the file /tmp/disk.img, and then mount this device on /mnt.

If no explicit loop device is mentioned (but only an option ‘-o loop’ is given), then mount tries to find some unused loop device and use that; for example:

mount /tmp/disk.img /mnt -o loop

The mount command automatically creates a loop device from a regular file if a filesystem type is not specified or the filesystem is known for libblkid, for example:

mount /tmp/disk.img /mnt

mount -t ext3 /tmp/disk.img /mnt

This type of mount knows about four options, namely loop, offset, sizelimit and encryption, that are really options to losetup. If the mount requires a passphrase, you are prompted for one unless you specify a file descriptor to read from instead with the –pass-fd option. These options can be used in addition to those specific to the filesystem type.

Since Linux 2.6.25 is supported auto-destruction of loop devices and then any loop device allocated by mount is freed by umount independently on /etc/mtab. You can also free a loop device by hand, using ’losetup -d’ or ‘umount -d’.

The following options can be provided when umounting a device with umount:

Return Codes

mount returns one of the following values to indicate what happened during its execution:

Files

mount makes use of the following files:

Examples

mount -t type devicename destination_directory

Mount the device of devicename devicename, of type type, at filesystem location destination_directory.

mount -t iso9660 -o ro /dev/cdrom /mnt

Mount a CD-ROM in the directory /mnt. iso9660 is the standard file system for CD-ROMs, -o ro tells mount to mount it as a read-only filesystem. /mnt must already exist for this command to be successful.

mount

Display all current mounts. Output appears similar to the following:

/dev/loop0 on / type ext4 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) none on /sys/fs/cgroup type tmpfs (rw) none on /sys/fs/fuse/connections type fusectl (rw) none on /sys/kernel/debug type debugfs (rw) none on /sys/kernel/security type securityfs (rw) udev on /dev type devtmpfs (rw,mode=0755) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620) tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755) none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880) none on /run/shm type tmpfs (rw,nosuid,nodev) none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755) /dev/sda3 on /host type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other,blksize=4096) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev) gvfsd-fuse on /run/user/lightdm/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=lightdm)

mount -l -t tmpfs

List all current mounts of type tmpfs. Output resembles the following:

none on /sys/fs/cgroup type tmpfs (rw) tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755) none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880) none on /run/shm type tmpfs (rw,nosuid,nodev) none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)

mount -a

Mount all filesystems listed in the filesystem table file /etc/fstab.

mount -o loop disk1.iso /mnt/disk

Mount the ISO Image file disk1.iso as a loop device (see above) at the directory /mnt/disk. The directory /mnt/disk must already exist for this command to be successful.

eject — Eject removable media.losetup — Set up and control loop devices.