5

I am booting cirros VMs outside of an Openstack environment using libvirt. At boot, the VM checks for metadata twenty times, which adds a lot of latency to the boot time.

cirros-ds 'net' up at 6.14
checking http://169.254.169.254/2009-04-04/instance-id failed 1/20: up 6.18. request failed failed 2/20: up 18.32. request failed failed 3/20: up 30.38. request failed failed 4/20: up 42.44. request failed [snip]

I'm using cirros-0.3.3.

Can I use cloud-init or some other mechanism to disable the metadata lookup?

Jeff Loughridge
  • 1,074
  • 2
  • 7
  • 18
  • Please do keep in mind that if this question is considered to be concerning a non-Production use case, it will likely end up closed as off-topic here on ServerFault. – Magellan Nov 22 '14 at 15:30
  • I understand how some might view this as a development/test question. Let me provide an example of a production use case. Using cirros as a "pinger VM" to measure VM to VM, host to host, or rack to rack latency/jitter/packet delivery. If these VMs are spun up dynamically to obtain a measurement ASAP, you wouldn't need the metadata service and you probably wouldn't want to set-up an HTTP server to send metadata. The VM's boot time is vital and any optimizations are helpful. – Jeff Loughridge Nov 24 '14 at 18:46

3 Answers3

2

I was able to answer my own question after a few days of research. You must pass "ds=nocloud" as a kernel option to the VM.

Here's how I did it.


#!/bin/sh

export VM_NAME=cirros$$
IMAGES_BASE=/var/lib/libvirt/images
cp $IMAGES_BASE/cirros/cirros-0.3.0-i386-blank.img $IMAGES_BASE/$VM_NAME.img

virt-install -r 256 \
  -n $VM_NAME \
  --vcpus=1 \
  --import \
  --autostart \
  --memballoon virtio \
  --network bridge=virbr0 \
  --boot kernel=$IMAGES_BASE/cirros/cirros-0.3.0-i386-vmlinuz,initrd=$IMAGES_BASE/cirros/cirros-0.3.0-i386-initrd,kernel_args="console=/dev/ttyS0 ds=nocloud" \
  --disk $IMAGES_BASE/$VM_NAME.img \
  --noautoconsole

The kernel, initrd, and blank image are contained in the UEC versions of cirros on the download page.

UPDATE - Another method is to edit /etc/cirros-init/config. Change the DATASOURCE_LIST variable. This method requires updating the VM image so I prefer using the kernel args method. The file /etc/cirros-init/config exists in cirros-0.3.3 but not cirros-0.3.0. I didn't check other versions.

Jeff Loughridge
  • 1,074
  • 2
  • 7
  • 18
1

One option will be to start the VM -> Set DATASOURCE_LIST="nocloud" in /etc/cirros-init/config -> Stop the VM and use the new image file as a reference for future VMs to be deployed.

-1

You might interested in : https://github.com/eprasad/virt-cirros . Virtualization platform friendly cirros image