43

I'm using Ubuntu 20.04 LTS.

My snapd service is unavailable :

$ systemctl status snapd.service
● snapd.service - Snap Daemon
     Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
     Active: deactivating (stop-sigterm) (Result: timeout)
TriggeredBy: ● snapd.socket
   Main PID: 29952 (snapd)
      Tasks: 10 (limit: 8186)
     Memory: 12.8M
     CGroup: /system.slice/snapd.service
             └─29952 /usr/lib/snapd/snapd

Oct 27 00:47:07 seb-C70D-B-311 systemd[1]: Starting Snap Daemon...
Oct 27 00:47:07 seb-C70D-B-311 snapd[29952]: AppArmor status: apparmor is enabled and all features are available
Oct 27 00:47:07 seb-C70D-B-311 snapd[29952]: AppArmor status: apparmor is enabled and all features are available
Oct 27 00:48:37 seb-C70D-B-311 systemd[1]: snapd.service: start operation timed out. Terminating.
$ time snap version
snap    2.52.1
snapd   unavailable
series  -

real    0m25.075s
user    0m0.036s
sys 0m0.060s

My /var/lib/snapd filesystem is full :

$ df -PTh /var/lib/snapd
Filesystem                                                            Type  Size  Used Avail Use% Mounted on
/dev/mapper/VG_Samsung_SSD_860_EVO_1TB__S3Z9NB0K4019-LV_var_lib_snapd ext4  4.9G  4.9G     0 100% /var/lib/snapd
$ ls -lh /var/lib/snapd/snaps
total 4.0G
-rw------- 1 root root  68K Sep 10 23:08 acrordrdc_53.snap
-rw------- 1 root root  68K Sep 20 13:03 acrordrdc_62.snap
-rw------- 2 root root 4.0K Sep 26 12:44 bare_5.snap
-rw------- 1 root root 146M Oct 10 21:58 chromium_1781.snap
-rw------- 2 root root 145M Oct 23 12:29 chromium_1801.snap
-rw------- 1 root root  56M Jun 23 18:57 core18_2074.snap
-rw------- 1 root root  56M Aug 15 17:45 core18_2128.snap
-rw------- 1 root root  62M Jul 24 10:15 core20_1081.snap
-rw------- 1 root root  62M Oct  8 22:05 core20_1169.snap
-rw------- 1 root root 100M Oct 15 11:18 core_11798.snap
-rw------- 1 root root 100M Oct 21 12:26 core_11993.snap
-rw------- 2 root root 163M Dec 19  2020 gnome-3-28-1804_145.snap
-rw------- 1 root root 165M Jul  8 16:18 gnome-3-28-1804_161.snap
-rw------- 1 root root 219M Jan  9  2021 gnome-3-34-1804_66.snap
-rw------- 1 root root 219M Jun 14 14:23 gnome-3-34-1804_72.snap
-rw------- 1 root root  66M Apr 22  2021 gtk-common-themes_1515.snap
-rw------- 1 root root  66M Sep 26 12:44 gtk-common-themes_1519.snap
-rw------- 2 root root 140K Aug 23  2020 gtk2-common-themes_13.snap
drwxr-xr-x 2 root root 4.0K Jul 10  2020 partial/
-rw------- 1 root root  33M Oct 13 20:06 snapd_13270.snap
-rw------- 1 root root  33M Oct 20 21:14 snapd_13640.snap
-rw------- 1 root root 136M Aug 23 00:17 whatsapp-for-linux_26.snap
-rw------- 1 root root 112M Oct 18 15:58 whatsapp-for-linux_27.snap
-rw------- 2 root root 304M Feb  6  2021 wine-platform-5-stable_16.snap
-rw------- 1 root root 304M Sep 26 12:44 wine-platform-5-stable_18.snap
-rw------- 2 root root 323M Sep 20 13:03 wine-platform-6-stable_8.snap
-rw------- 1 root root 347M Oct  8 22:05 wine-platform-runtime_250.snap
-rw------- 1 root root 347M Oct 15 11:19 wine-platform-runtime_251.snap
-rw------- 1 root root 347M Oct 23 12:29 wine-platform-runtime_252.snap
-rw------- 1 root root 164M Oct 26 22:50 wine-platform-runtime_252.snap.partial

Howto can I free up space properly on my /var/lib/snapd filesystem when snapd is unavailable ?

EDIT0 : Cannot start the snapd service successfully, maybe because my /var/lib/snapd filesystem is full.

SebMa
  • 2,927
  • 5
  • 35
  • 47

3 Answers3

67

You can remove all unused version of snap packages. You can create a script file and make it executable, or just copy & paste it in the console.

Note you need sudo rights for it.

#!/bin/sh
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
while read pkg revision; do
  sudo snap remove "$pkg" --revision="$revision"
done

If the snap remove command does not work because the snapd server is not run, you should free some space manually. You can remove an old version of a snap package file.

E.g., user ha two Chromium snaps, chromium_1781.snap and chromium_1801.snap. Just manually remove the older version using:

sudo rm /var/lib/snapd/snaps/chromium_1781.snap

And try to run the snapd service.

Also, you can clean your file logs to get free space by this command:

journalctl --vacuum-size=100M
Pablo Bianchi
  • 17,371
Alexey M.
  • 1,096
25

Run

sudo bash -c 'rm /var/lib/snapd/cache/*'

to clear the cache, that should give you some free space.

mook765
  • 18,644
2

The proposed solutions are a temporary fix. I have another solution. Let's assume you have a separate larger partition for /home path.

  1. Stop snap daemon in order to avoid errors.
  2. Move all content from /var/lib/snapd to /home/root/snap/snapd (or pick whatever directory under /home path). I recommend to use rsync for the copy/move process.
  3. Then change snapd storage location to the home partition via mount. Here's an extract from my /etc/fstab:
/home/root/snap/snapd /var/lib/snapd none bind 0 0
  1. Start snap daemon and test if everything works fine.

Solution is actually borrowed from Where is a snap stored and how can I change that? forum thread.