Now up to the GRUB2 boot loader. Create the file /etc/grub.d/09_swraid1_setup as follows:
1 2
| cp /etc/grub.d/40_custom /etc/grub.d/09_swraid1_setup
vi /etc/grub.d/09_swraid1_setup |
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| #!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry 'Ubuntu, with Linux 2.6.32-21-server' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod raid
insmod mdraid
insmod ext2
set root='(md0)'
linux /vmlinuz-2.6.32-21-server root=/dev/md2 ro quiet
initrd /initrd.img-2.6.32-21-server
} |
Make sure you use the correct kernel version in the
menuentry stanza (in the
linux and
initrd lines). You can find it out by running
uname -r or by taking a look at the current menuentry stanzas in the
### BEGIN /etc/grub.d/10_linux ### section in
/boot/grub/grub.cfg. Also make sure that you use
root=/dev/md2 in the
linux line.
The important part in our new
menuentry stanza is the line
set root='(md0)' - it makes sure that we boot from our RAID1 array
/dev/md0 (which will hold the /boot partition) instead of
/dev/sda or
/dev/sdb which is important if one of our hard drives fails - the system will still be able to boot.
Run
update-grub to write our new kernel stanza from
/etc/grub.d/09_swraid1_setup to
/boot/grub/grub.cfg.
Next we adjust our ramdisk to the new situation:
update-initramfs -u.
Now we copy the contents of /dev/sda1 and /dev/sda3 to /dev/md0 and /dev/md2 (which are mounted on /mnt/md0 and /mnt/md2):
1 2 3
| cp -dpRx / /mnt/md2
cd /boot
cp -dpRx . /mnt/md0 |
Preparing GRUB2 :
Afterwards we must make sure that the GRUB2 bootloader is installed on both hard drives,
/dev/sda and
/dev/sdb:
1 2
| grub-install /dev/sda
grub-install /dev/sdb |
Now reboot the system and hope that it boots ok from our RAID arrays.
Partager