Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More possible Cleanup targets #30

Open
cmahnke opened this issue Sep 21, 2023 · 2 comments
Open

More possible Cleanup targets #30

cmahnke opened this issue Sep 21, 2023 · 2 comments

Comments

@cmahnke
Copy link

cmahnke commented Sep 21, 2023

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?

@Cyber1000
Copy link

Cyber1000 commented Jan 7, 2024

just my 2 cents

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
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants