Stop letting your CI runners turn into disk-eating monsters

DevOps Tooling On Linux (CI/CD Runners, Ansible)

Stop letting your CI runners turn into disk-eating monsters

Technical Briefing | 11/27/2026

Every CI/CD runner host I have ever managed eventually hits the same wall: the disk is full because some developer decided to clone a massive repo with a giant .git directory and never cleaned it up. You set up these runners, run them for a few months, and suddenly the build agent is failing with disk space errors because it is still holding onto layers and cache files from three hundred builds ago.

Why relying on manual cleanup is a losing battle

I have seen teams write custom shell scripts to find and delete old directories, but those usually break when the runner software updates its internal storage structure. Ansible can handle this, but you need to be surgical. If you just run a blanket rm command, you might kill a build that is currently running. Instead, you need to target the workspace folders while respecting the lock files the agent leaves behind.

find /var/lib/gitlab-runner/builds -type d -name 'build-*' -mtime +7 -exec rm -rf {} +

  • Use find with mtime to only target builds older than a week
  • Target specific subdirectories rather than the root workspace folder to avoid nuking the configuration
  • Run this as a non-privileged cron job if possible to prevent accidents

If you are using Ansible to manage these agents, push a stateful task that checks for build directory age. Don’t just set and forget. Even better, look at your runner configuration to see if it supports ephemeral disk mounting so the entire workspace gets wiped at the block level when the VM drops. It is cleaner, faster, and saves you from those midnight alerts when the partition hits 100 percent.

Linux Admin Automation  |  © www.ngelinux.com  |  11/27/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted