The MLN Project

Complex virtual machine management made easy

Creating Software RAID on your UML

This example demonstrates how to create a software RAID on your virtual machine. You might wonder why this is interesting, but i can come up with three cases:
  1. You want to learn about Linux software RAID, but do not have the available partitions and space to do so.
  2. You want to improve performance or stability by introduction of redundancy.
  3. You need a bigger partition then the underlying filesystem can give you. So you glue several 2GB partitions together and mount it as a big filesystem.
I am not familiar with any benchmark suggesting a filesystem speedup or otherwise on UML in practice, but one could place each file (what will become a disk) on a separate disk on the physical machine.

The entire example is as root-free as possible, meaning you can try this without root privileges. That is why i don't address network connectivity in this example. You need to have the uml-utillites installed on the system you try this on. This can either be done manually, or through a package management tool.

Getting the latest version of MLN

This example will work on 0.73rc3cvs4 and up. If you want to get the lates CVS version, run this command:

wget "*checkout*/mln/mln-cvs/mln"

Finding a suitable template and uml version

The template used here is this: sarge-thick-V0.7.ext2.tar.gz
It contains the mdadm tool needed to administer software RAID in Linux.

The uml version is uml-2.6.12-rc2-mm3.tar.gz
It has compiled-in support for device-mapper and different RAID types. If you think of using your own uml kernel, make sure it supports device-mapper.

Creating the ekstra disks

MLN lets you specify more disks, but it does not create them for you, so we'll create the disks manually. I want to create a RAID level 5, so we need three disks for it. I make mine 1.5 GB each:

dd if=/dev/zero of=/old-disk/disk1 seek=1500 count=1 bs=1M

dd if=/dev/zero of=/old-disk/disk2 seek=1500 count=1 bs=1M

dd if=/dev/zero of=/other-disk/disk3 seek=1500 count=1 bs=1M

Note, that two of the partitions reside on a different disk.

MLN project file

Next, i write the project file:

global {

       project rt



host jumbo {

     template sarge-thick.ext2

     memory 96M

     term screen

     free_space 200M


     mount {

     	   /old-disk/disk1 none

	   /old-disk/disk2 none

	   /other-disk/disk3 none



This is a simple setup. No root password and no network connectivity. Look at the other examples in order to see how you can connect the hosts to the network.

Building and starting

Building and starting is done with these two commands:

mln build -f software-raid.mln

mln start -p rt

You can now connect to the virtual machine using screen

screen -r jumbo.rt

Setting up the software raid

We are now inside the virtual machine and are about to create the software raid and to add it to /etc/fstab in order to make it available at every reboot.

Creating the array

jumbo# mdadm -C /dev/md0 --level=raid5 --raid-devices=3 /dev/ubd32

/dev/ubd48 /dev/ubd64

Note the strange numbering for the different partitions. Every uml ubd device has a 16 count difference in /dev. Next, you may create a filesystem on the raid device:

jumbo: mkfs.ext3 /dev/md0

Writing /etc/mdadm/mdadm.conf

In ordder to make the administration tool detect the array next time it boots. Write this into the file /etc/mdadm/mdadm.conf

DEVICE /dev/ubd32 /dev/ubd48 /dev/ubd64

ARRAY /dev/md0 level=raid5 num-devices=3 devices=/dev/ubd32,/dev/ubd48,/dev/ubd64

Edit /etc/fstab

Last, we add the array to fstab and mount it:

jumbo# mkdir /raid

jumbo# echo "/dev/md0 /raid ext3 defaults 0  0" >> /etc/fstab

jumbo# mount -av

You can doublecheck the results with df. You now have a 3.5 GB partition put together by three 1.5 GB partitions in a RAID 5 setup.