To write this how to I’ll be redo the installation using two USB memory sticks as hard drives. The sticks, with 4GB capacity each one, are from different manufacturers but this should not affect the results.
So, let’s start:
- Boot in the Live CD (or USB) and choose to try without install
- Using GParted (System -> Administration -> GParted) create the partitions with the sizes you wish. Make sure the partitions you will use in RAID has exactly the same size. The file system type is not important because you will format the RAID array afterwards.
- Now, using apt-get, the application mdadm (don’t forget to run apt-get update first). That what will manage the array for us.
- During the installation process postfix (mail server) will also be installed. To configure it just choose Local only and answer the questions of the wizard.
- That’s an easy but important step, here we are going to create out array. To do that I used the following command:
# mdadm --create /dev/md1 --verbose --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
Explainig the command:
- --create is creating the array /dev/md1
- --verbose gives you better idea what’s going on in case you have a problem
- --level=1 sets RAID 1
- --raid-devices=2 is the number of devices we want in the array
- /dev/sdb1 /dev/sdc1 are the devices members of the created array
Executing that command you probably get a message similar to that:
mdadm: /dev/sda1 appears to contain an ext2fs file system
size=3927860K mtime=Thu Jan 1 01:00:00 1970
mdadm: size set to 3909248K
Continue creating array?
Type “yes“ and press enter. Your array should be created.
# mkfs.ext4 /dev/md1
The following steps are the most tricky and took me a while to find out the problem. Our new ubuntu installation doesn’t have mdadm installed on it so when you try boot the array can’t be assemble and, obviously, you can’t boot on it. So let’s install mdadm.
# mount /dev/md1 /target/
# mount --bind /dev/ /target/dev/
# mount --bind /sys/ /target/sys/
# mount --bind /proc/ /target/proc/
# chroot /target
# apt-get update
# apt-get install mdadm
# grub-install /dev/sdb
# grub-install /dev/sdc
root@ubuntu:/# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb1 sdc1
3909248 blocks [2/2] [UU]
by seocam - (Sergio Oliveira)