Tag: VHDX

Last updated by at .

Custom Hyper-V Quick Create VM Gallery

How to create a Custom Hyper-V Quick Create VM Gallery

You might have seen that Hyper-V in Windows 10 got a new Quick Create Feature, this will open up a virtual machine gallery, which allows you to download different virtual machine images. For example the default image is a Windows 10 dev environment, which allows developers to quickly spin up a development environment with Visual Studio inside a Hyper-V virtual machine. If you want to create your own items in the Hyper-V VM Gallery.

To do that you simple have to do three things:

  • Create a virtual machine image (a .iso or compatible .vhdx file)
  • Create a gallery source (.json file) and create a gallery item (configuration inside the .json file)
  • Add the gallery source to the VM Gallery UI


Nano Server Image Builder

Create a Nano Server using the Nano Server Image Builder

Last week Microsoft released Windows Server 2016 to the public and at the weekend Microsoft released the Nano Server Image Builder. I already wrote a few blog posts how you can create new Nano Server Images using PowerShell. The Nano Server Image Builder is a UI based wizard to create new Nano Server Images. The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with a graphical interface. Based on the inputs you provide, it generates images for deployment and it also creates reusable PowerShell scripts that allow you to create installations of Nano Server.

The Nano Server Image Builder can help you with the following tasks:

  • Graphical UI to create Nano Server Images
  • Adding drivers
  • Choose Windows Server Edition
  • Adding roles and features
  • Adding drivers
  • Adding updates
  • Configuration of Network Settings
  • Configuration of Domain settings
  • Set Remoting Options
  • Create an ISO file to boot from DVD or BMC (remote connection like HP ILO)

First download and install the Windows Assessment and Deployment Kit (ADK) and the Nano Server Image Builder.

I will not go trough all the options but here is just quickly how you can use it.

First create a new Nano Server Image (this can be a VHD, VHDX or WIM file. If you want to use it on a USB drive or ISO save it as a WIM file)

Nano Server Image Builder

Make sure you have prepared everything like the Windows Server 2016 files and drivers etc

Prepapre Nano Server Files

Select the Windows Server 2016 source

Nano Server Sources

Set more options, choose packages (roles and feature), drivers and more.

Nano Server Packages and Drivers

You can also configure some advanced options

Nano Server Image Builder Advanced Configuration

You can now create the Nano Server Image. The Nano Server Image Builder will also show you the PowerShell command to create more Nano Servers.

Nano Server Image Builder PowerShell Creation

You can also use this tool to create a bootable USB drive or ISO using an existing Nano Server Image.

Select the Nano Server Image you have already created

Nano Server Image Builder WIM file

As an option you can also create a ISO file

Nano Server Image ISO

 

You can now boot from USB drive or ISO and you can get the following WinPE Image to boot and this copies the Nano Server Image to the server

Nano Server WinPe

If you want to know more, check out the blog post from Scott Johnson (Microsoft): Introducing the Nano Server Image Builder



New-NanoServerImage

How to create a Nano Server Image using PowerShell

Last week Microsoft released Windows Server 2016 with the first GA release of Nano Server. A couple of months back I already wrote a blog post how you can create a new Nano Server Image in Technical Preview 4. This post is an updated version of that this post using Windows Server 2016 GA. In this post I will quickly show you how you can create a new VHD, VHDX or WIM file with your Nano Server configuration.

This is the PowerShell option, you can also use the Nano Server Image Builder.

First you have to download the latest Windows Server 2016 ISO file.

NanoServer Folder

If you open the Windows Server 2016 ISO file you can see a folder called “NanoServer” on the medium. This folder includes:

  • NanoServer.wim – This is the Nano Server Image file
  • Packages – The Package folder includes the Nano Server Packages, Windows Roles and Features and some basic drivers
  • NanoServerImageGenerator – In this folder you can find the Nano Server Image Generator PowerShell Module

