In my work I sometimes come across a problem when Linux is booted with the “Welcome to emergency mode” message. Most often, this problem occurs after an emergency power outage on a server, after a system crush or other similar situations. In 90% of cases, the error is related to fstab or Linux file system damage which can be fixed quite easily.
In this article we will discuss some ways to solve this issue.
How to Fix Linux File System Errors Using LiveCD?
Suppose, you have had a failure on your server, like an emergency power outage, and when connecting to your Linux server in the remote console or VNC, you see the following:
Welcome to emergency mode! After logging in, type “journalctl -xb” to view system logs, “systemctl reboot” to reboot, “systemctl default” or ^D to try again boot into default mode. Give root password for maintained (or press Control-D to continue).
If you press Control + D, your system will start booting, but in some time it gets back to the emergency mode:
To solve this problem, you need to boot your server from a LiveCD or LiveUSB and use the SystemRescueCd tool. I have booted my host from a LiveCD image with built-in systemrescuecd:
Then run file system check and fix all found errors using this command:
# fsck -y /dev/sda1
— where sda1 is your disk partition
You must check all partitions and restart your host. In most cases, your problem will be solved.
Emergency Mode due to /etc/fstab Issues
Another problem that may occur is an fstab damage or incorrect configuration. In my case, when I booted from systemrescuecd and checked the system, no errors were found, but the problem was not solved. Having opened fstab, I saw that there were no disk partitions to mount, only the boot disk entry was available in the configuration file:
To solve this problem, you must get UUIDs of your disks using blkid:
Then add all the information you have got in fstab and reboot your Linux host. If you have done it correctly, your Linux will boot in normal mode.
Linux Has Been Installed from a USB Stick
Also, I came across a situation when Linux had been installed from a USB media, and after a server restart, the system booted with ‘Welcome to emergency mode!’ message. After viewing fstab, it turned out that the USB device was displayed there as a working partition. In this case you can delete the USB drive mount entry and reboot the system. Like in the first case, you must boot from systemrescuecd and open fstab. It is likely, you will see a similar entry— /mnt/usb1:
Just remove this line if you are not using the USB drive.
Dualboot Windows and Linux configuration
Another variant of this problem reported by users is using both Windows and CentOS on the same computer (in dual boot configuration). The emergency mode error often occurs when mounting Windows partitions during the boot. Usually the problem is solved by disabling Windows fast startup.
To disable it, select Change settings that are currently unavailable in Control Panel\All Control Panel Items\Power Options\System Settings. Uncheck the option “Turn on fast startup”.
Save the changes and restart your device. After doing it, your Linux should boot normally.
If you use LVM partitions, this error may also occur. In general, the solution is similar to that related to a common partition: check your fstab configuration and fix errors in it.