Using tmpfs for faster builds
How to use the tmpfs feature with RunsOn, for faster builds
Since v2.8.2, you can configure RunsOn to automatically create a tmpfs volume, which will then be used to host the following directories:
/tmp(overlay)/home/runner(overlay)/var/lib/docker(bind mount)/var/lib/containerd(bind mount, since v3.5.0)
Since v3.6.0, the tmpfs volume is sized at the runner’s memory minus a reserve for the system, the RunsOn agent and the GitHub runner: 768 MiB plus 1/32 of the memory, which is about 0.9 GiB on a 4 GiB runner, 2.7 GiB on 64 GiB and 8.5 GiB on 256 GiB. A job that fills the volume gets No space left on device in that step (see Running out of disk space), instead of running the whole runner out of memory. tmpfs runners of any size also get compressed swap in memory, which compresses rarely used pages and leaves more room for the job’s processes. If a job needs more room, increase your runner size (large-memory instance types such as r8* are highly recommended); the job gets an out-of-memory warning when it needs a bigger runner.
Since v3.6.1, swap on disk also counts: a swap file or partition the image ships, or one a preinstall or prerun hook turns on, adds its full size to the volume. Once the hook has run, RunsOn resizes the volume and turns its compressed swap off, as it does on images that ship swap, so pages that do not compress can move to the disk. A volume a hook resized itself is left as it is, and swap that a job step adds is not counted. If your hook resizes /mnt/tmpfs from SwapTotal, remove that remount: SwapTotal also counts the compressed swap, which lives in memory and is turned off once the hook adds disk swap. A job slowed by swapping gets a memory pressure warning. For example, this preinstall gives a runner half of its root disk as swap:
fallocate -l "$(( $(df --output=size -k / | tail -1) / 2 ))KiB" /swapfilechmod 600 /swapfilemkswap /swapfileswapon /swapfileDocker images also use this memory. Ubuntu 26.04 images ship Docker 29, whose containerd image store keeps each downloaded layer next to its unpacked copy. A pulled image therefore takes about its compressed size plus its unpacked size. Docker also starts with an empty image store, so images baked into the AMI are not available on tmpfs runners.
Availability#
extras=tmpfs works on Linux runners only. It is available with both Flex and
Fleet. Windows runners do not support this capability.
Watch tmpfs pressure#
When tmpfs is enabled, v3.2 adds a Tmpfs Memory Utilization (%) chart to
the Complete runner step. It shows how much of /mnt/tmpfs the job used,
separately from overall host-memory utilization. The chart is part of the
standard inline metrics and needs no OpenTelemetry setup.
Usage#
Flex
Enable tmpfs from the job label and choose a runner with enough memory for the job’s writes:
jobs: tmpfs: runs-on: runs-on=${{ github.run_id }}/family=r8/ram=16/extras=tmpfs steps: - uses: runs-on/action@v2 - run: df -ah /mnt/tmpfs - run: df -ah /home/runner - run: df -ah /tmp - run: df -ah /var/lib/docker - run: df -ah /var/lib/containerdFleet
For Fleet, publish a runner fleet with tmpfs enabled in Terraform:
runners = { linux-tmpfs = { cpu = 8 ram = 16 family = ["r8g"] image = "ubuntu24-full-arm64" extras = ["tmpfs"] }}Use cases#
Using tmpfs is a good fit for:
- Speeding up I/O intensive workflows, since any writes to the directories listed above are done in memory, and are much faster than writing to disk.
To see how tmpfs compares with EBS gp3 and local NVMe on the same instances, down to fio numbers and real build times, see EC2 storage for GitHub Actions.
Accessing tmpfs#
If you include tmpfs in the extras parameter of your workflow job, a tmpfs volume will be created in the /mnt/tmpfs directory, and the directories specified above will automatically be bind-mounted or overlay-mounted into it.
Using tmpfs in your workflow#
jobs: efs: runs-on: runs-on=${{ github.run_id }}/family=r8/ram=16/extras=tmpfs steps: - uses: runs-on/action@v2 - run: df -ah /mnt/tmpfs # tmpfs 16G 724K 16G 1% /mnt/tmpfs - run: df -ah /home/runner # overlay 16G 724K 16G 1% /home/runner - run: df -ah /tmp # overlay 16G 724K 16G 1% /tmp - run: df -ah /var/lib/docker # tmpfs 16G 724K 16G 1% /var/lib/docker - run: df -ah /var/lib/containerd # tmpfs 16G 724K 16G 1% /var/lib/containerdConsiderations#
Again, this is a kind of YOLO mode (but with potentially great rewards), so make sure your are correctly right-sizing your runners.
Volatility (stopped/warm pools)#
tmpfs is volatile. Because /var/lib/docker and /var/lib/containerd are bind-mounted onto the tmpfs volume, all Docker state (images, containers, volumes) is lost on every stop/start. For stopped pools, warm boots skip host setup to keep resume latency low, so any container started during preinstall on the first boot will not exist on the next boot. Recreate required containers via prerun or job hooks.