Converting Virtualbox disk to ZFS volumes

I am trying to create zvol backed virtualbox guests using ZFS on Linux. Hopefully this is not too ambitious.

  1. Find size of original .VDI disk image: vboxmanage showhdinfo Fedora19.vdi
  2. Pass that file size into zfs create: zfs create -V40960M tank/VMs/Fedora19
  3. Convert .vdi file to raw, best if you can do this from one hd to another. In my case I’m reading from a zvol and writing to an ssd: vboxmanage clonehd Fedora19.vdi ~/tmp/Fedora19.raw –format RAW
  4. Load that back into a raw parition image: dd if=~/tmp/Fedora19.raw of=/dev/zvol/tank/VMs/9101-f19 bs=1280k
  5. now we can check partitions: vboxmanage internalcommands listpartitions –rawdisk /dev/zvol/tank/VMs/9101-f19
  6. Then we can create a vmdk file for the raw parition: vboxmanage internalcommands createrawvmdk -filename ~/VirtualBox\ VMs/9101-f19/9101-f19-B.vmdk -rawdisk /dev/zvol/tank/VMs/9101-f19 -partitions 1,2,3
  7. create an idea controller: vboxmanage storagectl …vboxmanage storagectl 9101-f19-B –name IDE –add ide
  8. add blank version of hard drive: vboxmanage storageattach 9101-f19-B –storagectl IDE –port 0 –device 0 –mtype normal –type hdd –medium none
  9. add hard drive: vboxmanage storageattach 9101-f19-B –storagectl IDE –port 0 –device 0 –mtype normal –type hdd –medium “/home/jreynolds/VirtualBox VMs/9101-f19-B/9101-f19-B.vmdk”
  10. …attach the CD rom and then repair the system…somehow my disk image stopped being bootable. :-(
Advertisements