Wednesday, September 21, 2011

ZFS and Virtualbox

Below are step by step instructions on setting up Virtualbox on Solaris10 and using zfs to clone.

Setup:

Solaris 10u8b5 installed on machine with 4 gig RAM and duo core processor.
Downloaded Latest Virtualbox from here: http://www.virtualbox.org/wiki/Downloads to /opt

Step 1: Install Virtualbox.
  1. cd /opt
  2. tar -xvf VirtualBox-3.0.4-50684-SunOS.tar
  3. pkgadd -d VirtualBoxKern-3.0.4-SunOS-r50684.pkg
  4. pkgadd -d VirtualBox-3.0.4-SunOS-r50684.pkg
Step 2: Setup zfs filesystem. This machine only has one hard drive so we make a zfs filesystem under UFS.
  1. cd /export/home
  2. mkfile 30000m vpool
Create SWAP space under ZFS: (Use roughly double the physical RAM)
  1. zfs create -V 10gb vpool/swap
Create the ZFS vpool
  1. zpool -f create vpool /export/home/vpool
Create an area to put the GOLDEN image:
  1. zfs create -V 15g vpool/GOLDEN_IMAGE/
Step 3: Get a GOLDEN image from net10-bambi.
  1. cd vpool/GOLDEN_IMAGE/
    #ftp <golden image repository>
    usual password.
  2. cd /export/vm_images/GOLDEN_images
  3. bin
  4. get Windows7_x86_b7229_vb_GOLDEN.vdi.tar.gz
  5. bye
  6. gunzip Windows7_x86_b7229_vb_GOLDEN.vdi.tar.gz
  7. tar -xvf Windows7_x86_b7229_vb_GOLDEN.vdi.tar
(Ideally at this point you should create a VM and point to the GOLDEN image, start the VM and update the GOLDEN with any patches/updates etc you need. Then stop the VM.)

Step 4: Cloning.
Ok we have the GOLDEN image now we can clone.
First we snapshot the GOLDEN image:
  1. zfs snapshot vpool/GOLDEN_IMAGE@golden
Then we create an area for TEST_IMAGE
  1. zfs create vpool/TEST_IMAGE
And then we clone:
  1. zfs clone vpool/GOLDEN_IMAGE@golden vpool/TEST_IMAGE/disk_image1
  2. zfs clone vpool/GOLDEN_IMAGE@golden vpool/TEST_IMAGE/disk_image2
  3. zfs clone vpool/GOLDEN_IMAGE@golden vpool/TEST_IMAGE/disk_image3
Change the uuid of each disk:

VBoxManage internalcommands setvdiuuid /vpool/TEST_IMAGE/disk_image1/Windows7_x86_b7229_vb_GOLDEN.vdi

VBoxManage internalcommands setvdiuuid /vpool/TEST_IMAGE/disk_image2/Windows7_x86_b7229_vb_GOLDEN.vdi

VBoxManage internalcommands setvdiuuid /vpool/TEST_IMAGE/disk_image3/Windows7_x86_b7229_vb_GOLDEN.vdi

Each of these disk_images is very small and only grows as the VM is used.

Step 5: Create VM.
This has been covered in previous emails/blogs so I wont cover it again. Basically just create your VM's, select "existing disk" and point it to one of the disk_images in Step 4.

No comments:

Post a Comment