1

What is the correct way to enter emergency mode during boot (without mounting any filesysstem) so I can run fsck?

systemd.unit=emergency.target as a kernel parameter dropped me into a shell though it did mount root.

If I replace the linux line in grub (on Arch) the following seems to work even though it shows some errors (device '' not found):

linux /vmlinuz-linux ro

This does not mount anything and allows me to run fsck -f on all drives.

Is there a better option or some documentation?

laktak
  • 5,946
  • Linux must have a filesystem as it needs to run at least an initial process and the code for this process needs to be stored somewhere. These days it is usual to have an initial ramdisk. If the ramdisk image is not compiled into the kernel image then it is passed by grub using the initd command. What you did appears to be to tell the initial ramdisk not to switch to a root filesystem on the hard drive. – icarus Jun 22 '20 at 20:24
  • emergency.target should mount the root filesystem read-only. Can you verify it's doing that on your system? – Mark Plotnick Jun 22 '20 at 21:41
  • @MarkPlotnick if I change rw to ro and add systemd.unit=emergency.target root is indeed mounted ro. Thanks for the hint. – laktak Jun 23 '20 at 20:03

1 Answers1

2

The ways to trigger emergency or rescue modes have been the same across multiple system management systems since 1995, when they were invented. systemd, the system-manager from the nosh toolset, and van Smoorenburg init all support these mechanisms. They are copiously documented, and have been in books on Linux since at least 1997.

In the kernel command line, set by LILO, GRUB, or some other bootstrap loader:

  • -b signifies emergency mode
  • -s signifies rescue mode

van Smoorenburg init, where these were invented, supports the additional synonyms S, single, and emergency. systemd and the nosh system-manager (actually system-control init which it passes the process #1 command-line on to) both support those synonyms and the further synonyms s, 1, and rescue.

All of these are documented in their respective manuals.

Further reading

JdeBP
  • 68,745
  • Thank you. In addition to -b or -s it is also necessary to change/remove rw from the kernel parameters so it's possible for fsck to check the drive. – laktak Jun 25 '20 at 09:24