diff --git a/.gitlab/ci/global.gitlab-ci.yml b/.gitlab/ci/global.gitlab-ci.yml
index ee88c36ba5aaf03f975d7624124867da10888258..c11d53f9a4f14b80f386ad80dd857659c94cc95e 100644
--- a/.gitlab/ci/global.gitlab-ci.yml
+++ b/.gitlab/ci/global.gitlab-ci.yml
@@ -16,7 +16,7 @@
     - export GOPATH=$CI_PROJECT_DIR/.go
     - mkdir -p $GOPATH
     - source scripts/utils.sh
-    - log_disk_usage "false" # https://gitlab.com/gitlab-org/gitlab/-/issues/478880
+    - log_disk_usage "true" # https://gitlab.com/gitlab-org/gitlab/-/issues/478880
 
 .default-before_script:
   before_script:
diff --git a/scripts/utils.sh b/scripts/utils.sh
index b60b06997af383ec2598f2a0f03652acec7aabb1..f1f0eb29b31dd2ba2bbb2c63e0baaf308ce09ab3 100644
--- a/scripts/utils.sh
+++ b/scripts/utils.sh
@@ -480,13 +480,38 @@ function define_trigger_branch_in_build_env() {
 }
 
 function log_disk_usage() {
-  local collapsed="${1:-true}"
-  section_start "log_disk_usage" "Disk usage" "${collapsed}"
+  local exit_on_low_space="${1:-false}"
+  local space_threshold_gb=2 # 2GB
 
+  available_space=$(df -h | awk 'NR==2 {print $4}') # value at the 2nd row 4th column of the df -h output
+
+  echo "*******************************************************"
+  echo "This runner currently has ${available_space} free disk space."
+  echo "*******************************************************"
+
+  section_start "log_disk_usage" "Disk usage detail" "true"
   echo -e "df -h"
   df -h
 
   echo -e "du -h -d 1"
   du -h -d 1
   section_end "log_disk_usage"
+
+  if [[ "$exit_on_low_space" = "true" ]]; then
+
+    if [[ $OSTYPE == 'darwin'* ]]; then
+      available_space_gb=$(df -g | awk 'NR==2 {print $4}')
+    else
+      available_space_gb=$(df -BG | awk 'NR==2 {print $4}' | sed 's/G//')
+    fi
+
+    if (( $(echo "$available_space_gb < $space_threshold_gb") )); then
+      echo "********************************************************************"
+      echo "This job requires ${space_threshold_gb}G free disk space, but the runner only has ${available_space}."
+      echo "Exiting now in anticipation of a 'no space left on device' error."
+      echo "If this problem persists, please contact #g_hosted_runners team."
+      echo "********************************************************************"
+      exit 111
+    fi
+  fi
 }