Lxd reload questions

In the past there have been times when I needed to re-install a system. I would leave the /home partition as to be used but not formatted and would re-format say /, var, usr and any others necessary.

Is there some way of doing the same with lxd?

(Containers developed are ‘parked’ but the system running this is (maybe) removed and re-installed.)

If you leave /var/lib/lxd as well as all the filesystem(s) where the containers are untouched you should be OK.

I have not tried this to be able to say for sure what you need to do.

If you use the .deb package of LXD, then all the files are located in /var/lib/lxd/. You would obviously take a backup of /var/lib/lxd/ and then do the experiments.

However, on Debian you are using the snap package of LXD. Here you need to make sure you keep all the required files. Do you have a separate computer that you can use for testing?

I’m using the snap package of LXD. Interesting that using that setup requires an ubuntu install.

I ‘only’ have 2 physical computers although the resources on each enable me to have lots of vms.

So this is also something that hasn’t been tested.

If I do a copy of the separate drive all the lxd containers are on will that be a reasonable safe bet to keep the work that was done inside the containers?

(I was setting up the containers for separate functions so installs of Postgresql 10 from source and other such ‘interesting’ software had been done. I guess if necessary I would just start over. I’ve already invested about 15 hours trying to get things working again with no apparent success and I’m thinking that that is too much time invested.)

A snap package puts files in /var/snap/ and ~/snap/ and /var/lib/snap/. Personally I would need to read quite a bit to be sure what is where. For the .deb package of LXD, I am more familiar. But this is just me.

If you want to investigate and peek into the snap-packaged LXD files, do this,

$ snap run --shell lxd
bash-4.3$ cd /var/snap/lxd/
bash-4.3$ ls -l

The output will look like

bash-4.3$ ls -l /var/snap/lxd
total 16
drwxr-xr-x 3 0 0 4096 Dec  5 12:12 5408
drwxr-xr-x 3 0 0 4096 Dec  5 12:12 5447
drwxr-xr-x 3 0 0 4096 Dec  5 12:12 5494
drwxr-xr-x 5 0 0 4096 Jan 25 22:31 common
lrwxrwxrwx 1 0 0    4 Jan 24 20:23 current -> 5494

In common, you probably get all the LXD files (apart from lxd.db, the database with the settings).
In current, you get the lxd.db, the database with the settings.

Hope this helps.

1 Like

Tried running
$snap run --shell lxd

not only was there no output - - - how in the heck to I reverse this?
(https://docs.snapcraft.io/reference/snap-command gives no instructions that I can find.)

When you run that command, you get a shell. This shell has the necessary permissions to look into the LXD files. It is a restricted account, so you need to cd into /var/snap/lxd and then run ls.

$ snap run --shell lxd
bash-4.3$ exit

Here is the reference, https://docs.snapcraft.io/reference/snap-command#run