amazon-grow-partition module: autodetect the root device
This commit is contained in:
parent
986e64280e
commit
1de8e1b02e
@ -10,13 +10,17 @@
|
|||||||
copy_bin_and_libs ${pkgs.gawk}/bin/gawk
|
copy_bin_and_libs ${pkgs.gawk}/bin/gawk
|
||||||
copy_bin_and_libs ${pkgs.gnused}/bin/sed
|
copy_bin_and_libs ${pkgs.gnused}/bin/sed
|
||||||
copy_bin_and_libs ${pkgs.utillinux}/sbin/sfdisk
|
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
|
cp -v ${pkgs.cloud-utils}/bin/growpart $out/bin/growpart
|
||||||
ln -s sed $out/bin/gnused
|
ln -s sed $out/bin/gnused
|
||||||
'';
|
'';
|
||||||
|
|
||||||
boot.initrd.postDeviceCommands = ''
|
boot.initrd.postDeviceCommands = ''
|
||||||
if [ -e /dev/xvda ] && [ -e /dev/xvda1 ]; then
|
rootDevice="${config.fileSystems."/".device}"
|
||||||
TMPDIR=/run sh $(type -P growpart) /dev/xvda 1
|
if [ -e "$rootDevice" ]; then
|
||||||
|
rootDevice="$(readlink -f "$rootDevice")"
|
||||||
|
parentDevice="$(lsblk -npo PKNAME "$rootDevice")"
|
||||||
|
TMPDIR=/run sh $(type -P growpart) "$parentDevice" "''${rootDevice#$parentDevice}"
|
||||||
udevadm settle
|
udevadm settle
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user