Specify LXD Storage Pool for VM image download

Summary

Question: How can I specify which LXD Storage Pool should be used to cache a virtual machine image?

When I add a Storage Pool to LXD, it creates a directory structure, including a ./images subdirectory. I would expect that I can tell LXD to store VM images into this custom Storage Pool, instead of the default Storage Pool.

However, I cannot find any mechanism to specify which Storage Pool should cache a VM image.

Repro Steps

  1. Install LXD and init lxd init --auto
  2. Create a new Storage Pool mkdir --parents /data/lxddata; lxc storage create mydir dir source=/data/lxddata
  3. Launch LXD VM in custom Storage Pool lxc launch --vm --storage=mydir images:ubuntu/23.04 u01
  4. VM image is cached under default Storage Pool, not /data/lxddata/images

lxc config set storage.images_volume ... should do what you want. It’s documented here https://linuxcontainers.org/lxd/docs/master/server/#miscellaneous-options

1 Like

Gotcha, so it’s a global setting, not something I can specify per-image? I guess I was thinking the latter.

I’m a bit confused by this:

Volume to use to store the image tarballs (syntax is POOL/VOLUME )

Wouldn’t I just specify the POOL, not a VOLUME? If I create a new POOL, then I don’t have any VOLUMES defined. When I download an image later on, wouldn’t that be considered a new VOLUME of type image?

No, the compressed image files themselves are downloaded, stored and periodically refreshed if there is a later one available. These files are used to create either optimized image volumes on a pool or directly to create instance volumes for storage pools that do not support optimized image volumes.

As such the compressed image files themselves are not related to a storage pool per-se.
However the storage.images_volume controls where these files are stored, if there isn’t enough space on the host’s root filesystem to store them.

See https://linuxcontainers.org/lxd/docs/master/reference/storage_drivers/
and https://linuxcontainers.org/lxd/docs/master/reference/storage_drivers/#storage-optimized-image-storage

Then`

2 Likes