mount — Mount a Filesystem
mount attaches a filesystem — a disk partition, block device, loop file, or remote share — to a directory so its contents become accessible under that path. On a WordPress VPS, you commonly use mount to attach a backup disk at /mnt/backups, a dedicated database volume at /var/lib/mysql, or extra storage for the uploads directory. Mounting the wrong device or forgetting to verify after a mount can cause backups to silently fill the root partition, so always confirm every mount with findmnt and df after the operation.
System Check
which mount # Expected: /bin/mount
mount --version # Expected: mount from util-linux x.xx
Mounting on a non-empty directory hides the existing files until you unmount. If the backup mount is missing at job time, backup archives will be written to the root partition (/) instead of the dedicated disk.
Best Practices
- Always verify after mounting — run
findmnt -T TARGETanddf -h TARGETimmediately after everymountcommand. - Prefer UUID-based mounts — device names like
/dev/sdb1can change across reboots; UUIDs are stable. Useblkidto find the UUID. - Check the device before mounting — run
lsblk -p -fandblkidto confirm the source device, filesystem type, and UUID before issuingmount. - Use an empty mount point — create a dedicated empty directory for the mount point via
mkdir -p. Mounting over an existing non-empty directory hides files. - Persist mounts in
/etc/fstab— ad-hoc mounts are lost on reboot. Add the entry to/etc/fstaband test it withmount -abefore relying on it. - Test bind mounts on staging first —
--bindis powerful and easy to misconfigure; validate paths and permissions before applying to production. - Use
rofor inspection — always mount recovery disks or unfamiliar devices read-only (-o ro) to avoid accidental writes. - Pair
mountwithumount— cleanly unmount (sudo umount TARGET) before detaching any physical or virtual disk.
Tips & Strategy
findmnt -T /mnt/backups # confirm the mount is active and shows correct source
df -h /mnt/backups # confirm available space on the newly mounted device
Running both after every mount prevents silent failures where the mount command appeared to succeed but the disk is missing or wrong.
sudo blkid /dev/sdb1
Copy the UUID from the output and use it in /etc/fstab instead of the device path — this survives disk reordering after a reboot or hardware change.
sudo mount -a
After editing /etc/fstab, run mount -a to mount all new entries. If it errors, you can fix the entry before the next reboot causes a failed boot.
noatime on busy WordPress sitessudo mount -o remount,noatime /var/www/html
Adding noatime suppresses the access-time write on every file read, reducing write amplification on high-traffic sites. Add it to the fstab entry for persistence.
--bind after verifying source is mountedBefore bind-mounting uploads to another volume, confirm the source volume is itself mounted:
findmnt /mnt/storage # must show before you bind from it
If the source isn't mounted, the bind will point at an empty directory on the root disk.
Syntax & Options Reference
Core Syntax
mount [OPTIONS] SOURCE TARGET
mount [OPTIONS] -a
mount # list all current mounts
SOURCE— the device, UUID, label, or filesystem image to mount.TARGET— the directory (mount point) where the filesystem will be accessible.-a— mount everything listed in/etc/fstab.
Source Formats
| Format | Example | When to use |
|---|---|---|
| Device path | /dev/sdb1 | Quick ad-hoc mounts, known device |
| UUID | UUID=66666666-7777-8888-9999-000000000000 | fstab entries, stable across reboots |
| Label | LABEL=BACKUP | When you assigned a label with e2label or tune2fs |
| Loop file | /path/to/image.iso | Mounting ISO images or disk images |
| NFS share | server:/export/path | Remote NFS mounts |
Complete Options Table
| Option | Long Form | Description | Example |
|---|---|---|---|
-t TYPE | --types=TYPE | Specify filesystem type (auto-detected if omitted) | mount -t ext4 /dev/sdb1 /mnt/backups |
-o OPTIONS | --options=OPTIONS | Comma-separated mount options | mount -o ro,noatime /dev/sdb1 /mnt/backups |
-a | --all | Mount all filesystems listed in /etc/fstab | mount -a |
--bind | --bind | Bind mount a directory to another location | mount --bind /mnt/storage/uploads /var/www/html/wp-content/uploads |
--rbind | --rbind | Recursively bind mount (includes submounts) | mount --rbind /mnt/storage /mnt/mirror |
--move | --move | Move a mount point to a new location | mount --move /mnt/old /mnt/new |
-r | --read-only | Mount read-only (same as -o ro) | mount -r /dev/sdb1 /mnt/backups |
-w | --rw | Mount read-write (default) | mount -w /dev/sdb1 /mnt/backups |
-n | --no-mtab | Do not write to /etc/mtab | mount -n /dev/sdb1 /mnt |
-v | --verbose | Print more information | mount -v /dev/sdb1 /mnt/backups |
-f | --fake | Simulate the mount (dry run) | mount -f /dev/sdb1 /mnt/backups |
-l | --show-labels | Show labels when listing mounts | mount -l |
--source SRC | --source=SRC | Specify source explicitly | mount --source /dev/sdb1 /mnt/backups |
--target TGT | --target=TGT | Specify target explicitly | mount --target /mnt/backups |
-L LABEL | Mount by filesystem label | mount -L BACKUP /mnt/backups | |
-U UUID | Mount by UUID | mount -U 66666666-7777-... /mnt/backups |
Common -o Mount Options
| Mount Option | Description | Example |
|---|---|---|
ro | Read-only | -o ro |
rw | Read-write (default) | -o rw |
noatime | Do not update access time on reads | -o noatime |
relatime | Update atime only if newer than mtime (default on most distros) | -o relatime |
noexec | Prevent execution of binaries on this filesystem | -o noexec |
nosuid | Ignore setuid bits | -o nosuid |
nodev | Ignore device files | -o nodev |
sync | All I/O is synchronous | -o sync |
async | All I/O is asynchronous (default) | -o async |
remount | Remount with new options without unmounting | -o remount,ro |
defaults | Equivalent to rw,suid,dev,exec,auto,nouser,async | -o defaults |
user | Allow non-root users to mount | -o user |
nouser | Only root can mount (default) | -o nouser |
auto | Mount automatically with -a | -o auto |
noauto | Do not mount with -a | -o noauto |
Practical Use Cases
1. List all current mounts
mount
/dev/sda1 on / type ext4 (rw,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
/dev/sdb1 on /mnt/backups type ext4 (rw,relatime)
Use case: Confirm what is currently mounted, on which device, with which options.
2. Mount a backup disk by device path
sudo mkdir -p /mnt/backups
sudo mount /dev/sdb1 /mnt/backups
findmnt -T /mnt/backups
TARGET SOURCE FSTYPE OPTIONS
/mnt/backups /dev/sdb1 ext4 rw,relatime
Use case: Attach a dedicated backup disk so backup jobs write to /mnt/backups instead of the root partition.
3. Mount by UUID (recommended)
sudo mount UUID=66666666-7777-8888-9999-000000000000 /mnt/backups
(no output on success)
Use case: UUID-based mounts survive device reordering across reboots — always prefer this over /dev/sdX paths.
4. Mount by label
sudo mount -L BACKUP /mnt/backups
(no output on success)
Use case: When the disk has a meaningful label set, this is more readable than a raw UUID in scripts and runbooks.
5. Mount read-only for safe inspection
sudo mount -o ro /dev/sdb1 /mnt/inspect
findmnt -T /mnt/inspect
TARGET SOURCE FSTYPE OPTIONS
/mnt/inspect /dev/sdb1 ext4 ro,relatime
Use case: Inspect a disk without any risk of writes — essential for recovery scenarios and forensic investigation.
6. Mount with explicit filesystem type
sudo mount -t ext4 /dev/sdb1 /mnt/backups
(no output on success)
Use case: Use when auto-detection fails, or to be explicit in runbooks and documentation.
7. Mount with noatime to reduce write amplification
sudo mount -o noatime /dev/sdb1 /mnt/backups
(no output on success)
Use case: Lower unnecessary writes on high-traffic filesystems — effective for the WordPress uploads and cache partitions.
8. Remount with new options (without unmounting)
sudo mount -o remount,ro /mnt/backups
findmnt -T /mnt/backups
TARGET SOURCE FSTYPE OPTIONS
/mnt/backups /dev/sdb1 ext4 ro,relatime
Use case: Switch a live mount between read-only and read-write without a full unmount cycle.
9. Bind mount (move uploads to a larger volume)
sudo mkdir -p /mnt/storage/uploads
sudo mkdir -p /var/www/html/wp-content/uploads
# mount the storage volume at /mnt/storage first (device/UUID example omitted)
# then bind it into the WordPress uploads path
sudo mount --bind /mnt/storage/uploads /var/www/html/wp-content/uploads
findmnt -T /var/www/html/wp-content/uploads -o TARGET,SOURCE,FSTYPE,OPTIONS
TARGET SOURCE FSTYPE OPTIONS
/var/www/html/wp-content/uploads /mnt/storage/uploads ext4 rw,relatime
Use case: Keep WordPress media on a larger disk while the application code stays on the smaller root volume.
Test bind mounts on staging first. Validate permissions and WordPress write access before adding the entry to /etc/fstab.
10. Mount all entries from /etc/fstab
sudo mount -a
(no output on success)
Use case: Validate a new /etc/fstab entry or re-mount anything that was skipped at boot — without rebooting.
11. Verbose mount for debugging
sudo mount -v /dev/sdb1 /mnt/backups
mount: /dev/sdb1 mounted on /mnt/backups.
Use case: Confirm the exact device and target when scripting or troubleshooting a suspected silent failure.
12. Simulate a mount (dry run)
sudo mount -f -v /dev/sdb1 /mnt/backups
mount: /dev/sdb1 mounted on /mnt/backups.
Use case: Verify the command syntax and options are valid before committing a real mount operation.
WordPress VPS Use Cases
| Situation | What you are mounting | Command | Why it matters |
|---|---|---|---|
| Dedicated backup disk | Backup disk at /mnt/backups | mount UUID=... /mnt/backups | Prevents backups from filling / |
| Separate database storage | DB volume at /var/lib/mysql | mount UUID=... /var/lib/mysql | Limits blast radius of DB growth |
| Separate uploads storage | Uploads via bind mount | mount --bind /mnt/storage/uploads /var/www/html/wp-content/uploads | Media growth does not consume the root disk |
| Recovery / forensic access | External or recovery disk | mount -o ro /dev/sdb1 /mnt/recover | Safe inspection without accidental writes |
Hands-On Practice
Quick Lab (5 Exercises)
- Run
mountwith no arguments and identify every currently mounted filesystem and its options. - Run
lsblk -p -fto list all block devices, their filesystems, and UUIDs. - If you have an unmounted partition, mount it read-only:
sudo mount -o ro /dev/sdXN /mnt/test. - Verify the mount with
findmnt -T /mnt/testanddf -h /mnt/test. - Add the mount to
/etc/fstabusing the UUID, then test it withsudo mount -a.
Task: Safe Backup Disk Mount
Write the full sequence of commands to safely mount /dev/sdb1 as a backup disk at /mnt/backups, verify it is correct, and confirm space is available.
Solution
# 1. Confirm the device exists and its filesystem
lsblk -p -f /dev/sdb1
sudo blkid /dev/sdb1
# 2. Create the mount point
sudo mkdir -p /mnt/backups
# 3. Mount using UUID for stability
sudo mount UUID=<uuid-from-blkid> /mnt/backups
# 4. Verify the mount
findmnt -T /mnt/backups
# 5. Confirm available space
df -h /mnt/backups
Mini Quiz
- What is the difference between mounting by device path (
/dev/sdb1) and by UUID? - Which option mounts a filesystem read-only?
- What does
mount -ado and when would you use it? - Why should you always run
findmntanddfafter amountcommand? - What is a bind mount and when is it useful for WordPress?
- What happens if you mount a device on a non-empty directory?
- Which mount option reduces write amplification on busy filesystems?
- How do you change mount options on a live filesystem without unmounting it?
Cheat Sheet
mount # List all current mounts
lsblk -p -f # List block devices with FS and UUID
sudo blkid /dev/sdb1 # Get UUID and filesystem type
sudo mkdir -p /mnt/backups # Create mount point
sudo mount /dev/sdb1 /mnt/backups # Mount by device path
sudo mount UUID=<uuid> /mnt/backups # Mount by UUID (recommended)
sudo mount -L BACKUP /mnt/backups # Mount by label
sudo mount -t ext4 /dev/sdb1 /mnt/backups # Mount with explicit FS type
sudo mount -o ro /dev/sdb1 /mnt/inspect # Read-only mount
sudo mount -o noatime /dev/sdb1 /mnt/backups # Mount with noatime
sudo mount -o remount,ro /mnt/backups # Remount with new options
sudo mount --bind /mnt/storage/uploads /var/www/html/wp-content/uploads # Bind mount
sudo mount -a # Mount all fstab entries
sudo mount -v /dev/sdb1 /mnt/backups # Verbose output
sudo mount -f -v /dev/sdb1 /mnt/backups # Dry run (fake)
findmnt -T /mnt/backups # Verify mount
df -h /mnt/backups # Check available space