In Linux, storage isn’t a drive letter. A filesystem is mounted onto a directory, its mount point, and becomes part of the single directory tree. mount attaches filesystems and umount detaches them. You’ll use them when adding a disk, attaching network storage or rescuing a system.
See what’s mounted
findmnt # tree view, the clearest
findmnt /var/www # which filesystem holds this path
df -hT # mounted filesystems with sizes and types
lsblk -f # block devices, filesystems and mount points
mount | column -t # the classic listing (long)
See lsblk and blkid.
Mount a disk partition
sudo mkdir -p /mnt/data
sudo mount /dev/vdb1 /mnt/data
mount detects the filesystem type automatically. To specify it, use -t ext4 or -t xfs.
Prefer UUIDs to device names. /dev/vdb can become /dev/vdc after adding disks:
sudo blkid /dev/vdb1
sudo mount UUID=3f1c… /mnt/data
A new, empty disk must be partitioned and formatted first. See fdisk and mkfs.
Unmount
sudo umount /mnt/data # by mount point (or device)
Note the spelling: umount, not “unmount”.
“target is busy”
umount: /mnt/data: target is busy.
A process has files open there, or a shell has its current directory inside it (often your own). Find it:
sudo lsof +f -- /mnt/data
sudo fuser -vm /mnt/data
cd out, stop the service, then unmount. As a last resort, umount -l (lazy) detaches the filesystem now and finishes cleaning up when it’s no longer busy.
Mount options
sudo mount -o ro /dev/vdb1 /mnt/data # read-only
sudo mount -o remount,rw / # make root writable again (rescue)
sudo mount -o noexec,nosuid,nodev /dev/vdc1 /srv/uploads
| Option | Effect |
|---|---|
ro / rw |
Read-only / read-write |
noexec |
Don’t allow running binaries from this filesystem |
nosuid |
Ignore setuid/setgid bits |
nodev |
Ignore device files |
noatime |
Don’t update access times (less disk I/O) |
defaults |
rw, suid, dev, exec, auto, nouser, async |
remount |
Change options of a mounted filesystem without unmounting |
noexec,nosuid,nodev on upload and temp directories is a useful hardening step. See setuid.
Make mounts permanent: /etc/fstab
mount on the command line lasts until reboot. For permanent mounts, add a line to /etc/fstab:
UUID=3f1c… /mnt/data ext4 defaults,noatime,nofail 0 2
Then test without rebooting:
sudo mount -a
findmnt /mnt/data
A wrong fstab entry can stop the server from booting. nofail and testing with mount -a prevent that. See the full fstab guide.
Bind mounts
A bind mount makes a directory visible at a second location:
sudo mount --bind /srv/data/www /var/www
In fstab:
/srv/data/www /var/www none bind 0 0
Use cases: moving data to a bigger disk while keeping the original path, and exposing a directory inside a chroot. Docker’s -v /host:/container volumes are bind mounts too.
ISO and disk images
sudo mount -o loop,ro ubuntu.iso /mnt/iso
sudo mount -o loop disk.img /mnt/img
For images with several partitions: sudo losetup -fP --show disk.img, then mount /dev/loop0p1.
Network shares
NFS:
sudo apt install nfs-common
sudo mount -t nfs 10.0.0.5:/exports/backups /mnt/backups
SMB/CIFS (Windows shares, NAS):
sudo apt install cifs-utils
sudo mount -t cifs //nas/backup /mnt/nas -o credentials=/root/.smbcred,uid=1000,gid=1000
/root/.smbcred (mode 600) contains username=… and password=… lines.
SSHFS (over SSH, no server setup needed):
sudo apt install sshfs
sshfs user@server:/var/backups /mnt/remote
fusermount -u /mnt/remote
For network mounts in fstab, add _netdev,nofail so boot doesn’t hang if the network or server is unavailable.
tmpfs: RAM disk
sudo mount -t tmpfs -o size=512m tmpfs /mnt/ramdisk
It’s fast, and the contents vanish on unmount or reboot. That’s useful for temporary build files or caches.
Mounting in a rescue situation
When a server won’t boot, the VNC console in your provider’s panel gets you a shell (emergency mode or single-user mode) where you can mount disks and fix files:
lsblk -f
sudo mount /dev/vda1 /mnt
sudo nano /mnt/etc/fstab # fix the broken entry
sudo umount /mnt
Quick reference
| Task | Command |
|---|---|
| Show mounts | findmnt / df -hT |
| Mount | sudo mount /dev/vdb1 /mnt/data |
| By UUID | sudo mount UUID=… /mnt/data |
| Unmount | sudo umount /mnt/data |
| Who is busy | sudo fuser -vm /mnt/data |
| Remount rw | sudo mount -o remount,rw / |
| Bind | sudo mount --bind src dst |
| ISO | sudo mount -o loop,ro f.iso /mnt/iso |
| Mount all from fstab | sudo mount -a |