How to : Install Ubuntu onto software RAID0

Found this nifty article which explains how to install Ubuntu onto software raid 0
2 hard-drive, best if they are identical.
Ubuntu liveCD
Boot into a live cd
Install “mdadm” and remove “dmraid” (the latter causes some of my drives to not show up in the installer).

sudo apt-get update
sudo apt-get install mdadm
sudo apt-get remove dmraid

Partitioning the two drives:
– Start the gparted partitioning manager
– Create a 500 MB partition on the “first” drive (“/dev/sda” + “/dev/sdb” = “/dev/sda” is the first one, but you can use any…I think)
– Create the main (“/”) partition on both drives, it’s size should be the rest of the free space minus the space used in the above partition and the swap partition beneath. Remember, this and the next partitions needs to be of equal size on both drives.
– The next partition is for your swap space. Create them with the same size as your RAM (combined they then will become doubled the space of your RAM).
It’s important you are aware what partitions are what “names”, sdb1 etc. You can also use different partitions sizes off course, as long as they have “enough” space.
[ad#Google Adsense-1]
Create the raids:

sudo mdadm –create /dev/md0 –verbose –level=0 –raid-devices=2 /dev/sda2 /dev/sdb1
sudo mdadm –create /dev/md1 –verbose –level=0 –raid-devices=2 /dev/sda3 /dev/sdb2

Format the new raids, or else the install application will want to alter the partition table, on the swap raid partition at least in my experience.

sudo mkfs.ext4 /dev/md0
sudo mkswap /dev/md1

Start the installer (on the desktop), but DON’T reboot in the end when it asks!!!
– Complete the steps…
– …until you get to the partitioning, choose the advanced option at the bottom.
– Choose “/dev/md0” and click change, choose ext4 (or what ever you want) in the dropdown menu, choose to format and choose mount point “/”.
– Choose “/dev/md1” and click change, choose swap (now the rest is greyd out?)
– Choose the 500MB partition, click change: ext4, format, “/boot”
– IMPORTANT! When you arrive at the summary page (after entering name, password etc), click advanced at bottom right, and choose the drive where the 500MB partition is located (“sda”, “sdb” etc….but NOT “sda1”, “sdb1” etc), this is where grub, the boot loader, will be installed.
– The pair partitions will show in black as unknown with a warning sign…just ignore this, it’s ok (assuming the drives doesn’t have additional problems).
You can skip the step on the summary page, but then the Ubuntu installer will install the boot loader on what ever drive it considers the first drive. This should be technically ok, but I prefer to keep Linux separate, had the Win7 connected, so it was detected by Grub.
[ad#Google Adsense-1]
We now need to do some stuff on the installed Linux, but before we boot off it because it can’t boot before we do. So we will mount it and “log” into it.

sudo mount /dev/md0 /target/
sudo mount –bind /dev/ /target/dev/
sudo mount –bind /sys/ /target/sys/
sudo mount –bind /proc/ /target/proc/
sudo mount –bind /dev/sda1 /target/boot/
sudo chroot /target

Notice the underlined part, you have to point it to the 500MB partition you created.
IMPORTANT: In Ubuntu 11.04, use the mounted dir, and not /dev/sda1.
“/media/7feb0b41-e0c2-4d98-b83e-f5f8f7b2e94b” <- example

sudo apt-get update
sudo apt-get remove dmraid
sudo apt-get install mdadm
sudo grub-install /dev/sda

Again, notice the underlined part, do the same as above, where is the 500MB partition?
Update: Notice that “dmraid” is now removed. A bird told me that it could interfere with mdadm. I installed/kept it, but you should probably remove it. Please tell me if this messes up things!
Update 2: Ubuntu 11.04 doesn’t have dmraid, so nothing to remove 
Reboot and remove the live cd/usb stick. If you have set the BIOS to boot from the correct HDD, your Linux Raid 0 setup should start 

Leave a Reply