fstab Builder

Build /etc/fstab lines for disks, shares, swap and RAM disks, and check an fstab
Build the right /etc/fstab line to mount a disk, an NFS or Windows (SMB) share, a swap file, a RAM disk or a bind mount at boot, with the safe steps to add it: back up, check with findmnt --verify, reload systemd, mount. Paste a line from blkid to fill in the UUID. Or paste your whole fstab to have every line explained and checked for mistakes that stop a server booting.
RUNS ENTIRELY IN YOUR BROWSER · NOTHING IS SENT ANYWHERE

Your system

More options

The six fields

FieldExampleWhat it means
1. DeviceUUID=3e6b…What to mount: a disk by its UUID or LABEL, a share like nas:/srv/share or //server/share, a swap file, or tmpfs.
2. Mount point/mnt/dataThe folder where it appears. none for swap. A space is written \040.
3. Typeext4The filesystem: ext4, xfs, btrfs, vfat, exfat, ntfs3, nfs, cifs, swap, tmpfs, or none for a bind mount.
4. Optionsdefaults,nofailComma-separated, no spaces. defaults when you need nothing special.
5. Dump0Only for the old dump backup tool. Always 0 today.
6. Pass2Check the filesystem at boot: 1 for /, 2 for other ext4 and vfat disks, 0 for everything else (xfs, btrfs, swap, shares).

Options you’ll use most

OptionWhat it does
nofailBoot carries on if it’s missing. Use it for every disk and share the system doesn’t need to start.
x-systemd.automountMount on first use, so boot never waits. Good for network shares and USB disks.
noatimeDon’t write a timestamp every time a file is read. Fewer writes, slightly faster.
roRead-only.
noautoDon’t mount at boot; mount it by hand with sudo mount /mnt/data.
noexec, nosuid, nodevData only: no programs, setuid bits or device files. Good for shared and removable storage.
uid=, gid=, umask=Owner and permissions for vfat, exFAT, NTFS and SMB, which don’t store Linux owners. ext4 and xfs refuse them.
credentials=SMB: a root-only file holding the user name and password, so they stay out of fstab.
_netdevNeeds the network. systemd already knows that for NFS and SMB; it matters for disks reached over iSCSI.
errors=remount-roext4: switch to read-only if the filesystem finds an error. Debian and Ubuntu use it for /.
subvol=, compress=zstdbtrfs: which subvolume to mount, and compress new files.
discardTell an SSD about deleted blocks at once. Most distributions run fstrim weekly instead, which is usually better.

fstab rules worth knowing

Won’t boot after an fstab change?

  1. At the emergency mode prompt, enter the root password. (No root password, as on Ubuntu? In the GRUB menu press e, add init=/bin/bash to the end of the line that starts with linux, and press Ctrl+X.)
  2. Make the disk writable: mount -o remount,rw /
  3. Put the backup back with cp /etc/fstab.bak-… /etc/fstab, or open nano /etc/fstab and put a # in front of the bad line.
  4. Restart: reboot (after init=/bin/bash, use sync then reboot -f).
  5. On a cloud server, use the provider’s serial or recovery console, or attach the disk to another server and fix the file there.

Mount a disk or share at boot without locking yourself out

Paste a line from sudo blkid or fill in the share details, and the builder writes the fstab line with the right options, then the steps to add it safely: back up the file, check it with findmnt --verify, tell systemd, and mount. The checker explains every line of an existing fstab and flags the mistakes that stop a server booting.

Common questions

How do I mount a drive automatically at boot in Linux?

Find the partition’s UUID with sudo blkid, make a folder with sudo mkdir -p /mnt/data, and add a line like UUID=… /mnt/data ext4 defaults,nofail 0 2 to /etc/fstab. Then run sudo findmnt --verify, sudo systemctl daemon-reload and sudo mount -a to test it before you reboot.

What do the two numbers at the end of an fstab line mean?

The fifth field is for the old dump backup tool and is always 0 today. The sixth decides the boot-time filesystem check: 1 for the root filesystem, 2 for other ext4 and FAT disks, and 0 for no check, which is right for xfs, btrfs, swap and network shares.

What does nofail do in fstab?

It lets the boot carry on if that disk or share is missing. Without it, systemd stops in emergency mode when a local disk listed in fstab isn’t there, and for a network share, logins wait until the mount times out. Use it for everything the system doesn’t need to start.

How do I fix emergency mode after editing fstab?

Enter the root password at the prompt, run mount -o remount,rw /, then restore your backup of /etc/fstab or put a # in front of the bad line, and reboot. If root has no password, add init=/bin/bash to the kernel line in the GRUB menu to get a shell.

How do I mount a Windows (SMB) share without putting the password in fstab?

Every user can read /etc/fstab, so put the user name and password in a separate file that only root can read (chmod 600), and point to it with credentials=/root/.smbcredentials. Install cifs-utils first, and add nofail so a missing server doesn’t hold up the boot.

Related tools: Systemd Generator · Error Message Decoder · All tools A–Z