7

I want to run an Ubuntu cloud image on on VMWare.

I just need to know how to set the OVF properties in a way that VMWare understands in order to pass parameters to cloud-init.

What I've done

Install VMWare Player 4.0.4, using the vmware workstation 8.0.2 / player 4.0.2 fix for linux 3.2+ patch to get around the compilation failure for virtual ethernet module.

Download precise-server-cloudimg-amd64.ovf, and also the precise-server-cloudimg-amd64.img file (compressed QCOW2 format, 220MB)

Convert the image from QCOW2 to VMDK:

qemu-img convert -O vmdk precise-server-cloudimg-amd64-disk1.img disk.vmdk

Edit the OVF <File> element to change the ovf:href and ovf:size to match the output of qemu-img:

<File ovf:href="disk.vmdk" ovf:id="file1" ovf:size="689569792"/> 

Edit the <Disk> element to set sparse VMDK format and desired capacity in bytes (8GB here):

<Disk ovf:capacity="8589934592" ovf:diskId="vmdisk1" ovf:fileRef="file1" 
ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#sparse"/>

Remove all the <Property> elements because vmplayer does not recognise them.

Configure the VirtualHardwareSection section to set CPU and RAM to taste.

Either run the OVF in vmplayer, or convert to vmx and run the vmx:

ovftools custom.ovf mymachine.vmx
vmplayer mymachine.vmx

Unfortunately I can't log in as "ubuntu" at the prompt because the OVF properties haven't been provided to cloud-init. How should I do this?

2
  • Have you tried downloading the "boot floppy .iso" (2Mb) and mount that as the CDROM? This will give you a grub prompt that allows you to also edit the command line. I've successfully made cloud images boot on VirtualBox using this technique.
    – mogsie
    Jun 20, 2012 at 9:54
  • No, but I think I'm going to try putting the "OVF Environment" XML file in an ISO that's mounted during first boot.
    – Graham
    Jun 20, 2012 at 12:25

3 Answers 3

4

This answer is based on the NoCloud README from CloudInit and gives you cloud-init on VMWare player.

Create the file "meta-data", using "localhost" as a guaranteed-to-resolve hostname to avoid DNS timeouts that make sudo take ages in a local hypervisor environment:

local-hostname: localhost

Create the file "user-data" file for CloudInit info. This one sets password to ubuntu, and asks me to change it on first login:

#cloud-config
password: ubuntu

Generate seed.iso from these files:

genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data

Attach "seed.iso" to the VM before first boot (set it to connect on start), and when grub appears, also add this kernel parameter for the first boot:

ds=nocloud-net

The machine will boot and configure itself. For future boots, we need to edit edit /etc/default/grub and run sudo update-grub to tell it we are not in EC2 (no cloud metadata service):

GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0 ds=nocloud"
1
0

I have found a way to make the Ubuntu Cloud Images bootable, and put my answer

Here's the gist of it:

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

The result is basically a bootable harddisk. You can convert this using whatever tools you have available to suit your virtualization, and (as you can see of the APPEND root=/dev/sda) things might need tweaking depending on what your virtual hardware is (scsi or ide or sata)...

2
  • Not keen on using extlinux, or modifying the image prior to boot. The cloud image comes compressed in qcow2 format, which you can't mount directly.
    – Graham
    Jul 2, 2012 at 12:26
  • Yeah, that's a nice thing. I couldn't figure out how to get an ISO to stick when we made an OVF or OVA of the thing, but making the disk bootable certainly helped. Thanks for the "console=ttyS0" tip too, btw!
    – mogsie
    Aug 15, 2012 at 12:02
0

This answer relates to precise pangolin, and describes a way to solve this problem without resorting to a CD image (which I couldn't get to work using VMware ESX).

It seems the Ubuntu Cloud Images now contain a boot sector (something I can't recall they did earlier). If you do convert the image to vmdk using qemu-img and clean up the OVF as described, you can in fact boot it up into grub without further ado. Grub has a default 5 seconds timeout, so you should be able to edit the boot parameters on the first boot to include:

init=/usr/lib/cloud-init/uncloud-init ubuntu-pass=ubuntu ds=nocloud-net console=tty0

This will print everything out to tty0, set the ubuntu password to something known, and force the "uncloud" initialization. and will allow you log in with the credentials provided. Note that the command line is visible for anyone who logs in (cat /proc/cmdline), so you should change the grub configuration after first boot (see below) and reboot.

I've had success with this technique using VMware ESX with only vncviewer installed locally; no VMware tools other than ovftool used to upload the ovf to ESX. Presumably the same technique will work with a VMware Player.

To make things more permanent modify /etc/default/grub and set add ds=nocloud-net to the command line again to avoid cloud-init making any further changes to your image. Run update-grub to then make it stick and reboot.

1
  • Hmm, this is progress for trying to use the new Ova format. Have you had success with that? Do you get a Grub menu after using qemu-img? I have to use Direct Boot options in Virt-manager to point to the kernel files but with similar boot parameters. Here's my notes on that if your interested: askubuntu.com/a/1376185/795299
    – alchemy
    Nov 17, 2021 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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