Moved /var/lib/snapd into /home/snapd and symlicked back. Snaps fail to start

Because in the partition my /var had been mounted, was rather small space I found out that /var/lib/snapd takes a huge chunk of space in it.

Therefore, I moved it into /home/snapd via rsync and symlinked it back:

sudo service snapd stop
sudo rsync -ravp /var/lib/snapd /home/snapd
sudo chmod --reference=/var/lib/snapd /home/snapd
sudo ln -s /home/snapd /var/lib/snapd

But that causes my snapd daemon to have the following issues:

sudo systemctl status snapd
● snapd.service - Snappy daemon
   Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-02-01 14:51:52 EET; 13min ago
 Main PID: 1178 (snapd)
    Tasks: 18 (limit: 4915)
   CGroup: /system.slice/snapd.service
           └─1178 /usr/lib/snapd/snapd

Φεβ 01 14:56:29 dimitris snapd[1178]: snapmgr.go:267: cannot read snap info of snap "lxd" at revision 11348: cannot find installed snap "lxd" at revision 11348: missing file /snap/lxd/11348/meta/snap.yaml
Φεβ 01 14:56:29 dimitris snapd[1178]: snapmgr.go:267: cannot read snap info of snap "snapcraft" at revision 3970: cannot find installed snap "snapcraft" at revision 3970: missing file /snap/snapcraft/3970/meta/s
Φεβ 01 14:56:29 dimitris snapd[1178]: snapmgr.go:267: cannot read snap info of snap "skype" at revision 112: cannot find installed snap "skype" at revision 112: missing file /snap/skype/112/meta/snap.yaml
Φεβ 01 14:56:29 dimitris snapd[1178]: snapmgr.go:267: cannot read snap info of snap "kde-frameworks-5-core18-sdk" at revision 31: cannot find installed snap "kde-frameworks-5-core18-sdk" at revision 31: missing 
Φεβ 01 14:56:29 dimitris snapd[1178]: snapmgr.go:267: cannot read snap info of snap "brave" at revision 63: cannot find installed snap "brave" at revision 63: missing file /snap/brave/63/meta/snap.yaml
Φεβ 01 14:56:29 dimitris snapd[1178]: snapmgr.go:267: cannot read snap info of snap "gnome-3-28-1804" at revision 116: cannot find installed snap "gnome-3-28-1804" at revision 116: missing file /snap/gnome-3-28-
Φεβ 01 14:56:29 dimitris snapd[1178]: snapmgr.go:267: cannot read snap info of snap "core18" at revision 1668: cannot find installed snap "core18" at revision 1668: missing file /snap/core18/1668/meta/snap.yaml
Φεβ 01 14:56:29 dimitris snapd[1178]: snapmgr.go:267: cannot read snap info of snap "gnome-characters" at revision 399: cannot find installed snap "gnome-characters" at revision 399: missing file /snap/gnome-cha
Φεβ 01 14:56:29 dimitris snapd[1178]: snapmgr.go:267: cannot read snap info of snap "minetest" at revision 1370: cannot find installed snap "minetest" at revision 1370: missing file /snap/minetest/1370/meta/snap
Φεβ 01 14:57:16 dimitris snapd[1178]: 2020/02/01 14:57:16 Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Time-out\r\nCache-Control: no-cache\r\nConnection: close\r\nConten
lines 1-18/18 (END)

And I am unable to launch any snap installed application. So how I can configure my snap daemon to look into /home/snapd folder instead of /var/lib/snapd one?

AFAIK you should use a bind mount to do that. I suggest trying with the following mount unit:

# /etc/systemd/system/var-lib-snapd.mount
[Unit]
Description=bind mount snapd from /home to /var/lib/snapd

[Mount]
What=/home/snapd
Where=/var/lib/snapd
Options=bind

[Install]
WantedBy=multi-user.target
RequiredBy=snapd.service

Save it to /etc/systemd/system/var-lib-snapd.mount, then:

# remove the symlink
$ rm -f /var/lib/snapd` symlink
$ systemctl daemon-reload
# enable the mount unit
$ systemctl enable var-lib-snapd.mount

and lastly reboot.

@zyga-snapd may also have some suggestions here.

1 Like

Maciek’s suggestion is accurate. You can mount additional storage under /var/lib/snapd or anywhere in the /var hierarchy. Do to so please stop snapd, move /var/lib/snapd to something like /home/snapd and establish the bind mount as described above.

Out of curiosity, how much space did you devote to the partition encompassing /var?