opscape

Disks and filesystems

mount

Attach a filesystem (a disk partition, image, network share or tmpfs) to a directory, or list what is mounted.

mount [-t TYPE] [-o OPTIONS] SOURCE TARGET | mount [-a] | umount TARGET

4 of 9 examples run in Debian 13.7 on 2026-10-31 · manual: mount(8)

Linux has one directory tree. A filesystem on a disk, USB stick, image file or network server becomes visible only when it is mounted on a directory, its mount point. Whatever that directory contained before is hidden until the filesystem is unmounted again with umount.

mount SOURCE TARGET does the attaching; the type is usually detected, and -o passes options such as ro (read-only), noexec or noatime. /etc/fstab lists what to mount at boot, and mount -a mounts everything in it that is not mounted yet. Mounting and unmounting need root, except for fstab entries marked user.

mount with no arguments lists every mount, but the output is long and hard to read; findmnt shows the same information as a tree, and lsblk shows which devices exist to be mounted.

The examples that mount something are not run: this site's sandbox is a container without the privileges to mount, and it has no spare disks. The ones that do run show listing, the permission error, and a dry run of an fstab file.

Examples

List mounts of one type

mount -t devpts,mqueue
explain
output
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)

-t with no source and target filters the listing by type. Each line reads SOURCE on TARGET type TYPE (OPTIONS).

Mounting as a normal user

mkdir -p /tmp/ram
mount -t tmpfs tmpfs /tmp/ram
outputexit 32
mount: /tmp/ram: must be superuser to use mount.
       dmesg(1) may have more information after failed mount system call.

Mounting needs root. mount exits with 32, its code for "mount failure".

Unmounting as a normal user

umount /dev/shm
explain
outputexit 32
umount: /dev/shm: must be superuser to unmount.

Unmounting needs root too. On a real system, as root, the error you will meet most is "target is busy": some process has a file open or its working directory inside the mount. lsof +f -- /mnt/data or fuser -vm /mnt/data finds it.

Dry-run an fstab with --fake

fstab
/dev/sdb1             /data       ext4   defaults,noatime   0 2
tmpfs                 /tmp        tmpfs  size=2G,mode=1777  0 0
server:/export/home   /mnt/home   nfs    defaults,_netdev   0 0
/dev/sdc1             /backup     ext4   noauto,nofail      0 2
mount --fstab fstab -a --fake -v
explain
output
/data                    : successfully mounted
/tmp                     : successfully mounted
/mnt/home                : successfully mounted
/backup                  : ignored

-a processes every fstab entry, --fake (-f) goes through the motions without calling the kernel, and -v reports each one. --fstab FILE reads an alternative file instead of /etc/fstab. /backup is ignored because of noauto: it is mounted only on request.

Mount a disk partition

sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data

Not run in the sandbox: needs root and a real disk; the sandbox has neither. No output is shown because none was captured.

The filesystem type is detected automatically. Find the partition name with lsblk first. sudo umount /mnt/data detaches it again (note the spelling: umount, no n).

Mount read-only and without executables

sudo mount -o ro,noexec,nosuid /dev/sdb1 /mnt/data
explain

Not run in the sandbox: needs root and a real disk. No output is shown because none was captured.

ro prevents writes (good for inspecting a disk from another machine or recovering data), noexec refuses to run programs from it, nosuid ignores setuid bits. Options are comma-separated without spaces. To change options on something already mounted, add remount: mount -o remount,rw / is the classic fix for a root filesystem that came up read-only.

Mount a disk image or ISO file

sudo mount -o loop,ro debian.iso /mnt/iso
explain

Not run in the sandbox: needs root and loop devices, which the sandbox does not provide. No output is shown because none was captured.

-o loop attaches the file to a loop device first, so a file containing a filesystem can be mounted like a disk. Recent mount versions add loop automatically for regular files.

A filesystem in memory

sudo mount -t tmpfs -o size=512M,mode=1777 tmpfs /mnt/scratch
explain

Not run in the sandbox: needs root (CAP_SYS_ADMIN), which the sandbox does not grant. No output is shown because none was captured.

tmpfs keeps files in RAM (and swap), so it is fast and empties on unmount or reboot. size caps it. The source name tmpfs is arbitrary but conventional.

Make a directory appear in a second place

sudo mount --bind /srv/site/uploads /var/www/uploads
explain

Not run in the sandbox: needs root (CAP_SYS_ADMIN). No output is shown because none was captured.

A bind mount shows the same directory at another path, without symlinks. It is how containers and chroots get selected host directories.

Common pitfalls

  • Mounting over a non-empty directory hides its contents until you unmount; the files are not lost, just invisible. This confuses people who mount over /home or /var.

  • Device names like /dev/sdb1 can change between boots. In /etc/fstab use UUID=... (from lsblk -f) and add nofail for disks that may be absent, or the boot can stop at an emergency shell.

  • After editing /etc/fstab, test with sudo findmnt --verify and sudo mount -a before rebooting.

GNU vs BSD and macOS

The examples above ran the GNU/Linux version. These are the differences that matter on macOS and the BSDs (written from their documentation, not run here).

  • BSD/macOS mount uses -t and -o too, but filesystem type names and options differ, and the fstab format has small differences. On macOS, removable disks are usually mounted with diskutil mount.

Options worth knowing

A selection, described in our own words. For the full list, see mount(8) or mount --help.

OptionWhat it does
-t, --types TYPEFilesystem type, or a list of types to filter the listing.
-o, --options OPTIONSComma-separated mount options (ro, noexec, loop, remount, ...).
-a, --allMount everything in fstab that is not mounted yet.
-r, --read-onlyMount read-only, like -o ro.
-w, --rwMount read-write (the default).
-f, --fakeDo everything except the actual mount (dry run).
-v, --verboseDescribe each action.
-l, --show-labelsWhen listing, include filesystem labels.
-L, --label LABELMount the filesystem with this label.
-U, --uuid UUIDMount the filesystem with this UUID.
-T, --fstab PATHUse an alternative fstab file.
-B, --bindBind-mount a directory at a second location.
-R, --rbindBind-mount a directory and everything mounted below it.
-M, --moveMove a mount to another mount point.
-n, --no-mtabDo not write to /etc/mtab.

Related