mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-27 00:11:30 -06:00
Add VirtIO functionality and more enhancements
- Added the ability to grab VirtIO Guest Tools - Modified the description of the Copy ISO files function because it basically had nonsense
This commit is contained in:
parent
aa717838b2
commit
2f8eaf4f18
@ -55,6 +55,8 @@ public class PowerManagement {
|
||||
$injectDrivers = $sync.MicrowinInjectDrivers.IsChecked
|
||||
$importDrivers = $sync.MicrowinImportDrivers.IsChecked
|
||||
|
||||
$importVirtIO = $sync.MicrowinCopyVirtIO.IsChecked
|
||||
|
||||
$mountDir = $sync.MicrowinMountDir.Text
|
||||
$scratchDir = $sync.MicrowinScratchDir.Text
|
||||
|
||||
@ -155,6 +157,11 @@ public class PowerManagement {
|
||||
}
|
||||
}
|
||||
|
||||
if ($importVirtIO) {
|
||||
Write-Host "Copying VirtIO drivers..."
|
||||
Microwin-CopyVirtIO
|
||||
}
|
||||
|
||||
Write-Host "Remove Features from the image"
|
||||
Microwin-RemoveFeatures
|
||||
Write-Host "Removing features complete!"
|
||||
|
@ -242,8 +242,8 @@ function Invoke-MicrowinGetIso {
|
||||
|
||||
# xcopy we can verify files and also not copy files that already exist, but hard to measure
|
||||
# xcopy.exe /E /I /H /R /Y /J $DriveLetter":" $mountDir >$null
|
||||
$totalTime = Measure-Command { Copy-Files "$($driveLetter):" $mountDir -Recurse -Force }
|
||||
Write-Host "Copy complete! Total Time: $($totalTime.Minutes)m$($totalTime.Seconds)s"
|
||||
$totalTime = Measure-Command { Copy-Files "$($driveLetter):" "$mountDir" -Recurse -Force }
|
||||
Write-Host "Copy complete! Total Time: $($totalTime.Minutes) minutes, $($totalTime.Seconds) seconds"
|
||||
|
||||
$wimFile = "$mountDir\sources\install.wim"
|
||||
Write-Host "Getting image information $wimFile"
|
||||
|
40
functions/microwin/Microwin-CopyVirtIO.ps1
Normal file
40
functions/microwin/Microwin-CopyVirtIO.ps1
Normal file
@ -0,0 +1,40 @@
|
||||
function Microwin-CopyVirtIO {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Downloads and copies the VirtIO Guest Tools drivers to the target MicroWin ISO
|
||||
.NOTES
|
||||
A network connection must be available and the servers of Fedora People must be up. Automatic driver installation will not be added yet - I want this implementation to be reliable.
|
||||
#>
|
||||
|
||||
try {
|
||||
Write-Host "Checking existing files..."
|
||||
if (Test-Path -Path "$($env:TEMP)\virtio.iso" -PathType Leaf) {
|
||||
Write-Host "VirtIO ISO has been detected. Deleting..."
|
||||
Remove-Item -Path "$($env:TEMP)\virtio.iso" -Force
|
||||
}
|
||||
Write-Host "Getting latest VirtIO drivers. Please wait. This can take some time, depending on your network connection speed and the speed of the servers..."
|
||||
Start-BitsTransfer -Source "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" -Destination "$($env:TEMP)\virtio.iso" -DisplayName "Downloading VirtIO drivers..."
|
||||
# Do everything else if the VirtIO ISO exists
|
||||
if (Test-Path -Path "$($env:TEMP)\virtio.iso" -PathType Leaf) {
|
||||
Write-Host "Mounting ISO. Please wait."
|
||||
$virtIO_ISO = Mount-DiskImage -PassThru "$($env:TEMP)\virtio.iso"
|
||||
$driveLetter = (Get-Volume -DiskImage $virtIO_ISO).DriveLetter
|
||||
# Create new directory for VirtIO on ISO
|
||||
New-Item -Path "$mountDir\VirtIO" -ItemType Directory | Out-Null
|
||||
$totalTime = Measure-Command { Copy-Files "$($driveLetter):" "$mountDir\VirtIO" -Recurse -Force }
|
||||
Write-Host "VirtIO contents have been successfully copied. Time taken: $($totalTime.Minutes) minutes, $($totalTime.Seconds) seconds`n"
|
||||
Get-Volume $driveLetter | Get-DiskImage | Dismount-DiskImage
|
||||
Remove-Item -Path "$($env:TEMP)\virtio.iso" -Force -ErrorAction SilentlyContinue
|
||||
Write-Host "To proceed with installation of the MicroWin image in QEMU/Proxmox VE:"
|
||||
Write-Host "1. Proceed with Setup until you reach the disk selection screen, in which you won't see any drives"
|
||||
Write-Host "2. Click `"Load Driver`" and click Browse"
|
||||
Write-Host "3. In the folder selection dialog, point to this path:`n`n `"D:\VirtIO\vioscsi\w11\amd64`" (replace amd64 with ARM64 if you are using Windows on ARM, and `"D:`" with the drive letter of the ISO)`n"
|
||||
Write-Host "4. Select all drivers that will appear in the list box and click OK"
|
||||
} else {
|
||||
throw "Could not download VirtIO drivers"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "We could not download and/or prepare the VirtIO drivers. Error information: $_`n"
|
||||
Write-Host "You will need to download these drivers manually. Location: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso"
|
||||
}
|
||||
}
|
@ -2,11 +2,17 @@ function Copy-Files {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
This function will make all modifications to the registry
|
||||
|
||||
Copies the contents of a given ISO file to a given destination
|
||||
.PARAMETER Path
|
||||
The source of the files to copy
|
||||
.PARAMETER Destination
|
||||
The destination to copy the files to
|
||||
.PARAMETER Recurse
|
||||
Determines whether or not to copy all files of the ISO file, including those in subdirectories
|
||||
.PARAMETER Force
|
||||
Determines whether or not to overwrite existing files
|
||||
.EXAMPLE
|
||||
|
||||
Set-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0"
|
||||
Copy-Files "D:" "C:\ISOFile" -Recurse -Force
|
||||
|
||||
#>
|
||||
param (
|
||||
@ -23,7 +29,7 @@ function Copy-Files {
|
||||
|
||||
foreach ($file in $files) {
|
||||
$status = "Copying file {0} of {1}: {2}" -f $counter, $files.Count, $file.Name
|
||||
Write-Progress -Activity "Copy Windows files" -Status $status -PercentComplete ($counter++/$files.count*100)
|
||||
Write-Progress -Activity "Copy disc image files" -Status $status -PercentComplete ($counter++/$files.count*100)
|
||||
$restpath = $file.FullName -Replace $path, ''
|
||||
|
||||
if ($file.PSIsContainer -eq $true) {
|
||||
@ -35,7 +41,7 @@ function Copy-Files {
|
||||
Set-ItemProperty -Path ($destination+$restpath) -Name IsReadOnly -Value $false
|
||||
}
|
||||
}
|
||||
Write-Progress -Activity "Copy Windows files" -Status "Ready" -Completed
|
||||
Write-Progress -Activity "Copy disc image files" -Status "Ready" -Completed
|
||||
} catch {
|
||||
Write-Host "Unable to Copy all the files due to an unhandled exception" -ForegroundColor Yellow
|
||||
Write-Host "Error information: $($_.Exception.Message)`n" -ForegroundColor Yellow
|
||||
|
@ -1175,6 +1175,7 @@
|
||||
ToolTip="Path to unpacked drivers all sys and inf files for devices that need drivers"
|
||||
/>
|
||||
<CheckBox Name="MicrowinImportDrivers" Content="Import drivers from current system" Margin="{DynamicResource MicrowinCheckBoxMargin}" IsChecked="False" ToolTip="Export all third-party drivers from your system and inject them to the MicroWin image"/>
|
||||
<CheckBox Name="MicrowinCopyVirtIO" Content="Include VirtIO drivers" Margin="{DynamicResource MicrowinCheckBoxMargin}" IsChecked="False" ToolTip="Copy VirtIO Guest Tools drivers to your ISO file. Check this only if you want to use it on QEMU/Proxmox VE"/>
|
||||
<Rectangle Fill="{DynamicResource MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/>
|
||||
<CheckBox Name="WPFMicrowinCopyToUsb" Content="Copy to Ventoy" Margin="{DynamicResource MicrowinCheckBoxMargin}" IsChecked="False" ToolTip="Copy to USB disk with a label Ventoy"/>
|
||||
<Rectangle Fill="{DynamicResource MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/>
|
||||
|
Loading…
Reference in New Issue
Block a user