Skip to content

Instantly share code, notes, and snippets.

@naisanza
Forked from bdha/vbox_to_kvm.txt
Created November 6, 2015 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naisanza/e520a38033ea258d467a to your computer and use it in GitHub Desktop.
Save naisanza/e520a38033ea258d467a 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment