How to use a disk as iSCSI target (PowerShell)?

Software-based VM-centric and flash-friendly VM storage + free version

Moderators: anton (staff), art (staff), Max (staff), Anatoly (staff)

Post Reply
Rob864
Posts: 3
Joined: Sat May 29, 2021 12:00 pm

Sat May 29, 2021 12:35 pm

Hi, I just started today with VSAN free and I'm trying to create an iSCSI target using a physically installed SATA HDD without using an image file. I need to do this in PowerShell.

I'm usually not afraid of PS but in this case, I just don't know where to start looking for the solution. I believe that none of the sample scripts apply in this case. I've been able to create a target using an image file with the sample script (CreateImageFile.ps1), no problem. But it isn't quite what I need. I would like to bring the disk online without an image file. What I could find in the help tells me that I want a raw device / disk bridge / SPTI setup. How can I do this with PowerShell?

Also, if there was a way to manage VSAN free with management console or web interface that would also work but I don't think that is included in the free version.

Any help would be appreciated!
Rob864
Posts: 3
Joined: Sat May 29, 2021 12:00 pm

Sun May 30, 2021 8:56 pm

I've been able to resolve this issue, but now I'm having a new issue. But first things first. I've discovered that an SPTI device had been automatically created for each disk.

I query them with:

Code: Select all

$server.Devices
They look like this:

Code: Select all

Name                   : \\?\scsi#disk&ven_wdc&prod_wd30ezrx-00dc0b0#4&239d8b02&0&030000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
DeviceType             : SPTI:Disk
DeviceId               : 0x000001BF55B49040
File                   : 
TargetName             : empty
TargetId               : empty
Size                   : 0
CacheMode              : empty
CacheSize              : empty
CacheBlockExpiryPeriod : empty
Exists                 : True
DeviceLUN              : 
IsSnapshotsSupported   : False
Snapshots              : 
SectorSize             : 
State                  : 0
Parent                 : 
Now I can create a new target with this device:

Code: Select all

New-Target -server $server -alias $targetAlias -devices "\\?\scsi#disk&ven_wdc&prod_wd30ezrx-00dc0b0#4&239d8b02&0&030000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}"
This works. But the new target does not work properly. On the initiator side (Windows Server 2019), I can connect to the target, no problem, but the new disk behaves unexpectedly in device manager. Although the disk was pre-formated with NTFS, the new disk shows a raw partition. When I try to format this partition, format fails to complete. Which means that the target is unusable. Any ideas?
yaroslav (staff)
Staff
Posts: 2340
Joined: Mon Nov 18, 2019 11:11 am

Tue Jun 01, 2021 4:47 pm

CreateImageFile.ps1 creates an image file that cannot be converted into the HA. Image file does not provide high availability.
For HA, use this script https://forums.starwindsoftware.com/vie ... p+3#p31505

Is there anything else I can assist you with?
nejir
Posts: 2
Joined: Sat Jun 12, 2021 1:05 am

Sat Jun 12, 2021 1:10 am

Rob864 wrote:Hi, I just started today with VSAN free and I'm trying to create an iSCSI target using a physically installed SATA HDD without using an image file. I need to do this in PowerShell.

I'm usually not afraid of PS but in this case, I just don't know where to start looking for the solution. I believe that none of the sample scripts apply in this case. I've been able to create a target using an image file with the sample script (CreateImageFile.ps1), no problem. But it isn't quite what I need. I would like to bring the disk online without an image file. What I could find in the help tells me that I want a raw device / disk bridge / SPTI setup. How can I do this with PowerShell?

Also, if there was a way to manage VSAN free with management console or web interface that would also work but I don't think that is included in the free version.

Any help would be appreciated!
One requirement for windows hosts to share one iScsi target is that they must be in a cluster. When you convert the volume to a CSV (clustered shared volume), the other nodes on the cluster will just see it and have access (assuming the general iScsi settings are correct)

If you manage to connect one ntfs volume to two hosts with iScsi outside of a cluster, the nodes will corrupt the data on the disk and you risk loosing everything. It looks like it works until you later discover you made a huge mistake.
Last edited by nejir on Sun Jun 13, 2021 9:39 am, edited 1 time in total.
Hi team, thanks for creating such an active forum.
yaroslav (staff)
Staff
Posts: 2340
Joined: Mon Nov 18, 2019 11:11 am

Sat Jun 12, 2021 7:47 am

Yes you are totally right.
Post Reply