Skip to content

Instantly share code, notes, and snippets.

@Pothulapati
Created June 1, 2022 10:17
Show Gist options
  • Select an option

  • Save Pothulapati/00cfc3ad012c4aebe24f87bb06abafc7 to your computer and use it in GitHub Desktop.

Select an option

Save Pothulapati/00cfc3ad012c4aebe24f87bb06abafc7 to your computer and use it in GitHub Desktop.
diff --git a/entrypoint.sh b/entrypoint.sh
index f08fe36..f943da6 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -7,6 +7,25 @@ if [ -z "$DOMAIN" ]; then
exit 1;
fi
+# M1 and cgroupsv2 stuff
+if ! grep -iq 'cpu.*hz' /proc/cpuinfo; then
+ cpuinfo_file=/etc/cpuinfo_with_fake_speed
+ cp /proc/cpuinfo $cpuinfo_file
+ echo "CPU MHz: 2345.678" >> $cpuinfo_file
+ mount --bind $cpuinfo_file /proc/cpuinfo
+fi
+
+if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
+ echo "[$(date -Iseconds)] [CgroupV2 Fix] Evacuating Root Cgroup ..."
+ # move the processes from the root group to the /init group,
+ # otherwise writing subtree_control fails with EBUSY.
+ mkdir -p /sys/fs/cgroup/init
+ busybox xargs -rn1 < /sys/fs/cgroup/cgroup.procs > /sys/fs/cgroup/init/cgroup.procs || :
+ # enable controllers
+ sed -e 's/ / +/g' -e 's/^/+/' <"/sys/fs/cgroup/cgroup.controllers" >"/sys/fs/cgroup/cgroup.subtree_control"
+ echo "[$(date -Iseconds)] [CgroupV2 Fix] Done"
+fi
+
mount --make-shared /sys/fs/cgroup
mount --make-shared /proc
mount --make-shared /var/gitpod/workspaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment