Add new comment

Restore GRUB (Archlinux)

Sometimes I have the need to restore GRUB as bootloader. This especially happens after a Windows installation/upgrade.

Note: this only works for grup version 1, not for grub version 2 and greater.

Anyway, I wanted to document (and share) and easy method for doing just this. Reason: I found it hard to find on the internet. If it turns out to be useful for you... then it would be nice if you leave a short (friendly) comment.

Here we go.

1. Boot linux

Well, of course we will boot Linux from a livecd. Personally I use the archlinux install cd for this, but all this is up to you! With the arch install cd at least I know that the following procedure works.

2. Set up the chroot environment

Now we need to use the originally installed linux system in order to install grub nicely. For this we use a chroot environment. Before we can start, find out what hard disk your linux system is on (use fdisk -l).

Create a directory where you would like to mount the device or partition, then mount it:

mkdir /mnt/arch
mount /dev/<device-or-partition-name> /mnt/arch

Now create the chroot environment:

cd /mnt/arch
mount -o bind /dev dev/
mount -t proc proc proc/
mount -t sysfs sys sys/

Mount other parts of your filesystem (e.g. /boot, /var, /usr...) that reside on separate partitions but which you need access to. For example:

mount /dev/<device-or-partition-name> boot/

Now chroot to your installed device or partition and define your shell:

chroot . /bin/bash

As we will be dealing with GRUB we need to ensure that our mtab file is up-to-date:

grep -v rootfs /proc/mounts > /etc/mtab

 

3. Install GRUB (again)

First we start the GRUB shell:

grub

 Now we are in the GRUB shell and we tell it where to boot from;. Let us ensure that we know where to boot from:

find /boot/grub/stage1

The answer to this will be used in the next command (example: for a /dev/sda5, the answer will be (hd0,4)):

root (hd0,4)
setup (hd0)

If this was succesfull, then exit GRUB:

quit

  and  exit the chroot environment:

  exit

 

 4. Finally

  Now make sure all changes have been saved

  sync

 and reboot to check if everything worked as planned.

 

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • E-Mail addresses are hidden with reCAPTCHA Mailhide.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • E-Mail addresses are hidden with reCAPTCHA Mailhide.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
By submitting this form, you accept the Mollom privacy policy.

© 2008 - 2013 Patrick Hanckmann

View Patrick Hanckmann's profile on LinkedIn