Mounting & Filesystem Management
Objective
Mount filesystems manually and persistently via /etc/fstab, understand filesystem types, and manage disk space.
Tools & Technologies
mountumountfstabblkiddfdu
Key Commands
mount -t ext4 /dev/sdb1 /mnt/datablkid /dev/sdb1df -hTdu -sh /var/*mount -aArchitecture Overview
sequenceDiagram
participant A as Admin
participant K as Kernel
participant VFS as VFS Layer
participant FS as Filesystem Driver
participant D as Block Device
A->>K: mount /dev/sdb1 /mnt/data
K->>D: Read superblock
D-->>K: Filesystem metadata
K->>FS: Load ext4 driver
FS->>VFS: Register mount point
VFS-->>A: /mnt/data accessible
Note over A,D: All file ops go through VFS → FS driver → device
Step-by-Step Process
01
Manual Mount
Mount a filesystem to a directory. Changes are temporary (lost on reboot).
# Mount ext4 partition
sudo mount -t ext4 /dev/sdb1 /mnt/data
# Mount with options
sudo mount -o ro,noexec /dev/sdb1 /mnt/data # read-only
sudo mount -o remount,rw /mnt/data # remount rw
# View mounted filesystems
mount | grep sdb
df -hT
02
Persistent Mounts via /etc/fstab
fstab entries survive reboots. Always use UUID, never /dev/sdX names.
# Get UUID
blkid /dev/sdb1
# UUID=abc123...
# Add to /etc/fstab:
# UUID=abc123 /data ext4 defaults 0 2
# Test fstab without rebooting
sudo mount -a
# fstab fields:
# device mountpoint fstype options dump pass
03
Disk Space Management
Monitor disk usage and find what's consuming space.
df -h # filesystem usage
df -hT # include filesystem type
# Find large directories
du -sh /var/* # dirs in /var
du -sh /* 2>/dev/null | sort -rh | head
# Find large files
find / -type f -size +100M 2>/dev/null | sort -k5 -rn
Challenges & Solutions
- Wrong UUID in fstab causes boot failure — use emergency mode to fix
- mount -a skips entries with noauto option
Key Takeaways
- nofail option in fstab prevents boot failure if device is absent (good for USB)
- pass field 2 enables fsck check on boot — set 0 to disable for non-root