Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@JakubOboza JakubOboza commented Apr 14, 2012

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

@bdha

This comment has been minimized.

Copy link
Owner Author

@bdha bdha commented Apr 14, 2012

Yup. Fixed.

@shh0

This comment has been minimized.

Copy link

@shh0 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
You can’t perform that action at this time.