Add systemd repart to grow root partition on boot

kalle 2024-11-22 20:55:14 +01:00
parent 843c64f8ed
commit c29cf76a5e
1 changed files with 37 additions and 1 deletions

View File

@ -21,7 +21,6 @@
services.qemuGuest.enable = lib.mkDefault true; services.qemuGuest.enable = lib.mkDefault true;
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.growPartition = lib.mkDefault true;
# Allow remote updates with flakes and non-root users # Allow remote updates with flakes and non-root users
nix.settings.trusted-users = [ nix.settings.trusted-users = [
@ -98,6 +97,43 @@
}; };
}; };
# Resize partition on boot
systemd.repart.partitions = {
"00-esp" = {
Type = "esp";
SizeMinBytes = "550M";
SizeMaxBytes = "550M";
Format = "vfat";
};
"10-root" = {
Type = "linux-generic";
Format = "btrfs";
};
};
boot.initrd = {
# Custom systemd units in the initrd
systemd = {
enable = true;
units = {
"resize-gpt.service" = {
description = "Resize GPT to use full disk size";
path = [ pkgs.gptfdisk ];
wants = [ "systemd-repart.service" ];
before = [ "systemd-repart.service" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "/run/current-system/sw/bin/sgdisk --move-second-header /dev/sdX";
};
};
"systemd-repart.service".wants = [ "resize-gpt.service" ];
};
repart = {
enable = true;
device = "/dev/sda";
};
};
};
system.stateVersion = lib.mkDefault "24.05"; system.stateVersion = lib.mkDefault "24.05";
}; };
} }