In Unix-like systems, a filesystem becomes accessible by being mounted at a directory—the mount point—within the existing filesystem tree. The root filesystem is mounted by the kernel at / at boot; other filesystems are mounted at chosen empty directories. Once mounted, the contents of the source device or image appear under that directory as if they were always there; when unmounted, the underlying directory returns to its original state.
The mount and umount commands:
sudo mount /dev/sdb1 /mnt # mount by device
sudo mount -t tmpfs -o size=1G tmpfs /mnt/ram # mount tmpfs
sudo mount -o remount,rw / # remount rw
sudo umount /mnt # unmount
mount # show current mounts
findmnt # tree-formatted view
Mount options (noexec, nosuid, nodev, noatime, ro, rw, rsize, soft) control how the kernel handles the filesystem. Recording these in /etc/fstab makes them persistent across reboots. Bind mounts (mount --bind /src /dst) expose one directory at another location, and are used heavily by containers. Mount namespaces give each container its own private view of the mount tree.
Related terms: fstab
Discussed in:
- Chapter 4: The Filesystem Hierarchy — The Root Directory
Also defined in: Textbook of Linux