adding baudrate and convert format changes

This commit is contained in:
lokesh 2014-08-07 14:46:49 +05:30
parent 57db47c61e
commit 3c1ef25cb5
2 changed files with 49 additions and 6 deletions

View File

@ -10,6 +10,8 @@ Runs on Windows 8, 8.1 and 2012 R2
Requires Powershell 3.0 or above and wim file from ISO Source folder. ISO is not required. Only Wim file is enough to generate and apply wim to vhd.
Please download and install qemu binary for getting qcow2 format of image from the link --> http://qemu.weilnetz.de/w64/ Also set it to system path.
Basic Usage
.\diskimagebuilder.ps1 -SourceFile <path>\install.wim -VHDFile <path>\VHDFilename -VHDSize <size of vhd>
@ -26,4 +28,4 @@ Add VirtIO Drivers
.\diskimagebuilder.ps1 -SourceFile <path>\install.wim -VHDFile <path>\VHDFilename -VHDSize <size of vhd> -VirtIOPath <path>\virtio.iso
All Commands Usage
.\diskimagebuilder.ps1 -SourceFile <path>\install.wim -VHDFile <path>\VHDFilename -VHDSize <size of vhd> -feature <featuretoenable> -UnattendPath <path>\unattend.xml -DriversPath <path to drivers folder> -CloudbaseInitMsiUrl < your cloudbaseinit msi url>
.\diskimagebuilder.ps1 -SourceFile <path>\install.wim -VHDFile <path>\VHDFilename -VHDSize <size of vhd> -feature <featuretoenable> -UnattendPath <path>\unattend.xml -DriversPath <path to drivers folder> -CloudbaseInitMsiUrl < your cloudbaseinit msi url> -baudrate <value> -OutputFormat vhd/qcow2 (Default will be vhd)

View File

@ -21,9 +21,7 @@
#.\diskimagebuilder.ps1 -SourceFile <path>\install.wim -VHDFile <path>\VHDFilename -VHDSize <size of vhd> -VirtIOPath <path>\virtio.iso
# All Commands Usage
#.\diskimagebuilder.ps1 -SourceFile <path>\install.wim -VHDFile <path>\VHDFilename -VHDSize <size of vhd> -feature <featuretoenable> -UnattendPath <path>\unattend.xml -DriversPath <path to drivers folder>
#.\diskimagebuilder.ps1 -SourceFile <path>\install.wim -VHDFile <path>\VHDFilename -VHDSize <size of vhd> -feature <featuretoenable> -UnattendPath <path>\unattend.xml -DriversPath <path to drivers folder> -baudrate <value> -OutputFormat vhd/qcow2 (Default will be vhd)
Param(
[Parameter(mandatory=$True,HelpMessage="Name and path of Sourcefile (WIM).")]
@ -55,10 +53,18 @@ Param(
[ValidateNotNullOrEmpty()]
[String]$CloudbaseInitMsiUrl,
[parameter(HelpMessage="Serial port baudrate")]
[ValidateNotNullOrEmpty()]
[String]$serialbaudrate,
[parameter(HelpMessage="Add Drivers Folder Path.")]
[ValidateNotNullOrEmpty()]
[String]$DriversPath,
[parameter(HelpMessage="Output format vhd\qcow2.")]
[ValidateNotNullOrEmpty()]
[String]$OutputFormat,
[parameter(HelpMessage="Add Drivers From Virtio ISO.")]
[ValidateNotNullOrEmpty()]
[String]$VirtIOPath
@ -84,6 +90,25 @@ if(!$CloudbaseInitMsiUrl){
}
if(!$serialbaudrate){
$serialbaudrate = "9600"
}
if($OutputFormat){
$arrFormats = @("vhd", "qcow2")
$Found = 0
for ($i=0; $i -lt $arrFormats.length; $i++) {
if($arrFormats[$i] -eq $OutputFormat){
$Found = 1
}
}
if(!$Found){
Write-W2VInfo "Not a valid output format"
exit
}
}
$VHDVolume = 'v'
$Error = 0
if(!$Index){
@ -259,10 +284,21 @@ function AddCloudbaseinit(){
function SerialPort(){
$VHDVolume = $VHDVolume + ":"
Write-W2VInfo "Adding Serial Port"
bcdedit /store $VHDVolume\boot\BCD /dbgsettings serial debugport:1 baudrate:9600
bcdedit /store $VHDVolume\boot\BCD /dbgsettings serial debugport:1 baudrate:$serialbaudrate
}
function convertoutputtoqcow2(){
try{
Write-W2VInfo "Converting to qcow2"
qemu-img.exe convert -f vpc -O qcow2 $VHDFile $VHDFile.Replace("vhd","qcow2")
Remove-Item $VHDFile
}catch{
Write-W2VInfo "qemu is not installed or its path is not set to system path. So ouput will be in vhd format"
exit
}
}
foreach($p in $testpaths){
@ -331,7 +367,12 @@ SerialPort
#select and detach the vdisk created by the disk.
remove-vhd($VHDFile)
Write-W2VInfo "================= Please check logs directory for Image creation log files. ===================="
if($OutputFormat){
if($OutputFormat -eq "qcow2"){
convertoutputtoqcow2
}
}
Write-W2VInfo "================= Completed Image Creation and ready. ======================="