Trying LXD virtual machines

Hey

Thanks alot,

For anyone who wants a complete profile, here is one including auto setting up the lxd-agent’s

stolen from @simos I added the runcmd

config:
  user.user-data: |
    #cloud-config
    ssh_pwauth: yes

    users:
     - name: ubuntu
       passwd: "$6$iBF0eT1/6UPE2u$V66Rk2BMkR09pHTzW2F.4GHYp3Mb8eu81Sy9srZf5sVzHRNpHP99JhdXEVeN0nvjxXVmoA6lcVEhOOqWEd3Wm0"
       lock_passwd: false
       groups: lxd
       shell: /bin/bash
       sudo: ALL=(ALL) NOPASSWD:ALL


    runcmd:
     - mount -t 9p config /mnt/
     - cd /mnt && ./install.sh
     - reboot
description: ""
devices:
  config:
    source: cloud-init:config
    type: disk
name: vm
1 Like

Note that we are working on having the systemd unit files for the agent pre-built into most of our images in the near future, so that step should become a thing of the past soon enough :slight_smile:

Awesome :smile: (please announce it)

Hi!

I get a matching image with the host, i.e. both are x86_64.
If you get x86 while your host is x86_64, then it should be a bug (which I cannot replicate here).
I suppose the semantics are to follow by default the architecture of the host, unless you explicitly specify otherwise (as it, for example, ubuntu:18.04/i386).

I have tried though to launch a i386 virtual machine, and I might hit a feature.
Specifically,

$ lxc image list ubuntu:bionic/i386
+---------------+--------------+--------+--------------------------------------------+--------------+-----------------+----------+------------------------------+
|     ALIAS     | FINGERPRINT  | PUBLIC |                DESCRIPTION                 | ARCHITECTURE |      TYPE       |   SIZE   |         UPLOAD DATE          |
+---------------+--------------+--------+--------------------------------------------+--------------+-----------------+----------+------------------------------+
| i386 (5 more) | 6b11d9656e44 | yes    | ubuntu 18.04 LTS i386 (release) (20200107) | i686         | CONTAINER       | 180.09MB | Jan 7, 2020 at 12:00am (UTC) |
+---------------+--------------+--------+--------------------------------------------+--------------+-----------------+----------+------------------------------+
| i386 (5 more) | ffb876ca48fb | yes    | ubuntu 18.04 LTS i386 (release) (20200107) | i686         | VIRTUAL-MACHINE | 318.13MB | Jan 7, 2020 at 12:00am (UTC) |
+---------------+--------------+--------+--------------------------------------------+--------------+-----------------+----------+------------------------------+

Ok, the name ubuntu:bionic/i386 is not a single image, but it the name for both the container image and the VM image.

Which means that the image cannot be found, while in fact I assume that lxc image info expects to result in a single image, not two of them.

$ lxc image info ubuntu:bionic/i386
Error: The requested image couldn't be found

lxc image info as a --vm option though. Still, it does not filter the two results into a single result.

$ lxc image info --vm ubuntu:bionic/i386
Error: The requested image couldn't be found

I got the profile from @stgraber’s announcement. :-).

Its an error in your tutorial unfortunetly :frowning_face: its where you put ubuntu:18.04 that causes the issue

What should I change in my post so that it works for you? I cannot replicate here.

The i386 info call should have been fixed with a recent change I made. I believe we pushed it to stable yesterday.

1 Like

Found a regression, fix is going through CI.

My eventual hope for GUI-VM support would be something what exists with Chrome OS / Crostini, which runs Linux containers managed by LXD within their own VM. The solution includes virtual GPU support, passing sound out of the container, solution for mounting files and external drivers. Also, GUI apps with “.desktop” files get surfaced in the host’s launcher and will launch the VM to run the app if needed.

They narrowed their scope of integration work by focusing primarily on one VM running one container with GUI integration.

i did all steps but when i want login i get “Login incorrect”

username:
ubuntu
password:
$6$s.wXDkoGmU5md$d.vxMQSvtcs1I7wUG4SLgUhmarY7BR.5lusJq1D9U9EnHK2LJx18x90ipsg0g3Jcomfp0EoGAZYfgvT22qGFl/

is that correct?

In the example above the password is ubuntu, the long string for the password is its hashed form, when logging in, use ubuntu.

i try it and it not work
i will show example for you

see https://youtu.be/KMb8aYcjRnY

NOTE: LXD version is 3.20

Most likely the cloud-init data in the profile did not get processed somehow, therefore the Ubuntu account did not probably get created. LXD does not parse the cloud-init data but sends them directly to the container/VM.
I could not distinguish an issue from the lxc profile show vm output.

