How-to

The Linux mount Command: Drives, Options and fstab

Mounting attaches a filesystem to a folder. Do it by hand to test, then write it into /etc/fstab by UUID so it survives every reboot.

What is mounted right now?

findmnt -t ext4,xfs,btrfs,vfat
findmnt /srv
lsblk -f

findmnt prints a clean tree of mounts and can filter by type or path. lsblk -f lists every block device with its filesystem, label, UUID and mount point, so it shows both what is mounted and what is sitting unused. On a machine with two drives, check here which one holds the root filesystem before you touch anything.

How do I mount a drive by hand?

sudo mkdir -p /data
sudo mount /dev/nvme1n1p1 /data
df -hT /data

The folder must exist first. mount detects the filesystem type automatically in most cases; force it with -t xfs if detection fails. If the drive is new and has no filesystem yet, create a partition and format it first with Create a partition in Linux and Format a disk on Linux.

Why should I mount by UUID?

Device names such as nvme1n1 are assigned in the order the kernel finds devices, and that order can change after a firmware or kernel update. A UUID belongs to the filesystem itself and never moves. Get it with:

sudo blkid -s UUID -o value /dev/nvme1n1p1

How do I make a mount permanent?

Add a line to /etc/fstab. The six fields are: what, where, type, options, dump and fsck order.

UUID=4c1e2f6a-91b3-4d0e-a7a2-0f5c8e6d9b21  /data  xfs  defaults,noatime,nofail  0  2

Then test without rebooting:

sudo systemctl daemon-reload
sudo umount /data
sudo mount -a && findmnt /data

mount -a mounts everything in fstab and fails loudly on a typo. Always run it after editing, because a broken fstab line can stop the next boot, and on a remote server with no console that means a reinstall from the panel. findmnt --verify also checks the whole file for mistakes.

Which mount options matter on a server?

OptionEffect
noatimeSkips updating access times on reads; fewer writes, faster
nofailBoot continues if the device is missing; use for every data disk
x-systemd.device-timeout=10sWaits only 10 seconds for a missing device
roRead only
noexec,nosuid,nodevBlocks binaries, setuid and device files; good for upload and temp folders
discardOnline TRIM; usually skip it and rely on the weekly fstrim timer

The fifth field is almost always 0. The sixth is 1 for the root filesystem, 2 for other local filesystems that should be checked at boot, and 0 for network shares and XFS on some setups, since XFS does not use boot time fsck.

What is a bind mount?

A bind mount shows the same directory in a second place. It is useful to move a data folder onto a bigger drive without changing paths in app configs:

sudo rsync -aHAX /var/lib/docker/ /data/docker/
sudo mount --bind /data/docker /var/lib/docker
# fstab line:
/data/docker  /var/lib/docker  none  bind,nofail  0  0

Stop the service before copying and start it after the bind is in place.

How do I mount a network share?

sudo apt install -y nfs-common
sudo mount -t nfs4 -o vers=4.2,_netdev 198.51.100.8:/exports/media /mnt/media

Use _netdev in fstab for any network filesystem, so systemd waits for networking first. For SMB shares the type is cifs and you need the cifs-utils package. Over the public internet, wrap NFS in WireGuard or use SSHFS; plain NFS has no encryption.

How do I unmount when the target is busy?

sudo umount /data
sudo fuser -vm /data
sudo umount -l /data     # lazy, last resort

A busy target means some process has a file open or a shell sits inside the folder. fuser -vm lists them, and lsof command gives more detail. Stop those processes, then unmount. A lazy unmount detaches the folder at once and finishes when the last user leaves; it hides the problem rather than fixing it, so use it rarely.

How do I mount a disk image or ISO file?

sudo mount -o loop,ro /root/rescue-tools.iso /mnt/iso
sudo losetup -fP --show /srv/images/vm-disk.raw
sudo mount /dev/loop3p1 /mnt/vmroot

The loop device turns a file into a block device. -o loop handles that in one step for simple images, while losetup -P also scans the partition table inside the file, so a full VM disk image shows its partitions as loop3p1, loop3p2 and so on. Detach with sudo umount and then sudo losetup -d /dev/loop3 when you are done.

Machines With Two Drives to Mount

ServerProcessorCores / threadsMemoryStorageNetworkPer monthSmallest order
S3Intel Xeon E-2356G6 / 1264 GB DDR42x 1 TB NVMe2x 10 Gbps$80.38$80.38 (1 month)
S5Intel Xeon E-2276G6 / 12128 GB DDR42x 1 TB NVMe2x 10 Gbps$88.72$88.72 (1 month)
D52x Intel Xeon Gold 5315Y16 / 32256 GB DDR42x 2 TB NVMe2x 25 Gbps$305.34$305.34 (1 month)

Keep Reading

Create a partition in Linux

Partition an empty drive on a Linux server with parted, fdisk or sgdisk, using GPT and proper alignment, without risking the system disk.

Open

Format a disk on Linux

Turn the blank second NVMe drive into usable space: identify it, partition with GPT, choose ext4 or XFS, mount by UUID and keep TRIM on.

Open

lsof command

Use lsof to see which process holds a file, a port or a deleted log open, and free disk space without a reboot.

Open

Two-drive mirror (RAID 1)

How RAID 1 keeps a full copy of your data on two drives, which machines have two drives and how to check it with mdadm.

Open

FAQ

Quick Answers

The boot can stop in emergency mode. Test every change with mount -a before rebooting, and add nofail to data disks.

No. Run systemctl daemon-reload and mount -a to apply it now.

mount attaches filesystems; findmnt only lists them, in a clearer format.

Usually not. The fstrim.timer that ships with systemd trims weekly with less overhead.

Run sudo mount -o remount,ro /data. Use rw to switch back.