Friday, September 26, 2008

USB Flash Raid for VM

Because I have entirely too much time on my hands, and this is entirely too cool, I have granted one of my Xen VM's access to two USB thumb drives as a Raid Level 1 mirror. Turns out, this taught me a solution to previous problem, as well.

I inserted the two drives in the Dom0 system, where they appeared as /dev/sda and /dev/sdb. I used fdisk to set their types to FD = Linux raid autodetect. Next, I assigned them to the DomU:
# virsh attach-disk valkyrie /dev/sda hdc
# virsh attach-disk valkyrie /dev/sdb hdd
From DomU, define the raid
# fdisk -l 2>/dev/null | grep "/dev/hd.1"
/dev/hdc1 1 489 31270+ fd Linux raid autodetect
/dev/hdd1 1 489 31270+ fd Linux raid autodetect
# mdadm -C /dev/md0 -l 1 -n 2 /dev/hdc1 /dev/hdd1
mdadm: /dev/hdc1 appears to contain an ext2fs file system
size=31268K mtime=Fri Feb 9 13:12:40 2007
mdadm: /dev/hdd1 appears to contain an ext2fs file system
size=31268K mtime=Fri Feb 9 13:12:40 2007
Continue creating array? y
mdadm: array /dev/md0 started.
# mke2fs -j /dev/md0
Mount per SOP.

Unfortunately, this is not persistant across reboots. For this, we need to edit the VM's config file and change the disk line to include:
disk = [ "tap:aio:/xen/valkyrie.img,xvda,w",
      "phys:/dev/sda,hdc,w",
      "phys:/dev/sdb,hdd,w"
]
That should get it.

No comments:

Post a Comment