Mounting_fstab
Chapter 14: Mounting and fstab
Section titled “Chapter 14: Mounting and fstab”Overview
Section titled “Overview”This chapter covers mounting file systems, configuring automatic mounting with /etc/fstab, and systemd mount units for modern Linux systems.
14.1 Mount Basics
Section titled “14.1 Mount Basics”mount Command
Section titled “mount Command”# Mount basicsudo mount /dev/sdb1 /mnt/data
# Mount with optionssudo mount -o rw,noexec /dev/sdb1 /mnt/data
# Mount read-onlysudo mount -o ro /dev/sdb1 /mnt/data
# Remountsudo mount -o remount,rw /
# Unmountsudo umount /mnt/datasudo umount /dev/sdb1
# Lazy unmount (force)sudo umount -l /mnt/data
# Check mountsmountfindmntCommon Mount Options
Section titled “Common Mount Options”| Option | Description |
|---|---|
| rw | Read-write |
| ro | Read-only |
| suid | Allow setuid |
| nosuid | Disallow setuid |
| exec | Allow executables |
| noexec | Disallow executables |
| auto | Mount automatically |
| noauto | No auto mount |
| user | Allow user mount |
| nouser | Only root can mount |
| defaults | rw,suid,dev,exec,auto,nouser,async |
| nofail | Don’t fail if device missing |
14.2 /etc/fstab
Section titled “14.2 /etc/fstab”fstab Format
Section titled “fstab Format”<device> <mount point> <type> <options> <dump> <fsck>Example fstab
Section titled “Example fstab”# Device Mount Point Type Options Dump PassUUID=abc123 / ext4 defaults 1 1UUID=def456 /boot ext4 defaults 0 2UUID=ghi789 /home ext4 defaults 0 2UUID=jkl012 none swap sw 0 0/dev/sdb1 /mnt/data ext4 defaults 0 2Fields Explained
Section titled “Fields Explained”| Field | Description |
|---|---|
| Device | Device path, UUID, or LABEL |
| Mount Point | Target directory |
| Type | Filesystem type (ext4, xfs, nfs, etc.) |
| Options | Mount options |
| Dump | Backup (0/1) |
| fsck | Order (0=skip, 1=root, 2=other) |
14.3 UUID and Labels
Section titled “14.3 UUID and Labels”Using UUID
Section titled “Using UUID”# Find UUIDsudo blkidls -l /dev/disk/by-uuid/
# Use in fstabUUID=abc123-def456-ghi789 / ext4 defaults 0 1Using Labels
Section titled “Using Labels”# Label filesystemsudo e2label /dev/sdb1 mydatasudo xfs_admin -L mydata /dev/sdb1
# Use in fstabLABEL=mydata /mnt/data ext4 defaults 0 214.4 Systemd Mount Units
Section titled “14.4 Systemd Mount Units”Mount Units
Section titled “Mount Units”[Unit]Description=Data MountAfter=network.target
[Mount]What=/dev/sdb1Where=/mnt/dataType=ext4Options=defaults
[Install]WantedBy=multi-user.targetEnable Mount
Section titled “Enable Mount”sudo systemctl daemon-reloadsudo systemctl enable mnt-data.mountsudo systemctl start mnt-data.mount
# Check statussystemctl status mnt-data.mountAutomount Units
Section titled “Automount Units”[Unit]Description=Data Automount
[Automount]Where=/mnt/data
[Install]WantedBy=multi-user.target14.5 Common Mount Examples
Section titled “14.5 Common Mount Examples”# Mount NFSsudo mount -t nfs server:/share /mnt/nfs
# With optionssudo mount -t nfs -o rw,hard,intr server:/share /mnt/nfs
# fstab entryserver:/share /mnt/nfs nfs defaults 0 0CIFS/SMB
Section titled “CIFS/SMB”# Mount SMBsudo mount -t cifs //server/share /mnt/share -o user=username
# With passwordsudo mount -t cifs //server/share /mnt/share -o user=username,password=pass
# fstab entry//server/share /mnt/share cifs credentials=/etc/samba/credentials 0 0ISO Image
Section titled “ISO Image”# Mount ISOsudo mount -o loop,ro image.iso /mnt/iso
# fstab entry/path/to/image.iso /mnt/iso iso9660 ro,loop 0 0tmpfs (RAM Disk)
Section titled “tmpfs (RAM Disk)”# Mount tmpfssudo mount -t tmpfs -o size=2G tmpfs /mnt/ramdisk
# fstab entrytmpfs /mnt/ramdisk tmpfs size=2G 0 014.6 Interview Questions
Section titled “14.6 Interview Questions”Q: What is the difference between mount and fstab?A: mount: command to mount immediately; fstab: automatic mount at boot
Q: What does the 'nofail' option do?A: Don't fail if device doesn't exist (useful for optional mounts)
Q: What is the fsck field in fstab?A: Order of filesystem check at boot (0=skip, 1=root, 2=other)
Q: How do you find UUID of a device?A: sudo blkid or ls -l /dev/disk/by-uuid/
Q: What is systemd automount?A: Mount on first access (on-demand)Summary
Section titled “Summary”- mount: Command to mount filesystems
- fstab: Automatic mount configuration
- UUID: Preferred way to identify devices
- systemd: Modern mount units
Next Chapter
Section titled “Next Chapter”Chapter 15: Disk Quotas and Limits
Last Updated: February 2026