Your apt install was a no operation. LXD does not use the apt version, it use its own ‘vendored’ snap version.
The net effect of setting the criu.enable to true and restarting lxd (the logical way would be sudo snap restart lxd, since the change is at the snap level) is to set the path to load the snapified version of criu (that you can find in /snap/lxd/current/criu/). By looking at /proc//environ this can be seen quite easily.
Very probably the OP problem was coming from mixing ‘enable’ and ‘enabled’ and not restarting LXD after setting the correct value (enable, NOT enabled). Unfortunately Snap is allowing the user to set any value for a snap, even non existing ones.
sudo snap set lxd foo.baz=spam
sudo snap get lxd
Key Value
criu {…}
foo {…}
I tried setting bothcriu.enableandcriu.enabled, restarted, and no dice.
...:~$ sudo snap set lxd criu.enabled=true ...:~$ sudo snap get lxd criu Key Value criu.enable true criu.enabled true ...:~$ systemctl reload snap.lxd.daemon ...:~$ lxc snapshot dev-dwk --stateful Error: Unable to create a stateful snapshot. CRIU isn't installed
regarding this suggestion: sudo cat /proc/16688/environ
to check the environment (forgive the stupid question), which process do I target? htop shows a number of processes referring to LXD, so wasn’t quite sure which one to look at.
So, there are a number of instances of that process. Taking one of them at random, I don’t see criu in the environ data. I rebooted and restarted containers before checking:
Nope, you’re right. I screwed it up the first time.
So the environ of that process is similar … ARCH=x86_64-linux-gnuSNAP_INSTANCE_KEY=SNAP_COMMON=/var/snap/lxd/commonLXD_LXC_TEMPLATE_CONFIG=/snap/lxd/current/lxc/config/TEMPDIR=/tmpLD_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void:/snap/lxd/12317/lib/x86_64-linux-gnu::/snap/lxd/12317/lib:/snap/lxd/12317/lib/x86_64-linux-gnu:/snap/lxd/current/lib:/snap/lxd/current/lib/x86_64-linux-gnuLISTEN_PID=478SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/voidHOME=/tmp/LISTEN_FDS=1SNAP_USER_DATA=/root/snap/lxd/12317LXD_EXEC_PATH=/snap/lxd/current/bin/lxdLXD_DIR=/var/snap/lxd/common/lxd/LXD_SHIFTFS=falseSNAP_REVISION=12317TMPDIR=/tmpSNAP_CURRENT=/snap/lxd/currentXTABLES_LIBDIR=/snap/lxd/current/lib/xtables/JOURNAL_STREAM=9:67703SNAP_CONTEXT=7pPmVFdSD3LnKR6PllcwKxFCnYcjD37KHYy3vyrdDlVHSNAP_VERSION=3.18SNAP_INSTANCE_NAME=lxdPATH=/snap/lxd/12317/usr/sbin:/snap/lxd/12317/usr/bin:/snap/lxd/12317/sbin:/snap/lxd/12317/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/lxd/current/binINVOCATION_ID=c4ebf70a895645a4bbfb38093a771c1cXDG_RUNTIME_DIR=/run/user/0/snap.lxdLISTEN_FDNAMES=unixSNAP_DATA=/var/snap/lxd/12317LXD_CLUSTER_UPDATE=/snap/lxd/current/commands/refreshLANG=C.UTF-8SNAP_ARCH=amd64SNAP_USER_COMMON=/root/snap/lxd/commonSNAP_COOKIE=7pPmVFdSD3LnKR6PllcwKxFCnYcjD37KHYy3vyrdDlVHSNAP_REEXEC=SNAP_NAME=lxdLXD_LXC_HOOK=/snap/lxd/current/lxc/hooks/PWD=/var/snap/lxd/12317SNAP=/snap/lxd/12317
I have found the start script for lxd in /snap/lxd/current/commands/daemon.start, it contains this:
# Setup CRIU
if [ "${criu_enable:-"false"}" = "true" ]; then
echo "==> Enabling CRIU"
export PATH="${SNAP_CURRENT}/criu:${PATH}"
fi
so there should be something in a log somewhere, let’s see… yes that’s it
sudo journalctl -u snap.lxd.daemon
you should see something about CRIU just after some systemd messages in your log. If not that’s because criu.enable is not equal to ‘true’ and if you have set it up correctly it could be snap’s fault if the lxd start script don’t see it.
So looking in the log, there is nothing about CRIU mentioned. It would seem that for some reason the daemon startup script is failing to see that criu is enabled.
I tried something as a total hack to try to confirm this theory…
I copied the contents /snap/lxd/current/commands to ~/tmp and then did this: sudo mount --bind -o nodev,ro /home/$USER/tmp /snap/lxd/current/commands/
Then I modified the daemon.start in the ~/tmp directory …
# Setup CRIU
# if [ "${criu_enable:-"false"}" = "true" ]; then
echo "==> Enabling CRIU"
export PATH="${SNAP_CURRENT}/criu:${PATH}"
# fi
… and I restarted the daemon. Sure enough, the log now shows CRIU being enabled. Next, I tried to create a stateful snapshot. This time, the error about CRIU not bieng installed was gone. There was in fact another error that seems unrelated (Error: mkdir /var/snap/lxd/common/lxd/containers/dev-dwk: file exists) but I’m not worried about that since obviously this is a total hack for testing only.
The main thing I wanted to prove is that for some reason, the LXD startup is not seeing the configuration key.
If in 24 hours you have no further help (from me or someone else) in your place I’d think of backup your containers / uninstall lxd and snap itself and install again, restore your containers if necessary and try again. There seems to be something wrong in the snap / lxd interaction, maybe something is broken.
Just to confirm what worked for me after installing lxd with snap:
--> sudo snap set lxd criu.enable=true
--> sudo snap restart lxd
--> sudo snap get lxd criu
Key Value
criu.enable true
I no longer get the “CRIU not installed” error, but the dump does fail. I realize this is a CRIU error, but this is for a brand new launched ubuntu:20.04 image. If that can’t dump out of the box I doubt anything else can. But I will try some other images.
Yeah, I did that and confirmed the value. It still doesn’t work. What’s strange is that is I am working through another issue and it seems to me like values set with snap set lxd ... are simply not getting conveyed to the container on my machine. Trying to set debug=true so as to get the debug log messages is also not working for me. I’m scratching my head.
values set with snap set lxd ... are simply not getting conveyed to the container on my machine
By the container do you mean the snap “container” that has LXD installed in or the LXD container you are trying to snapshot? The configuring part is really about configuring your LXD installation and not the container you are trying to snapshot.
Sorry, bad word choice. I meant that the snap doesn’t seem to see the value. I hacked the snap a while back and got into the file system and manually changed criu.enabled to true, and then the snap “saw” CRIU as enabled (although I got a different error message at that point). But setting criu.enable=true with sudo snap set lxd criu.enable=true never seemed to get the snap to recognize CRIU as enabled. snap get lxd criu will show it as criu.enable true though.
Ya its a bit weird with snap. I don’t really like them to be honest considering they have all the monitors and configuration loading blah. Systemd is way more than enough of this kind of stuff anyways.