How to chroot into linux distro on disk when you can't boot via grub

This will restore your grub startup menu

(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:

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.

Links

Hi!

The blog "Alvistec" aims to positioning itself as a recurring site for consultation, in alternative technologies. The Alvistec blog aims so that becomes one most visited sites of tech enthusiasts that contributes to facilitates and to spreads the use of free software, electronics reuse; among other topics.

Caution!: This site is not liable for any damage caused to people or equipment with the information it is exposed. All content is purely informational purposes and is not intended to be a guide. The presented material has been used solely for training purposes and/or entertainment. Viewer discretion is advised.