What is a "Server on a stick"?
It is the Windows server equivalent of the Windows consumer product feature "Windows To Go". Basically it is creating a Windows Server image on a bootable USB drive
Why?
Some of the reasons I have done it
- To create a portable "server". The drive can then be plugged into a machine that supports USB boot, like a desktop or laptop, and used for demo or short-term production
- Physical server configuration limits may mean the internal drives are best used for Storage Spaces. Drives used for system drives cannot also be used for Storage Spaces. Booting off an internal USB in effect provides configuration flexibility
- Bootable PCIe SSD drive firmware can only be maintained if you are booted off a different device
- Because I can. Dell, for example, have always pushed one of the advantages of VMWare as the ability to boot off an internal USB. Now I can also boot Hyper-V off the internal USB
Pre-requisites
- First and foremost, an appropriate USB drive
- Most external USB drives, basically a 2.5" SATA II or SATA III drive in a USB-powered case, will work
- You are looking for a drive capacity of at least 64GB. 2.5" laptop SSDs work for me
- Becomes a trifle more difficult if you are trying to cram an external drive into a server so you can boot off the internal USB port. Be very careful with the alternate power plug on USB cables; as a metal object it has the potential to short against various internal points. Probably the best option is to cut it off, use some glue to make sure the cut wires do not short against each other or anything else
- Flash drives ("thumb drives", "memory sticks", whatever you call these ubiquitous devices in your environment) are a bit more complex. You really need a "Windows To Go" certified drive. A list of Microsoft-certified manufacturers is found here, each manufacturer will only have certified selected product items
- You are looking for a drive capacity of at least 64GB. Expect certified drives to come at a price premium
- Your drive has to return device metadata indicating it is not removable. Technically, as I understand it, the RMB bit returned in the STORAGE_DEVICE_DESCRIPTOR must be off
- You will find multiple forum entries referring to a now-discontinued Lexar utility, BootIt. There are also some unsupported (unsigned ?) drivers. Going down this road may also lead to a drawer full of useless drives
- Most external USB drives, basically a 2.5" SATA II or SATA III drive in a USB-powered case, will work
- Appropriate distribution media. There are multiple media options, an .iso file that I can mount works for me
- A Windows platform that supports the dism (Deployment Image Servicing and Management) and bcdboot commands. The commands have been there since Windows 7; Windows Server 2012 R2 works for me
- A smidgen patience
Preparing the disk
The basic process is described here. I have some differences of opinion with the provided script
- Hardcoded use of disk 0, which may lead you to destroy the platform you are executing the script from
- Use of the shrink subcommand, that doesn't appear to work for me
- For a minimal footprint you may choose to omit creation of the recovery partition
Thus, execute the diskpart utility from an elevated privilege command prompt with subcommands as follows
rem == List the disks available on your platform
list disk
rem == From the above list select the disk number you wish to prepare
rem == The provided commands will attach drives as letters S, R, and W. Check if this will
rem conflict with your platform, substitute as necessary
rem == Clean the selected drive. Be sure to set the drive number appropriately
select disk n
clean
rem == Create the system partition
rem Check the size against a recently created system of the same version
create partition primary size=350
format quick fs=ntfs label=System
assign letter=S
active
rem == Create the recovery partition
rem Check the size against a recently created system of the same version
rem Omit this step for a minimal configuration
create partition primary size=15000
format quick fs=ntfs label=Recovery
assign letter=R
set id=27
rem == Create the Windows partition
create partition primary
format quick fs=ntfs label=Windows
assign letter=W
rem == List volumes
rem 3 new partitions assigned to letters S, R, and W should be visible
list volume
exit
Installing Windows
The basic process is described here. I have some differences of opinion with the provided script
- The index number may be variable
- The provided script installs into the recovery volume root
- The implicit use of the bcdboot command concerns me
Execute the following commands from an elevated privilege command prompt
- The command list implies that drive letters S, R, and W have previously been assigned to appropriate volumes
- The commnd list implies that the distribution media is assigned drive letter F
rem == List the available indexes from the install image
dism /Get-Imageinfo /ImageFile:F:\Sources\install.wim
rem == Copy the install image to the recovery partition
rem Omit this step if the recovery partition is not created
copy F:\sources\install.wim R:\install.wim
rem == Apply the install image to the Windows partition using the appropriate index
dism /Apply-Image /ImageFile:F:\Sources\install.wim /ApplyDir:W:\ Index:n
rem == Display file attributes and override
attrib W:\Windows\System32\Recovery\WinRE.wim
attrib W:\Windows\System32\Recovery\WinRE.wim -s -h
rem == Copy the Windows RE tools to the System Partition
md S:\Recovery\WindowsRE
copy W:\Windows\System32\Recovery\WinRE.wim S:\Recovery\WindowsRE\WinRE.wim
rem == Copy boot files from the Windows partition to the System Partition
bcdboot W:\Windows /s S: /f all
rem == In the Recovery partition set the location of the Windows partition
rem Use the appropriate index
rem Omit this step if the recovery partition is not created
md R:\Recovery\WindowsRE
W:\Windows\System32\reagentc /setosimage /path R:\Recovery\WindowsRE /target W:\Windows /index n
rem == In the System partition set the location of the Windows RE tools
rem Omit this step if the recovery partition is not created
W:\Windows\System32\reagentc /setreimage /path S:\Recovery\WindowsRE /target W:\Windows
rem == Reset file attributes
attrib W:\Windows\System32\Recovery\WinRE.wim +s +h
Troubleshooting notes
- Why not run the standard Windows install process against the USB drive directly? The standard Windows install process does not support USB drives, the USB drive will not be available for install. However, once installed using the process above, and provided the machine supports USB boot, the system should boot
- Partition creation failure If an unsupported flash drive is used utility diskpart will typically fail on creation of the second partition
- Boot failure Failure of the bcdboot command to copy the appropriate files to the correct system partition will cause subsequent boot off the USB drive to fail