Home / Alt manpages / mount(8)

  • mount(8)
  • Admin command
  • linux

Mount a Linux Filesystem Safely with mount(8)

You will attach a filesystem to a directory, confirm what the kernel actually mounted, and detach it again without guessing which device name is in use. The examples match mount from util-linux 2.41.3, installed on this machine.

Allow about fifteen minutes for a one-off mount, or longer if you are editing /etc/fstab. You need a filesystem that is already created, an empty or disposable mountpoint, and elevated privileges for ordinary system mounts. Do not use a valuable device as a test target.

1. Check the installed command

Start with read-only checks. This confirms the command version and shows the mounted filesystems without changing anything:

$ mount --version
mount from util-linux 2.41.3 (libmount 2.41.3: btrfs, namespaces, idmapping, fd-based-mount, statx, assert, debug)
$ findmnt

The exact feature list can differ between builds. The useful version is the first line. For scripts and more controlled queries, prefer findmnt; the mount manual describes mount's no-argument listing as a compatibility mode.

Checkpoint

You know which mount implementation will run and have not changed the system.

2. Inspect the device and choose a mountpoint

List filesystem types, labels and identifiers before selecting a source. This is an ordinary command and normally needs no root access:

$ lsblk --fs
NAME        FSTYPE FSVER LABEL     UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1
|-nvme0n1p1 vfat   FAT32 EFI       1234-ABCD                              500M     2% /boot/efi
`-nvme0n1p2 ext4   1.0   work      11111111-2222-3333-4444-555555555555    120G    31% /srv/work

Your output will differ. Do not copy the sample UUID. The manual recommends filesystem or partition identifiers because names such as /dev/sda1 can change after hardware changes. Confirm that an identifier is unique on your machine before putting it into configuration.

Create a dedicated mountpoint only when you have decided that the directory may become the root of the mounted filesystem:

$ sudo install -d -m 0755 /mnt/example-disk
$ findmnt --target /mnt/example-disk || true

Mounting hides the directory's previous contents while the mount is active. It does not delete them. If the directory is already a mountpoint, stop and inspect it rather than layering another mount by accident.

3. Mount a filesystem explicitly

Give both the source and target when you want an explicit operation. Here the source is a placeholder UUID, so replace it with an identifier from your own lsblk --fs output:

$ sudo mount UUID=11111111-2222-3333-4444-555555555555 /mnt/example-disk
$ findmnt --target /mnt/example-disk
TARGET             SOURCE      FSTYPE OPTIONS
/mnt/example-disk  /dev/sdX1   ext4   rw,relatime

mount normally detects the filesystem type. Add -t TYPE only when detection is not sufficient or the filesystem needs a specific type, for example sudo mount -t vfat /dev/sdX1 /mnt/example-disk. The displayed source may be the resolved device rather than the UUID you typed.

For a read-only mount, use an explicit option:

$ sudo mount -o ro UUID=11111111-2222-3333-4444-555555555555 /mnt/example-disk
$ findmnt -no SOURCE,FSTYPE,OPTIONS --target /mnt/example-disk
/dev/sdX1 ext4 ro,relatime

Read-only is a useful safety boundary, but it is not a substitute for checking the source. A wrong device can still expose sensitive data to the account that can read the mount.

4. Verify the result before using it

Check the target, source, type and options together. The query is read-only:

$ findmnt --target /mnt/example-disk -o TARGET,SOURCE,FSTYPE,OPTIONS
TARGET             SOURCE      FSTYPE OPTIONS
/mnt/example-disk  /dev/sdX1   ext4   rw,relatime

Then check that the path is accessible:

$ test -r /mnt/example-disk && echo readable
readable
$ df -h -- /mnt/example-disk
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdX1       200G   80G  120G  40% /mnt/example-disk

Do not treat a successful mount exit status as proof that the intended filesystem is present. Compare SOURCE and FSTYPE with your plan. If they are wrong, do not write data there.

5. Add a persistent mount through fstab

Use /etc/fstab when the mount should be available by policy rather than as a temporary manual action. Editing this file is service-affecting and requires root. Make a backup first:

$ sudo cp --preserve=all /etc/fstab /etc/fstab.bak
$ sudoedit /etc/fstab

A typical entry uses the UUID you verified earlier:

UUID=11111111-2222-3333-4444-555555555555 /mnt/example-disk ext4 defaults,nofail 0 2

Here defaults asks for the filesystem's normal default options. nofail changes boot and mount-all behaviour when the device is absent, so use it only when that is what you want. The final fields are the traditional dump and filesystem-check fields; keep values appropriate for the filesystem rather than copying them blindly.

Before asking for every entry to be mounted, test just the new target. Because the entry is in fstab, naming the mountpoint is enough:

$ sudo mount /mnt/example-disk
$ findmnt --target /mnt/example-disk

To test all eligible entries, sudo mount -a mounts entries in fstab except those marked noauto. That can start network mounts and other services, so review the file first. If the test fails, read the error, correct the entry, and use sudo mount -a again only after checking what has already succeeded.

When both a source and target are supplied, mount does not read fstab by default. A one-argument form such as mount /mnt/example-disk does use the table. This difference is a common distraction when a manually supplied option appears not to match an fstab entry.

6. Use a bind mount only for a deliberate second view

A bind mount exposes an existing directory at another path. It does not copy files. This changes the namespace and normally needs root:

$ sudo install -d -m 0755 /mnt/example-view
$ sudo mount --bind /srv/work /mnt/example-view
$ findmnt --target /mnt/example-view -o TARGET,SOURCE,FSTYPE,OPTIONS
TARGET             SOURCE     FSTYPE OPTIONS
/mnt/example-view  /dev/sdX2  ext4   rw,relatime,bind

Writes through either path affect the same underlying files. That makes bind mounts useful for a controlled service view, but unsafe as a pretend backup. If you need a read-only bind view, remount the bind target explicitly and verify the result:

$ sudo mount -o remount,bind,ro /mnt/example-view
$ findmnt --target /mnt/example-view -o TARGET,OPTIONS
/mnt/example-view  ro,relatime,bind

Do not use --rbind casually: it also includes mounts nested below the source. Treat it as a namespace change that deserves a specific reason and a rollback plan.

7. Unmount and recover cleanly

Finish by detaching the target. Check that no shell or process has its current directory inside it:

$ cd /
$ sudo umount /mnt/example-view
$ findmnt --target /mnt/example-view || echo unmounted
unmounted
$ sudo umount /mnt/example-disk
$ findmnt --target /mnt/example-disk || echo unmounted
unmounted

If umount reports that the target is busy, close shells, editors and services using the path, then retry. Do not jump to lazy or forced unmounting merely to silence the error: a service may still be writing, and the result can be surprising. If a mount was created by an fstab entry, remove or correct that entry before the next boot if it should no longer return.

Checkpoint

Both targets are absent from findmnt, and any persistent entry reflects the state you actually want.

Done means

  • You identified the filesystem by a verified UUID or another deliberate source.
  • The mountpoint was checked before mounting, and its hidden contents were understood.
  • findmnt confirmed the target, source, filesystem type and options.
  • Any fstab change was backed up and tested on its named target.
  • Bind mounts were treated as shared access to the same data, not copies.
  • Temporary mounts were unmounted and persistent configuration was left intentional.