Migrate from PPA to Snap


(John R) #21

Exactly my question too.
i've not migrated just purged the deb and started again.
now i want to change the bridge config and change to dir instead of btrfs.
how on earth is lxd's config acheived when used as a snap?


#22

Snaps put their data in several places, and you can get a list at
https://docs.snapcraft.io/reference/env

I have not migrated yet to the snap version of LXD.
I believe you can find the data at SNAP_USER_DATA (see link above).


(John R) #23

Thanks. Hope you're going to write a blog post on lxd via snap !!
meanwhile ive found
Github/lxc/lxd/blob/master/doc/networks.md
i guess thats the way to configure , wonder if direct editing of files is allowed?


#24

It is possible to edit the writable files of a snap. Ideally, try something like

$ snap run --shell lxd
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

myusername@mycomputer:/home/myusername$ export | grep SNAP
declare -x SNAP="/snap/lxd/2"
declare -x SNAP_ARCH="amd64"
declare -x SNAP_COMMON="/var/snap/lxd/common"
declare -x SNAP_CONTEXT="jMq5GNxwHPgTcPPnB2PtRXngc1hK5gS2mkdefjlW7nLQ"
declare -x SNAP_COOKIE="jMq5GNxwHPgTcPPnB2PtRXngc1hK5gS2mkkdefjlW7nLQ"
declare -x SNAP_DATA="/var/snap/lxd/2"
declare -x SNAP_LIBRARY_PATH="/var/lib/snapd/lib/gl:/var/lib/snapd/void"
declare -x SNAP_NAME="lxd"
declare -x SNAP_REEXEC=""
declare -x SNAP_REVISION="2"
declare -x SNAP_USER_COMMON="/home/myusername/snap/lxd/common"
declare -x SNAP_USER_DATA="/home/myusername/snap/lxd/2"
declare -x SNAP_VERSION="dd696dc-1"
myusername@mycomputer:/home/myusername$

Obviously, if something breaks, mention that you may have edited some internal files... :slight_smile:

As shown earlier in this thread, the LXD SQlite database is actually in SNAP_COMMON.

(I still did not migrate yet to the snap version of LXD. The above is from another snap).


(John R) #25

