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

Categories:  Linux
Labels:  terminal, tutorials, command, bash, 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:

Instructions

Boot from livecd or usb, then in the terminal window enter:

$ sudo su
# TARGET=/media/sda1
# mkdir -p $TARGET
# mount /dev/sda1 $TARGET
# mount --bind /dev     $TARGET/dev
# mount --bind /dev/pts $TARGET/dev/pts
# mount --bind /proc    $TARGET/proc
# mount --bind /sys     $TARGET/sys
# cp /etc/resolv.conf    $TARGET/etc/
# chroot $TARGET /bin/bash

This places you in a root terminal on the linux system
Do whatever you want to do there, e.g. re-install grub

# grub-install /dev/sda
# update-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

Thats it…

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.

Reference

http://crunchbanglinux.org/forums/post/225409/

Related Posts:

Social Profiles

Alvistec spanish
Plan Alvistec in Youtube
Privacy policy

This web site uses third's cookies and the Google's cookies to offer services, personalize ads and analyze traffic (Google analytics).
The information on the use of the this web site is shared with Google and another ads provider platforms. When you using this web site, you accept cookies use.
See more about the Cookies

This web accept cryptocoin donations
BTC address, LTC, ETH, Uphold:
Why donations?