What is fstab?

/etc/fstab defines how drives are mounted automatically at boot.

Basic Structure

UUID=xxxx  /mnt/storage  ext4  defaults  0  2
FieldDescription
UUIDDisk identifier
Mount PointWhere it mounts
Filesystemext4, ntfs, xfs, etc
OptionsMount options
DumpBackup flag
PassFilesystem check order

Find UUID

sudo blkid

Example: Mount ext4 Drive

sudo mkdir -p /mnt/storage
sudo nano /etc/fstab
Add:
UUID=abcd-1234  /mnt/storage  ext4  defaults  0  2

Test Without Reboot

sudo mount -a

Common Options

OptionDescription
defaultsStandard mount options
noatimeDisable access time logging
roRead-only
rwRead-write
Doing a read only mount:
UUID=abcd-1234  /mnt/storage  ext4  ro  0  2

Conclusion

Using UUID in fstab ensures stable mounts even if device names change.