Bagikan melalui


Remote Desktop Session Host on Azure VM - Workaround for Resizing User Profile Disks

User profile disks allow users to save personal settings and files when they are signed in to a session on an RD Session Host server in a collection, and then have access to the same settings and files when signing in to a different RD Session Host server in the collection.

You might face situations in which your users may need more space and for this reason you are then trying to resize the VHDx associated to the UPD disks, stored on your Azure RDSH Server.

Today the only method for easily resizing a VHDx file is by using the Resize-VHD cmdlet.
This cmdlet belong to the Hyper-V Poweshell modules and requires the Hyper-V role in order to work.

If you have tried to install the Hyper-V in Windows Server 2008 R2 or 2012 through Server Manager probably encountered the following message: The following message appears preventing you from continuing the process: Hyper-V can not be installed: The hypervisor is already running.  

This means that currently, there is no supported way for resizing VHDx disks inside an Azure VM.

Leveraging the blog post from Gilson Banin, How to Install Hyper-V on a Virtual Machine in Hyper-V, I will present you a workaround for this purpose.

DISCLAIMER

THIS WORKAROUND RELIES ON AN UNSOUPPORTED SCENARIO: WE ARE BASICALLY USING A TEMPORARY VM WITH THE PURPOSE TO HOST HYPER-V ROLE. THIS TEMPORARY ENVIRONMENT IS NOT SUPPORTED BY MICROSOFT. USE IT ONLY AT YOUR OWN RISK.

Prerequisites

Make backups of all the VHDX files that you are going to resize, before applying the below steps.

Setup the Management Environment

  1. Create a new temporary VM (a small size will be fine, like A1) and join this VM to your existing VNET.

  2. Force Installation of Hyper-V Role using this PowerShell command (from Gilson's blog post):

    Enable-WindowsOptionalFeature –Online -FeatureName Microsoft-Hyper-V –All –NoRestart

  3. Restart the VM.

  4. Add the "Hyper-V Management Toos" feature:

  5. Map the shared folder containing your VHDXs on a local drive.

Resizing

Log in to the mgmt VM and run the following from an elevated PowerShell prompt:
 

Resize-VHD -Path <full_path_to_a_vhdx_file_to_reize> -SizeBytes <new_size>

i.e.:

Resize-VHD -Path F:\UserDisks\UVHD-S-1-5-21-318835583-3572637251-3921833130-3102.vhdx -SizeBytes 3GB

Expanding Volume Size

  1. Mount the VHDX and open Disk Management:
  2. Extend the Volume size to all the available space:
  3. Do not forget to detach the VHDx

Validating

Now RDP into the environment and run "dir" from a command prompt default location and check for the free space:

3GB!

Finalize

You can destroy the management VM, once you finished with all the resizings.

References

The above procedure is based on information provided in this article:

Have a good time Resizing!

Rossano