Skip to content

Instantly share code, notes, and snippets.

@bdha
Created March 1, 2012 04:04
Show Gist options
  • Save bdha/1947201 to your computer and use it in GitHub Desktop.
Save bdha/1947201 to your computer and use it in GitHub Desktop.
Migrating from VirtualBox to KVM on ZFS
# It's important to convert the vbox image (VMDK or VDI or whatever) using
# the same version of VirtualBox that created it. You can try converting the image
# with qemu-img or kvm-img, but weird version mismatches will possibly make it not
# work.
# On your VirtualBox machine:
cd $VBOX_ROOT/$MACHINE_ROOT/
VBoxManage clonehd machine.vmdk machine.img --format RAW
scp machine.img root@kvm-host:/somewhere
# Now go over to your KVM host.
ssh root@kvm-host
cd /somewhere
# You may want to run something like the following to ensure your raw image is
# bootable before taking all the time to dd it.
qemu-system-x86_64 -drive file=machine.img,boot=on
# You need to see how big of a volume you need for the image, and then create a
# sparse dataset of that size and dd the raw image onto the ZFS raw block device.
ls -l machine.img
123456b
zfs create -V 123456b zones/machine
dd if=machine.img of=/dev/zvol/rdsk/zones/machine
# That's it. Point your KVM branded zone at that dataset and it should boot.
#
# Cheers.
@JakubOboza
Copy link

You have machine.raw in line 20 and machine.img in line 25 which refers to the same file. (i'm right ? )

@bdha
Copy link
Author

bdha commented Apr 14, 2012

Yup. Fixed.

@shh0
Copy link

shh0 commented Aug 6, 2017

dd if=machine.img of=/dev/zvol/rdsk/zones/machine

This takes incredibly long. According to the partition size, you should add something like bs=1M or similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment