Automation

 View Only
Expand all | Collapse all

reclaim storage

  • 1.  reclaim storage

    Posted Mar 14, 2020 04:18 PM

    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



  • 2.  RE: reclaim storage
    Best Answer

    Posted Mar 14, 2020 06:13 PM

    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)



  • 3.  RE: reclaim storage

    Posted Mar 14, 2020 07:01 PM

    L.

    I am glad you dont sleeeeeepppppp

    I get this error

    any thought



  • 4.  RE: reclaim storage

    Posted Mar 14, 2020 07:14 PM

    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.



  • 5.  RE: reclaim storage

    Posted Mar 14, 2020 11:58 PM

    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



  • 6.  RE: reclaim storage

    Posted Mar 15, 2020 01:30 AM

    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



  • 7.  RE: reclaim storage

    Posted Mar 15, 2020 06:52 AM

    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



  • 8.  RE: reclaim storage

    Posted Mar 16, 2020 04:33 PM

    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



  • 9.  RE: reclaim storage

    Posted Mar 16, 2020 04:43 PM

    Which PowerCLI version are you using?



  • 10.  RE: reclaim storage

    Posted Mar 16, 2020 05:47 PM

    5.1.1798



  • 11.  RE: reclaim storage

    Posted Mar 16, 2020 05:50 PM

    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.



  • 12.  RE: reclaim storage

    Posted Mar 16, 2020 06:36 PM

    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



  • 13.  RE: reclaim storage

    Posted Mar 16, 2020 07:58 PM

    L.

    I am getting somewhere!!!

    after running the script (while on vcenter)

    I got the following error

      

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

    suggestions chief

    Thanks



  • 14.  RE: reclaim storage

    Posted Mar 16, 2020 08:01 PM

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



  • 15.  RE: reclaim storage

    Posted Mar 17, 2020 09:17 PM

    L.

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

    Thanks a bunch



  • 16.  RE: reclaim storage

    Posted Mar 17, 2020 09:31 PM

    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



  • 17.  RE: reclaim storage

    Posted Mar 19, 2020 04:07 AM

    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



  • 18.  RE: reclaim storage

    Posted Mar 19, 2020 07:11 AM

    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


  • 19.  RE: reclaim storage

    Posted Mar 21, 2020 03:58 AM

    L.

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

    Thanks



  • 20.  RE: reclaim storage

    Posted Jun 22, 2023 06:54 AM

    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.



  • 21.  RE: reclaim storage

    Posted Jun 22, 2023 07:36 AM

    You could loop over all the datastores.