Xenserver does not reclaim space after deleting VDI or Snapshot.

The exact cause for the above error has already been mentioned in my older blog
To Solve this issue, do the following steps
Step 1: scan your SR for orphaned VHDs
vhd-util scan -f -m “VHD-*” -l “VG_XenStorage-<uuid_of_SR>” –p
for example:
[root@MytestCase]# vhd-util scan -f -m “VHD-*” -l “VG_XenStorage-99dfb8a9-2dcc-b610-45ca-2010fb0e475b” -p
vhd=VHD-75fa7730-091d-4d6b-bcae-79ae11efa79d capacity=21474836480 size=21525168128 hidden=1 parent=none
vhd=VHD-7ec19bd2-1c86-44c0-83f1-aab4c8bd7e41 capacity=26843545600 size=26902265856 hidden=1 parent=none
vhd=VHD-902f17f1-c254-4cde-8519-a004b8721581 capacity=64424509440 size=64558727168 hidden=1 parent=none
vhd=VHD-94bc9c71-6e33-4281-9c1d-9ecd6f1da4c0 capacity=16106127360 size=16143876096 hidden=1 parent=none
vhd=VHD-975c1983-449c-4021-9843-3a6f5d36f564 capacity=21474836480 size=21525168128 hidden=1 parent=none
vhd=VHD-cb0d1245-2445-455f-bb17-3331172def32 capacity=21474836480 size=21525168128 hidden=1 parent=none
vhd=VHD-d5c21ed0-3970-4ac9-8ce8-70a90f7ce147 capacity=16106127360 size=16143876096 hidden=1 parent=none
vhd=VHD-d6a48e7f-307c-4053-a2f2-f05e6abcab49 capacity=16106127360 size=16143876096 hidden=1 parent=none
vhd=VHD-fc646534-658a-4550-b7e8-f13c6fbfe935 capacity=16106127360 size=16143876096 hidden=1 parent=none
vhd=VHD-6a0e604d-439f-4ec5-85f1-090574cd8cce capacity=26843545600 size=26902265856 hidden=0 parent=none
Step 2: Make a full copy of the VM and delete the old VM. Then check whether the chain is removed from the SR. this process will remove the VHD chain whereas step 3 should be used to remove the Orphan VHDs
Step 3: if step 2 does not reclaim space, then try to remove the Orphan VHD
lvremove /dev/VG_Xenstorage-<uuid_of_SR>/VHD-uuid
For Ex:
[root@XENH3-TEST VG_XenStorage-3a490822-9d03-50ae-01a2-07e8d877bb17]# lvremove /dev/VG_XenStorage-3a490822-9d03-50ae-01a2-07e8d877bb17/VHD-b21c101c-8f66-4202-842a-eb7173bee109
  /dev/sdb: read failed after 0 of 4096 at 0: Input/output error
  /dev/sde: read failed after 0 of 4096 at 0: Input/output error
  Logical volume “VHD-b21c101c-8f66-4202-842a-eb7173bee109″ successfully removed
The above happens only if the VHD do not have a Symbolic link to it. you can check this by the following command
/dev/ VG_XenStorage-<uuid of ur SR># ls -l
Step 4: Change the hidden VHD to unhidden
vhd-util set -f hidden -v 0 -n <path to vhd file>
Note: to find out the path, type ls –l in /dev/ VG_XenStorage-<uuid of ur SR>
For Ex:
vhd-util set -f hidden -v 0 -n  /dev/mapper/VG_XenStorage–99dfb8a9–2dcc–b610–45ca–2010fb0e475b-VHD–6a0e604d–439f–4ec5–85f1–090574cd8cce
Now you will be able to see the VHD in the XenCenter.
Step 5: Now attach the disk to any VM, modify its size and start the VM
Now the disk which was used by dom 0 will be used by the VM
Step 6: Now stop the VM, then deattach the disk and finally delete it

Source: https://sysadmino.wordpress.com/2014/03/03/xenserver-does-not-reclaim-space-after-deleting-vdi-or-snapshot/


Can Remote Desktop Services be deployed and administered by PowerShell alone, without a Domain in WIndows Server 2012 and 2012 R2? YES!!

Here we go:

  1. Install the Remote Desktop Licensing and the Remote Desktop Session Host role services using the following steps:
    • Open Server Manager
    • Click on Manage and select Add Roles and Features
    • Select Role-based or Feature-based installation
    • Under Remote Desktop Services, choose Remote Desktop Licensing and Remote Desktop Session Host role services.
    • Proceed with installation
  2. Add the License Server to Terminal Server License Servers group and restart the Remote Desktop service (you can use licmgr.exe)
  3. Add the licenses to the license server.
  4. Configure the Remote Desktop Session Host role with to use the local Remote Desktop Licensing server. Follow these steps:
    • Open PowerShell as administrator
    • Type the following command on the PS prompt and press Enter:

$obj = gwmi -namespace "Root/CIMV2/TerminalServices" Win32_TerminalServiceSetting

Run the following command to set the licensing mode (Note: Value = 2 for Per device, Value = 4 for Per User, we use per-user)


Run the following command to replace the machine name with License Server (mylicenseserver is the name of your server):


Run the following command to verify the settings that are configured using above mentioned steps:


You should see the server name in the output.

Once done this, reboot the system and log in with any user (if using a workgroup, you know your users must be part of the Remote Desktop Users) and the trial period message will dissapear.

Source of all this mess: http://support.microsoft.com/kb/2833839

Managing with Powershell

There are a few things you can manage with Powershell. To see the commands try:

import-module RemoteDesktop get-command -module RemoteDesktop

There is a list of commands you can execute via Powershell to manage your box. However, I’ve tried a few but some of them require you to have some extra features installed, that can’t be deployed on the scenario we are talking about.

The ugly way

If none of the above works for you, there is a way to reset the grace period to the initial 120 days. Of course, I don’t recommend doing this, as the user will keep noticing the message. Of course, you’ll need to purchase proper licenses.

To reset the counter, just delete this registry key:

HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\Grace Period

Of course, you’ll need extra-privileges to do that, executing regedit as administrator will not work. Try this:

  • Get PSEXEC
  • Start a cmd as administrator
  • run psexec -s -i regedit.exe
  • delete the desired key
  • reboot

Hope some of this works for you. If you do some advances with Powershell and RDS, let us know.

Source: http://serverfault.com/questions/541870/can-remote-desktop-services-be-deployed-and-administered-by-powershell-alone-wi