From 613758779587b7313ecb8da9cf37125d5f08356f Mon Sep 17 00:00:00 2001 From: lokesh Date: Mon, 11 Aug 2014 12:04:56 +0530 Subject: [PATCH] adding UEFI Disk layout support --- README.md | 5 ++++- windows-diskimage-builder/diskimagebuilder.ps1 | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a2895e5..eddca21 100644 --- a/README.md +++ b/README.md @@ -27,5 +27,8 @@ Add Unattend answer file Add VirtIO Drivers .\diskimagebuilder.ps1 -SourceFile \install.wim -VHDFile \VHDFilename -VHDSize -VirtIOPath \virtio.iso +Add UEFI Disk format support +.\diskimagebuilder.ps1 -SourceFile \install.wim -VHDFile \VHDFilename -VHDSize -disklayout UEFI (if not specified Default will be bios) + All Commands Usage -.\diskimagebuilder.ps1 -SourceFile \install.wim -VHDFile \VHDFilename -VHDSize -feature -UnattendPath \unattend.xml -DriversPath -CloudbaseInitMsiUrl < your cloudbaseinit msi url> -baudrate -OutputFormat vhd/qcow2 (Default will be vhd) +.\diskimagebuilder.ps1 -SourceFile \install.wim -VHDFile \VHDFilename -VHDSize -feature -UnattendPath \unattend.xml -DriversPath -CloudbaseInitMsiUrl < your cloudbaseinit msi url> -baudrate -OutputFormat vhd/qcow2 (if not specified Default will be vhd) -disklayout UEFI (if not specified Default will be bios) diff --git a/windows-diskimage-builder/diskimagebuilder.ps1 b/windows-diskimage-builder/diskimagebuilder.ps1 index 1584463..fe64d91 100644 --- a/windows-diskimage-builder/diskimagebuilder.ps1 +++ b/windows-diskimage-builder/diskimagebuilder.ps1 @@ -21,7 +21,9 @@ #.\diskimagebuilder.ps1 -SourceFile \install.wim -VHDFile \VHDFilename -VHDSize -VirtIOPath \virtio.iso # All Commands Usage -#.\diskimagebuilder.ps1 -SourceFile \install.wim -VHDFile \VHDFilename -VHDSize -feature -UnattendPath \unattend.xml -DriversPath -baudrate -OutputFormat vhd/qcow2 (Default will be vhd) +#.\diskimagebuilder.ps1 -SourceFile \install.wim -VHDFile \VHDFilename -VHDSize -feature -UnattendPath \unattend.xml -DriversPath + +# Please download and install qemu binary for getting qcow2 format of image from the link --> http://qemu.weilnetz.de/w64/ Param( [Parameter(mandatory=$True,HelpMessage="Name and path of Sourcefile (WIM).")] @@ -65,6 +67,10 @@ Param( [ValidateNotNullOrEmpty()] [String]$OutputFormat, +[parameter(HelpMessage="UEFI Disk layout")] +[ValidateNotNullOrEmpty()] +[String]$disklayout, + [parameter(HelpMessage="Add Drivers From Virtio ISO.")] [ValidateNotNullOrEmpty()] [String]$VirtIOPath @@ -202,7 +208,12 @@ function CreateThrwDiskpart(){ $GB = [System.UInt64] $VHDSize*1024 $path = $vhdFile $script = "create VDISK FILE=`"$path`" maximum=`"$GB`" type=expandable `r`nselect VDISK FILE=`"$path`"`r`nattach VDISK`r`ncreate partition primary`r`nassign letter=`"$VHDVolume`"`r`nformat fs=ntfs quick label=vhd`r`nactive`r`nexit" - $script | DISKPART + $gptscript = "create VDISK FILE=`"$path`" maximum=`"$GB`" type=expandable `r`nselect VDISK FILE=`"$path`"`r`nattach VDISK`r`convert gpt`r`ncreate partition primary`r`nassign letter=`"$VHDVolume`"`r`nformat fs=ntfs quick label=vhd`r`nexit" + if($disklayout){ + $gptscript | DISKPART + }else{ + $script | DISKPART + } $VHDVolume = [string]$VHDVolume + ":" Write-W2VInfo " $VHDVolume is the drive letter" dism.exe /apply-Image /ImageFile:$SourceFile /index:$Index /ApplyDir:$VHDVolume\ @@ -373,6 +384,7 @@ if($OutputFormat){ } } +Write-W2VInfo "================= Please check logs directory for Image creation log files. ====================" Write-W2VInfo "================= Completed Image Creation and ready. ======================="