Skip to content

Commit

Permalink
Fix root volume resizing on EC2 KVM instances (M5, C5, etc) (#39488)
Browse files Browse the repository at this point in the history
(cherry picked from commit 3a47c7e)
  • Loading branch information
ngortheone authored and Mic92 committed Apr 25, 2018
1 parent 159b63a commit 7aee0da
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nixos/modules/virtualisation/grow-partition.nix
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 7aee0da

Please sign in to comment.