The Procedure:
- For conformity, create a directory under /mnt say sda2.
Code: Select all
mkdir /mnt/sda2
- Mount the root partition holding the installation to be modified. I will assume it is: /dev/sda2
Code: Select all
mount /dev/sda2 /mnt/sda2
- I found that for the chroot to work properly I had to bind the /sys, /proc and /dev directories as follows:
Code: Select all
mount -o bind /sys /mnt/sda2/sys mount -o bind /proc /mnt/sda2/proc mount -o bind /dev /mnt/sda2/dev
- Do the actual chroot as follows:
If you are going to install packages containing daemons, you may need to prevent them from starting. The Debian Chroot Wiki contains this information.
Code: Select all
chroot /mnt/sda2 /bin/sh
- After finishing with the chroot, exit.
Code: Select all
exit
- Unmount the bound file systems.
Code: Select all
umount /mnt/sda2/dev umount /mnt/sda2/proc umount /mnt/sda2/sys
- Finally unmount the partition. If applicable to your case, unmount the other partitions that make part of the repaired installation. Finally, unmount the partition (in our case, sda2).
Code: Select all
umount /mnt/sda2
Using chroot to repair grub-pc from within a LiveCD session or from within another running session.
The first thing I found about repairing an otherwise badly behaving grub-pc, is by purging it completely together with its configuration files. This means, when I was asked to remove the grub files I replied in the affirmative.
The Procedure
- Purge grub-pc together with all its files under /boot.
Needless to repeat, answer that you want to delete all traces of grub-pc.
Code: Select all
# apt-get remove --purge grub-pc
- Reinstall grub-pc.
When asked where to install the first stage select the MBR or the protective MBR in case of GPT.
Code: Select all
# apt-get install grub-pc