Thomas' Tech Tips

Rescue non-bootable Linux system from a rescue cd and chroot

22 February 2023 - Thomas Damgaard

Sometimes you have find yourself in a situation in which a machine fails to boot up Linux for some reason or other.

In such situations, the machine can be salvaged by booting up on a bootable Linux Live CD image or USB. From there you can mount the machine’s file systems and fix the issue preventing it from booting.

This is how to do it.

Boot up the machine on a rescue image or live CD/live USB.

From the rescue system open a terminal and run:

mount /dev/md1 /mnt
mount /dev/md0 /mnt/boot
for name in proc sys dev ; do mount --bind /$name /mnt/$name; done
mount --bind /etc/resolv.conf /mnt/etc/resolv.conf
chroot /mnt/ /bin/bash

In the above, the root file system is on /dev/md1. /boot file system is on /dev/md0.

Now you have a shell with the original machine’s filesystems mounted. From here you should fix whatever issue is preventing Linux from booting.

Typically this involves running:

update-initramfs -uv; update-grub

But sometimes it can be a more serious issue.

Note, sometimes update-grub will hang after the cpio step. This is due to some issues with systemd and udev causing vgs command to hang for a long time.

This happened for me today, and I let it hang and went to lunch. When I came back it had terminated.

After this you should be ready to try rebooting.

More information on:

Filed under: boot, chroot, debian, grub, howto, initramfs, linux, tips

Back to article list