Removing files from /var/lib/snapd/cache


#1

My cache directory in /var/lib/snapd/cache is taking up a lot of space, and there are lots of files in there with hardlink count 1. Since they are not linked to any snaps retained, is it safe for to remove all those cache files manually, or is there any CLI way to remove them?


#2

That directory should have at most 5 files that have hardlink count 1. In any case it’s safe to remove the contents of the directory, but it’d be interesting to know how you got to a lot of files (I’m assuming ‘a lot’ is more than 5).


#3
$ sudo ls -l /var/lib/snapd/cache/|wc -l
15

i definitely have more than 5 …

https://paste.ubuntu.com/p/s5mJDByGzk/


#4

I “win”.

alan@hal:~$ sudo ls -l /var/lib/snapd/cache/|wc -l
131
alan@hal:~$ sudo du -hs /var/lib/snapd/cache/
8.9G	/var/lib/snapd/cache/

http://paste.ubuntu.com/p/djhTT3VCBB/


#5

@popey, as I said, you should have at most 5 files that have hardlink count 1. You have exactly 5:

$ grep '^-[^ ]* [^2]' popey.log
-rw------- 1 root root 269029376 Jan 22 10:47 586dcea87fc36c58a87a172f52c43a2f3912aab1d5107a1c405e54623f0a873e072a14ebaa2ae9f26144def57d959a1d
-rw------- 1 root root  14254080 Jan 25 16:47 b41d54d8d8a3d933fb25ad0ae808813b9d4bd9bdb8dffcead8fa9d571123ceea88efff312abb554a8e45972c41a07ac4
-rw------- 1 root root 102203392 Feb  5 11:29 d55a6f1d5c9cb74fd17d7c4274ee6ccf2986bb4c8b624af716987ba32d30d31a6f6dccbede084981dbe28813a8dc831a
-rw------- 1 root root   2428928 Feb  5 22:38 927def6f03dd6ab6593f333f5a64bfeda69e640b743926bb8130d27a6e06e589b04eb7419ccf6b4e516f52dab58d9e44
-rw------- 1 root root 138698752 Feb  9 15:35 c097594fde3a8a330931b73fc8b825623e89d483026667aedc3e221752e19b389c504f2c1d6bb07c169957487373ccd1

@ogra curiously has 6,

$ grep '^-[^ ]* [^2]' ogra.log 
-rw------- 1 root root  166887424 Okt 22 16:46 10e3d11f16769e924455525b88fd2a6c19e9829504b744caae0354192525363039236689bf07a5109bb5b282fb64ed63
-rw------- 1 root root   25534464 Okt 14 01:05 12e42914d97c4cfe78a4b954960d16d0854587e31da4de3b52b290f80046a676fa5a3ff622f378814bb4bf2225456a87
-rw------- 1 root root   69873664 Okt 15 22:03 4d469a100fc2eabf8ad6a5238ea596227706207241b4ed0bec8c9fa2d156af0398244ebd508150c4e9f00974a139646b
-rw------- 1 root root   85970944 Sep 27 18:11 5e1cdf4b0395d97dc95ad862471b13455187785a027fb948bebdb070240c0bd1e5361adbb89f1472239bbc203d5ecbb5
-rw------- 1 root root  180424704 Okt 28 12:00 879d8002cc53ae7a2f4873b76024dd066bb87a9f4a561af87511d86579845d564688c9653fc6505e27576a793805a9b7
-rw------- 1 root root  121106432 Nov 15 17:58 b5fe786026172d99e64e77019189127f5e62510e3e5a8b45ef163e9dc885d7b714155d0288a27af13c23c52f3b1e081f

so something might’ve hiccuped in his last instal. I’d expect it to clean up the next time. @ogra, please let me know :slight_smile:


#6

ah, you can get to have over 5 if you remove something that’s in the cache. The cache should then get cleaned up (LRUly) the next time something new is installed.