Skip to content

Commit

Permalink
Merge pull request NixOS#39164 from ngortheone/master
Browse files Browse the repository at this point in the history
Fix root volume resizing on EC2 KVM instances (M5, C5, etc)
  • Loading branch information
copumpkin authored Apr 20, 2018
2 parents 0e09510 + 3a47c7e commit ec569fc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nixos/modules/system/boot/grow-partition.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ with lib;
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}"
parentDevice="$rootDevice"
while [ "''${parentDevice%[0-9]}" != "''${parentDevice}" ]; do
parentDevice="''${parentDevice%[0-9]}";
done
partNum="''${rootDevice#''${parentDevice}}"
if [ "''${parentDevice%[0-9]p}" != "''${parentDevice}" ] && [ -b "''${parentDevice%p}" ]; then
parentDevice="''${parentDevice%p}"
fi
TMPDIR=/run sh $(type -P growpart) "$parentDevice" "$partNum"
udevadm settle
fi
'';
Expand Down

0 comments on commit ec569fc

Please sign in to comment.