(Apply to debian and derivatives)
Assumption 1: Your distro is installed on /dev/sda1 but is not accessible via grub.
Assumption 2: /dev/sda1 is the root partition, and you do not have a separate boot partition.
Goal: reinstall grub in mbr of /dev/sda:
Boot from livecd or usb, then in the terminal window enter:
This places you in a root terminal on the linux system
Do whatever you want to do there, e.g. re-install grub
To exit from chroot:
Press control-D or enter exit
This brings you back to where you were in the live session and you can unmount
# umount -l $TARGET/dev/pts # umount -l $TARGET/dev # umount -l $TARGET/proc # umount -l $TARGET/sys
Reboot into the your linux distro system on disk.
Edit1: Replaced ‘/usr/bin/bash’ by ‘/bin/bash’.
Edit2: Start with defining TARGET, and reference it in all subsequent lines.
Edit3: Use sudo su in stead of sudo.
Edit4: cp /etc/resolv.conf into the chroot to make apt-get possible.