Move LXD from /var/snap to an existing ZFS pool

having disk space issues and i’m pretty sure it’s on my OS drive and not my main storage

NAME   SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
DATA  16.2T  7.63T  8.62T         -     4%    46%  1.00x  ONLINE  -
LXC   99.5G  10.9G  88.6G         -    24%    10%  1.00x  DEGRADED  -

NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
DATA 16.2T 7.63T 8.62T - 4% 46% 1.00x ONLINE -
raidz1 16.2T 7.63T 8.62T - 4% 46%
sdb - - - - - -
sdc - - - - - -
sdd - - - - - -
LXC 99.5G 10.9G 88.6G - 24% 10% 1.00x DEGRADED -
/var/snap/lxd/common/lxd/disks/LXC.img 99.5G 10.9G 88.6G - 24% 10%

essentially I’d like to move all of my containers to a new zpool on the my actual datastore.

Your best option is probably to do something like:

  • lxc storage create DATA zfs source=DATA/lxd
  • lxc move NAME --storage DATA
  • lxc profile device set default root pool DATA
  • lxc storage delete LXC

So effectively adding a new pool to LXD which is backed by your existing zpool, then move the containers over to it through LXD and once empty, remove the old pool, after setting the new one as the default for new containers.

1 Like

i’m missing an option

@SERVER:~$ sudo lxc move rproxy --storage DATA
Description:
  Move containers within or in between LXD instances

Usage:
  lxc move [<remote>:]<container>[/<snapshot>] [<remote>:][<container>[/<snapshot>]] [flags]
...
Error: Invalid number of arguments

I tried to sudo lxc move rproxy rproxy --storage DATA to keep the same name but that didn’t work either. I’m assuming I’ll need to move them all to a new name and then rename. i tried that and received this error Error: Failed to run: rsync -a -HAX --sparse --devices --delete --checksum --numeric-ids --xattrs --bwlimit 0 -q /var/snap/lxd/common/lxd/storage-pools/LXC/containers/rproxy/ /var/snap/lxd/common/lxd/storage-pools/DATA/containers/rproxy2: rsync: read errors mapping "/var/snap/lxd/common/lxd/storage-pools/LXC/containers/rproxy/rootfs/usr/include/asm-generic/auxvec.h": Input/output error (5)

@SERVER:~$ sudo lxc list
+-------------+---------+--------------------+------+------------+-----------+
|    NAME     |  STATE  |        IPV4        | IPV6 |    TYPE    | SNAPSHOTS |
+-------------+---------+--------------------+------+------------+-----------+
| ansible     | RUNNING | 10.1.20.20 (eth0)  |      | PERSISTENT | 2         |
+-------------+---------+--------------------+------+------------+-----------+
| log         | RUNNING | 10.1.20.50 (eth0)  |      | PERSISTENT | 2         |
+-------------+---------+--------------------+------+------------+-----------+
| nagios      | RUNNING | 10.1.20.100 (eth0) |      | PERSISTENT | 2         |
+-------------+---------+--------------------+------+------------+-----------+
| rproxy      | RUNNING | 10.1.20.11 (eth0)  |      | PERSISTENT | 4         |
+-------------+---------+--------------------+------+------------+-----------+
| tbx         | RUNNING | 10.1.20.101 (eth0) |      | PERSISTENT | 2         |
+-------------+---------+--------------------+------+------------+-----------+
| unifipihole | RUNNING | 10.1.20.53 (eth0)  |      | PERSISTENT | 2         |
+-------------+---------+--------------------+------+------------+-----------+

Ah yeah, having to provide the same name twice is correct and no, you won’t need to change the container name.

I’m not sure why you’re getting that input/output error.

Do you get into the same problem with your other containers too?

Not sure if LXD requires it, but if the container wasn’t stopped at the time of the move, I’d strongly recommend to stop it first.