CL too lenient wrt storage

CL’s root partition is 40GiB and I’ve been running out of disk space too often in the past few months with gigantic files or folders in 4 locations, 2 of them related to swupd and the last 2 I don’t know which program’s responsible.
The first is swupd’s download cache (last time hitting 1.8GiB), which apparently doesn’t clean itself up not as frequently as it should? But that’s alright, I can deal with it.
The second is swupd’s /var/lib/swupd/manifest folder (currently taking 1.9GiB). Why?
The third is /usr/share/clear/optimized-elf at 1.8GiB. ???
The fourth and hilariously tragic is /var/cache/debuginfo, taking over 6GiB. Yeah, what’s with that??

1 Like

Well the good news is that we have a format bump coming up this week, and that may help with reducing the manifest folder size a bit. Your optimized-elf folder is way smaller than mine :wink:
Feel free to nuke the debuginfo - it should clear out after 7 days of non-use, but it’s possible something got stuck.

Ok. But is there any I shouldn’t nuke? And what exactly is in the optimized-elf folder?

Anything in /var/cache should be fine to nuke.
Clear’s pretty resilient for most damage - you can use swupd to repair most things except if you nuke swupd itself :slight_smile:

1 Like

Good to know.

what exactly is in the optimized-elf folder?

Still dodging :wink: :stuck_out_tongue:

optimized-elf contains things built with avx2 or avx512 enabled. They replace associated content on the system (and then hardlink back for update speed purposes). So the size on disk used shouldn’t make any impact.

1 Like

Thank you for the info. What about the files which are not hard linked to another file? What about the broken symbolic links?

$ cd /usr/share/clear/optimized-elf

$ du -sh .
2.6G	.

$ ls -l | awk '$2 == 1 { print $0 }' | wc -l    # 3068
$ ls -l | awk '$2 != 1 { print $0 }' | wc -l    # 2626
$ ls -l | grep -c -- '->'    # 598 broken symbolic links

What’s up with libsane? Most of the broken symbolic links are libsane-*.

$ ls -l | grep -c libsane    # 344

You can remove anything that isn’t linked to another file (though it is odd to me they aren’t being cleaned up if we not longer are shipping them as swupd should remove them). The broken symlinks are because we don’t remove symlinks at this point from the avx2 and avx512 buildroots (and they are often broken because they are relative).

1 Like

Same story, just removed ~3 GB ELFs. Swupd cleanup is definitely broken.

 sudo find /usr/share/clear/optimized-elf -type f -delete

I wrote a post-OS-update purge script. First, check /lib/modules for a new kernel and reboot using the new kernel before running the purge script.

# Purge script for Clear Linux OS.

if [ -d "$dir" -a -x "/usr/bin/clr-boot-manager" ]; then
  echo "Purging $dir of prior kernel after OS software update"
  sudo clr-boot-manager update

if [ -d "$dir" ]; then
  echo "Purging $dir of symlinks and unlinked files"
  pushd "$dir" >/dev/null

  # symlinks
  files=$(ls -l | awk '/->/ { print $9 }')
  [ -n "$files" ] && sudo rm -f $files

  # unlinked files
  files=$(ls -l | awk '$2 == 1 { print $9 }')
  [ -n "$files" ] && sudo rm -f $files

  unset files
  popd >/dev/null

if [ -d "$dir" ]; then
  echo "Purging $dir of core dumps"
  sudo rm -rf "$dir"/*

if [ -d "$dir" -a -x "/usr/bin/swupd" ]; then
  echo "Purging $dir of cache content and metadata"
  sudo swupd clean --all --quiet


$ sudo bash  # (or) sudo /path/to/
Purging /lib/modules of prior kernel after OS software update
Purging /usr/share/clear/optimized-elf of symlinks and unlinked files
Purging /var/cache/debuginfo of core dumps
Purging /var/lib/swupd of cache content and metadata

It looks like the CL team is looking into issue 2740 :sparkling_heart: