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 ?


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

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:

1 Like

Hi, i tried to start a Xubuntu VM from the iso (following this, 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
  - mount -t 9p config /mnt
  - cd /mnt
  - ./
  - cd /
  - umount /mnt
  - systemctl start lxd-agent  # XXX: causes a reboot
lxc start --console u1

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

1 Like