I usually create a folder on my C:\NanoServer to store all the things I need, which makes things a little simpler.

Create Nano Server Image Folder

  • Base – This is a temporary folder where the images get mounted while updating or creating new images
  • Drivers – This is the folder where I copy all the drivers for a physical image
  • Files – This is the unpacked Windows Server 2016 ISO image (including, the sources folder, NanoServer folder, support, boot and efi folder as well as the setup.exe file)
  • Images – In this folder I store all the new created images
  • Updates – In this folder I store the Windows Server 2016 Update cumulative updates (.cab files)
  • XMLs – In this folder I store unattend.xml files if I need to do a extended configuration.

Of course you don’t have to use this folder structure, but it makes things easier.

If you have a look at the Packages folder you can find all the available packages for Nano Server:

Nano Server Packages

A new Nano Server Image can be created using the New-NanoServerImage PowerShell cmdlet. This will create a new Nano Server Image in a VHDX including the VM Guest drivers and nothing more.

New-NanoServerImage

  • MediaPath – The location with the Windows Server 2016 files
  • BasePath – Temporary folder to mount the WIM file
  • TargetPath – Where the new Image file gets stored. You can create a .wim, .vhd or .vhdx file
    • .vhd creates a Image for a Generation 1 VM (BIOS boot)
    • .vhdx create a Image for a Generation 2 VM (UEFI boot)
  • DeploymentType allows you to choose between Guest and Host
    • Guest creates a Virtual Machine
    • Host creates a Physical Image
  • Edition can be Standard or Datacenter
  • ComputerName adds the server name of the Nano Server
  • MaxSize changes the Partition size, if you are not using this parameter it will create a default partition of 4GB

Hyper-V NanoServer VHDX

You can now copy the VHDX file from the Images folder, attach this to a new Hyper-V virtual machine and boot.

This will show the Nano Server recovery console:

Hyper-V Nano Server Console

There are more parameters to add roles and features, updates, drivers and additional configuration like IP addresses and more

For example if you want to add some updates to the Nano Server Image you can use the following cmdlet:

To add a fixed IP address you can for example use the following cmdlet:

If you have some advanced deployment you can use for example the following thing, which helps you to set different configuration options. This example here is designed for a physical Hyper-V host

You can for example use this VHDX file now to create a boot from VHDX scenario:

I hope this helps you to get started with Nano Server in Windows Server 2016. I also prepared a blog post how you can create a Nano Server Image using the Nano Server Image Builder tool.



unatted xml file for VM

Add unattend.xml to VHDX File for VM automation

If you for example don’t have System Center Virtual Machine Manager or another tool to create Virtual Machine Templates and automate the deployment, you can also do this using Sysprep, PowerShell and an unattend.xml file to automate or simplify the Virtual Machine creation process. In other blog posts I already wrote how you can sysprep Virtual Machines or how you can create Hyper-V Virtual Machines using PowerShell. In this post I will show you how you can add an unattend.xml file to your VHD or VHDX so your virtual machine gets some default settings like regional information.

Here we have a basic unattend.xml file. If you want to enhance it, or create your own, you can also use the Windows ADK.

To use this unattend.xml you first have to sysprep a virtual machine and create a sysprep VHD file. After that you can mount the VHDX file and insert the unattend.xml file to the VHD. Copy the unattend.xml file to the following location: D:\Windows\Panther (in my case the VHD was mounted as D drive).

You can mount the VHDX using the UI or PowerShell:

There are more paths as well. You can check out the Windows Setup Automation Overview on TechNet where you can see all the possible paths to place the unattend.xml file.



sysprep.exe vm mode

Windows Sysprep for Virtual Machines

For using the same system image for different virtual machines or physical computer, Microsoft created a tool called sysprep.exe. This blog post covers Most people should be already familiar with that tool. If not here is the description:

