Switching LXD Storage Pools

By chimo on (updated on )
Short post so I remember how I moved my containers from a "dir" storage pool to btrfs.

I found the answer here. Turns out it’s pretty simple. I have about 27 containers at the moment, which isn’t a huge lot, but enough that I didn’t want to run these commands manually for every container. I ended up using the following script to migrate my running containers to the new storage pool:


mapfile -t containers < <(lxc list status=running -c n --format csv)

for container in "${containers[@]}"
    echo "Stopping ${container}..."
    lxc stop "${container}"

    echo "Renaming ${container}..."
    lxc move "${container}" "${container}"-tobemoved

    echo "Moving ${container}..."
    lxc move "${container}"-tobemoved "${container}" --storage=btrfs_pool

    echo "Starting ${container}..."
    lxc start "${container}"