VMware Cloud Community
mikelleen
Contributor
Contributor

Creating datastore from mounted VMFS Disk/LUN producing different results between PowerCLI and vSphwere client?? Possible resignature issue or ???

I am trying to take a SAN volume that is a copy (snapshot) of an existing SAN volume that had VM's on it. I want to use PowerCLI to create a datastore from that scsi device. I have used the vSphere client to do this without issues and now want to use PowerCLI to do the same.

For testing I am using LUN ID 255 for the volume that is the snapshot copy, and I have presented the LUN to the vCenter host. The LUN shows up correctly in the Configuration tab of the vCenter host under the Hardware - Storage - Devices which is as it should be:

Capture1.JPG

So I now have a mounted SCSI device that was presented to my host by my SAN. It is a distinct SAN volume created from a snapshot of an existing SAN volume that was used as a vSphere datastore, containing VM's. Still pretty normal stuff, and no issues to this point.

Typically when I create a datastore from a mounted scsi device that was a SAN snapshot I use the vSphere client. I have not had any issues doing this. I create a datastore from the attached SCSI LUN device.

I use the vSphere client to create a datastore using the Add Storage option in Configuration tab of the vCenter host under the Hardware - Storage - Datastores. I use athe Disk/LUN storage type, select the applicable LUN (255 in this case), I then get a "Select VMFS Mount Options" dialog box that asks for the VMFS mount option of "Keep the existing", "Assign a new signature", "Format the disk". I normally select "Assign a new signature":

Capture2.JPG

Note the alert stating "References to the existing signature ..."

When I select the finish button, a task is run in the recent tasks window "Resignature unresolved VMFS volume" when that task completes, my datastore is available and I can browse the datastore and see the folder sturcture including the VM folders, VMDK files, etc.

I think this is the step or issue I am having when trying to script this in PowerCLI, the resignature of the scsi device when creating the datastore.

The issue I am having is that when I attempt to create the datastore from PowerCLI using the code below, the datastore comes up empty, as if formatted, or not re-signatured.

The code I use for creating the datastore from PowerCLI is as follows:

$VIServ = Connect-VIServer -Server myvshpereserver -User $LoginID -Password $LoginPass

# Rescan to pick up scsi drive changes from SAN

Get-VMHostStorage

-VMHost $TargetVMCenterHost -RescanAllHba -RescanVmfs

#Use LUN 255 for testing

$scsilun

= ":L255"

$scsi

= Get-ScsiLun -VmHost $TargetVMCenterHost -LunType disk | Where{ $_.RuntimeName -match "$scsilun" }

$path

= Get-ScsiLunPath -ScsiLun $scsi

New-Datastore -VMHost $TargetVMCenterHost -Name $TargetVMCenterDatastoreName -Path $scsi.CanonicalName -Vmfs

I have read several articles on resignature options and I have to be missing something. We are on vSphere 5 and trying to set the resignature option on the host fails, I believe this option is no longer available.

Running the following:

Get-VMHost $TargetVMCenterHost | Set-VMHostAdvancedConfiguration -Name LVM.EnableResignature -Value 1

Returns:

Set-VMHostAdvancedConfiguration : 9/23/2011 10:41:42 AM    Set-VMHostAdvancedConfiguration        A specified parameter was not correct.

At line:1 char:65
+ Get-VMHost $TargetVMCenterHost | Set-VMHostAdvancedConfiguration <<<<  -Name LVM.EnableResignature -Value 1
    + CategoryInfo          : NotSpecified: (:) [Set-VMHostAdvancedConfiguration], InvalidArgument

Sorry for how long this post is, but I would really appreciate any help on this,

THANKS!

7 Replies
LucD
Leadership
Leadership

The advanced parameter LVM.EnableResignature disappeared in vSphere 4.x

In vSphere 4.x you can use the ResignatureUnresolvedVmfsVolume_Task method.

That method should be available in vSphere 5.x as well, according to this entry in the SDK Reference.


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

titaniumlegs
Enthusiast
Enthusiast

Actually, EnableResignature is still there, even in ESXi 5.0.  It's just that it's hidden from the vSphere client and there are better ways to do it now, with more granular control.

~ # vmware -v
VMware ESXi 5.0.0 build-469512
~ # esxcfg-advcfg -g /LVM/EnableResignature
Value of EnableResignature is 0

As to the original poster, when you ran New-Datastore, yes you reformatted the datastore.

Share and enjoy!

Peter

Share and enjoy! Peter If this helped you, please award points! Or beer. Or jump tickets.
LucD
Leadership
Leadership

Thanks for the the info.

I should indeed have been more specific, the parameter is not available to the Set-VMHostAdvancedConfiguration cmdlet (and the vSphere client) anymore since 4.x.


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

0 Kudos
mikelleen
Contributor
Contributor

So maybe I am asking the wrong question, you state:

"As to the original poster, when you ran New-Datastore, yes you reformatted the datastore."

How do I create the datastore from the mounted SCSI lun without formatting it?

Sorry to be asking newby questions, but I am new to Power CLI and have gotten everything else figured out but this with help from other posters.

0 Kudos
mikelleen
Contributor
Contributor

SO after digging in and gaining a little better knowledge of what LucD has posted, I was able to come up with a solution:

#Add datastore to host

#Get scsi device for target LUN No.

$scsilun

= "L" + $TargetLUNNo

$scsi

= Get-ScsiLun -VmHost $TargetVMCenterHost -LunType disk | Where{ $_.RuntimeName -match "$scsilun" }

$scsiCname

= $scsi.CanonicalName

#Create a list of unbound scsi devices

$hostView

= get-vmhost -name $TargetVMCenterHost | get-view

$dsView

= get-view $hostView.ConfigManager.DatastoreSystem

$unBound

= $dsView.QueryUnresolvedVmfsVolumes()

#Loop thru unbound scsi devices and resignature applicable device.

foreach

($ub in $UnBound) {

$extPaths

= @()

$Extents

= $ub.Extent;

foreach

($ex in $Extents) {

$extPaths

= $extPaths + $ex.DevicePath

}

#Only resignature desired LUN No.

IF ($extPaths -match $scsiCname)

{

$res = New-Object VMware.Vim.HostUnresolvedVmfsResignatureSpec

$res.ExtentDevicePath = $extPaths

$dsView.ResignatureUnresolvedVmfsVolume($res)

}

}

#Find and rename new datastore.

$NewDatastore

= Get-Datastore -VmHost $TargetVMCenterHost | Where{ $_.Name -like "snap-*$ProdVol0" }

Set-Datastore

$NewDatastore -Name $TargetVMCenterDatastoreName

teckdiag
Contributor
Contributor

Are you using it for the purpose of automatically mounting snapshots?

If Yes how are you handling that part in code?

Everytime you resign to attach the snap volume it generates a unique uuid.  Once you unmount/detach the partition and then reset the snapshot it is bound to have the new unique signature after that.

0 Kudos
nzmarkc
Contributor
Contributor

Wow! Big ups to you mikelleen! This will save me much time, clicking and frustration.

Thank you!

Mark

P.S.: Just found out this only works **one** cloned LUN at a time. I tried doing multiple clones then running this, but it fails. None-the-less, your solution is great!

0 Kudos