Files
Ventoy/build-scripts/layout/switch-uefi-loader.ps1

45 lines
1.7 KiB
PowerShell

# Install the Paravis GRUB2 UEFI loader as the active first/second stage on p1.
# EFI\BOOT\bootx64.efi = shim (MS), EFI\BOOT\fbx64.efi = our signed GRUB2 (+.sbat)
param(
[ValidateSet('grub2','xorboot','ventoy')]
[string]$Loader = 'grub2'
)
$p1 = 'F:'
$boot = "$p1\EFI\BOOT"
$bkp = 'C:\PF\Ventoy\backup\uefi-loaders'
New-Item -ItemType Directory -Force $bkp | Out-Null
function Save-Current([string]$tag) {
Get-ChildItem $boot -File -ErrorAction SilentlyContinue | Where-Object { $_.Extension -eq '.efi' } | ForEach-Object {
Copy-Item $_.FullName (Join-Path $bkp "$tag-$($_.Name)") -Force
}
}
Save-Current 'current'
switch ($Loader) {
'grub2' {
Copy-Item 'G:\EFI\BOOT\BOOTX64.EFI' "$boot\bootx64.efi" -Force
Copy-Item 'C:\PF\ParavisGrub\grubx64.efi' "$boot\fbx64.efi" -Force
Copy-Item 'G:\EFI\BOOT\mmx64.efi' "$boot\mmx64.efi" -Force
Copy-Item 'C:\PF\ParavisGrub\grub.cfg' "$p1\efi\Paravis\Boot\grub2\grub.cfg" -Force
}
'xorboot' {
Copy-Item 'C:\PF\Ventoy\backup\xorboot-uefi\bootx64.efi.orig' "$boot\bootx64.efi" -Force
foreach ($f in 'fbx64.efi','mmx64.efi') {
if (Test-Path "$boot\$f") { Remove-Item "$boot\$f" -Force }
}
}
'ventoy' {
# firmware entry should point at p2 (VTOYEFI); nothing to do on p1
Write-Host 'Ventoy is booted directly from p2 (VTOYEFI) - select that entry in firmware'
}
}
Get-ChildItem $boot -File -Filter '*.efi' | Sort-Object Name | ForEach-Object {
$s = Get-AuthenticodeSignature $_.FullName
$subj = if ($s.SignerCertificate) { ($s.SignerCertificate.Subject -replace '^CN=([^,]+).*', '$1') } else { '-' }
"{0,-14} {1,9} {2,-12} {3}" -f $_.Name, $_.Length, $s.Status, $subj
}