Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to turn the disk image from a cloud image (former UEC image) into a bootable VirtualBox (for Vagrant). I can run the image in kvm (using as a starter), but how can I turn the .img disk file into a bootable VirtualBox disk? I would rather not use the floppy as boot.

share|improve this question
up vote 1 down vote accepted

The solution is indeed to make the image itself bootable. After days of searching the interwebs I found that the solution is to use the package extlinux, which is a derivative of syslinux — a solution for making FAT disks bootable. extlinux works on e2fs and derivatives, this works perfectly on any old ext2 system.

mkdir /mnt/image
mount -o loop cloud-image.img /mnt/image
mkdir /mnt/image/extlinux/
extlinux --install /mnt/image/extlinux/
echo "DEFAULT /vmlinuz" > /mnt/image/extlinux/extlinux.conf
echo "APPEND root=/dev/sda init=/usr/lib/cloud-init/uncloud-init" \
     "ubuntu-pass=ubuntu ds=nocloud" >> /mnt/image/extlinux/extlinux.conf
umount /mnt/image

This will make the image bootable, and disable built-in cloud initialization techniques and so on.

Notes: I haven't worked out how to specify an APPEND which allows it to use the "root=LABEL=cloudimage-rootfs".

The resulting image can then boot using qemu, kvm or vmware, without additional floppies, kernels, or anything. And from what I understand, apt-get upgrading the kernel will make that kernel active the next boot.

edit: I forgot to mention the obvious that you need to perform this loop-back mounting on the raw disk image, and then convert the resulting file to a VDI using vboxmanage convertfromraw cloud-image.img cloud-image.vdi

share|improve this answer
root=LABEL=cloudimage-rootfs can be replaced with root=/dev/disk/by-label/cloudimg-rootfs not tested but I'll assume the initrd is using udev as far as I know LABEL tends to be an init script variable, meaning its dependant on ubuntu's init scripts which I do not know enough about. – strings Jan 7 '13 at 23:07
Why not just booting the VM and installing grub? – Blaisorblade Feb 12 '14 at 5:16
The point was to be able to do this without having to boot it, so as to support things like cloud-init in a non-cloud environment, using stock UEC images. I think this answer might be obsolete, as I've seen that UEC images actually are bootable as-is (which was not the case a couple of years ago). – mogsie Feb 20 '14 at 11:08

Perhaps this is useful?

share|improve this answer
While certainly useful, it does not help with the current problem, as the disk file from cloud images is not a bootable disk. It works in KVM because I can boot a specific kernel file, and tell it where the root file system is. What I need is a way to turn the disk image into a bootable disk. – Magne Rasmussen Sep 26 '11 at 6:26
Then you have to solve this problem just like you would with a real computer and load a live cd/usb image, chroot your target disk, and install the boot loader and kernel. Start there, get it working in KVM then convert it to a VirtualBox image. – ppetraki Jan 27 '12 at 3:02
@ppetraki want to make that an answer for upvoting? – Tom Brossman Apr 3 '12 at 13:14
@Tom: Sorry, I don't use Vbox anymore. – ppetraki Apr 3 '12 at 15:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.