Unlocking yourself out of a dead boot

This morning I was presented with an annoying situation with my debian installation: systemd tried to boot, since there was some failures mounting some partitions it aborted the boot process and tried to drop to a root shell, but since the root account was locked systemd shrugged and gave up the whole process leaving me with an unfixable system. This is a known bug by the way.

I tried using the shell from the install CD but it doesnt have the crypto tools to mount my root (because it’s encrypted :^).

I imagined that there had to be some GRUB boot option to force systemd to ignore all errors and continue with the boot. I wasn't able to find that but I got something that enabled me to solve the problem:

  1. Whenever the GRUB screen appear press "e" to edit the entry.

  2. Go to the kernel boot line like the following:

    linux   /vmlinuz-4.9.0-2-amd64 root=/dev/mapper/fedora-00 ro single iommu=soft
  3. And do the these:

  1. Change "ro" to "rw" to allow you to make changes to the filesystem.

  2. Append "init=/bin/sh" to the line so the kernel will drop to a shell instead of running systemd.

  3. Boot with that configuration(by either pressing Ctrl+x or F10)

  4. Once you are logged in use vi to edit /etc/fstab.

  5. Comment the lines that are causing the problem, or use the nofail option as explained here.

  6. Reboot the machine normally.