Azure Stack Development Kit Installer (on USB)

If you want to deploy the Azure Stack Development Kit, the deployment guide instructs you to install a clean Windows 2012R2 or 2016 server OS on the physical host to then configure it to boot from the CloudBuilder VHDX on the C drive. In this blogpost the initial installation of Windows 2012R2 / 2016 is not used anymore. There are still advantages of using the Windows 2016, as it allows for a quick reboot, removal/replacement of the VHDX and a quick redeploy of the ASDK image. But, the USB installer works just as fast.

So, what if you could just boot from WinPE, copy the Cloudbuilder.vhdx file to the designated server OS disk and make it bootable and then reboot the host. You’d have a lot more space available, and you’d have a much cleaner system to run. But what if we now could actually automate the WinPE doing all stuff for us, such as:

  • Clean the OS disks
  • Copy the VHDX file to the OS disk
  • Prepare the VHDX file with an unattend.xml
  • Download the required files for installation
  • Reboot and set the system ready for ASDK install

This you can do now with the following guide/scripts. That me and Mark Scholman of Azurestack.blog made for you.

Disclaimer: while this works just as well as the full Windows 2016 installation to prepare the host for the cloudbuilder.vhdx, I have no confirmation from the product group that this is a supported way to install the ASDK. 

Preparing the scripts

Download the four files in a zip file from HERE. [updated 14/11/17-21:39 DXB time]  They are:

  • PrepareAzureStackPOC.ps1
  • PrepareAzureStackPOC.psm1
  • DiskPartClear.txt
  • WinPE.jpg

(TIP: after downloading, unlock the files so they are fully trusted and you don’t get the Security Warning when running the scripts..)

(open the file properties of the ps1 and psm1 and check the unblock version)

(After copying the files now to the USB, the WinPE installer will not ask you for confirmation to run the scripts anymore..)

Preparing the Network part of the scripts (optional)

If you want to run the network version of the script, you need to change a few lines in the PrepareAzureStackPOC.ps1 file.

At the top of the file (lines 25 and onwards) you will find the variables. First of all the $DellHost, if you have a dell, it will download the OpenManage software for you (unsupported to run this). Next you have the $DVM_Username and $DVM_Password variables. These are the network share credentials. The $ShareRoot is the NAS/FileServer and the $sourceVHD is where the cloudbuilder.vhdx can actually be found on the share (in my case \\10.0.1.1\AzureStack\DeployAzureStack\MASImage\cloudbuilder.vhdx)

Note that if you are using a multi-partition USB stick with the cloudbuilder.vhdx on it, the values here will not be used at all. If the installer finds the vhdx on the USB drive, it will not initiate a network connection.

And finally, the password to be set for the ASDK Windows installation (it will be added to the unattend.xml file).

 

Preparing the USB drive

There are two options for the scripts.

  • The first one is that WinPe is booted from the USB drive and it pulls the CloudBuilder.vhdx from a network share.
  • The second option uses a USB drive with two partitions where it boots from the first partition, and copies the CloudBuilder.vhdx from a second partition on the USB drive.

For the first option:

Put the USB drive in, format it and give it a driveletter: P: for example

For the second option

Open CMD.exe in administrative mode and open diskpart

Type list disk

Select the USB drive based on the total storage

Select Disk <x>
Clear
create partition primary size=2000
format quick fs=fat32 label=”WinPE Boot”
assign letter =p
active
create partition primary
format fs=ntfs quick label=”VHD”
assign letter=Q

Copy the cloudbuilder.vhdx to the Q drive

The script will automatically detect which version you want to use. It searches for the additional partition on the USB drive (and the cloudbuilder.vhdx). If it does not find the file, it will switch to network mode.

Preparing WinPE

In order to prepare for the WinPE installation, you’d need to have the Windows 10 Assessment and Deployment Kit. You can find the latest version (1709) on https://developer.microsoft.com/en-us/windows/hardware/windows-assessment-deployment-kit

When installing, only select Deployment Tools and Windows Preinstallation Environment (Windows PE).

After the installation, open the Deployment and Imaging Tools environment in an administrative mode.

Next run the following commands in that window:

copype.cmd amd64 D:\winpe_amd64
Dism /mount-image /imagefile:D:\winpe_amd64\media\sources\boot.wim /index:1 /mountdir:D:\winpe_amd64\mount
Dism /Image:D:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"
Dism /Image:D:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFX.cab"
Dism /Image:D:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab"
Dism /Image:D:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab"
Dism /Image:D:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab"
Dism /Image:D:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab"

What this will do is:

  • Create a folder winpe_amd64 on your D: drive(if you don’t have a D drive, change all to C:)
  • Mount the image
  • Install required CAB’s (like Powershell, WMI, Network etc)

Next, open a powershell window and paste the following:

$startnet = Get-Content D:\winpe_amd64\mount\windows\system32\startnet.cmd
$startnet += "`r`npowershell -c Set-ExecutionPolicy Unrestricted -Force"
$startnet += "`r`npowershell -NoExit -c X:\PrepareAzureStackPOC.ps1"
$startnet
Set-Content -Value $startnet -Path "D:\winpe_amd64\mount\windows\system32\startnet.cmd" -Force

 

If you would like to change the background of the WinPE deployment, you need to go to D:\winpe_amd64\mount\windows\system32\winpe.jpg and take ownership of the file. After taking ownership, close the security window and reopen it. Now set it to Administrators Full Control and click ok. Now you can delete the file and replace it with a new one (local file copy, a copy from a network location usually does not work).

Next, place the three files in the root: d:\winpe_amd64\mount

And create the bootable USB drive using

Dism /unmount-image /mountdir:D:\winpe_amd64\mount /commit
MakeWinPEMedia /UFD D:\winpe_amd64 P:

 

ISO Boot

It is also possible to create a bootable ISO image (that you can mount in iDrac/ilo). In order to create the iso, type the following in the  Deployment and Imaging Tools environment window

MakeWinPEMedia /ISO D:\winpe_amd64 D:\winpe_amd64\WinPE_Stack.iso
Obviously the ISO image does not allow you to create the 2nd partition and load a 23GB file on it. So, when using the ISO image, it will always switch over to the network deployment mode.

Boot it!

Once you have the USB key ready, boot your ASDK server from it.

!!!!!NOTE THAT IT WILL DESTROY THE DATA ON YOUR DRIVES!!!!! (without asking you)

In the picture above, you see the system in action. As you can see it tries to find the local USB drive (cloudbuilder.vhdx) and then cleans the data of your disks (it will actually search for the smallest  SATA/SAS drive and clean that one. The ASDK installer takes care of all the other drives)

After it cleaned the drive, it will create a new partition on it and if internet is found, it will download the ASDK_Installer.ps1, the master.zip, VisualStudioCode.exe and possibly the DellOpenManage software. These will be placed on the new drive under the \sources\ directory. During the bootstrapping of the CloudBuilder VHDX they are copied to the local drive so that they are available under the root drive when booting into the CloudBuilder VHDX.

Finally, it will copy the CloudBuilder VHDX file to the local drive, prepare the unattend.xml file and prepare the CloudBuilder VHDX for booting. The boot sequence even takes into account if the server is set of UEFI or BIOS mode. Finally, reboot your server (wpeutil reboot) and it should boot normally into the CloudBuilder VHDX.

After two more reboots, login to the server with your password and start the asdk_installer from the C:\asdk_installer directory. This will start the Azure Stack installation and you can continue as described in the Azure Stack documentation.

Tagged , , , ,