Wednesday, October 4, 2017

Unmap on Physical LUN




TABLE OF CONTENTS
Overview
In order to perform space reclamation on the Clustered Shared Volume (CSV) a drive letter to mount point mapping is required. Sdelete can be run on CSVs using the command subst to assign a virtual drive to the CSV mount point and then run sdelete on the virtual drive to perform space reclamation. This article details all of the steps required to perform this task.
Steps
Step 1 -- Find out which volume is the CSV
Open up a Windows PowerShell session
Run "List Volume" | diskpart
Note down the CSVFS Volume path, in the example below, the path is: "C:\ClusterStorage\Volume1\"
Example
01
PS C:\> "List Volume" | diskpart
02
Microsoft DiskPart version 6.3.9600
03
Copyright (C) 1999-2013 Microsoft Corporation.
04
On computer: HYPERV-NODE1
05
DISKPART>
06
 Volume     ### Ltr Label       Fs    Type       Size    Status    Info
07
 ---------- --- --- ----------- ----- ---------- ------- --------- --------
08
 Volume      0   E                    CD-ROM         0 B No Media
09
 Volume      1      System Rese NTFS  Partition   350 MB Healthy   System
10
 Volume      2   C              NTFS  Partition   238 GB Healthy   Boot
11
 Volume      3      SQL2014 Sys NTFS  Partition   199 GB Healthy
12
   C:\Pure Storage\SQL2014-Sys\
13
 Volume      4      SQL2014 Tem NTFS  Partition  2047 GB Healthy
14
   C:\Pure Storage\SQL2014-Tempdb\
15
 Volume      5   F  CommVault L NTFS  Partition  1023 GB Healthy
16
 Volume      6      CSV         CSVFS Partition    15 TB Healthy
17
   C:\ClusterStorage\Volume1\
18
 Volume      7   D                    Removable      0 B No Media
19
 Volume      8      SQL2014 Dat NTFS  Partition  5119 GB Healthy
20
   C:\Pure Storage\SQL2014-Data\
21
22
DISKPART>
23
PS C:\>
If you have multiple Clustered Shared Volumes across a large number of Windows Server Failover Clusters the below PowerShell can be used to determine the CSVs on each of the individual clusters from one centralized PowerShell script.
01
Import-Module FailoverClusters
02
$Volumes = @()
03
$ClusterName = "<CLUSTER_NAME>"
04
05
$CSV = Get-ClusterSharedVolume -Cluster $ClusterName
06
ForEach ($CSV in $CSVS) {
07
  $CSVInfo = $CSV | Select -Property Name -ExpandProperty SharedVolumeInfo
08
  ForEach ( $CSVInfo in $CSVInfos ) {
09
    $Volumes = New-Object PSObject -Property @{
10
       Path = $CSVInfo.FriendlyVolumeName
11
    }
12
    $Volumes.Path
13
  }
14
}
Step 2 -- Find out which drive letters are currently in use on the system.
List drive letters currently in use: Get-PSDrive -PSProvider FileSystem
1
PS B:\> Get-PSDrive -PSProvider FileSystem
2
Name        Used (GB)       Free (GB)    Provider   Root
3
----        ---------       ---------    --------   ----
4
C               39.81          198.32    FileSystem C:\
5
D                                        FileSystem D:\
6
E                                        FileSystem E:\
7
F               27.78          996.09    FileSystem F:\
8
P                                        FileSystem P:\
9
X                                        FileSystem X:\
Use the subst command and assign a virtual drive letter to the CSV volume. In my example below, I will use drive B: and map the CSV volume to "C:\ClusterStorage\Volume1\"
view sourceprint
01
S G:\> subst B: C:\ClusterStorage\Volume1
02
PS G:\> B:
03
PS B:\> ls
04
Directory: B:\
05
Mode      LastWriteTime           Length Name
06
----      -------------       ---------- ----
07
d----   7/12/2015 6:15 PM                PowerShellSDK_1-0-15-0
08
d----   7/12/2015 6:15 PM                PowerShellToolkit-2-8-0-430
09
d----   7/12/2015 6:16 PM                PowerShellToolkit-3-0-0-0
10
d----  7/20/2015 11:46 PM                PythonToolkit-1-4-0
11
d----   9/28/2015 6:35 PM                SCOM
12
d---- 12/30/2015 11:14 PM                vdbench-1
13
d----   7/12/2015 6:04 PM                vdbench-2
14
d----   7/12/2015 6:04 PM                vdbench-3
15
-a---  12/18/2015 1:29 AM     2718328422 PowerShellSDK_1-0-15-0.VHDX
16
                                       4
