
Injecting unattend.xml into VHD(X)
After creating the unattend.xml file which includes your customized settings, we need to inject it into the image.
Injecting the unattend.xml into a VHD(X) basically involves mounting the image first.
There are four steps involved to inject the unattend.xml file, as follow:
- Before we inject the unattend.xml file, we should create a mount directory.
From an elevated command prompt, run the following command:
dism /Mount-Image /ImageFile:.\NanoServer.vhdx /Index:1 /MountDir:.\mountdir
Please update the extension of the image VHD(X) according to the image created earlier.
- Apply the unattend.xml file that you already created and customized by running the following command:
dism /image:.\mountdir /Apply-Unattend:.\unattend.xml
- Create a Panther folder under C:\Windows\ (this folder is used by Windows systems for storing files during setup). Copy the unattend.xml file to it using the following two commands:
md .\mountdir\windows\panther
copy .\unattend.xml .\mountdir\windows\panther
What this does is basically, when the image is booting, the offline servicing section of the unattend.xml file will execute without any reboot. However, with oobeSystem and specialize, the content of those two sections of the unattend.xml will execute on boot, so as the Nano Server boots, they will execute.
- Unmount the VHD with /commit which is very important to keep these changes by running the following command:
dism /Unmount-Image /MountDir:.\mountdir /Commit
We would prefer to use Windows PowerShell that we covered earlier to create and customize a Nano image using the Nano PowerShell module.