5

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.

4
  • Make snapd active, then remove the snap packages using sudo snap remove packagename. What do you mean with "My /var/lib/snapd filesystem is full :"? Is that residing on a separate partition that is full?
    – vanadium
    Oct 27, 2021 at 7:06
  • @vanadium Hi, thank you for your answer. See my EDIT0.
    – SebMa
    Oct 27, 2021 at 14:00
  • Never seen someone have a separate partition only for the snaps. The problem is caused by a lack of space. Solution: enlarge that partition. Recommendation: do not have that on a dedicated partition.
    – vanadium
    Oct 27, 2021 at 15:54
  • @vanadium Can't. I don't have spare space anymore.
    – SebMa
    Oct 28, 2021 at 17:02

2 Answers 2

3

You can remove all unused version of snap packages. You can create 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 you file logs to get free space by this command:

journalctl --vacuum-size=100M
5
  • will snap command work if snapd service is deactivated? Nov 26, 2021 at 9:23
  • not sure. but if it can't, you should free some space manually e.g. you can remove one of snap package file with old version manually e.g. user have two chromium_1781.snap and chromium_1801.snap. just remove less version; and try to run snapd service; also you can clean you logs file to get free space by this command journalctl --vacuum-size=100M Nov 26, 2021 at 11:15
  • in my opinion you should add your last comment in your answer. Nov 26, 2021 at 11:19
  • @AlexeyMuravyov You wrote e.g. user have two chromium_1781.snap and chromium_1801.snap. just remove less version And try to run snapd service . Can this removal be done with rm ?
    – SebMa
    Nov 26, 2021 at 11:39
  • sure. use sudo rm for less version of snap package, but better remove application packages like chromium or watsapp or wine and not core and gnome. sure you don't need a lot of space to run daemo. Also you can remove some movies from you machine )) and resize snap partition if you use separate one for it Nov 26, 2021 at 11:42
2

Run

sudo rm /var/lib/snapd/cache/*

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

2
  • Just what I was looking for. Sad that I could not wait long enough until your answer came along. I unfortunately had to manually delete everything by doing sudo apt purge snapd
    – SebMa
    Nov 26, 2021 at 11:53
  • I'm missing something basic here: that command silently doesn't remove any file, I had to sudo sh -c 'rm -rf /var/lib/snapd/cache/*' Jun 30 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.