Mountpoint

From LQWiki
Jump to navigation Jump to search

Mountpoint is a command which allows you to identify whether a given directory is in fact a mount point or not. A mount point is a directory (preferably an empty one) on which a disk partition can be mounted to make its contents accessible to programs.

Whereas in Windows each partition is an island universe, in Linux all mounted partitions comprise a single file system, organized like a many-branched tree with a common root. This root is the root directory of the partition which has been designated as the root partition. Here the Linux kernel will expect to find all the top-level directories that allow the root partition to function as such.

Other partitions are usually mounted on directories on the root partition, particularly directories that come under the top-level /mnt and /media directories. By convention, the /mnt tree is generally used for occasional mounting of hard drive partitions for administrative purposes, and the /media tree for exchangeable storage devices such as CDs, USB drives and SD-cards, which are often mounted by users.

Mounting a device turns the mount point into a synonym for the root directory of that device. Its child directories become sub-directories of the mount point. If the mount point already contains files, these become invisible for the duration of the mount, but they are not deleted. As soon as the device is unmounted, the original contents of the mount point become accessible again.

To mount a partition or other block device, you use the mount command. This generally needs to be given three pieces of information: the device to be mounted, the mount point and the type of filesystem on the device. Various mount options can also be given. Devices listed in the /etc/fstab file are automatically mounted at boot time (unless given the option noauto). This file also contains the necessary information for mounting those devices which the administrator has decided to make user-mountable. Devices not listed in /etc/fstab can only be mounted by the root user.

You can see which partitions and other devices are mounted at any time, and their mount points, by using the mount command without any arguments. The mountpoint command, with a directory as argument, produces a printed message stating either "directoryname is a mountpoint" or "directoryname is not a mountpoint".