0

I've used ubuntu-cloud template as LXC containers, and they all worked fine. Recently I switched to use libvirt-lxc, and followed instructions in Ubuntu document, but the image initialized differently from LXC:

  1. Tried to connect to AWS's meta-data server and got errors:

    2013-02-05 00:55:48,209 - util.py[WARNING]: 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed [50/120s]: url error [timed out]
    
  2. Default password didn't work. I need to enable password by modifying the rootfs' /etc/shadow because the default password of "ubuntu" account had been banned.

I think LXC pre-handle the cloud-init issues and feed it some user-data and meta-data. I tried to find how to do this manually, but the cloud-init document page didn't help, because it's examples are all for euca-tools.

And I also noticed that lxc-start has an option -C :"The -C option will create a cloud container, configured for use with a metadata service." But I just didn't know how to map this option and it's all related settings to libvirt_lxc.

How can I init the image/rootfs correctly ?

snowmantw
  • 111
  • 4

1 Answers1

1

Ok, after searching several days to solve the cloud-init issues, I found I can prepare a seed disk to mount in guest system to let cloud-init boot with. In detail:

  1. Create a libvirt domain XML with LXC rootfs
  2. Prepare meta-data and user-data files just following this reference
  3. Instead of createing a ISO file, we can add a mount option in our domain XML to seed files to cloud-init:

    <!-- language: lang-xml -->
    <filesystem type='mount'>
      <source dir='./seed-dir-path'/>
    
      <!-- Make sure your rootfs has `/var/lib/cloud/seed` directory first-->
    
      <target dir='/var/lib/cloud/seed/nocloud'/>
    </filesystem>
    
  4. Define the domain and start it. Now the cloud-init will get the meta-data and user-data.

And, cloud-init lacks documents 1,2. I've spent a lots of time on searching pieces of information from issue tracker, blog and even github repos. In contrast, the libvirt, has a useful Wiki at least.

snowmantw
  • 111
  • 4