Optimising Gitlab runners with RAM disks

The application I build run on both Linux and Windows, and because of this, often my build pipelines consist of jobs on Linux and Windows machines.

By default the builds directory is located on the hard drive. If we do not care about the object files, we can run the build on a RAM disk (tmpfs in Linux) and upload the artefacts.

This reduces HDD load and allows us to build a bit faster.


Download a RAM disk tool. ImDisk works for me. Setup a RAM disk at R:\ and ensure it is big enough to store the git repo as well as the intermediate build objects.

Goto the Gitlab runner location, and edit the config.toml file.

concurrent = 10
check_interval = 0

  session_timeout = 1800

  name = "Windows10"
  url = "https://gitlab.com"
  token = "TOKEN"
  executor = "shell"
  shell = "powershell"
  output_limit = 32768
  builds_dir = "R:\\GitlabRunner\\builds"
  enabled = true

Ensure that the builds_dir points to a location on the R drive and that custom build dir is set to enabled.

It’s also a good idea to set the %TEMP% and %TMP% to the R:/Temp directory, as some linker steps from Microsoft utilise the TEMP folder.


It’s a good idea to run the gitlab runner in a docker file.

Regardless the config.toml is generally located under /srv/gitlab-runner

  name = "devel runner"
  url = "https://gitlab.com/"
  token = "TOKEN"
  executor = "docker"
  builds_dir = "/ramdisk"
  cache_dir = "/ramdisk/cache"
    enabled = true
    tls_verify = false
    image = "alpine:latest"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/ramdisk:/ramdisk:rw", "/cache:/ramdisk/cache:rw"]
    shm_size = 0

Similar to the Windows config, add in the builds and cache dir, but also let docker know about the volumes.

mkdir /ramdisk

Setup a tmpfs of 20Gigabytes by adding a line into the /etc/fstab

tmpfs /ramdisk tmpfs exec,rw,size=20G 0 0

You should be set to build at the speed of RAM and not be limited to HDD access speeds.

Note that all data on the RAM drive is lost after a reboot, so don’t put anything on there that you are not prepared to lose.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s