Moving a container between projects acts more like a copy then delete function. Why?

lxc move mycontainer mycontainer --project default --target-project backups

Just getting started with LXD projects. Tried the above command after creating a project named backups.

I expected it to run really fast, just updating the project association configs.

But instead it took a while to run. That was because the above command literally copies the container and deletes the original (and the container was 10GB). I watched, while refreshing zfs list, as

serverpool/lxd/containers/mycontainer

was copied to

serverpool/lxd/containers/backups_mycontainer

Then the original was deleted.

This move was using my laptop, on the default storage. Nothing was configured for the backups project to use anything different than what the default project uses. The storage volume for both should also be the same. To setup the project I used:

lxc project create backups -c features.images=false -c features.profiles=false

As instructed in the tutorial at Introduction to LXD projects | Ubuntu

I’m curious why moving between projects is a “copy” then “delete” type function, rather than simply renaming the container & updating some sort of project associations.

Just as a comparison, imagine having a 100GB file and you move filename.tar.gz from your current folder into ./subfolder/filename.tar.gz Linux doesn’t copy the file into ./subfolder/filename.tar.gz then delete the original. It just renames the file to the new location.

Why doesn’t (or why can’t) moving containers between LXD projects work like that?

There’s probably a good reason for it being this way. I’m just trying to understand this better.

Hello again!
This kind of memory management is usually a responsibility of the storage driver, and as probably the simplest one, the dir driver presents some limitations like the one you just described. The zfs driver is smarter and can accomplish the desired behavior in your use case.
For comparison, I tried this with a container on dir and another on zfs:

➜ lxc storage create default dir
➜ lxc storage create test zfs
➜ lxc init ubuntu:n c -s test
➜ lxc init ubuntu:n d
➜  time lxc move d d --project default --target-project test
lxc move d d --project default --target-project test  0,04s user 0,04s system 1% cpu 4,513 total
➜  time lxc move c c --project default --target-project test
lxc move c c --project default --target-project test  0,04s user 0,04s system 13% cpu 0,551 total

That said, it would be possible to implement some workaround for this, but this would be unnecessary meddling with the storage driver’s behavior. If someone wants that level of efficiency they should just use a more appropriate storage driver. Hope that is clear :smiley:

Hi there,

What storage pool driver was the instance on?

You mentioned zfs list, can I assume it was on a LXD managed ZFS pool?