Grub disk: something automatic?
Tom H
tomh0665 at gmail.com
Thu Jan 28 16:12:59 UTC 2010
> 1. If possible, arrange your hard drives so your primary linux partition
> is on your boot hard drives. When bootstrapping grub, disconnect the
> other hard drives. It's impossible for even grub to mix up the hard
> drive numbering when there is only hd0. It will not matter how badly
> device.map is inaccurate on future update-grub runs, since grub will now
> auto-fix itself based on UUID's.. (I'm really loving this new feature.)
Disconnecting the other HDs is pretty radical but why not! :)
> 2. Install grub on the super-block of your filesystem as well as the
> mbr. (this won't work with XFS filesystem, since XFS does not leave
> space on the superblock)
> ex: grub-install /dev/sda1
I have lost track whether this is a grub1 or grub2 situation but, if
it is grub2, you cannot run "grub-install /dev/sda1". You can force an
install to /dev/sda1 but I was told off by Goh Lip the last time that
I suggested it (and rightly so!).
Regarding chrooting, Johnnylee Rollins posted a chroot procedure (for grub1) at
https://lists.ubuntu.com/archives/ubuntu-users/2010-January/208595.html
<begin>
This is how you boot from livecd and chroot into your system to reinstall grub.
1.) Boot into the live Ubuntu cd
2.) When you get to the desktop open a terminal.
2.1) Become root with sudo -i
3.) You have to mount your root partition.
3.1) # mkdir /mnt/root
3.2) # mount -t ext3 /dev/x /mnt/root (x is your root partition's
device name. Mine is /dev/sda1)
4.) Now you have to mount the proc subsystem and udev inside /mnt/root
4.1) # mount -t proc none /mnt/root/proc
4.2) # mount -o bind /dev /mnt/root/dev
5.) Now you have to chroot into your mounted system.
5.1) # chroot /mnt/root /bin/bash
6.) Now to reinstall grub. If you aren't root after chrooting, add
sudo to this command
6.1) # grub
7.) Now you should have a prompt that looks like this: grub> we're
going to locate our grub installation
7.1) grub> find /boot/grub/stage1 (only copy and paste the "find
/boot/grub/stage1" part)
7.2) grub should print out some location. Mine said (hd0,1)
8.) Now we're going to make sure grub uses the partition with grub on it
8.1) grub> root (hd0,1) (replace 0,1 with where grub said your
installation was.)
9.) Now to install grub onto the partition
9.1) grub> setup (hd0) (replace this with the first number you got in step 7.1)
</end>
I would add
4.3) # mount -o bind /dev/pts /mnt/root/dev/pts
4.4) # mount -o bind /sys /mnt/root/sys
out of habit and because (on RHEL and Fedora) without 4.3, you will
get an error that a log entry cannot be written so I do it whether
other distributions need it or not.
For grub2, you would have to replace 6-9 by
6. grub-install /dev/sdX
7. grub-mkconfig -o /boot/grub/grub.cfg
For safety's sake, whether you use the grub1 or grub2 procedure, I
recommend that you exit the chroot and umount all the mounts before
rebooting.
More information about the ubuntu-users
mailing list