Exam weight: 3 β LPIC-1 v5, Exam 101
What You Need to Know
- Mount and unmount filesystems manually.
- Configure automatic mounting at boot via
/etc/fstab. - Use labels and UUIDs to identify partitions.
- Work with systemd mount unit files.
Key utilities: /etc/fstab, /media/, mount, umount, blkid, lsblk.
What is Mounting
A filesystem in Linux cannot be used directly. It must first be attached to a point in the directory tree β called a mount point. After mounting, the partition’s contents are accessible through that directory.
Mounting can be done manually with mount, automatically via /etc/fstab at boot, or through systemd unit files.
The mount Command
Basic Syntax
mount -t TYPE DEVICE MOUNTPOINT
TYPEβ filesystem type (ext4,btrfs,exfat,ntfs, etc.)DEVICEβ partition with the filesystem, e.g./dev/sdb1MOUNTPOINTβ directory to attach to; must already exist
mount -t exfat /dev/sdb1 ~/flash/
Any files previously in the mount point directory become inaccessible while another filesystem is mounted on top.
Viewing Mounted Filesystems
mount without arguments lists all mounted filesystems. Filter by type with -t:
mount -t ext4
# /dev/sda1 on / type ext4 (rw,noatime,errors=remount-ro)
mount -t ext4,fuseblk # multiple types comma-separated
Output format: SOURCE on TARGET type TYPE OPTIONS.
Alternatives: cat /proc/self/mounts, cat /proc/mounts, findmnt.
Key Options
| Option | Description |
|---|---|
-t TYPE | specify filesystem type |
-o OPTS | pass comma-separated mount options |
-r / -ro | mount read-only |
-w / -rw | mount read-write |
-a | mount all filesystems in /etc/fstab |
--bind | make a directory’s contents visible at another path |
Remounting an already-mounted filesystem β no need to specify type:
mount -o remount,ro /dev/sdb1
mount -o remount,ro /mnt/data # by mount point
mount --bind makes a directory’s contents accessible at another location without copying:
mount --bind /src /dst
The umount Command
Accepts either device name or mount point β both are equivalent:
umount /dev/sdb1
umount ~/flash
| Option | Description |
|---|---|
-a | unmount all filesystems in /etc/fstab |
-f | force unmount (useful for unreachable network filesystems) |
-r | if unmounting fails, remount read-only |
Options combine: umount -fr /mnt/server.
Busy Filesystem: lsof
When you get target is busy, some process is holding files open:
lsof /dev/sdb1
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# evince 3135 carol 16r REG 8,17 21881768 5195 /media/.../file.pdf
Close the program, then unmount.
/mnt vs /media
/mntβ conventional for manual, temporary mounts./mediaβ standard for removable media. Modern distributions auto-mount there:/media/USER/LABEL.
/etc/fstab
Describes filesystems that can be mounted. Each line has exactly 6 fields:
FILESYSTEM MOUNTPOINT TYPE OPTIONS DUMP PASS
| Field | Description |
|---|---|
FILESYSTEM | device, UUID, or label |
MOUNTPOINT | mount point path |
TYPE | filesystem type |
OPTIONS | comma-separated mount options |
DUMP | whether dump backs this up (usually 0) |
PASS | fsck check order on boot; 0 = skip |
Example:
/dev/sda1 / ext4 noatime,errors=remount-ro 0 1
Mount Options
| Option | Description |
|---|---|
defaults | = rw,suid,dev,exec,auto,nouser,async |
atime / noatime | update access time on reads |
auto / noauto | mount with mount -a or not |
exec / noexec | allow / deny binary execution |
user / nouser | allow / deny mounting by regular users |
group | allow mounting by users in the device’s group |
owner | allow mounting by the device’s owner |
suid / nosuid | respect / ignore SUID/SGID bits |
ro / rw | read-only / read-write |
sync / async | synchronous / asynchronous I/O |
dev / nodev | interpret block/character devices |
remount | remount already-mounted filesystem (mount -o only, not fstab) |
sync on flash media shortens device lifespan due to limited write cycles.
UUID and Labels
Device names are unstable β /dev/sdb1 may become /dev/sdc1 after reconnection. UUIDs and labels don’t change between reconnections.
lsblk -f
lsblk -f /dev/sda1
# NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
# sda1 ext4 6e2c12e3-472d-4bac-a257-c49ac07f3761 64.9G 33% /
blkid
blkid
blkid /dev/sda1
# /dev/sda1: UUID="6e2c12e3-..." TYPE="ext4" PARTUUID="..."
Both utilities are listed in the 104.3 objectives.
Using UUID and LABEL
In /etc/fstab:
UUID=6e2c12e3-472d-4bac-a257-c49ac07f3761 / ext4 noatime,errors=remount-ro 0 1
LABEL=homedisk /home ext4 defaults 0 2
On the command line:
mount UUID=56C11DCC5D2E1334 /mnt/external
mount LABEL=Backup /mnt/backup
Mounting via systemd
systemd manages mounting through unit files in /etc/systemd/system/.
If you mount a filesystem manually without a fstab entry or mount unit, systemd automatically generates a temporary mount unit and tracks the mount point.
Mount Unit (.mount)
[Unit]
Description=External data disk
[Mount]
What=/dev/disk/by-uuid/56C11DCC5D2E1334
Where=/mnt/external
Type=ntfs
Options=defaults
[Install]
WantedBy=multi-user.target
| Field | Description |
|---|---|
What= | device (typically via /dev/disk/by-uuid/) |
Where= | full mount point path |
Type= | filesystem type |
Options= | mount options |
WantedBy= | target (multi-user.target for normal boot) |
File Naming
File name = mount point with / replaced by -, plus .mount extension:
| Mount point | File name |
|---|---|
/mnt/external | mnt-external.mount |
/var/log/db | var-log-db.mount |
/ | -.mount |
File goes in /etc/systemd/system/.
Managing Units
systemctl daemon-reload
systemctl start mnt-external.mount
systemctl status mnt-external.mount
systemctl enable mnt-external.mount # persist across reboots
Automount Unit (.automount)
Mounts on demand β when the mount point is first accessed:
[Unit]
Description=Automount for the external data disk
[Automount]
Where=/mnt/external
[Install]
WantedBy=multi-user.target
File name: mnt-external.automount. Same naming rule.
systemctl daemon-reload
systemctl start mnt-external.automount
systemctl enable mnt-external.automount
Quick Reference
# View mounted filesystems
mount
mount -t ext4,ntfs
findmnt
# Mount
mount -t ext4 /dev/sdb1 /mnt/data
mount -o ro,noatime /dev/sdb1 /mnt/data
mount -o remount,ro /mnt/data
mount UUID=... /mnt/data
mount LABEL=Backup /mnt/backup
mount -a
mount --bind /src /dst
# Unmount
umount /dev/sdb1
umount /mnt/data
umount -fr /mnt/server
umount -a
# Device info
lsblk -f /dev/sdb1
blkid /dev/sda1
# Who is using the filesystem
lsof /dev/sdb1
# systemd
systemctl daemon-reload
systemctl start mnt-external.mount
systemctl enable mnt-external.mount
Exam Questions
- How many fields in a valid
/etc/fstabline? β 6: FILESYSTEM, MOUNTPOINT, TYPE, OPTIONS, DUMP, PASS. - Two ways besides device name to identify a partition in fstab? β
UUID=andLABEL=. - What does
mount --binddo? β Makes a directory’s contents visible at another path. - What happens if you mount manually without fstab/unit entry? β systemd auto-generates a temporary mount unit.
- Which commands list all mounted filesystems? β
mount,cat /proc/self/mounts,cat /proc/mounts,findmnt. - What does
noautoin fstab mean? β Entry is skipped bymount -a; must be mounted manually. - What does
nousermean? β Regular users cannot mount this filesystem; only root can. - How to force-unmount an unreachable network filesystem? β
umount -f -r /mnt/server. - Where does a mount unit go and what is it named? β
/etc/systemd/system/, name = mount point with slashesβdashes +.mount. - Must you specify type when remounting? β No, device or mount point is sufficient.
- What does
defaultsinclude? βrw, suid, dev, exec, auto, nouser, async. - How to disable binary execution while keeping
defaults? β Addnoexec:defaults,noexec. - Difference between
lsblk -fandblkid? βlsblk -fshows a table with free space and mount point;blkidgives compact output suitable for scripts. - How to find processes holding files on a busy filesystem? β
lsof /dev/sdXN. - Why is
syncnot recommended for flash storage? β Writes happen synchronously, wearing out flash cells faster due to limited write cycles.
Exercises
Exercise 1 β Mount ext4 read-only with options
Mount ext4 on /dev/sdc1 to /mnt/external read-only, with options noatime and async.
Answer
mount -t ext4 -o noatime,async,ro /dev/sdc1 /mnt/external
Exercise 2 β Find what is holding a busy filesystem
Unmounting /dev/sdd2 returns target is busy. How do you find which files are open?
Answer
lsof /dev/sdd2
Output shows: process name, PID, user, and the open file. Close the program, then unmount.
Exercise 3 β noauto and mount -a
/etc/fstab contains:
/dev/sdb1 /data ext4 noatime,noauto,async
Will this filesystem be mounted by mount -a?
Answer
No. The noauto option tells mount -a to skip this entry. The filesystem must be mounted manually.
Exercise 4 β Finding a filesystem’s UUID
How do you find the UUID of the filesystem on /dev/sdb1?
Answer
lsblk -f /dev/sdb1
# or
blkid /dev/sdb1
lsblk -f shows a table with type, label, UUID, free space and mount point. blkid gives compact output, convenient for scripts. Both are in the 104.3 objectives.
Exercise 5 β Remount as read-only
An exFAT filesystem is mounted at /mnt/data. How do you remount it read-only?
Answer
When remounting, type and UUID are not needed β mount point alone is sufficient:
mount -o remount,ro /mnt/data
Exercise 6 β List ext3 and ntfs mounts
How do you list all mounted filesystems of type ext3 and ntfs?
Answer
mount -t ext3,ntfs
Exercise 7 β nouser and regular user mounting
/etc/fstab contains:
/dev/sdc1 /backup ext4 noatime,nouser,async
Can a regular user mount this filesystem with mount /backup?
Answer
No. The nouser option allows only root to mount this filesystem.
To allow regular users: use user (any user) or group (users in the device’s group).
Exercise 8 β Force-unmount an unreachable network filesystem
A network filesystem at /mnt/server has become unreachable due to connection loss. How do you force-unmount it, or fall back to read-only if that fails?
Answer
umount -fr /mnt/server
-f forces unmount; -r falls back to remounting read-only if unmounting fails.
Exercise 9 β fstab entry for btrfs Backup
Write an /etc/fstab line that mounts a btrfs volume with label Backup at /mnt/backup with default options but no binary execution.
Answer
LABEL=Backup /mnt/backup btrfs defaults,noexec 0 0
defaults includes exec. Adding noexec overrides it β the last matching option wins.
DUMP and PASS are 0 0: skip dump backup, skip fsck on boot.
Exercise 10 β fstab equivalent of a mount unit
Given this systemd mount unit:
[Unit]
Description=External data disk
[Mount]
What=/dev/disk/by-uuid/56C11DCC5D2E1334
Where=/mnt/external
Type=ntfs
Options=defaults
[Install]
WantedBy=multi-user.target
What is the equivalent /etc/fstab line, and what must the unit file be named and where should it go?
Answer
fstab equivalent:
UUID=56C11DCC5D2E1334 /mnt/external ntfs defaults 0 0
What=/dev/disk/by-uuid/UUID is a symlink path created by udev. In fstab, the same UUID is written as UUID=.
Unit file: mnt-external.mount in /etc/systemd/system/.
Naming rule: replace each / in the mount point path with -:
| Mount point | File name |
|---|---|
/mnt/external | mnt-external.mount |
/var/log/db | var-log-db.mount |
/ | -.mount |
LPIC-1 Study Notes | Topic 104: Devices, Linux Filesystems, Filesystem Hierarchy Standard