Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

One Line, Six Fields

UUID=your-uuid  /mnt/data  ext4  defaults,nofail  0  2
FieldExampleMeaning
1. DeviceUUID=…What to mount
2. Mount point/mnt/dataWhere it appears
3. Typeext4File system type
4. OptionsdefaultsComma-separated, no spaces
5. Dump0Old backup flag; leave 0
6. Pass2Order of the boot check

Fields are separated by spaces or tabs. Lines that start with # are comments.

Field 1: Name the Device by UUID

Names such as /dev/vdb1 can change between boots when disks are added or found in another order. The UUID belongs to the file system and stays the same. Find it with:

lsblk -f
sudo blkid /dev/vdb1

LABEL=data also works if the label is unique. LVM volumes can be named by their path, such as /dev/data_vg/data_lv, because LVM names do not depend on the order in which disks are found.

Field 4: Common Options

OptionEffect
defaultsThe default set: read-write, mounted at boot
nofailBoot continues if the disk is missing
noatimeReads do not update access times
roRead-only
noexecPrograms cannot run from it
_netdevNeeds the network first

Use nofail on every data disk. Without it, a missing or broken data disk stops the boot in emergency mode. Network file systems also need _netdev.

Fields 5 and 6: Dump and Pass

  • Dump: 0 on current systems.
  • Pass 1: the root file system only, checked first.
  • Pass 2: other ext4 file systems, checked after root.
  • Pass 0: no check. Use it for XFS, whose fsck step does nothing, and for swap.

Typical Lines

UUID=your-root-uuid  /          ext4  errors=remount-ro  0  1
UUID=your-data-uuid  /mnt/data  ext4  defaults,nofail    0  2
UUID=your-xfs-uuid   /srv       xfs   defaults,nofail    0  0
/swapfile            none       swap  sw                 0  0

The root line on Debian and Ubuntu often carries errors=remount-ro, which makes the kernel switch to read-only after a file system error; see read-only file system error. The swap line is explained in how to add a swap file.

Edit and Test Safely

A wrong line can stop the server from booting. Keep a copy, edit, and test before any reboot:

sudo cp /etc/fstab /etc/fstab.bak
sudo nano /etc/fstab
sudo findmnt --verify
sudo systemctl daemon-reload
sudo mount -a

findmnt --verify checks that the file can be parsed and that its entries are usable; add --verbose for details. systemd turns fstab into mount units, so daemon-reload makes it read the new file. mount -a mounts everything not yet mounted, so an error shows now rather than at the next boot. Manual mounting is covered in how to mount a drive in Linux.

When the Server Does Not Boot

  1. Open the server console in your provider's control panel. A failed mount usually ends in emergency mode with a message about a mount or device timeout.
  2. Log in as root. If root has no password and the console refuses, boot the rescue system from the control panel instead and mount the root partition.
  3. If the root file system is read-only, run mount -o remount,rw / so you can edit the file. If the kernel log shows file system errors, repair first instead, as in the fsck guide.
  4. Restore the copy with cp /etc/fstab.bak /etc/fstab, or comment out the new line.
  5. Reboot and check the boot as in how to reboot a Linux server.
Was this answer helpful?
Loading...