From 84ce618213129c42b4a026342534f588d55de1ec Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sun, 28 Jan 2024 11:30:19 +0000 Subject: [PATCH] recovery: grow fs to partition size before starting sshd sshd expects there to be space in /persist/secrets that it can use to write host keys, but when we make ext4fs images we don't put any free space in them --- examples/recovery.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/recovery.nix b/examples/recovery.nix index 55b6efe..79c6982 100644 --- a/examples/recovery.nix +++ b/examples/recovery.nix @@ -44,13 +44,16 @@ in rec { dependencies = [ config.services.hostname ]; }; - services.sshd = svc.ssh.build { }; + services.sshd = svc.ssh.build { + dependencies = [ config.services.growfs ]; + }; services.defaultroute4 = svc.network.route.build { via = "$(output ${services.dhcpc} router)"; target = "default"; dependencies = [services.dhcpc]; }; + services.resolvconf = oneshot rec { dependencies = [ services.dhcpc ]; name = "resolvconf"; @@ -63,6 +66,16 @@ in rec { ) ''; }; + + services.growfs = let name = "growfs"; in oneshot { + inherit name; + up = '' + . ${serviceFns} + device=$(grep /persist /proc/1/mountinfo | cut -f9 -d' ') + ${pkgs.e2fsprogs}/bin/resize2fs $device + ''; + }; + filesystem = dir { etc = dir { "resolv.conf" = symlink "${services.resolvconf}/.outputs/resolv.conf";