Skip to content

Mounting_fstab

This chapter covers mounting file systems, configuring automatic mounting with /etc/fstab, and systemd mount units for modern Linux systems.


Terminal window
# Mount basic
sudo mount /dev/sdb1 /mnt/data
# Mount with options
sudo mount -o rw,noexec /dev/sdb1 /mnt/data
# Mount read-only
sudo mount -o ro /dev/sdb1 /mnt/data
# Remount
sudo mount -o remount,rw /
# Unmount
sudo umount /mnt/data
sudo umount /dev/sdb1
# Lazy unmount (force)
sudo umount -l /mnt/data
# Check mounts
mount
findmnt
OptionDescription
rwRead-write
roRead-only
suidAllow setuid
nosuidDisallow setuid
execAllow executables
noexecDisallow executables
autoMount automatically
noautoNo auto mount
userAllow user mount
nouserOnly root can mount
defaultsrw,suid,dev,exec,auto,nouser,async
nofailDon’t fail if device missing

<device> <mount point> <type> <options> <dump> <fsck>
/etc/fstab
# Device Mount Point Type Options Dump Pass
UUID=abc123 / ext4 defaults 1 1
UUID=def456 /boot ext4 defaults 0 2
UUID=ghi789 /home ext4 defaults 0 2
UUID=jkl012 none swap sw 0 0
/dev/sdb1 /mnt/data ext4 defaults 0 2
FieldDescription
DeviceDevice path, UUID, or LABEL
Mount PointTarget directory
TypeFilesystem type (ext4, xfs, nfs, etc.)
OptionsMount options
DumpBackup (0/1)
fsckOrder (0=skip, 1=root, 2=other)

Terminal window
# Find UUID
sudo blkid
ls -l /dev/disk/by-uuid/
# Use in fstab
UUID=abc123-def456-ghi789 / ext4 defaults 0 1
Terminal window
# Label filesystem
sudo e2label /dev/sdb1 mydata
sudo xfs_admin -L mydata /dev/sdb1
# Use in fstab
LABEL=mydata /mnt/data ext4 defaults 0 2

/etc/systemd/system/mnt-data.mount
[Unit]
Description=Data Mount
After=network.target
[Mount]
What=/dev/sdb1
Where=/mnt/data
Type=ext4
Options=defaults
[Install]
WantedBy=multi-user.target
Terminal window
sudo systemctl daemon-reload
sudo systemctl enable mnt-data.mount
sudo systemctl start mnt-data.mount
# Check status
systemctl status mnt-data.mount
/etc/systemd/system/mnt-data.automount
[Unit]
Description=Data Automount
[Automount]
Where=/mnt/data
[Install]
WantedBy=multi-user.target

Terminal window
# Mount NFS
sudo mount -t nfs server:/share /mnt/nfs
# With options
sudo mount -t nfs -o rw,hard,intr server:/share /mnt/nfs
# fstab entry
server:/share /mnt/nfs nfs defaults 0 0
Terminal window
# Mount SMB
sudo mount -t cifs //server/share /mnt/share -o user=username
# With password
sudo mount -t cifs //server/share /mnt/share -o user=username,password=pass
# fstab entry
//server/share /mnt/share cifs credentials=/etc/samba/credentials 0 0
Terminal window
# Mount ISO
sudo mount -o loop,ro image.iso /mnt/iso
# fstab entry
/path/to/image.iso /mnt/iso iso9660 ro,loop 0 0
Terminal window
# Mount tmpfs
sudo mount -t tmpfs -o size=2G tmpfs /mnt/ramdisk
# fstab entry
tmpfs /mnt/ramdisk tmpfs size=2G 0 0

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)

  • mount: Command to mount filesystems
  • fstab: Automatic mount configuration
  • UUID: Preferred way to identify devices
  • systemd: Modern mount units

Chapter 15: Disk Quotas and Limits


Last Updated: February 2026