From 1de8e1b02ef9bd5e65382f0b3998106ffc328094 Mon Sep 17 00:00:00 2001 From: Nathan Zadoks Date: Wed, 17 Feb 2016 12:59:51 +0100 Subject: amazon-grow-partition module: autodetect the root device --- nixos/modules/virtualisation/amazon-grow-partition.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'nixos/modules/virtualisation') diff --git a/nixos/modules/virtualisation/amazon-grow-partition.nix b/nixos/modules/virtualisation/amazon-grow-partition.nix index 69b80d900bad..02a0dd65fdc0 100644 --- a/nixos/modules/virtualisation/amazon-grow-partition.nix +++ b/nixos/modules/virtualisation/amazon-grow-partition.nix @@ -10,13 +10,17 @@ copy_bin_and_libs ${pkgs.gawk}/bin/gawk copy_bin_and_libs ${pkgs.gnused}/bin/sed copy_bin_and_libs ${pkgs.utillinux}/sbin/sfdisk + copy_bin_and_libs ${pkgs.utillinux}/sbin/lsblk cp -v ${pkgs.cloud-utils}/bin/growpart $out/bin/growpart ln -s sed $out/bin/gnused ''; boot.initrd.postDeviceCommands = '' - if [ -e /dev/xvda ] && [ -e /dev/xvda1 ]; then - TMPDIR=/run sh $(type -P growpart) /dev/xvda 1 + rootDevice="${config.fileSystems."/".device}" + if [ -e "$rootDevice" ]; then + rootDevice="$(readlink -f "$rootDevice")" + parentDevice="$(lsblk -npo PKNAME "$rootDevice")" + TMPDIR=/run sh $(type -P growpart) "$parentDevice" "''${rootDevice#$parentDevice}" udevadm settle fi ''; -- cgit 1.4.1