Mailinglist Archive: opensuse (946 mails)

< Previous Next >
Re: Grub Recovery Cheat-Sheet [was Re: [opensuse] Trashed boot loader]
  • From: Bruce Ferrell <bferrell@xxxxxxxxxxxx>
  • Date: Thu, 21 Oct 2010 21:04:16 -0700
  • Message-id: <4CC10D40.6070503@xxxxxxxxxxxx>
On 10/21/2010 08:00 PM, David C. Rankin wrote:
On 10/21/2010 07:59 PM, Bruce Ferrell wrote:

OK, I got a kernel update and it trashed the boot loader leaving in a
grub prompt.

SO, since the system repair option was removed because "about the only
thing it was used for was to fix the boot loader", how do I fix it? I
really don't want to re-install.

Bruce Ferrell

+++++++++++++++
Normal Install
+++++++++++++++

(1) Boot with the install cd and get to a command line (repair
console/whatever)
(2) chroot your system "in say" /mnt

use 'cat /proc/partitions' to list your partitions, then start with your
root
partition, home partition and then /boot (if separate and any others).
Example:

(assuming / is on /dev/sda1, /boot on /dev/sda2 and /home on /dev/sda3)

mount /dev/sda1 /mnt
mount /dev/sda2 /mnt/boot
mount /dev/sda3 /mnt/home
mount -o bind /dev /mnt/dev
mount -o bind /proc /mnt/proc
mount -o bind /sys /mnt/sys
cd /mnt
chroot /mnt

** now you have your system chrooted under /mnt and can use any tools
(Yast/etc.) to reinstall grub. Just do it by hand, it's easier:

(3) type 'grub' (no quotes)

If you are not sure which partition actually holds stage1 boot, use the
command 'find' like this:

(4) grub> find /boot/grub/stage1 ( or just 'find stage1' )

This will search for the file name '/boot/grub/stage1' and show the
devices
which contain the file. Next set the root device correctly followed by the
command 'setup' to complete the process. To set grub's root:

(5) grub> root (hd0,0)

where hd0 represents the drive (hd0 - first drive, hd1 - second drive, etc..)

The next number is grub's root partition (not the same as your linux
partition). This is the partition you BOOT from. So, if you have a separate
/boot partition, this is the '0' based partition number for your /boot
partition. If you have NO separate /boot partition, then this will just be
your
/ partition number.

If you have a RAID setup, then define the array that will serve as 'hd0',
'hd1' in your device.map file. Example:

00:21 archangel:~> cat /boot/grub/device.map
(hd0) /dev/mapper/nvidia_fdaacfde
(hd1) /dev/mapper/nvidia_baaccaja
(fd0) /dev/fd0

Then, run the command 'setup'

(6) grub> setup (hd0)

Your output should be:

Checking if "/boot/grub/stage1" exists....... no
Checking if "/grub/stage1" exists....... yes
Checking if "/grub/stage2" exists....... yes
Checking if "/grub/e2fs_stage1_5" exists....... yes
Running "embed /grub/e2fs_stage1_5 (hd0)"....... 15 sectors are embedded
succeded
Running "install /grub/stage1 (hd0) (hd0) 1+15 p (hd0,2)/grub/stage2
/grub/grub.conf....... succeded
Done

The setup command has installed the GRUB boot loader on the Master Boot
Record (MBR) of the first drive. (or drive specified with (hd#))

(7) Type quit

grub> quit

GRUB is now in the MBR.

(8) go check your kernel line in the /boot/grub/menu.lst file and make sure
the
initrd and vmlinuz files are linked to the proper files in /boot. If you need
to
re-link them, just use 'ln -sf <target> <link>' Like:

ln -sf vmlinuz-2.6.25.20-0.7-default vmlinuz
ln -sf initrd-2.6.25.20-0.7-default initrd

(9) exit the chroot setup by typing 'exit'

reboot :p


Mr Rankin,

I don't care what they say, you are a scholar and a gentleman! And I'll
keep your secret!

Thank you

Bruce
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups