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.
mount -favThen you can see the mounting results.
The parameters are:
-f,--fakedry run; skip the mount(2) syscall — this is only a test and will not actually mount anything-a,--allmount all filesystems mentioned in fstab — test everything in/etc/fstab-v,--verbosesay what is being done — show as much log output as possible
After the test, you can run
mount -avto 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.
swapoff -a # 关闭所有swap
swapon -a # 开启所有swapEnabling 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.
sudo blkid | grep UUID= | grep /dev/sda1
Comments
No comments yet — be the first to write one.