Can you put your profile on pastebin.ubuntu.com to check for any formatting issues?
An additional guide to creating VMs in LXD is at https://blog.simos.info/how-to-use-virtual-machines-in-lxd/

1 Like

VM profile: https://pastebin.ubuntu.com/p/hB3BWxYQw7/
nice article easy for beginners like me :grimacing:

after i read simos article
i add

  config:
    source: cloud-init:config
    type: disk

to devices in vm profile
and issue fixed :smiley:

Your Youtube video shows that the cloud-init configuration was not applied in the container.
lxc console should show some additional output during network initialization, that looks similar to

[  OK  ] Started Network Service.
         Starting Network Name Resolution...
         Starting Wait for Network to be Configured...
[  OK  ] Started Network Name Resolution.
[  OK  ] Reached target Network.
[  OK  ] Reached target Host and Network Name Lookups.
[  OK  ] Started Wait for Network to be Configured.
         Starting Initial cloud-init job (metadata service crawler)...
[    7.138458] cloud-init[666]: Cloud-init v. 19.4-33-gbb4131a2-0ubuntu1~18.04.1 running 'init' at Wed, 05 Feb 2020 17:52:53 +0000. Up 7.03 seconds.
[    7.141724] cloud-init[666]: ci-info: ++++++++++++++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++++++++++++
[    7.143822] cloud-init[666]: ci-info: +--------+------+----------------------------+---------------+--------+-------------------+
[    7.148156] cloud-init[666]: ci-info: | Device |  Up  |          Address           |      Mask     | Scope  |     Hw-Address    |
[    7.152140] cloud-init[666]: ci-info: +--------+------+----------------------------+---------------+--------+-------------------+

There is a #cloud-config missing, which is essential. I added it myself in my test, but still it did not work.

You do not set a static IPv4 address, which means that the VM would not finish booting up until it timed out for the DHCP lease. Hence, no cloud-init until it got an IP address (which could not get). I set an IPv4 address with your profile, but still the VM did not get an IPv4 address (hence, not ubuntu account is created).

I tried again (LXD 3.20) with my VM profile and it worked for me.
I cannot figure out what is wrong with your profile.

thank you, it works now
see https://youtu.be/tbn_0cQmjHs

i think
lxc config device add v1 config disk source=cloud-init:config
has no effect at all

i add next to VM Profile

  devices:
    config:
      source: cloud-init:config
      type: disk

and issue fixed

How to see only container and not vm with “lxc image list ubuntu:/t/i386”?

It is for packer image nameing.

Each container has a set of properties, and you can currently filter on those properties.

$ lxc image list ubuntu:t/i386 --format=json | jq .
...
    "auto_update": false,
    "properties": {
      "architecture": "i386",
      "description": "ubuntu 14.04 LTS i386 (release) (20191107)",
      "label": "release",
      "os": "ubuntu",
      "release": "trusty",
      "serial": "20191107",
      "type": "root.tar.xz",
      "version": "14.04"
    },
...
    "architecture": "i686",
    "cached": false,
    "filename": "ubuntu-14.04-server-cloudimg-i386-lxd.tar.xz",
    "fingerprint": "57f0966d5e5db7e61adb71892d39799654af5a08d6224cd1a13c4720780ad003",
    "size": 126346984,
    "type": "container",
    "created_at": "2019-11-07T00:00:00Z",
    "last_used_at": "0001-01-01T00:00:00Z",
    "uploaded_at": "2019-11-07T00:00:00Z"
  }
]

The type is not inside the properties block, and filtering on that does not appear to work.

$ lxc image list ubuntu:t/i386 version=14.04
+-----------------+--------------+--------+--------------------------------------------+--------------+-----------+----------+------------------------------+
|      ALIAS      | FINGERPRINT  | PUBLIC |                DESCRIPTION                 | ARCHITECTURE |   TYPE    |   SIZE   |         UPLOAD DATE          |
+-----------------+--------------+--------+--------------------------------------------+--------------+-----------+----------+------------------------------+
| t/i386 (2 more) | 57f0966d5e5d | yes    | ubuntu 14.04 LTS i386 (release) (20191107) | i686         | CONTAINER | 120.49MB | Nov 7, 2019 at 12:00am (UTC) |
+-----------------+--------------+--------+--------------------------------------------+--------------+-----------+----------+------------------------------+
$ lxc image list ubuntu:t/i386 type=container
+-------+-------------+--------+-------------+--------------+------+------+-------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCHITECTURE | TYPE | SIZE | UPLOAD DATE |
+-------+-------------+--------+-------------+--------------+------+------+-------------+

If you where to filter using jq, you would use something like

lxc image list ubuntu:t/i386 --format=json | jq -r '.[] | select(.type == "container")'