OK, Ive got the network bridge reconfigured
(This is version 2.20 that is installed from the snap, not the 16.04 repository version that's 2.0, without the lxc network commands)

My mistake was looking for a "ranges" variable to modify, whereas what is needed is to add it.
Here's some sequence of commands for anyone else, and the ps output showing that the dnsmasq config had been updated.

lxc network
lxc network list
lxc network show lxcbr0
lxc network get lxcbr0 ipv4.dhcp.ranges
lxc network get lxcbr0 ipv4.address
lxc network set lxcbr0 ipv4.address 10.0.3.1/24
lxc network set lxcbr0 ipv4.dhcp.ranges 10.0.3.100-10.0.3.199
lxc network get lxcbr0 ipv4.address
lxc network get lxcbr0 ipv4.dhcp.ranges
lxc network show lxcbr0
lxc list
lxc start xenial1
lxc exec xenial1 -- /bin/bash

Edited, of course for display!

root@myhostname:~# ps -ef | grep dnsmasq
dnsmasq
--strict-order
--bind-interfaces
--pid-file=/var/snap/lxd/common/lxd/networks/lxcbr0/dnsmasq.pid
--except-interface=lo
--interface=lxcbr0
--quiet-dhcp
--quiet-dhcp6
--quiet-ra
--listen-address=10.0.3.1
--dhcp-no-override
--dhcp-authoritative
--dhcp-leasefile=/var/snap/lxd/common/lxd/networks/lxcbr0/dnsmasq.leases
--dhcp-hostsfile=/var/snap/lxd/common/lxd/networks/lxcbr0/dnsmasq.hosts
--dhcp-range 10.0.3.100,10.0.3.199,1h
-s lxd
-S /lxd/
--conf-file=/var/snap/lxd/common/lxd/networks/lxcbr0/dnsmasq.raw
-u lxd


(Stéphane Graber) #26

The snap stores its data at /var/snap/lxd/common/lxd (equivalent of /var/lib/lxd with the deb).


(Stéphane Graber) #27

If upgrading from the PPA to the package in backports, no data migration is required, everything stays in the same place.

if you already ran lxd.migrate with the snap, then moving things back to non-snap will be a bit challenging and may require manual database surgery. The main idea is to stop both LXD daemon, remove /var/lib/lxd, then move /var/snap/lxd/common/lxd to /var/lib/lxd, then remove the snap and finally start the deb LXD daemon.

Depending on your storage configuration, you'll then need to manually edit the storage paths in the database at /var/lib/lxd/lxd.db (storage_pools_config table) and then restart the daemon.


#28

Here is my post about migrating from PPA to snap package,
https://blog.simos.info/how-to-migrate-lxd-from-deb-ppa-package-to-snap-package/


#29

Hi, after updating to snap i can't resize containers.
I always get
ext2fs_check_mount_point: Can't check if filesystem is mounted due to missing mtab file while determining whether /dev/lxdpool/containers_postfix is mounted.

I'm using LVM Thin with ext4


(Stéphane Graber) #30

That's a weird error. I'll try to setup a test system with the snap and LVM and poke at resizing ext4, xfs and btrfs to see what may be going on there.


(Stéphane Graber) #31

Looks like an easy enough fix in the snap, pushing a fix to edge now.


(Stephen Nesbitt) #32

Regards the apparmor issue...

I ran into this as well. As I recall the base problem was that the default apparmor profile assumes that $HOME is the top level home directory and all sub-directories are actual user accounts. If that is not the case - for example my home directory is located at /home/FUZZBUTT/snesbitt - then you'll need to change the apparmor profile. I did this using:
sudo dpkg-reconfigure apparmor

-steve


(Stéphane Graber) #33

LVM issue should now be fixed in stable.


#34

After updating snap i get
error: no such file or directory
Also some Container were offline.

After rebooting everthing works fine.

Edit: If i change the size of a container again, it doesn't work and it show again
error: no such file or directory
Try lxc info --show-log nginx for more info


(M) #35

I ran the migration from PPA to snap this week using the instructions of your post and apparently everything went well, but today I realised that containers don't get IPs:

lxc list
+------------------------+---------+------+------+------------+-----------+
|          NAME          |  STATE  | IPV4 | IPV6 |    TYPE    | SNAPSHOTS |
+------------------------+---------+------+------+------------+-----------+
| nextcloud-snap-compile | RUNNING |      |      | PERSISTENT | 0         |
+------------------------+---------+------+------+------------+-----------+
| xenial-build-essential | RUNNING |      |      | PERSISTENT | 0         |
+------------------------+---------+------+------+------------+-----------+

The network configuration seems OK to me.

$ lxc network show lxdbr0 
config:
  ipv4.address: 10.191.236.1/24
  ipv4.nat: "true"
  ipv6.address: fd42:665:f76c:c564::1/64
  ipv6.nat: "true"
description: ""
name: lxdbr0
type: bridge
used_by:
- /1.0/containers/nextcloud-snap-compile
- /1.0/containers/xenial-build-essential
managed: true

And this:

$ brctl show
bridge name     bridge id               STP enabled     interfaces
docker0         8000.02421bdc7fa5       no
lxdbr0          8000.fed5f98ef38a       no              vethY24P0G

What am I missing?


(Stéphane Graber) #36

Try running:

lxc network create blahbr0

And see if that gives you an error (it likely will), based on that error we can figure out what's going on.


(M) #37

Well, there were no errors:

$ lxc network create blahbr0
Network blahbr0 created
$ lxc network list
+---------+----------+---------+-------------+---------+
|  NAME   |   TYPE   | MANAGED | DESCRIPTION | USED BY |
+---------+----------+---------+-------------+---------+
| blahbr0 | bridge   | YES     |             | 0       |
+---------+----------+---------+-------------+---------+
| docker0 | bridge   | NO      |             | 0       |
+---------+----------+---------+-------------+---------+
| lxdbr0  | bridge   | YES     |             | 2       |
+---------+----------+---------+-------------+---------+
| wlp58s0 | physical | NO      |             | 0       |
+---------+----------+---------+-------------+---------+

#38

So you have the managed lxdbr0 interface, and the two containers are attached to that interface.
Use ps ax and check to see whether the dnsmasq process is actually running.
It should be a single dnsmasq process with the following name

dnsmasq --strict-order --bind-interfaces --pid-file=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.pid --except-interface=lo --interface=lxdbr0 --quiet-dhcp --quiet-dhcp6 --quiet-ra --listen-address=10.191.236.1 --dhcp-no-override --dhcp-authoritative --dhcp-leasefile=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.leases --dhcp-hostsfile=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.hosts --dhcp-range 10.191.236.2,10.191.236.254,1h --listen-address=fd42:665:f76c:c564::1 --enable-ra --dhcp-range ::,constructor:lxdbr0,ra-stateless,ra-names -s lxd -S /lxd/ --conf-file=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.raw -u lxd

Then, check in /var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.leases to verify whether there are these two leases.


(M) #39

Well, after creating the new network everything worked as before: now the containers are getting leases. I don't really know what the problem was, but anyway, thanks a lot for your help!


(Harolds) #40

I had this issue too after upgrading from lxd 2.2.x PPA to lxd 3.0 snap. The problem was that the extra dns config that was loaded in lxd 2.2 was in /etc/default/dns.conf. But with the snap version it seems that lxd can no longer read it from there (chroot?). So I moved it to /var/snap/lxd/common/lxd/networks/lxdbr0 and edited the lxdbr0 config to use it. Now all is working again!

This was de error:

err=“Failed to run: dnsmasq --strict-order --bind-interfaces --pid-file=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.pid --except-interface=lo --interface=lxdbr0 --quiet-dhcp --quiet-dhcp6 --quiet-ra --listen-address=10.0.4.1 --dhcp-no-override --dhcp-authoritative --dhcp-leasefile=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.leases --dhcp-hostsfile=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.hosts --dhcp-range 10.0.3.2,10.0.3.254,1h --listen-address=fd42:54b1:e4a:3702::1 --enable-ra --dhcp-range ::,constructor:lxdbr0,ra-stateless,ra-names -s lxd -S /lxd/ --conf-file=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.raw -u lxd: dnsmasq: cannot read /etc/default/dns.conf: No suchfile or directory” lvl=eror msg=“Failed to bring up network” name=lxdbr0 t=2018-05-02T12:07:09+0000