I borked my primary boot device’s grub installation last week because I wanted to start Windows 7 to play some LAN games. Windows 7 wouldn’t boot from grub, so I thought I’d install a new grub version. I reinstalled grub before regenerating the config file and rebooted. Too bad the Arch packages don’t handle that for you, as I was used to in Debian. This caused the grub to fail booting both Windows and Arch, so I resorted to changing my primary boot device in the BIOS.
Now, one week later, I decided to fix it, and as I can never recall by heart what the steps to take are, here’s a recipe, pretty much for my own convenience.
I’m running Arch Linux currently, but the same principle should work for any Linux flavour you might be using.
Recipe
- Boot from whatever live CD you have lying around
- Login in a shell
- Create a local mount point for your hard disk’s root device (eg
/mnt/root
) Mount the root partition onto that mount point
# mount /dev/sda1 /mnt/root
Mount the device system
# mount -o bind /dev /mnt/root/dev
Mount the proc file system
# mount -t proc none /mnt/root/proc
Change root
# chroot /mnt/root
Make sure the boot partition is mounted, if you have one.
# mount /boot
Regenerate grub config
# grub-mkconfig -o /boot/grub/grub.cfg
Reinstall grub
# grub-install /dev/sda
Reboot and enjoy.
# shutdown -r now
Of course, you need to substitute the device names with your own.
Hi,
Great and relevant post….
Recently setup little Libretto U100 laptop to dual boot WinXPP and Arch…..worked well…
Then I decided to install Win 7 over WinXPP and after that I can only boot up to Win7, don’t see Grub boot menu now…
So, your instructions are just what I was looking for….
However, when I try to do Step 7 Change Root in your instructions, I get the following error message:
chroot: failed to run command /bin/zsh: No such file or directory
This seems odd as I did create the /mnt/root directory and did Steps 1-6 before trying to do Step 7
Any suggestions?
Thanks,
Mark
I am assuming your chrooted environment lacks zsh, which is probably set up as your account’s shell. I suggest either trying to install zsh within the /mnt/root, or try changing your user’s default shell, by calling
chsh
first.Hi, Just something to be aware of, on 16.04.4 I had to mount /sys as well as /proc and /dev,
like this: mount -t sysfs sys /mnt/root/sys
Thanks for the tutorial, it just saved me a LOT of messing around!