Difference between revisions of "User:Faelar"

From ArchWiki
Jump to: navigation, search
(Removing all content from page)
Line 1: Line 1:
 +
[[Category:Boot process (English)]]
 +
[[Category:System recovery (English)]]
 +
[[Category:HOWTOs (English)]]
  
 +
{{i18n_links_start}}
 +
{{i18n_entry|English|Reinstalling GRUB}}
 +
{{i18n_entry|Español|Reinstalando GRUB}}
 +
{{i18n_entry|Česky|Přeinstalování GRUBu (Česky)}}
 +
{{i18n_entry|Italiano|Reinstalling GRUB (Italiano)}}
 +
{{i18n_entry|Ελληνικά|Reinstalling GRUB (Ελληνικά)}}
 +
{{i18n_entry|简体中文|重装GRUB}}
 +
{{i18n_links_end}}
 +
 +
 +
==Introduction==
 +
 +
This guide will show you how to reinstall GRUB with an Arch Installation CD if you lose GRUB somehow.
 +
 +
===Notes===
 +
 +
*In this guide, I'll be using <tt>sda</tt> 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|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 <tt>hda</tt> iinstead of <tt>sda</tt> if you  have IDE devices and you are not using libata.
 +
 +
== Booting the Install CD ==
 +
The first thing you will need is an [http://www.archlinux.org/download 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 <tt>root= option</tt>) and move on to the next step.
 +
 +
=== 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 <tt>sda1</tt> as the root partition and <tt>ext3</tt> as the filesystem in this example; change those for your personal setup.
 +
 +
cd /
 +
# If you are using a pre-0.7.1 CD, sda1 will be /dev/discs/disc0/part1
 +
mount -t ext3  /dev/sda1 /mnt
 +
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
 +
 +
===Reinstalling GRUB===
 +
Edit <tt>/boot/grub/menu.lst</tt> and make sure that everything is in order. Once you are completely sure that <tt>menu.lst</tt> 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
 +
 +
====Errors====
 +
If you get an error that says <tt>The file /boot/grub/stage1 not read correctly</tt>, it probably means that your fstab/mtab is incorrect for some reason and needs to be fixed. These files are <tt>/etc/mtab</tt> and <tt>/etc/fstab</tt>. 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 <tt>sed: can't read /boot/grub/device.map: No such file or directory</tt>, 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.

Revision as of 10:58, 9 June 2009

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end


Introduction

This guide will show you how to reinstall GRUB with an Arch Installation CD if you lose GRUB somehow.

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 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.

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.

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 /
# If you are using a pre-0.7.1 CD, sda1 will be /dev/discs/disc0/part1
mount -t ext3   /dev/sda1 /mnt
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

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

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.