Reinstalling GRUB
From ArchWiki
| i18n |
|---|
| English |
| Español |
| Italiano |
| 简体中文 |
Contents |
[edit] Introduction
This guide will show you how to reinstall GRUB with an Arch Installation CD if you lose GRUB somehow.
[edit] Notes
- In this guide, I'll be using sda as my root udev type references. If you are using a pre-0.7.1 installation CD, you will have to substitute udev references for devfs references. See Technical_Terms#Hard_Drives if this doesn't make sense.
- Also, be aware that this guide is aimed at people using SATA drives, not IDE so subsitute IDE names like hda iinstead of sda if you have IDE devices and you are not using libata.
[edit] Booting the Install CD
The first thing you will need is an Install CD. Any install CD should work; however, using the latest CD will be easier than using an older CD.
Boot the CD as if you were doing an installation (DO NOT use the root= option) and move on to the next step.
[edit] Mount and Chroot into Your Current Installation
Now, you need to mount your current installation. The general process for this is as follows:
- NOTE: You need to know what the proper partitions and filesystem types are. I will use sda1 as the root partition and ext3 as the filesystem in this example; change those for your personal setup.
cd / mount -t ext3 /dev/sda1 /mnt #If you are using a pre-0.7.1 CD, sda1 will be /dev/discs/disc0/part1 mount -t proc proc /mnt/proc mount -t sysfs sys /mnt/sys mount -o bind /dev /mnt/dev chroot /mnt /bin/bash
Now you should be logged in as root, and into your current installation as if you had just booted it and logged in as root.
If your /boot directory is on the same partition as your /, move on to the next step. If on the other hand it's on a separate partition (for example, /dev/sda2), then you need to mount that partition now to /boot so that grub can find the files it needs:
mount -t ext2 /dev/sda2 /boot
[edit] Reinstalling GRUB
Edit /boot/grub/menu.lst and make sure that everything is in order. Once you are completely sure that menu.lst is correct, run the following command:
grub-install /dev/sda
This command should complete sucessfully if you have followed all the steps. (If not, take a look at the notes below.) That's it, you're done! Exit chroot and reboot:
cd / umount -a exit cd / umount -a reboot
[edit] Errors
If you get an error that says The file /boot/grub/stage1 not read correctly, it probably means that your fstab/mtab is incorrect for some reason and needs to be fixed. These files are /etc/mtab and /etc/fstab. Edit them and make sure they point to the correct partitions, then rerun grub-install.
If this still doesn't fix the error message and you're using ext2/3 as filesystem for your boot partition, use "tune2fs -l /dev/sda1" to check for the Inode size of your root/boot partition. Anything else than 128 will make grub unable to read the partition. The only solution for this problem is to recreate your rootfs with the correct options (fix /etc/mke2fs.conf and set inode_size to 128).
If you get an error that says sed: can't read /boot/grub/device.map: No such file or directory, it means that you need to use the --recheck option with grub-install.
grub-install --recheck /dev/sda
Hopefully that covers all the issues you should encounter. If you get any other errors, reboot and do the guide step-by-step again.
Hope this guide was helpful! — Shadowhand