What should I expect for disk space use when using lxc copy and zfs on the target host?

I attempted to use lxc copy to copy a container to a new host with a 180 GB brand new ZFS storage pool.

On the source machine, it’s a btrfs storage pool, where “lxc storage info” reports that there are 166 GB storage used, and a total space of 416 GB. “du -hs /” on the single container reports that only about 60 GB are actually in use, while “df -h” reports that the root file system is 388 GB.

So those are lot of different numbers about the size of my source data!

With LXD and ZFS on the target host, which number is the best estimate of disk space that would actually be used? Would it be closer to storage used according to the container, storage used according to LXD or the “total space”?

Disclaimer: Given that my connection between the two servers appears to be unstable and the large volume of data, I’m likely to switch to rsync to get this copy done but remain curious about how this would work.

Backing up containers over the network is potentially of interest to Chrome OS / Crostini users trying to get their data off the laptop.

Actual used space between filesystems can vary quite a bit, though usually more in the 15-20% range.
That part depends on exactly how data is stored, block alignment, …

On top of this, there is another thing relevant to what you did here.
Your source host likely had working copy-on-write between the image and the containers created from it, so the used space was only the delta.

When moving to ZFS, if the remote host doesn’t have that image, the containers are transferred in full, effectively duplicating any amount of shared data they may have had on the source. If most of your containers came from the same image, this can grow your usage quite significantly.

One way around this would be to configure ZFS deduplication, but beware of the memory usage when doing so.

1 Like