If you want Linux to boot even if the disk mount fails, add the nofail option to fstab.

The reason for writing this article in the first place

I did it

I reduced the number of USB HDDs connected to my Raspberry Pi running at home by one, but forgot to mess with fstab.

What happened as a result

In a situation where you cannot log in with SSH! I usually operate it headless, but when I hurriedly connect the display and see the error, it seems that it is in emergency mode. Even if I connect the keyboard and press a key, the same error message goes around, and even if I connect the display and the keyboard, I can not recover.

Corresponding

Pull out the micro SD of the unbootable Raspberry Pi and connect it to another Raspberry Pi via a USB card reader. Then, mount it in an appropriate directory and change the fstab of the Raspberry Pi that became unbootable as follows.

Before changing fstab


/dev/sdb1 /mnt/hoge ext4 defaults 0 0

After changing fstab


/dev/sdb1 /mnt/hoge ext4 defaults,nofail 0 0

Now when I plug the micro SD into the original machine and restart it, it revives, ignoring the mounting error. When I looked at what happened later with fdisk -l, the drive that was previously connected to / dev / sdb1 was moved to / dev / sda1.

I found out by investigating

Apparently, if the drive listed in fstab is not found or there is an error, Linux will simply give up booting and go into emergency mode? (It may differ depending on the distribution, but since it is a quick survey from the starting point, please let me know if you have any details.)

best practice

** On Linux, add the nofail option when mounting with fstab the kind of disks that will be mounted and removed. ** **

Perhaps even for virtual machines on the cloud, if you write the setting to mount the virtual VHD in fstab, remove it by the management operation on the cloud side, and accidentally reboot the OS, I feel that the same situation will occur.

Recommended Posts

If you want Linux to boot even if the disk mount fails, add the nofail option to fstab.
Add Windows to the Linux OS boot menu
If you want your colleagues to use the same language
If you want to include awsebcli with CircleCI, specify the python version
Isn't Qt the strongest library if you want to easily output SVG?
Workaround if you cannot add to LD_LIBRARY_PATH
Linux: Netplan configuration guide to see when you want to fix the IP address
If you want to enter the virtual environment with jupyter, nb_conda_kernels is recommended
If you want to create a Word Cloud.
When you want to update the chrome driver.
What to do if the Microsoft Store opens even if you run python on Windows
What to do if you get the error ʻERR_FEATURE_UNAVAILABLE_ON_PLATFORM` when using ts-node-dev on Linux