Refactor structure of DerGeret's disk
This commit is contained in:
parent
021f9c767a
commit
41bfc2df9e
1 changed files with 24 additions and 8 deletions
|
@ -11,28 +11,44 @@ $Global:SetupConfigPostprocessor = {
|
||||||
$diskConfig = $setupComponent.SelectSingleNode("./ua:DiskConfiguration/ua:Disk", $namespace);
|
$diskConfig = $setupComponent.SelectSingleNode("./ua:DiskConfiguration/ua:Disk", $namespace);
|
||||||
$installationPartition = $setupComponent.SelectSingleNode("./ua:ImageInstall/ua:OSImage/ua:InstallTo/ua:PartitionID", $namespace);
|
$installationPartition = $setupComponent.SelectSingleNode("./ua:ImageInstall/ua:OSImage/ua:InstallTo/ua:PartitionID", $namespace);
|
||||||
|
|
||||||
$newIndex = [int]$installationPartition.InnerText;
|
$newIndex = 2;
|
||||||
$installationPartition.InnerText = "$($newIndex + 1)";
|
$installationPartition.InnerText = "$($newIndex + 1)";
|
||||||
$partitionCreations = $diskConfig.SelectSingleNode("./ua:CreatePartitions", $namespace);
|
$partitionCreations = $diskConfig.SelectSingleNode("./ua:CreatePartitions", $namespace);
|
||||||
$newPartition = $partitionCreations.SelectNodes("./ua:CreatePartition", $namespace)[0].CloneNode($true);
|
$winPartition = ($partitionCreations.SelectNodes("./ua:CreatePartition", $namespace) | Select-Object -Last)[0];
|
||||||
|
$newPartition = $winPartition.CloneNode($true);
|
||||||
|
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
|
|
||||||
for ($i = 0; $i -lt $partitionCreations.ChildNodes.Count; $i++) {
|
for ($i = 0; $i -lt $partitionCreations.ChildNodes.Count; $i++) {
|
||||||
$partition = $partitionCreations.ChildNodes[$i];
|
$partition = $partitionCreations.ChildNodes[$i];
|
||||||
$order = [int]$partition.SelectSingleNode("./ua:Order", $namespace).InnerText;
|
$order = [int]$partition.SelectSingleNode("./ua:Order", $namespace).InnerText;
|
||||||
|
$offset += [int]$partition.SelectSingleNode("./ua:Size", $namespace).InnerText;
|
||||||
|
$newOrder = $order;
|
||||||
|
|
||||||
if ($order -ge $newIndex) {
|
if ($order -eq 2) {
|
||||||
$partition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$($order + 1)";
|
$newOrder--;
|
||||||
} else {
|
} else {
|
||||||
$offset += [int]$partition.SelectSingleNode("./ua:Size", $namespace).InnerText;
|
if ($order -ge $newIndex) {
|
||||||
|
$newOrder++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order -lt 2) {
|
||||||
|
$newOrder++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order -ne $newOrder) {
|
||||||
|
$partition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newOrder";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add 1 TB space before Windows installation... wha-!? For Linux, ofc! I use Arch Linux, btw.
|
# Add space before Windows installation... wha-!? For Linux, ofc! I use Arch Linux, btw.
|
||||||
$newPartition.SelectSingleNode("./ua:Size", $namespace).InnerText = "$((64 * 1024) - $offset)";
|
$size = $winPartition.OwnerDocument.CreateElement("Size");
|
||||||
$newPartition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newIndex";
|
$size.InnerText = "$((1 * 1024 * 1024) - $offset)";
|
||||||
|
$winPartition.RemoveChild($winPartition.SelectSingleNode("./Extend"));
|
||||||
|
$winPartition.AppendChild($size);
|
||||||
|
|
||||||
|
$newPartition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newIndex";
|
||||||
$null = $partitionCreations.AppendChild($newPartition);
|
$null = $partitionCreations.AppendChild($newPartition);
|
||||||
|
|
||||||
$partitionModifications = $diskConfig.SelectSingleNode("./ua:ModifyPartitions", $namespace);
|
$partitionModifications = $diskConfig.SelectSingleNode("./ua:ModifyPartitions", $namespace);
|
||||||
|
|
Loading…
Reference in a new issue