We usually edit /etc/fstab to determine which drives, swap, and so on should be mounted at boot. If the file contains errors, the system will fail on reboot, and you’ll have to fix it in safe mode or single-user mode, which is a hassle.

Can we check fstab without rebooting? Yes, we can.

Bash
mount -fav

Then you can see the mounting results.

The parameters are:

  • -f, --fake dry run; skip the mount(2) syscall — this is only a test and will not actually mount anything
  • -a, --all mount all filesystems mentioned in fstab — test everything in /etc/fstab
  • -v, --verbose say what is being done — show as much log output as possible

After the test, you can run

Bash
mount -av

to actually mount all drives.

Additionally, the command above does not account for swap. We can test with the swapoff/swapon combination to make sure the entire file is fine.

Bash
swapoff -a # 关闭所有swap
swapon -a # 开启所有swap

Enabling all swap here basically reads the /etc/fstab file to decide what to swapon. If everything mounts correctly after doing this, it means the fstab file is written correctly, and you can reboot with confidence.

References

For the fstab file format, you can refer to here and here.

For how to get the UUID, you can refer to here.

Bash
sudo blkid | grep UUID= | grep /dev/sda1