maximize-build-space icon indicating copy to clipboard operation
maximize-build-space copied to clipboard

More possible Cleanup targets

Open cmahnke opened this issue 2 years ago • 2 comments

Since the Runner VMs are populated by a script, the knowledge of the contents of its configuration can help with identifying further target to remove. For example: https://github.com/actions/runner-images/blob/main/images/linux/toolsets/toolset-2204.json

How about either generating the options of this option directly from the JSON file or create some sort of rollback mechanism, than can take a similar script and just remove the software missing from the modified json file?

cmahnke avatar Sep 21 '23 18:09 cmahnke

just my 2 cents

  • "linux" seems to have changed to "ubuntu" in your link: https://github.com/actions/runner-images/blob/main/images/ubuntu/toolsets/toolset-2204.json
  • seems like a valid approach, meanwhile I've found another

Thanks to everyone who works on this project. I've looked a little bit deeper today. Based on PR #20 following things to add:

  • there is a package google-cloud-cli instead of google-cloud-sdk, but there is a bigger sized folder /usr/lib/google-cloud-sdk
  • I reduced the info from this PR a little bit, since that didn't come with my method:
sudo apt-get purge -y '^llvm-.*' azure-cli powershell mono-devel
  • The following gets every userinstalled package, filters packages which shouldn't get removed, uninstalls everything not filtered and then cleans up config-files:
removePackages=`apt list --manual-installed | awk '{print $1}' | sed 's|\(.*\)/.*|\1|' | grep -E -v 'base*|bash|binutils|bsdutils|bzip2|ca-certificates|coreutils|curl|dbus|diffutils|dpkg*|file|findutils|git*|grep|gzip|hostname|init|iproute2|iputils-ping|keyutils|lib*|linux-headers*|linux-image*|lld*|locales|login|lsb-release|make|net-tools|openssh-*|openssl|patchelf|rpm|rsync|session-manager-plugin|shellcheck|ssh|sudo|sysvinit-utils|tar|tcl*|time|tk|tzdata|ubuntu-*|unzip|upx-ucl|walinuxagent|wget|xz-utils|zip*|zsync|apt|dash|ncurses-bin|shim-signed|grub-efi-*|mokutil|sbsigntool|secureboot-db|docker-*|containerd.io' | tr '\n' ' '`
echo "Removing following userinstalled packages: $removePackages"
sudo apt-get purge -y $removePackages
sudo apt-get clean && sudo apt-get autoremove --purge -y $(dpkg -l | grep '^rc' | awk '{print $2}') && sudo rm -rf /var/lib/apt/lists/* 
  • Keep in mind, that that also removes things like python3 (since I had the specific need I added this to this filter as well) - maybe pass additional-filter string to the script
  • There are still dirs you don't need and have lot of data for example /etc/skel (0,5GB) or /usr/local/.ghcup (haskel - some GB), you may or may not delete them, depending on what you need. Some things of them (/etc/skel) will work for (nearly) everyone.
  • you may remove containerd.io and docker-* afterwards (if you don't need it), but this action uses docker, so I couldn't remove before
Folders to remove (Klick here to open collapsed panel)
sudo rm -rf /opt/hostedtoolcache
sudo rm -rf /usr/local/games
sudo rm -rf /usr/local/sqlpackage
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/edge_driver
sudo rm -rf /usr/local/share/gecko_driver
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/share/chromedriver-linux64
sudo rm -rf /usr/local/share/vcpkg
sudo rm -rf /usr/local/lib/python*
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/julia*
sudo rm -rf /opt/mssql-tools
sudo rm -rf /etc/skel
sudo rm -rf /usr/share/vim
sudo rm -rf /usr/share/postgresql
sudo rm -rf /usr/share/man
sudo rm -rf /usr/share/apache-maven-*
sudo rm -rf /usr/share/R
sudo rm -rf /usr/share/alsa
sudo rm -rf /usr/share/miniconda
sudo rm -rf /usr/share/grub
sudo rm -rf /usr/share/gradle-*
sudo rm -rf /usr/share/locale
sudo rm -rf /usr/share/texinfo
sudo rm -rf /usr/share/kotlinc
sudo rm -rf /usr/share/swift
sudo rm -rf /usr/share/doc
sudo rm -rf /usr/share/az_9.3.0
sudo rm -rf /usr/share/sbt
sudo rm -rf /usr/share/ri
sudo rm -rf /usr/share/icons
sudo rm -rf /usr/share/java
sudo rm -rf /usr/share/fonts
sudo rm -rf /usr/lib/google-cloud-sdk
sudo rm -rf /usr/lib/jvm
sudo rm -rf /usr/lib/mono
sudo rm -rf /usr/lib/R
sudo rm -rf /usr/lib/postgresql
sudo rm -rf /usr/lib/heroku
sudo rm -rf /usr/lib/gcc
  • Doing all of this before your action I'm getting additional 24 GB compared to your main-branch (PR seems to get 5-6 GB additional)

Cyber1000 avatar Jan 07 '24 17:01 Cyber1000

As said that would remove nearly everything (even things like haskell, even if you say haskell:false), therefore this would need more effort to get it into a PR, don't think having enough time in the near future, but maybe someone finds the time (or can use this info)

Cyber1000 avatar Jan 07 '24 17:01 Cyber1000