/etc/fstab lists which disk is mounted where at every boot; one bad line can stop the machine from coming up.
Use UUID= instead of /dev/sdb1, add nofail for secondary disks, and always test with findmnt --verify and mount -a before rebooting.
Keep a copy of fstab and an open SSH session while you edit.
This article shows how to permanently mount an ext4 file system (created on an LVM volume or an ordinary partition) at /srv/app on Ubuntu 24.04 LTS, so that the machine still boots even when the disk is absent.
It explains why a broken fstab is so dangerous and how to test it yourself before rebooting.
sudo rights; a file system already created with mkfs.ext4.
A directory to use as the mount point: sudo mkdir -p /srv/app.
A spare SSH session or console left open, so you can fix things if something goes wrong.
A backup copy: sudo cp /etc/fstab /etc/fstab.bak.
Warning: a bad line in /etc/fstab can drop the machine into emergency mode at boot, requiring direct console access to fix. For a remote machine with no console, the risk is greater.
Steps
Each fstab line has six fields separated by whitespace:
<device> <mount point> <type> <options> <dump> <fsck>
Example:
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /srv/app ext4 defaults,nofail 0 2
The dump field is usually 0. The fsck field is the order of file system checks at boot: 1 is for the root file system /, 2 for other file systems, and 0 means no check.
sudo blkid /dev/vg_data/lv_app
lsblk -f
Names like /dev/sdb1 can change when you add disks or change their order, whereas the UUID is tied to the file system and stays stable.
With LVM the /dev/<VG>/<LV> path is also stable, but the UUID is still the consistent choice.
sudo nano /etc/fstab
Add a line at the end with your real UUID (as in the example above). What the options mean:
defaults: the default option set (rw, suid, dev, exec, auto, nouser, async).
nofail: if the device is not present, the boot is not treated as failed. Use it for secondary data disks; do not use it for a disk the system cannot run without.
x-systemd.device-timeout=10s (optional extra): limits how long systemd waits for the device to appear, instead of waiting long before giving up.
sudo findmnt --verify
sudo systemctl daemon-reload
sudo mount -a
findmnt /srv/app
findmnt --verify reads fstab and reports syntax errors,
nonexistent UUIDs and missing mount points. daemon-reload reloads the mount units that systemd generates from fstab. mount -a mounts every entry not yet mounted; if it reports an error,
fix it right away and do not reboot.
Only when mount -a succeeds and findmnt /srv/app shows the right device:
Write a test file into /srv/app.
Reboot with sudo reboot while you still have a fallback way in.
After it comes up, run findmnt /srv/app and df -h /srv/app.
If the disk holds data that a service needs, check that the service runs correctly after the mount using systemctl status, as in systemctl on Ubuntu 24.04: enabling, disabling and restarting services and checking their status.
With Docker, remember that volume data lives under Docker's data directory by default, so to use a separate disk you must put it in the right place; read Named volumes and bind mounts: where data lives when a container is removed to learn where data lives.
A mistyped UUID or mount point. findmnt --verify catches most of these; if you skip it, the machine may enter emergency mode.
Mount point not created. mount reports that the directory does not exist; create it with mkdir -p.
Using nofail and forgetting about it. If the disk is absent, the service still starts but writes data into the empty directory on the root disk, and you think it was saved on the secondary disk.
For important services, add a check that the mount point is mounted.
Spaces in the options. Options are separated by commas, with no whitespace.
Editing fstab but forgetting daemon-reload. systemd may keep the old configuration until it is reloaded.
Recovering after an incident. In emergency mode, put /etc/fstab.bak back or put a # at the start of the faulty line, then reboot.
A safe fstab line uses a UUID instead of a device name, nofail for secondary disks, and the routine of findmnt --verify, daemon-reload, mount -a before rebooting.
Keep a backup and a fallback way in; most boot problems caused by fstab can be avoided with these three checks.