6

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 https://help.ubuntu.com/community/UEC/Images 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.

3 Answers 3

1

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

4
  • 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, 2013 at 23:07
  • Why not just booting the VM and installing grub? Feb 12, 2014 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, 2014 at 11:08
  • If you want to use VirtualBox, you can use VBoxManage internalcommands createrawvmdk -filename cloud-image.vmdk -rawdisk cloud-image.img to create a meta description file for using the image with a new virtual machine.
    – Florian
    Aug 2, 2016 at 13:22
1

Perhaps this is useful? http://en.wikibooks.org/wiki/QEMU/Images#Exchanging_images_with_VirtualBox

4
  • 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. Sep 26, 2011 at 6:26
  • 2
    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, 2012 at 3:02
  • @ppetraki want to make that an answer for upvoting? Apr 3, 2012 at 13:14
  • @Tom: Sorry, I don't use Vbox anymore.
    – ppetraki
    Apr 3, 2012 at 15:10
0

There is now an Ova formatted image that works after importing into VirtualBox, see my long search below. I still haven't figured out how to boot an image in Virt-manager, and would like to, but extlinux didnt help. It's not seeing the kernel file locations with Direct Boot.

What are the different versions available as Ubuntu cloud-images?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .