Monday, May 7, 2012

Install Grub2 from a LiveCD

KNOW:
Command line basics
chroot
grub

You would think that installing Grub...or GRUB2 from a LiveCD will be an easy task -- think again.  There is a lot to know so let's get to it.

1) Boot to a liveCD.  Most graphic LiveCD's take 20 years to bootup -- Ubuntu being a great one for that but you can get text only LiveCD's so look for em.

2) Run terminal.  You need to get to a terminal to make this work.

3) We're now going to make the installed version of linux work instead of the LiveCD. This is tricky so let's get to it.

(a) you MUST know the partitian for your boot (/boot) and your mnt (/) locations.
In this example, we're going to use /sdb6 for our root (/) and /sdb1 for our boot.  Most installations don't separate the two but I'm giving you the extreme example.

sudo /mnt/sdb6 /mnt

Here we mount the entire partitian to the /mnt directory.

sudo /mnt/sdb1 /mnt/boot

(IF your boot partitian is different, otherwise leave alone)

Now we're going to point three directories (/proc /dev /sys) to our new mount point.

mount -t proc none /mnt/proc
mount -o bind /sys /mnt/sys
mount -o bind /dev /mnt/dev  (the devices)
cp -L /etc/resolv.conf /mnt/etc/resolv.conf

The purpose of this is to simply avoid host name errors

chroot /mnt/ /bin/bash  (most critical)
env-update 
source /etc/profile 
export PS1="(chroot) $PS1"

NOTE:
cp /proc/mounts /etc/mtab

(use this if you plan to reinstall grub)

sudo grub-install /dev/sdb1

That should shove it on the boot of the drive.

 

No comments:

Post a Comment