Sysprep prepares a Windows installation (Windows client and Windows Server) for imaging, allowing you to capture a customized installation. Sysprep removes PC-specific information from a Windows installation, “generalizing” the installation so it can be reused on different PCs. With Sysprep you can configre the PC to boot to audit mode, where you can make additional changes or updates to your image. Or, you can configure Windows to boot to the Out-of-Box Experience (OOBE).

This is great so you can sysprep a virtual machine copy the VHD or VHDX file and use it for the first boot of different VMs. In Windows Server 2012 and Windows 8, Microsoft added an addition to sysprep called the mode switch “/mode:vm”. The mode:vm switch allows you to identify the Windows as a Virtual Machine and sysprep.exe will generalize a Virtual Hard Disk (VHD or VHDX) so that you can deploy the VHD as a VHD on the same Virtual Machine (VM) or hypervisor. You must deploy the VHD on a Virtual Machine (VM) or hypervisor with the same hardware profile. For example, if you created VHD in Microsoft Hyper-V, you can only deploy your VHD to Microsoft Hyper-V VMs with a matching hardware profile, and you can only run VM mode from inside a VM.

This will boost the performance and time for the virtual machine for the first startup and installation. This also work of course with virtual machines running on other hypervisors such as VMware or Xen.

Run the following command inside the Virtual Machine (You find sysprep.exe in the  C:\Windows\System32\Sysprep folder):

Now you can copy the VHD or VHDX file from that virtual machine and use it for other VMs.



Create Nano Server VHDX

How to create a Nano Server Image

Last week Microsoft released Windows Server 2016 Technical Preview 4, which includes a lot of changes and fixes. Since I had some presentations on Nano Server in the past weeks I will quickly cover how you can create a Nano Server VHD or VHDX file.

If you download the ISO with Windows Server 2016 ISO you and mount this file you can see a folder called Nano Server. In this folder you can find the NanoServer.wim file and some PowerShell scripts as well as a folder called Packages, which includes the features, roles, driver and agents for Nano Server.

I usually copy all the PowerShell scripts (and the new module) to C:\NanoServer, even if you don’t have to, but it makes it easier for me.

Nano Server on Windows Server 2016

If you have a look at the Packages folder you can find all the available packages for Nano Server:

Nano Server Packages

Now to create a new Nano Server VHD file you can use the following steps:

First go to the directory where you stored the PowerShell files, for me this would be C:\NanoServer

Import the PowerShell Module and use the command to create a new Nano Server Image

Create Nano Server VHDX

This will create a new Nano Server Image including the VM Guest drivers and nothing more. The D:\ drive still is the Windows Server Image (ISO), the Base folder is used to mount and create the temporary files and the TargetPath is where you can find the finished VHDX file. You can now create a new Virtual Machine using this VHD file.

Nano Server Hyper-V Console

Of course you can also create Nano Server including other roles:

Nano Server Container Host:

Nano Server for Apps and using a  fix IP Address and Computername

If you want to try Nano Server running in Microsoft Azure, you can also do this:

Nano Server on Azure

 



System Center Logo

SCVMM 2012 R2 Error 23317 When You Try to Apply Changes on VM That is Using Shared VHDX Disk

A customer of mine had a issue when he tried to change properties of Virtual Machines in System Center Virtual Machine Manager 2012 R2 which use shared VHDX, which were not created with VMM. The properties do he wanted to change had nothing to do with the Shared VHDX it self. He tried to set the availability set for these Virtual Machines.

The Error in SCVMM is the following:

Error (23317)
The operation Change properties of virtual machine is not permitted on a virtual machine that has shared virtual hard disks.

Recommended Action
The operation Change properties of virtual machine is not permitted on a virtual machine that has shared virtual hard disks.

Stanislav Zhelyazkov (Microsoft MVP) blogged about this in October 2013. The solution is pretty easy and is called PowerShell. Just do the modification but do not apply it. Use the script view in Virtual Machine Manager to get the code which would run behind the scene.

For example:

Remove all the things you don’t need and run the script: