When systemd Boots You into Emergency Mode, Now What

Introduction to Emergency Mode

I’ve seen this go wrong when a critical system service fails or a filesystem gets corrupted - systemd boots you into emergency mode. This is a sign that something has gone wrong during the boot process, and it’s usually due to a failed mount, a critical system service failure, or even a corrupted root filesystem. When this happens, you’re presented with a minimal environment to troubleshoot and potentially repair your system.

Understanding Emergency Mode

The real trick is to understand that emergency mode is a special target in systemd that allows you to perform administrative tasks when the system cannot boot normally. It’s similar to the rescue target but with more services available, such as networking. To enter emergency mode, systemd will automatically switch to it if a critical service fails to start or if the root filesystem cannot be mounted. Don’t bother with trying to manually switch to emergency mode unless you’re sure that’s what you need.

Troubleshooting in Emergency Mode

When you find yourself in emergency mode, the first step is to understand why you’re there. I usually start with checking the systemd logs for hints:

journalctl -xb

This command shows you the logs from the current boot, which can help you identify the issue. Look for error messages related to service failures or filesystem issues. This is where people usually get burned - they don’t take the time to read through the logs and end up missing crucial information.

Common Issues and Solutions

In practice, one common reason for entering emergency mode is a failed mount. If a filesystem is corrupted or a disk is failing, systemd might not be able to mount it, leading to emergency mode. You can try to repair the filesystem using fsck:

fsck /dev/sda1

Replace /dev/sda1 with the actual device name of the corrupted filesystem. Another issue could be a critical service failing to start. Check the service status with:

systemctl status

This command lists all services and their current status. If a critical service is failing, you might need to repair or reconfigure it.

Rebooting and Recovery

Once you’ve identified and potentially fixed the issue, you can try to reboot your system:

systemctl reboot

If the problem persists, you might need to use a live CD or USB stick to perform more extensive repairs or backups. For more information on systemd targets and emergency mode, you can refer to the systemd.io documentation.

Additional Tips

  • Regularly backing up your system and important data can save you a lot of trouble in case of a failure.
  • Keeping your system up to date with the latest security patches and software updates can prevent many issues.
  • Familiarizing yourself with systemd and its capabilities can make troubleshooting and system management more efficient.

See also