online11
Contributor
Contributor

Add existing datastores to ESX without formatting

Hi everyone, I am new to scripting, trying to find a script that add disks to ESX host just like we do on vcenter.

Rescan disks - Add Storage - Select Disk/Lun - naa IDs are known - Keep existing signature - Finish

Scenario is that: I have 50+ replicated disks that I have to import on DR site with a known naa.ids

luns ids like below:

Fibre Channel Disk (naa.500506680180831a8000000000000505):1

Fibre Channel Disk (naa.400503480180821a8000000000000502):1

Fibre Channel Disk (naa.300503380180811a8000000000000511):1

Fibre Channel Disk (naa.200502280180851a8000000000000435):1

...

..

Lets say I have 2 ESX hosts not clustered.

ESX1 and ESX2

How would you add those 50 disks to the ESX hosts with a powercli script?

I am working on this issue quite some time but couldn't find a satisfactory answer.

PS: Keep existing signature is not a must, could be assign a new signature. All I need is not to format disk cause there is data inside.

Thanks...

Reply
0 Kudos
LucD
Leadership
Leadership

Did you already try  ' Get-VMHostStorage -RescanAllHBA -RescanVmfs'


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

Reply
0 Kudos
online11
Contributor
Contributor

Hi LucD, but I need to import those disks, not only rescanning. Am I missing something on your question?

Reply
0 Kudos
LucD
Leadership
Leadership

I would first like to make sure that you don't "see" the LUNs after a simple scan.

If not, you can will have to use the Get-EsxCli cmdlet to find any detached LUNs and attach them

$esxcli.storage.core.device.detached.list()

Once you find the detached LUNs (cross-check with your input), you can use the same cmdlet to attach the LUN.

$esxcli.storage.core.device.set

but watch out there was a syntax change between 5.0 and 5.1 !


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

Reply
0 Kudos
online11
Contributor
Contributor

Simple scan shows all luns fine, no problem there. Even tho no need to rescan disks before adding. I need to find a way to add as existing storage without formatting. Thanks

Reply
0 Kudos
LucD
Leadership
Leadership

That's what

$esxcli.storage.filesystem.mount

allows you to do.

Have a look at Managing VMFS volumes

You can do the same, with the same parameters, with the Get-EsxCli cmdlet


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

View solution in original post

Reply
0 Kudos
online11
Contributor
Contributor

Thanks LucD!

Reply
0 Kudos