17
-a---  12/18/2015 1:30 AM     1084227584 PowerShellToolkit-2-8-0-430.VHDX
18
                                       0
19
-a---    9/9/2015 6:36 PM     9802088448 PowerShellToolkit-3-0-0-0.VHDX
20
-a---  11/23/2015 3:58 AM     1114426572 PythonToolkit-1-4-0.VHDX
21
                                       8
22
-a---    1/9/2013 2:26 PM         155736 sdelete.exe
23
-a---  12/18/2015 2:48 AM     1007052390 vdbench-1.VHDX
24
                                       4
25
-a---  12/18/2015 2:48 AM     1037251379 vdbench-2.VHDX
26
                                       2
27
-a---  12/18/2015 2:48 AM     1090938470 vdbench-3.VHDX
28
                                       4
 Run sdelete to free space on the CSV.
You must have the sdelete.exe file in command path or the file sdelete.exe must exist on the current path. If you do not have the sdelete program, you will have to go download from Microsoft TechNet.
Go to the virtual drive, in my example above, I have drive B: mapped to the CSV, run: B:
Run .\sdelete -z -s 
Note Running the above parameters will zero free space and apply to sub-directories.
Note If there are CSV deleted files or folders in the Trash Bin that is not emptied, you will need to empty the trash bin before running sdelete to reclaim the space.
1
PS B:\> .\sdelete -z -s
2
SDelete - Secure Delete v1.61
3
Copyright (C) 1999-2012 Mark Russinovich
4
Sysinternals - www.sysinternals.com
5
SDelete is set for 1 pass.
6
Zeroing free space on B:\: 0%

References
Reference syntax for “subst”
01
PS C:\Users\Administrator.CSGLAB> subst /?
02
Associates a path with a drive letter.
03
04
 SUBST [drive1: [drive2:]path]
05
 SUBST drive1: /D
06
    drive1:        Specifies a virtual drive to which you want to assign a path.
07
   [drive2:]path  Specifies a physical drive and path you want to assign to
08
                  a virtual drive.
09
   /D             Deletes a substituted (virtual) drive.
10
 
11
  Type SUBST with no parameters to display a list of current virtual drives.

Reference syntax for “sdelete”
01
PS B:\> .\sdelete.exe /h
02
 SDelete - Secure Delete v1.61
03
Copyright (C) 1999-2012 Mark Russinovich
04
Sysinternals - www.sysinternals.com
05
06
 usage: B:\sdelete.exe [-p passes] [-s] [-q] <file or directory> ...
07
       B:\sdelete.exe [-p passes] [-z|-c] [drive letter] ...
08
   -a         Remove Read-Only attribute
09
   -c         Clean free space
10
   -p passes  Specifies number of overwrite passes (default is 1)
11
   -q         Don't print errors (Quiet)
12
   -s or -r   Recurse subdirectories
13
   -z         Zero free space (good for virtual disk optimization)
Back to top

No comments:

Post a Comment

Vmware NSX SSL creation 

Using OpenSSL for NSX Manager SSL import: Creates CSR and 4096 bit KEY Creating NSX 6.4.2 SSL    openssl req -out nsxcert.csr -newkey rsa:40...