Forum Discussion
MeganHarris
Jul 11, 2024Copper Contributor
How do I burn an ISO image to USB and make it bootable?
I recently tried to make a bootable USB, but ran into some problems. I had an ISO file and originally wanted to directly copy ISO to USB drive, but then I found that the USB would not be bootable on ...
ChristianGarcia
Jul 11, 2024Copper Contributor
I once tried to automate the process of burning ISO image to USB using PowerShell scripts. I first found some basic PowerShell script examples online and modified them slightly to suit my needs. It was actually quite simple, mainly automating some repetitive steps through the script, such as mounting ISO, copying files to USB, etc.
I remember that after I debugged the script, I only needed to run it once, and it would automatically handle the entire process. However, I encountered some minor issues with permissions and script compatibility at the beginning, and I had to test and modify it several times before it succeeded.
Below is the script I wrote, sharing it with you!
# Identify the target USB drive (ensure correct drive letter)
$usbDrive = "D:"
# Format the USB drive
Format-Volume -DriveLetter $usbDrive.Trim(":") -FileSystem NTFS -Confirm:$false
# Mount the ISO file
$isoPath = "C:\path\to\your\iso\file.iso"
$mountResult = Mount-DiskImage -ImagePath $isoPath -PassThru
$volumeInfo = $mountResult | Get-Volume
# Copy files to the USB
$isoDriveLetter = $volumeInfo.DriveLetter
xcopy "$($isoDriveLetter):\*" "$usbDrive\" /s /e
# Clean up: Unmount the ISO
Dismount-DiskImage -ImagePath $isoPath
Save the above script as a .ps1 file, such as CreateBootableUSB.ps1. Navigate to the directory where the script is located in PowerShell and run it!
EdvaldoGuimaraes
Aug 23, 2024Copper Contributor
Christian, I didi some improvement in your beaultiful script
Write-Host("Voce Digitou $usbDrive confirma?")
Pause
Write-Host("Formatando Unidade $usbDrive")
Format-Volume -DriveLetter $usbDrive.Trim(":") -FileSystem NTFS -Confirm:$false
$isoPath = Read-Host("Digite o caminho da ISO")
Write-Host("Voce Digitou $isoPath confirma?")
Pause
Write-Host("Montando Unidade")
$mountResult = Mount-DiskImage -ImagePath $isoPath -PassThru
$volumeInfo = $mountResult | Get-Volume
$isoDriveLetter = $volumeInfo.DriveLetter
xcopy "$($isoDriveLetter):\*" "$usbDrive\" /s /e
Dismount-DiskImage -ImagePath $isoPath
Write-Host("Voce Digitou $usbDrive confirma?")
Pause
Write-Host("Formatando Unidade $usbDrive")
Format-Volume -DriveLetter $usbDrive.Trim(":") -FileSystem NTFS -Confirm:$false
$isoPath = Read-Host("Digite o caminho da ISO")
Write-Host("Voce Digitou $isoPath confirma?")
Pause
Write-Host("Montando Unidade")
$mountResult = Mount-DiskImage -ImagePath $isoPath -PassThru
$volumeInfo = $mountResult | Get-Volume
$isoDriveLetter = $volumeInfo.DriveLetter
xcopy "$($isoDriveLetter):\*" "$usbDrive\" /s /e
Dismount-DiskImage -ImagePath $isoPath