Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Public/Functions/Disk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,11 @@ Author: David Segura - Recast Software
[string]$BootLabel = 'USB Boot',

[ValidateLength(0,32)]
[string]$DataLabel = 'USB Data'
[string]$DataLabel = 'USB Data',

#Creates the Boot partition first (at the start of the disk) instead of last
#Lets the Data partition be extended into trailing free space later, e.g. after cloning onto a larger USB drive
[switch]$BootFirst
)

#=================================================
Expand Down Expand Up @@ -1807,11 +1811,20 @@ Author: David Segura - Recast Software
Set-Disk -Number $GetUSBDisk.Number -PartitionStyle MBR -ErrorAction Stop
}
if ($GetUSBDisk.SizeGB -le 2000) {
Write-Verbose '$DataDisk = $GetUSBDisk | New-Partition -Size ($GetUSBDisk.Size - 2GB) -AssignDriveLetter | Format-Volume -FileSystem NTFS -NewFileSystemLabel $DataLabel'
$DataDisk = $GetUSBDisk | New-Partition -Size ($GetUSBDisk.Size - 2GB) -AssignDriveLetter | Format-Volume -FileSystem NTFS -NewFileSystemLabel $DataLabel -ErrorAction Stop
if ($BootFirst) {
Write-Verbose '$BootDisk = $GetUSBDisk | New-Partition -Size 2GB -IsActive -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel $BootLabel'
$BootDisk = $GetUSBDisk | New-Partition -Size 2GB -IsActive -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel $BootLabel -ErrorAction Stop

Write-Verbose '$BootDisk = $GetUSBDisk | New-Partition -UseMaximumSize -IsActive -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel $BootLabel'
$BootDisk = $GetUSBDisk | New-Partition -UseMaximumSize -IsActive -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel $BootLabel -ErrorAction Stop
Write-Verbose '$DataDisk = $GetUSBDisk | New-Partition -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem NTFS -NewFileSystemLabel $DataLabel'
$DataDisk = $GetUSBDisk | New-Partition -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem NTFS -NewFileSystemLabel $DataLabel -ErrorAction Stop
}
else {
Write-Verbose '$DataDisk = $GetUSBDisk | New-Partition -Size ($GetUSBDisk.Size - 2GB) -AssignDriveLetter | Format-Volume -FileSystem NTFS -NewFileSystemLabel $DataLabel'
$DataDisk = $GetUSBDisk | New-Partition -Size ($GetUSBDisk.Size - 2GB) -AssignDriveLetter | Format-Volume -FileSystem NTFS -NewFileSystemLabel $DataLabel -ErrorAction Stop

Write-Verbose '$BootDisk = $GetUSBDisk | New-Partition -UseMaximumSize -IsActive -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel $BootLabel'
$BootDisk = $GetUSBDisk | New-Partition -UseMaximumSize -IsActive -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel $BootLabel -ErrorAction Stop
}
}
#=================================================
# -ge 2TB
Expand Down
19 changes: 15 additions & 4 deletions Public/OSDCloud/OSDCloudUSB.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
.PARAMETER fromIsoUrl
Specifies the value for fromIsoUrl.

.PARAMETER BootFirst
Switch. Creates the WinPE Boot partition first (at the start of the disk) instead of last.
Lets the Data partition be extended into trailing free space later, e.g. after cloning onto a larger USB drive.

.EXAMPLE
New-OSDCloudUSB -WorkspacePath <WorkspacePath> -fromIsoFile <fromIsoFile>
Runs New-OSDCloudUSB with common parameters.
Expand All @@ -41,7 +45,11 @@
#Path to an OSDCloud ISO saved on the internet
#This file will be downloaded and mounted and the contents will be copied to the OSDCloud USB
[Parameter(ParameterSetName='fromIsoUrl',Mandatory)]
[System.String]$fromIsoUrl
[System.String]$fromIsoUrl,

#Creates the WinPE Boot partition first (at the start of the disk) instead of last
#Lets the Data partition be extended into trailing free space later, e.g. after cloning onto a larger USB drive
[switch]$BootFirst
)
#=================================================
# Block
Expand Down Expand Up @@ -182,18 +190,21 @@
#=================================================
# New-BootableUSBDrive
#=================================================
$BootableUSBDrive = New-BootableUSBDrive -BootLabel $BootLabel -DataLabel $DataLabel
$BootableUSBDrive = New-BootableUSBDrive -BootLabel $BootLabel -DataLabel $DataLabel -BootFirst:$BootFirst
$BootableUSBDrive = $BootableUSBDrive | Select-Object -First 1
#=================================================
# Test USB Volumes
#=================================================
$WinPEPartition = Get-USBPartition | Where-Object {($_.DiskNumber -eq $BootableUSBDrive.DiskNumber) -and ($_.PartitionNumber -eq 2)}
$WinPEPartitionNumber = if ($BootFirst) { 1 } else { 2 }
$OSDCloudPartitionNumber = if ($BootFirst) { 2 } else { 1 }

$WinPEPartition = Get-USBPartition | Where-Object {($_.DiskNumber -eq $BootableUSBDrive.DiskNumber) -and ($_.PartitionNumber -eq $WinPEPartitionNumber)}
if (-NOT ($WinPEPartition)) {
Write-Warning "[$(Get-Date -format s)] Unable to create OSDCloud WinPE Partition"
Write-Warning "[$(Get-Date -format s)] Something went very very wrong in this process"
Break
}
$OSDCloudPartition = Get-USBPartition | Where-Object {($_.DiskNumber -eq $BootableUSBDrive.DiskNumber) -and ($_.PartitionNumber -eq 1)}
$OSDCloudPartition = Get-USBPartition | Where-Object {($_.DiskNumber -eq $BootableUSBDrive.DiskNumber) -and ($_.PartitionNumber -eq $OSDCloudPartitionNumber)}
if (-NOT ($OSDCloudPartition)) {
Write-Warning "[$(Get-Date -format s)] Unable to create OSDCloud Data Partition"
Write-Warning "[$(Get-Date -format s)] Something went very very wrong in this process"
Expand Down