LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Recover grub with /boot on a separate partition. (https://www.linuxquestions.org/questions/linux-newbie-8/recover-grub-with-boot-on-a-separate-partition-832212/)

werepacman 09-14-2010 10:07 PM

Recover grub with /boot on a separate partition.
 
Hi.
Somehow I broke my boot. Probably after playing with PClinuxOS install which has legacy grub version.
I need help with recovering grub with /boot on a separate partition.
Most tutorials suggest that boot directory is on the same partition with system. But I have boot on the /dev/sda1 and Kubuntu on the /dev/sda5.

I tried to boot from Ubuntu livecd and execute

sudo grub-install --root-directory=/mnt/sda1 /dev/sda
or
sudo grub-install --root-directory=/mnt/sda5 /dev/sda

But with no result. I always boot in the empty grub console.
Fortunately I have all my boot drive in tar.bz2, so I can experiment.

What should I do to recover my boot?

santana 09-14-2010 10:35 PM

1. Boot into the live CD

2. from console
~$ sudo apt-get update

3. Now mount the exiting Linux install:
~$ sudo mount /dev/sda5 /mnt/
~$ sudo mount /dev/sda2 /mnt/boot

4. Bind your /dev, /proc and /sysfs and copy over the resolv.conf then chroot into it:
~$ sudo mount –bind /dev /mnt/dev/
~$ sudo mount -t proc proc /mnt/proc/
~$ sudo mount -t sysfs sys /mnt/sys/
~$ sudo cp /etc/resolv.conf /mnt/etc/resolv.conf
~$ sudo chroot /mnt

5. Now install and grub:

~$ apt-get update
~$ apt-get install grub

6. Create the GRUB directory:
~$ mkdir /boot/grub/

7. Copy over the GRUB files to the new grub folder:
~$ cp /usr/lib/grub/x86_64-pc/* /boot/grub/
(Replace x86_64-pc with your architecture if you are using something other than AMD64)

8. Now run grub:
~$ grub
grub> device (hd0) /dev/sda
grub> find /boot/grub/stage1
grub> root (hd0,X)
grub> setup (hd0)

If ‘fine /boot/grub/stage1′ shows something else than 0,0, for example 1,0, then do ‘root (hd1,X) X is the partition number where / is.

9. Now you can create a menu.lst by running:
~$ update-grub


All times are GMT -5. The time now is 09:17 PM.