Monday, August 9, 2010

Creating a WinPE 3.0 bootable CDROM for extending the C partition on VMware

VMware makes it very easy to grow the size of an underlying disk. With Windows 2008R2 you can extend the file system online. With Windows 2003 you can extend the file system of any drive except the system drive (the C drive usually) online using diskpart extend. To extend the system drive there are a number of work-around methods such as attaching the drive to a second VM.

I decided to create a WinPE 3.0 bootable CDROM ISO to use as an alternative method--partly to play with WinPE 3.0. I wanted to include the pvscsi drivers from VMware 4.1 and use a Windows 2008 R2 base. It turned out to be pretty straight-forward.

First download the Windows Automated Intallation Kit software from Microsoft and install it on a VM that has VMware 4.x tools installed. The kit is identical for Windows 7 and 2008 R2. You can use it on a 32-bit or 64-bit version of Windows. I tried out both successfully but stuck with the 64-bit version.

Here is a script that you can run that will build the ISO. Run it in an elevated "Deployment Tools Command Prompt" after you install the kit. It will copy the VMware SCSI drivers from the VM and create an ISO that upon boot will extend the C drive and shutdown the VM. Depending on the version of Windows and VMware tools you may not have both the pvscsi and scsi drivers, but if there is no specialized driver the included Windows driver should work.

  • set targetdir=c:\winpe
  • copype.cmd %PROCESSOR_ARCHITECTURE% %targetdir%
  • Copy %targetdir%\winpe.wim %targetdir%\ISO\Sources\boot.wim
  • xcopy "%ProgramFiles%\vmware\VMware Tools\Drivers\pvscsi\*.*" %targetdir%\drivers\pvscsi\*.* /e
  • xcopy "%ProgramFiles%\vmware\VMware Tools\Drivers\scsi\*.*" %targetdir%\drivers\scsi\*.* /e
  • Dism /Mount-WIM /WimFile:%targetdir%\ISO\Sources\boot.wim /index:1 /MountDir:%targetdir%\mount
  • Del %targetdir%\ISO\boot\bootfix.bin
  • echo select volume=c > %targetdir%\mount\Windows\System32\diskpart.ini
  • echo extend noerr >> %targetdir%\mount\Windows\System32\diskpart.ini
  • echo list volume >> %targetdir%\mount\Windows\System32\diskpart.ini
  • echo [LaunchApps] > %targetdir%\mount\Windows\System32\winpeshl.ini
  • echo diskpart.exe, "/s diskpart.ini" >> %targetdir%\mount\Windows\System32\winpeshl.ini
  • echo wpeutil.exe, shutdown >> %targetdir%\mount\Windows\System32\winpeshl.ini
  • Dism /image:%targetdir%\mount /Add-Driver /Driver:%targetdir%\drivers /recurse
  • dism /unmount-wim /mountdir:%targetdir%\mount /commit
  • oscdimg -n -b%targetdir%\etfsboot.com %targetdir%\ISO %targetdir%\winpe_%PROCESSOR_ARCHITECTURE%_extend.iso

No comments:

Post a Comment