amazon-grow-partition module: autodetect the root device

wip/yesman
Nathan Zadoks 8 years ago
parent 986e64280e
commit 1de8e1b02e
  1. 8
      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
'';

Loading…
Cancel
Save