Subject: [PATCH 1/1] gnu: machine: hetzner: Fix deployment on smaller instances.

From: Roman Scherer <[email-masked]>
Date: Sun, 23 Feb 2025 13:22:01 +0100

* gnu/machine/hetzner.scm (hetzner-machine-rescue-install-os): Avoid out of
disk space error by bind mounting /mnt/tmp/gnu/store to /gnu/store.
* tests/machine/hetzner.scm: Test with smaller instances.
* doc/guix.texi: Mention unsupported instance.

Change-Id: If8bfb6733de493b51813b3e82e255849192f7cba
---
 doc/guix.texi             | 4 +++-
 gnu/machine/hetzner.scm   | 9 ++++++++-
 tests/machine/hetzner.scm | 4 ++--
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 83ba0f3292..51db3f9c77 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -45361,7 +45361,9 @@ Invoking guix deploy
 @code{"cx42"} corresponds to a x86_64 server that has 8 VCPUs, 16 GB of
 memory and 160 GB of storage, while @code{"cax31"} to the AArch64
 equivalent.  Other server types and their current prices can be found
-@uref{https://www.hetzner.com/cloud/#pricing, here}.
+@uref{https://www.hetzner.com/cloud/#pricing, here}.  The @code{"cpx11"}
+server type is currently not supported, since its rescue system is too
+small to bootstrap a Guix system from.
 
 @item @code{ssh-key}
 The file name of the SSH private key to use to authenticate with the
diff --git a/gnu/machine/hetzner.scm b/gnu/machine/hetzner.scm
index 1d9a3f4385..e87149a06a 100644
--- a/gnu/machine/hetzner.scm
+++ b/gnu/machine/hetzner.scm
@@ -551,6 +551,13 @@ (define (hetzner-machine-rescue-install-os machine ssh-session server)
 cp /root/.ssh/authorized_keys /mnt/root/.ssh/authorized_keys
 chmod 600 /mnt/root/.ssh/authorized_keys
 
+# Small instance don't have much disk space.  Bind mount the store of the
+# resuce system to the tmp directory of the new Guix system.
+mkdir -p /mnt/tmp/gnu/store
+mkdir -p /gnu/store
+mount --bind /mnt/tmp/gnu/store /gnu/store
+
+apt-get install guix --assume-yes
 cat > /tmp/guix/deploy/hetzner-os.scm << EOF
 (use-modules (gnu) (guix utils))
 (use-package-modules ssh)
@@ -605,7 +612,7 @@ (define (hetzner-machine-rescue-install-packages machine ssh-session)
      (format #f "#!/usr/bin/env bash
 set -eo pipefail
 apt-get update
-apt-get install guix cloud-initramfs-growroot --assume-yes"))
+apt-get install cloud-initramfs-growroot --assume-yes"))
     (format #t "successfully installed rescue system packages on '~a'\n" name)))
 
 (define (hetzner-machine-delete machine server)
diff --git a/tests/machine/hetzner.scm b/tests/machine/hetzner.scm
index 39eac4a4d5..1552bcb9a0 100644
--- a/tests/machine/hetzner.scm
+++ b/tests/machine/hetzner.scm
@@ -64,7 +64,7 @@ (define %arm-machine
    (environment hetzner-environment-type)
    (configuration (hetzner-configuration
                    (labels %labels)
-                   (server-type "cax41")
+                   (server-type "cax11")
                    (ssh-key %ssh-key-file)))))
 
 (define %x86-machine
@@ -76,7 +76,7 @@ (define %x86-machine
    (environment hetzner-environment-type)
    (configuration (hetzner-configuration
                    (labels %labels)
-                   (server-type "cpx51")
+                   (server-type "cx22")
                    (ssh-key %ssh-key-file)))))
 
 (define (cleanup machine)
-- 
2.48.1