From 58c3a496eedf34e075de0f526ff74c2455694cdb Mon Sep 17 00:00:00 2001 From: sleeuwenhoek Date: Fri, 27 Nov 2020 09:42:55 +0100 Subject: [PATCH 1/3] Set Recovery partition before OS partition This way the OS disk can be expanded later on when de VHDX is enlarged. --- Public/New-OSDBuilderVHD.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Public/New-OSDBuilderVHD.ps1 b/Public/New-OSDBuilderVHD.ps1 index e7e796f..eda938d 100644 --- a/Public/New-OSDBuilderVHD.ps1 +++ b/Public/New-OSDBuilderVHD.ps1 @@ -177,6 +177,12 @@ function New-OSDBuilderVHD { Write-Host "Creating MSR Partition 128MB" -ForegroundColor Green $PartitionMSR = New-Partition -DiskNumber $DiskNumber -GptType '{e3c9e316-0b5c-4db8-817d-f92df00215ae}' -Size 128MB + If($IncludeRecoveryPartition){ + Write-Host '========================================================================================' -ForegroundColor DarkGray + Write-Host "Creating Recovery Partition 984MB NTFS" -ForegroundColor Green + $PartitionRecovery = New-Partition -DiskNumber $DiskNumber -GptType '{de94bba4-06d1-4d40-a16a-bfd50179d6ac}' -UseMaximumSize + $PartitionRecovery | Format-Volume -FileSystem NTFS -NewFileSystemLabel Recovery -Confirm:$false | Out-Null + } Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Creating $OSDriveLabel Partition NTFS" -ForegroundColor Green $PartitionOS = New-Partition -DiskNumber $DiskNumber -GptType '{ebd0a0a2-b9e5-4433-87c0-68b6b72699c7}' -UseMaximumSize @@ -186,12 +192,6 @@ function New-OSDBuilderVHD { Add-PartitionAccessPath -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber -AssignDriveLetter $PartitionOS = Get-Partition -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber $PartitionOSVolume = [string]$PartitionOS.DriveLetter+":" - If($IncludeRecoveryPartition){ - Write-Host '========================================================================================' -ForegroundColor DarkGray - Write-Host "Creating Recovery Partition 984MB NTFS" -ForegroundColor Green - $PartitionRecovery = New-Partition -DiskNumber $DiskNumber -GptType '{de94bba4-06d1-4d40-a16a-bfd50179d6ac}' -UseMaximumSize - $PartitionRecovery | Format-Volume -FileSystem NTFS -NewFileSystemLabel Recovery -Confirm:$false | Out-Null - } Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Expand-WindowsImage -ImagePath $VhdInstallWim -Index 1 -ApplyPath $PartitionOSVolume\" -ForegroundColor Green Try { Expand-WindowsImage -ImagePath $VhdInstallWim -Index 1 -ApplyPath $PartitionOSVolume\ -ErrorAction Stop | Out-Null } @@ -221,4 +221,4 @@ function New-OSDBuilderVHD { Write-Host -ForegroundColor Green "$($MyInvocation.MyCommand.Name) END" Write-Host '========================================================================================' -ForegroundColor DarkGray } -} \ No newline at end of file +} From 58921fe491d0c0b8af83f10137f638fa217f3561 Mon Sep 17 00:00:00 2001 From: sleeuwenhoek Date: Fri, 27 Nov 2020 09:56:13 +0100 Subject: [PATCH 2/3] Update New-OSDBuilderVHD.ps1 --- Public/New-OSDBuilderVHD.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Public/New-OSDBuilderVHD.ps1 b/Public/New-OSDBuilderVHD.ps1 index eda938d..18c772c 100644 --- a/Public/New-OSDBuilderVHD.ps1 +++ b/Public/New-OSDBuilderVHD.ps1 @@ -180,14 +180,14 @@ function New-OSDBuilderVHD { If($IncludeRecoveryPartition){ Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Creating Recovery Partition 984MB NTFS" -ForegroundColor Green - $PartitionRecovery = New-Partition -DiskNumber $DiskNumber -GptType '{de94bba4-06d1-4d40-a16a-bfd50179d6ac}' -UseMaximumSize + $PartitionRecovery = New-Partition -DiskNumber $DiskNumber -GptType '{de94bba4-06d1-4d40-a16a-bfd50179d6ac}' -Size 984MB $PartitionRecovery | Format-Volume -FileSystem NTFS -NewFileSystemLabel Recovery -Confirm:$false | Out-Null } Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Creating $OSDriveLabel Partition NTFS" -ForegroundColor Green $PartitionOS = New-Partition -DiskNumber $DiskNumber -GptType '{ebd0a0a2-b9e5-4433-87c0-68b6b72699c7}' -UseMaximumSize $PartitionOSSize = (Get-PartitionSupportedSize -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber) - Resize-Partition -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber -Size ($PartitionOSSize.SizeMax - 984MB) + Resize-Partition -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber -Size ($PartitionOSSize.SizeMax) $PartitionOS | Format-Volume -FileSystem NTFS -NewFileSystemLabel $OSDriveLabel -Confirm:$false | Out-Null Add-PartitionAccessPath -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber -AssignDriveLetter $PartitionOS = Get-Partition -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber From c2ccc85c53cbfbd221c8073168873679e54c2cd1 Mon Sep 17 00:00:00 2001 From: sleeuwenhoek Date: Fri, 27 Nov 2020 09:57:36 +0100 Subject: [PATCH 3/3] Update New-OSDBuilderVHD.ps1 --- Public/New-OSDBuilderVHD.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/Public/New-OSDBuilderVHD.ps1 b/Public/New-OSDBuilderVHD.ps1 index 18c772c..703331f 100644 --- a/Public/New-OSDBuilderVHD.ps1 +++ b/Public/New-OSDBuilderVHD.ps1 @@ -187,7 +187,6 @@ function New-OSDBuilderVHD { Write-Host "Creating $OSDriveLabel Partition NTFS" -ForegroundColor Green $PartitionOS = New-Partition -DiskNumber $DiskNumber -GptType '{ebd0a0a2-b9e5-4433-87c0-68b6b72699c7}' -UseMaximumSize $PartitionOSSize = (Get-PartitionSupportedSize -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber) - Resize-Partition -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber -Size ($PartitionOSSize.SizeMax) $PartitionOS | Format-Volume -FileSystem NTFS -NewFileSystemLabel $OSDriveLabel -Confirm:$false | Out-Null Add-PartitionAccessPath -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber -AssignDriveLetter $PartitionOS = Get-Partition -DiskNumber $DiskNumber -PartitionNumber $PartitionOS.PartitionNumber