summaryrefslogtreecommitdiffstats
path: root/nixos/modules/installer/cd-dvd/sd-image.nix
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2020-12-02 21:48:02 +0100
committerJörg Thalheim <joerg@thalheim.io>2020-12-02 21:52:38 +0100
commit11ee54305298de16df4bfde14dc27e220bea5417 (patch)
tree8db01c83f18215cfaf033e88ea3feca159cf891d /nixos/modules/installer/cd-dvd/sd-image.nix
parentdeca8d0087502e4dde04d768b3889c719968457d (diff)
sd-image: fix resizing if root is not the second partition.
Diffstat (limited to 'nixos/modules/installer/cd-dvd/sd-image.nix')
-rw-r--r--nixos/modules/installer/cd-dvd/sd-image.nix3
1 files changed, 2 insertions, 1 deletions
diff --git a/nixos/modules/installer/cd-dvd/sd-image.nix b/nixos/modules/installer/cd-dvd/sd-image.nix
index d9799aa69c95..c8c5a46dfb87 100644
--- a/nixos/modules/installer/cd-dvd/sd-image.nix
+++ b/nixos/modules/installer/cd-dvd/sd-image.nix
@@ -223,9 +223,10 @@ in
# Figure out device names for the boot device and root filesystem.
rootPart=$(${pkgs.util-linux}/bin/findmnt -n -o SOURCE /)
bootDevice=$(lsblk -npo PKNAME $rootPart)
+ partNum=$(lsblk -npo MAJ:MIN $rootPart | awk -F: '{print $2}')
# Resize the root partition and the filesystem to fit the disk
- echo ",+," | sfdisk -N2 --no-reread $bootDevice
+ echo ",+," | sfdisk -N$partNum --no-reread $bootDevice
${pkgs.parted}/bin/partprobe
${pkgs.e2fsprogs}/bin/resize2fs $rootPart