If a system is unable to boot completely, Emergency Mode and Rescue Mode offer an opportunity to fix problems.
- [Instructor] When a system has problems severe enough to keep it from booting into a multi-user target, sometimes we can use rescue mode or emergency mode to look around and diagnose an issue. On systems running System D, rescue mode and emergency mode are targets that take the system into a single-user environment. Rescue mode boots a single-user shell, starts some system services and tries to mount available file systems. Emergency mode starts a single-user shell in a read-only root file system. Neither mode enables network connections though so keep that in mind.
If a system is damaged in some way, especially if a particular service is broken or the file system is damaged, it may start itself up into rescue or emergency targets if it can't reach the multi-user or graphical targets. And you can boot into either of these targets manually by modifying boot parameters or by isolating the target from the command line. To boot into these targets manually, we'll interrupt the boot process with Escape. Choose the relevant entry and press E to edit the boot arguments. We'll find the Linux line and to go into rescue mode, at the end of that line we'll add systemd.unit=rescue.target.
To move into emergency mode, we'd edit that line to end with systemd.unit=emegency.target. And then we'll press Control + X to boot with these options. This change won't affect later boots though. Let's go into rescue mode. I'll restart my virtual machine and interrupt its boot process by pressing Escape. Then with my entry highlighted, I'll press E and move down to the Linux line.
I'll move to the end, add a space, and write systemd.unit=rescue.target and then I'll press Control + X. I'm told that we can look at logs with journalctl -xb which can be helpful to see what might be preventing the system from reaching the regular targets. I'm also given commands to reboot and to continue into default mode which is whatever target is set for the system, usually graphical mode.
If I press Control + D here, I'll continue into the default mode as well, but I want to use rescue mode so I'll press Enter. And here I am at the root prompt. If this isn't a good reminder to set a password for the root user on your systems, I don't know what is. If you have set a root password, you'll be prompted to enter it. This system has its normal file systems mounted as read-write along with a few services, but there's no network access. There's no graphical environment running and the only user able to use this system is root. This mode gives you access to your system as normal, generally speaking, to use root to resolve any issues that you might need to.
That might be rolling back updates, reconfiguring services, freeing up space, or checking out the file system. If you can get to rescue mode, you have a pretty wide array of tools at your disposal, but the system may not always get this far. Emergency mode gives us a more limited environment to work with which mounts only the root file system in read-only mode. There are essentially no services running except the bare minimum to get to a single-user shell. This mode is usually used for troubleshooting from the ground up. Almost nothing is running so we can use this mode to enable services and targets one by one to trace problems.
You can move from emergency mode to rescue mode with systemctl rescue if the system is functional enough to allow it. These modes give you an opportunity to troubleshoot and repair your system to some extent. And while they're not commonly used day to day, they're good to know about if you need them. For now though, I'll type reboot and start my system up normally.
Note: Because this is an ongoing series, viewers will not receive a certificate of completion.