From ee8e4aa661e730a26657dc9227811e4082b7ea67 Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Sun, 9 Jul 2023 01:02:14 +0200
Subject: [PATCH] Try fixing the partition extension

---
 profiles/DerGeret/Windows/Setup.ps1 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/profiles/DerGeret/Windows/Setup.ps1 b/profiles/DerGeret/Windows/Setup.ps1
index c7e1ccab..274628de 100644
--- a/profiles/DerGeret/Windows/Setup.ps1
+++ b/profiles/DerGeret/Windows/Setup.ps1
@@ -16,7 +16,6 @@ $Global:SetupConfigPostprocessor = {
     $partitionCreationContainer = $diskConfig.SelectSingleNode("./ua:CreatePartitions", $namespace);
     $partitionCreations = $partitionCreationContainer.SelectNodes("./ua:CreatePartition", $namespace);
     $winPartition = ($partitionCreations | Select-Object -Last 1);
-    $newPartition = $winPartition.CloneNode($true);
 
     $garbage = 0;
 
@@ -45,10 +44,12 @@ $Global:SetupConfigPostprocessor = {
     # Add space before Windows installation... wha-!? For Linux, ofc! I use Arch Linux, btw.
     $size = ($partitionCreationContainer.SelectNodes("./ua:CreatePartition/ua:Size", $namespace) | Select-Object -First 1).CloneNode($true);
     $size.InnerText = "$((64 * 1024) - $garbage)";
-    $null = $winPartition.RemoveChild($winPartition.SelectSingleNode("./ua:Extend", $namespace));
+    $extendTag = $winPartition.RemoveChild($winPartition.SelectSingleNode("./ua:Extend", $namespace));
     $null = $winPartition.AppendChild($size);
+    $newPartition = $winPartition.CloneNode($true);
 
     $newPartition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newIndex";
+    $newPartition.SelectSingleNode("./ua:Size", $namespace).InnerText = "100";
     $null = $partitionCreationContainer.AppendChild($newPartition);
 
     $partitionModificationContainer = $diskConfig.SelectSingleNode("./ua:ModifyPartitions", $namespace);
@@ -56,6 +57,7 @@ $Global:SetupConfigPostprocessor = {
     $newModification = $partitionModifications[2].CloneNode($true);
     $newModification.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newIndex";
     $newModification.SelectSingleNode("./ua:PartitionID", $namespace).InnerText = "$newIndex";
+    $null = $newModification.AppendChild($extendTag.CloneNode($true));
 
     foreach ($partition in $partitionModifications) {
         $partitionID = [int]$partition.SelectSingleNode("./ua:PartitionID", $namespace).InnerText;