VMware Cloud Community
fborges555
Enthusiast
Enthusiast
Jump to solution

reclaim storage

HI

I am reclaiming storage at this point doing the following

ssh to the esxi

and run esxcli storage vmfs unmap -l DS

can I accomplish the same using PSC to connect to the esxi host and run that command and not SSH to it

I can connect to the esxi by  connect-viserver but I dont know how to run the esxcli storage vmfs unmap -l DS from within Powershell cli

Thanks for any help

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use the Get-EsxCli cmdlet for that (while connected to the vCenter).

$esxName ='MyEsx'

$esxcli = Get-EsxCli -VMHost $esxName -V2

$argHash = @{

    volumelabel = 'DS'

}

$esxcli.storage.vmfs.unmap.Invoke($argHash)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
20 Replies
LucD
Leadership
Leadership
Jump to solution

You can use the Get-EsxCli cmdlet for that (while connected to the vCenter).

$esxName ='MyEsx'

$esxcli = Get-EsxCli -VMHost $esxName -V2

$argHash = @{

    volumelabel = 'DS'

}

$esxcli.storage.vmfs.unmap.Invoke($argHash)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L.

I am glad you dont sleeeeeepppppp

I get this error

pastedImage_0.png

any thought

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You would need to provide more info about the storage and its backing.


In KB2048466 it says

"The VAAI primitive UNMAP only works on SAN arrays where the partition offset is a multiple of 1 MB"

VMFS 6 requires unmap granularity of 1MB.

It could be that your SAN has a larger unmap granularity block size than 1MB.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L.

where would I go getting more info on this cmdlet

does it matter if the vmfs is 5 or 6 ? they have to be thin provisioning correct ?

Thanks

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L.

learning curve

what is wrong with this statement

$Esxcli=get-esxcli -vmhost xxx.xxx.xxx.xxx

$Esxcli.storage.vmfs.unmap("DS")

when ran I get

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

It could be that port 902 is not open on the ESXi node (FW rule).

You can test with the curl command.

Something like: curl esx.domain:902


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L.

I ran your script  and It came back with the following error

Index(zero Base) must be greater than or equal to zero.....

any ideas why

Thanks

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Which PowerCLI version are you using?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

5.1.1798

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Really?

Any specific reason for that?


That is a very old version.

Can you upgrade?
See Welcome PowerCLI to the PowerShell Gallery – Install Process Updates for detailed instructions.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L.

Just came with my VDI , my bad I did not check on version and upgrade for a most up-to-date one

on my way

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L.

I am getting somewhere!!!

after running the script (while on vcenter)

I got the following error

   pastedImage_0.png

Then I connected to the esxi directly and ran the script again but now I get the following

pastedImage_1.png

suggestions chief

Thanks

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You are most probably hitting the timeout mentioned (and solved) in PowerCLI for SCSI Unmap


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L.

How can I go on your script and check when the entire process is done?

Thanks a bunch

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You mean something like this?

$code = {

  $esxName ='MyEsx'


  $esxcli = Get-EsxCli -VMHost $esxName -V2

  $argHash = @{

    volumelabel = 'DS'

  }

  $esxcli.storage.vmfs.unmap.Invoke($argHash)

}

Measure-Command -Expression $code


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L.

I would like to know when the process is completed, so I can close the ps session?

I will check on your code

Thanks

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That depends how you are running this.

Are you starting a .ps1 script from your PS session?
If yes, adding the following line at the end should work.

Stop-Process $PID


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L.

I would like to convert this on a PS1 that can be used on a schedule to run twice a week.

Thanks

Reply
0 Kudos
Kamote261
Contributor
Contributor
Jump to solution

Hi LuCD,

About your script, is there a way to apply this to all Datastore in vCenter. This issue is currently killing our environment. We are not big company with limited storage. When storage is full and all VMs will go down and it happens many times.

We ussually do the reclaiming when issue arises on one cluster. If this can be modified for all DS in a vCenter, I can run the script weekly.

Reply
0 Kudos