Regarding LXD agent for custom images

Hi All,

I came across “lxd agent” in VM images which was meant for seamless integration with the lxd ecosystem and for commands like “lxc exec” to work properly.

I havent seen any other advantages for the same. Can you share if there are any ?
Also need details or documentation on how can I add support for lxd-agent in custom image ?

Thanks

Ubuntu ships with a tiny package called lxd-agentloader which consists of a systemd unit file, some udev rules and a small bash script

https://git.launchpad.net/ubuntu/+source/lxd-agent-loader/tree/

This allows the lxd-agent to be copied from the VMs config drive and run on startup.

You can also use cloud-init or do it manually, see

“VM cloud-init” section on:

https://documentation.ubuntu.com/lxd/en/latest/reference/devices_disk/#types-of-disk-devices

1 Like

Hi, i tried to start a Xubuntu VM from the iso (following this https://documentation.ubuntu.com/lxd/en/latest/howto/instances_create/#create-a-vm-that-boots-from-an-iso), and when i tried to use lxd file push i got Error: LXD VM agent isn't currently running.

How do you install the lxd-agent manually, once you have downloaded the source ?

For a Xubuntu VM you could either manually install the package lxd-agent-loader or use cloud-init to do so. For Linux VMs that are not based on Ubuntu, this should do the trick:

lxc config device add u1 config disk source=cloud-init:config
lxc config set u1 cloud-init.user-data - << EOF
#cloud-config
runcmd:
  - mount -t 9p config /mnt
  - cd /mnt
  - ./install.sh
  - cd /
  - umount /mnt
  - systemctl start lxd-agent  # XXX: causes a reboot
EOF
lxc start --console u1

I’ll add those to the doc link you provided, thanks!

1 Like