Core Linux – Setting up GRUB

To prepare for installing grub, it is necessary to chroot into the system mounted on /mnt. To do this, we need a working /proc and /dev under /mnt; this is accomplished like thus:

mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev

Then perform the chroot – making the new environment mounted under /mnt our new environment:

chroot /mnt /bin/bash

Note that this makes bash the current shell – not my general choice (I prefer ksh) but things might break if you use the wrong shell….

Now we can install and configure grub:

grub-mkdevicemap
grub-install --grub-setup=/boot/grub/grub.cfg /dev/sda
/sbin/grub-install: line 223: /boot/grub/grub.cfg: Permission denied
grub-setup --directory=/boot/grub --device-map=/boot/grub/device.map /dev/sda
cat /boot/2.6.21.1/grub >> /boot/grub/grub.cfg

The error comes from grub-install apparently trying to write to grub.cfg (which has permissions 644). The directions say this error can be ignored – so that’s what we’ll do.

The resulting grub.cfg looks like this:

# Set timeout
set timeout=30

# Set default entry
set default=0

# Grub configuration for linux-2.6.21.1
menuentry "Core 2.0 GNU/LInux (2.6.21.1)"{
set root=(hd0,1)
linux (hd0,1)/boot/2.6.21.1/bzImage root=/dev/hda1 vga=5
}

In this case, this is certainly wrong. The last stanza is preconfigured for hda and for a single volume root. Since I have two partitions, and am using /dev/sda, it should be:

# Grub configuration for linux-2.6.21.1
menuentry "Core 2.0 GNU/LInux (2.6.21.1)"{
set root=(hd0,1)
linux (hd0,1)/2.6.21.1/bzImage root=/dev/sda3 vga=5
}

Then edit /etc/fstab:

/dev/sda1 /boot ext3 defaults 0 0
/dev/sda3 / ext3 defaults 0 0
/dev/sda2 swap swap defaults 0 0

Then reboot:

exit
cd /
umount /mnt/dev
umount /mnt/proc
umount /mnt/boot
umount /mnt
shutdown -rn now

Next time…. the first boot.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: