Friday, April 03, 2009

OVS: Add a new disk to a guest

Running out of disk space is something that happens all to soon in today's (database) systems. Even on my laptop! So I needed more disks. How do I do that when working with OVS and guests?

That's actually quite easy to accomplish on linuxy OS'es. As every device is treated as a 'file' you can therefore create new devices by making a file and connect it to a device driver.

In our case we need to add a disk to a linux guest from OVS. Following are the steps to create the device and present it to the guest.
  1. create a file in Domain0 for the guest (e.g.: in the running_pool)
    dd if=/dev/zero of=disk2.img bs=1M count=(1024*#GB_needed)
  2. change the disk configuration of the guest
    edit your vm.cfg and add the disk to the disk parameter.
    disk = ['file:/OVS/vm1/running_pool/system.img,hda,w','file:/OVS/vm1/running_pool/disk2.img,hdb,w']
  3. reboot the guest
    xm shutdown guest
    xm create guest
  4. logon to guest
    ssh hostname
  5. partition the new disk
    fdisk /dev/hdb
  6. create the desired filesystem on the partition(s). Example ext3
    mkfs -t ext3 /dev/hdb1
  7. Add filesystem to /etc/fstab for automatic mounting at boot
    /dev/hdb1 /u02 ext3 defaults 0 0

That's all!

No comments:

Post a Comment