If I have relatively small / filesystem, but large /opt partition and I want to export a container to /opt, and said container is larger than free space on / then lxc export fails:
Error: Create backup: Backup storage: Failed to run: tar -cf /var/snap/lxd/common/lxd/backups/main/backup0 --xattrs -C /var/snap/lxd/common/lxd/backups/lxd_backup_583972121 --transform s,^./,backup/, .: tar: /var/snap/lxd/common/lxd/backups/main/backup0: Wrote only 2048 of 10240 bytes
tar: Error is not recoverable: exiting now
Then the machine is left in broken state: disk is full, lxc list is unresponsive, etc. I have to go to /var/snap/lxd/common/lxd/backups and erase everything there, then I have to reboot the machine, snap restart lxd does not help.
I tried to avoid this problem symlinking backup directory, making /opt/backups and pointing /var/snap/lxd/common/lxd/backups to /opt/backups. Does not work:
Error: Create backup: Backup storage: stat /var/snap/lxd/common/lxd/backups: no such file or directory
So, it seems that I canât avoid dumping container to root filesystem first. Is it possible to change this behavior to export containers even if root filesystem is smaller than largest container? Leaving a lot of rarely used space in root fs does not make sense when SSDs are involved⊠what about an option --backup-tmpdir or something like that?
We canât look for free space ahead of time as itâs impossible to tell how big a backup will be ahead of time. Some containers will be using 2GB on ZFS but will take 6GB or more in backup. Some containers on dir backend can shrink significantly, âŠ
What we need though is to ensure that LXD cleans things up on failure to generate the backup so that you donât have to go cleaning things up and reboot at least. @monstermunchkin
itâs possible if you use LXD 3.17, on most distros it means using snap LXD. I have never used the feature myself but by clicking the link you should see that adding a pool on a dedicated partition and creating a custom volume (lxc storage create <driver/type zfs, btrfs,âŠ> source=<path/to/partition> then lxc storage volume ), then using the storage.backup key to the config (lxc config set storage.backup=pool/volume should do the trick.
If I understand correctly, you had LXD 3.0 installed from system packages and switched to snap, in this case you should uninstall the lxc system packages; to test this try to run
/snap/bin/lxc list
if it works, thatâs the problem.
maybe you installed your pool on a partition that is not mounted when LXD starts ? if you restart lxd manually by running snap restart lxd, does it work better ?
lvl=info msg=âLXD 3.20 is starting in normal modeâ path=/var/snap/lxd/common/lxd t=2020-02-05T17:21:36+0100 lvl=eror msg=âFailed to start the daemon: Failed to chmod dir /var/snap/lxd/common/lxd/backups: chmod /var/snap/lxd/common/lxd/backups: no such file or directoryâ t=2020-02-05T17:21:36+0100 lvl=info msg=âStarting shutdown sequenceâ