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:
- --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
- To format the new array with the file system you want use the command line. In the following example I’m using ext4 but it could be ext2, ext3, xfs, etc.
- Open the Ubuntu Installer using the shortcut in the desktop. Choose the language you prefer, the time zone you are located and your keyboard layout. After that you should be in the step 4: Prepare disk space. Choose the last option “Specify partitions manually (advanced)“. Select the RAID array to be used by the mount point you want. In my case I’m using as / (root). Click in forward, configure you user, recheck the information and client in install.
- Wait until the installation in finished.
- Mount the installation (and also proc, sys and dev on it) and chroot to the directory:
- Install mdadm with apt-get (like you did in the step 3):
- At this point you should be able to boot in your new system, but WAIT! The Ubuntu installer usually install the boot loader (GRUB2) in just one of your disks, if this disk fails you won’t be able to boot your system. To avoid that let’s install it in both disks:
- Reboot your system, remove the CD and enjoy your redundancy. ;)
# mdadm --create /dev/md1 --verbose --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
Explainig the command:
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[1] sdc1[0]
3909248 blocks [2/2] [UU]
by seocam - (Sergio Oliveira)
26 comments: