amazon-grow-partition module: autodetect the root device

This commit is contained in:
Nathan Zadoks 2016-02-17 12:59:51 +01:00
parent 986e64280e
commit 1de8e1b02e

View File

@ -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
'';