Table of Contents
Understanding Mount Points
Linux does not automatically “show” every filesystem; you must attach (mount) a filesystem into the single directory tree.
Key ideas specific to mounting:
- A mount point is an existing, empty directory where a filesystem becomes visible (for example
/mnt/backup). - After mounting, the directory’s previous contents (if any) become hidden until you unmount.
- You can mount:
- Local partitions (e.g.
/dev/sda1) - Removable media (USB sticks, external drives)
- Network filesystems (NFS, SMB/CIFS, etc.)
- System-wide, persistent mounts are usually defined in
/etc/fstab(covered only lightly here).
Basic `mount` Command Usage
The mount command attaches a filesystem to a mount point.
General syntax:
mount [options] <source> <mountpoint>Where:
<source>: device or remote resource (e.g./dev/sda1,server:/share)<mountpoint>: existing directory (e.g./mnt/data)[options]: filesystem type, mount options, etc.
Viewing Currently Mounted Filesystems
To see what’s currently mounted:
mountor more readable:
mount | column -tCommon alternatives:
findmnt # Structured overview (recommended)
df -h # Shows mounted filesystems and usageExamples:
findmnt
findmnt /home # Show only the mount that provides /home
findmnt /dev/sda1 # Show where this device is mounted
findmnt is especially useful to see the hierarchy of mounts and which device backs each directory.
Mounting by Device
Suppose you have a partition /dev/sdb1 you want to mount at /mnt/data:
- Create the mountpoint directory if it doesn’t exist:
sudo mkdir -p /mnt/data- Mount:
sudo mount /dev/sdb1 /mnt/data- Verify:
findmnt /mnt/data
ls /mnt/dataIf the filesystem type cannot be auto-detected, specify it:
sudo mount -t ext4 /dev/sdb1 /mnt/data
Common filesystem types include ext4, xfs, btrfs, vfat, ntfs, nfs, cifs, etc.
Mounting by UUID or Label (Temporarily)
While /etc/fstab is the canonical place to use UUIDs/labels, you can also mount explicitly by them.
Find identifiers:
lsblk -f
# or
blkidYou will see something like:
/dev/sdb1: UUID="1234-ABCD" TYPE="ext4" PARTLABEL="data"Mount via UUID:
sudo mount UUID=1234-ABCD /mnt/dataMount via label:
sudo mount LABEL=data /mnt/data
Mounting by UUID or label is more robust than using /dev/sdX names, which can change between boots, but persistent configuration typically belongs in /etc/fstab (covered elsewhere).
Temporary vs Persistent Mounts
- Running
mounton the command line creates a temporary mount: - It lasts until you unmount or reboot.
- Useful for one-off operations (e.g. copying files from a USB drive).
- Persistent mounts (across reboots) are controlled by
/etc/fstab: - You define entries there, then run
mount -aor reboot. - Detailed
fstabconfiguration and all options are treated in the parent storage/filesystems context; here we’ll only show howmountinteracts with it.
Mount all filesystems defined in /etc/fstab (except those marked noauto):
sudo mount -aCommon Mount Options
Mount options alter how the filesystem behaves. These are passed with -o:
sudo mount -o <option1,option2,...> <source> <mountpoint>Some commonly-used options:
ro— mount read-only:
sudo mount -o ro /dev/sdb1 /mnt/datarw— mount read-write (default for many local filesystems).noexec— do not allow execution of binaries from this filesystem.nosuid— ignore setuid/setgid bits on this filesystem.nodev— do not interpret device files on this filesystem.uid/gid— for some non-Unix filesystems (e.g.vfat,ntfs), sets the owning user/group of files:
sudo mount -t vfat -o uid=1000,gid=1000 /dev/sdc1 /mnt/usbumask— for some non-Unix filesystems, controls default permissions mask:
sudo mount -t vfat -o uid=1000,gid=1000,umask=022 /dev/sdc1 /mnt/usb
Note that not all options apply to all filesystem types; consult man mount and the specific filesystem’s documentation.
Mounting Removable Media (USB Drives)
Most desktop environments auto-mount USB devices. On servers or minimal systems, you often mount them manually.
Typical workflow:
- Identify the device:
lsblk
# or
sudo fdisk -l
Look for a new device (/dev/sdc1, /dev/sdd1, etc.) after plugging in the USB drive.
- Create a mountpoint (once):
sudo mkdir -p /mnt/usb- Mount (filesystem type usually
vfatorexfatfor USB sticks):
sudo mount /dev/sdc1 /mnt/usb
# or, if needed:
sudo mount -t vfat /dev/sdc1 /mnt/usb- Use the data:
ls /mnt/usb
cp /mnt/usb/file .- Unmount before unplugging (covered in more detail below):
sudo umount /mnt/usbNever unplug while it’s still mounted, especially when writing data.
Unmounting (`umount`)
Unmounting detaches a filesystem from its mount point and flushes writes.
Command:
sudo umount <mountpoint-or-source>Examples:
sudo umount /mnt/data
sudo umount /dev/sdc1When Unmounting Fails (“Target is busy”)
A common error:
umount: /mnt/data: target is busy.This means some process is using the filesystem (open files, working directory, etc.).
Ways to resolve:
- Leave that directory:
If your shell is inside the mountpoint, unmount will fail. Move out:
cd
sudo umount /mnt/data- Close files using it:
Close any editors, file managers, terminals, or programs accessing files under that mount.
- Find which processes are using it:
- Using
lsof:
sudo lsof +f -- /mnt/data- Using
fuser:
sudo fuser -vm /mnt/dataThen stop or kill those processes (carefully) and try unmounting again.
- Force or lazy unmount (with caution):
- Force unmount (dangerous; risk of data loss):
sudo umount -f /mnt/data- Lazy unmount (detaches now, cleans up when no longer busy):
sudo umount -l /mnt/dataUse these only when normal unmounting doesn’t work and you understand the consequences (especially for writes).
Mounting and Unmounting with `systemd` (`systemd-mount`)
On systemd-based systems, you can also use systemd-mount for temporary, service-like mounts.
Example:
sudo systemd-mount /dev/sdb1 /mnt/dataTo list systemd-managed mounts:
systemctl --type=mountTo unmount via systemd:
sudo systemd-umount /mnt/data
# or through systemctl if you know the unit name:
sudo systemctl stop mnt-data.mount
This approach integrates mounts with systemd units, which can be useful in more advanced setups (timers, dependencies, etc.).
Bind Mounts
A bind mount makes an existing directory tree visible at another location in the filesystem. It does not create a separate filesystem; it’s just another view of the same data.
Example: make /var/www/html accessible under /srv/www:
- Ensure the target directory exists:
sudo mkdir -p /srv/www- Bind mount:
sudo mount --bind /var/www/html /srv/www
Now /srv/www and /var/www/html refer to the same underlying files.
To unmount:
sudo umount /srv/wwwBind mounts are especially handy for:
- Chroot environments
- Container setups
- Sharing data between paths without symlinks
Persistent bind mounts (via /etc/fstab) are part of broader storage configuration and are not detailed here.
Special Mount Types: `tmpfs` and `proc` (Operational View)
These are usually configured by the system, but you may occasionally interact with them manually.
`tmpfs`
tmpfs is a memory-backed filesystem; common for /run, /tmp (on some systems).
Manual mount example:
sudo mount -t tmpfs -o size=512M tmpfs /mnt/ramdiskUnmount:
sudo umount /mnt/ramdiskUse cases include fast, temporary storage where persistence across reboots is not required.
`proc`, `sysfs`, `devpts`, etc.
These pseudo-filesystems provide interfaces to the kernel; they are typically mounted automatically during boot.
Example (only for specific troubleshooting or chroot environments):
sudo mount -t proc proc /mnt/chroot/proc
sudo umount /mnt/chroot/proc
Manipulating these is an advanced use-case; normally you just need to know they are mounts and may show up in mount/findmnt output.
Safe Workflow for Temporary Mounts
A practical pattern for manual mounts:
- Create mountpoint (once):
sudo mkdir -p /mnt/backup- Mount when needed:
sudo mount /dev/sdb1 /mnt/backup- Verify:
findmnt /mnt/backup- Use:
rsync -av /home/ /mnt/backup/home-backup/- Flush and unmount:
sync # optional, forces pending writes to disk
sudo umount /mnt/backup- Check it’s gone:
findmnt /mnt/backup # should show nothingBuilding this habit (especially the unmount step) greatly reduces the risk of data corruption, particularly on removable media.