How to Manage Disk Space in CI for Large Repos
A large checkout plus Docker images fills a runner fast; df -h, docker system prune, and removing unused toolchains reclaim gigabytes.
The error no space left on device is common on large-repo builds. Inspect with df -h, then reclaim space by pruning Docker, deleting caches, and removing preinstalled SDKs the job does not use.
Steps
- Run
df -hto see what is full before and after cleanup. - Run
docker system prune -afto drop unused images and layers. - Delete large preinstalled toolchains you do not need.
Free space example
.github/workflows/ci.yml
- name: Free disk space
run: |
df -h
docker system prune -af --volumes
sudo rm -rf /usr/local/lib/android /opt/ghc /usr/share/dotnet
df -hGotchas
- GitHub-hosted Ubuntu runners ship many SDKs preinstalled; removing unused ones reclaims tens of gigabytes.
- Do not delete a toolchain your job needs; verify the path is safe before
rm -rf.
Related guides
How to Clean the Workspace on Self-Hosted CI RunnersReset a persistent self-hosted runner workspace between GitHub Actions jobs with git clean and reset, avoidin…
How to Reduce Artifact Size in CI for a Large RepoShrink GitHub Actions artifacts from a large repository by scoping upload paths, excluding junk, compressing,…