StarWind vSAN Free..

Software-based VM-centric and flash-friendly VM storage + free version
tanjum
Posts: 34
Joined: Mon Jul 21, 2025 12:02 pm

Tue Jul 29, 2025 11:22 am

Appreciate that yaroslav..
tanjum
Posts: 34
Joined: Mon Jul 21, 2025 12:02 pm

Tue Jul 29, 2025 1:19 pm

yaroslav (staff) wrote:
Tue Jul 29, 2025 11:20 am
Hi,

Sadly there's no script for that. Let me please figure it out internally.
Hi yaroslav,

Does this work in the paid version, I'm trying to achieve the below ?

As mentioned I only have 1 storage server, I will be adding another one later. So if I setup 1 server now with LUNs, can I add a second server in HA later and have the original LUN extended with the capacity from the second server without losing any data ?

The idea in this scenario is to eventually have the same setup as if the 2 servers were setup as HA the 1st time allowing for synchronization of data over disks in 2 different servers..
yaroslav (staff)
Staff
Posts: 4309
Joined: Mon Nov 18, 2019 11:11 am

Wed Jul 30, 2025 7:12 am

It works easily for both paid and free. There will be a minor iSCSI disconnection when the standalone is promoted to HA. Please be aware of that and shut down the client VMs.
With the paid version, you just go to the replication manager >add replication partner and complete the wizard.
With the script, it's a little bit trickier and will require practicing it with a test device (ideally with file system and a test VM on it).
First, make sure you have a full backup that you are comfortable restoring from. If your device skips sync, data will be doomed. Long story short, you will slightly rework the create HA script.
Make sure to pay close attention to
  • ImageName
  • CreateImage
  • SotrageName
  • CreateTarget
under primary and secondary nodes.
THE EXAMPLE IMPLIES SYNCING FROM PRIMARY NODE!!!

Code: Select all

param($addr="172.27.31.198", $port=3261, $user="root", $password="starwind", 	
$addr2="172.27.31.199", $port2=$port, $user2=$user, $password2=$password, 
#common 	
$initMethod="syncfromfirst", 	
#$size=1024, 	
$sectorSize=512, 	
$failover=0, 	
$bmpType=1, 	
$bmpStrategy=0, 
#primary node 	
$imagePath="/mnt/sdb1/volume1", 	
$imageName="test2", 	
$createImage=$false, 	
$storageName="imagefile1", 	
$targetAlias="test2", 	
$poolName="pool1", 	
$syncSessionCount=1, 	
$aluaOptimized=$true, 	
$cacheMode="none", 	
$cacheSize=0, 	
$syncInterface="#p2=172.16.20.231:3260,172.27.21.231:3260", 	
$hbInterface="#p2=172.16.10.231:3260,172.27.31.199:3260", 	
$createTarget=$false, 	
$bmpFolderPath="", 
#secondary node 	
$imagePath2="/mnt/sdb1/volume1", 	
$imageName2="test2", 	
$createImage2=$true, 	
$storageName2="", 	
$targetAlias2="test2", 	
$poolName2="pool1", 	
$syncSessionCount2=1, 	
$aluaOptimized2=$false, 	
$cacheMode2=$cacheMode, 	
$cacheSize2=$cacheSize, 	
$syncInterface2="#p1=172.16.20.230:3260,172.27.21.230:3260", 	
$hbInterface2="#p1=172.16.10.230:3260,172.27.31.198:3260", 	
$createTarget2=$true, 	
$bmpFolderPath2=""
 	)  
tanjum
Posts: 34
Joined: Mon Jul 21, 2025 12:02 pm

Wed Jul 30, 2025 12:39 pm

Thanks yaroslav for the script, and time and effort, much appreciated..

I'll test this and see how it goes..
yaroslav (staff)
Staff
Posts: 4309
Joined: Mon Nov 18, 2019 11:11 am

Wed Jul 30, 2025 3:02 pm

Good luck :)
tanjum
Posts: 34
Joined: Mon Jul 21, 2025 12:02 pm

Wed Jul 30, 2025 7:18 pm

Hi yaroslav,

The test storage in VMware Workstation setup is as follows.

Server 1 - 6 x 100 GB = 600 GB
Server 2 - 6 x 100 GB = 600 GB

RAID-5 setup on both servers Storage Pool.

Server 1 - Usable Capacity = 499.66 GB
Server 2 - Usable Capacity = 499.66 GB

Server 1 - Volume 1 - Usable Capacity = 499.65 GB
Server 2 - Volume 1 - Usable Capacity = 499.65 GB

Capacity before HA
Server 1 - LUN - Capacity = 487.93 GB

Then I create Storage Pools, Volumes in Server 2, and add Server 1 in Add appliance for HA..
  • ImageName = vlab on both Nodes
  • CreateImage = $false on Node 1, $true on Node 2
  • StorageName = "" on both nodes
  • CreateTarget = $false on Node 1, $true on Node 2
Then run the script..

When running script for HA LUN creation it shows the below error..

Code: Select all

Request to  192.168.30.101 ( 192.168.30.101 ) : 3261
-
control ImageFile -CreateHeader:"Headers\vlab\vlab.swdsk" -pathDirHeaderBackup:"/mnt/md0/vol1" -file:"/mnt/md0/vol1\vlab.img" -Size:"0" -CacheMode:"none" -CacheSizeMB:"0" -BlockSize:"0" -psectorSize:"4096" -sectorSize:"512"
-
200 Failed: file already exists.
My edited code..

Code: Select all

param($addr="192.168.30.101", $port=3261, $user="root", $password="starwind",
      $addr2="192.168.30.201", $port2=$port, $user2=$user, $password2=$password,
$initMethod="syncfromfirst",
#$size=487930,
$sectorSize=512,
$failover=0,
$bmpType=1,
$bmpStrategy=0,
#primary node
$imagePath="/mnt/md0/vol1",
$imageName="vlab",
$createImage=$false,
$storageName="",
$targetAlias="vlab",
$poolName="pool1",
$syncSessionCount=1,
$aluaOptimized=$true,
$cacheMode="none",
$cacheSize=0,
$syncInterface="#p2=192.168.35.201:3260,192.168.40.201:3260",
$hbInterface="#p2=192.168.45.201:3260,192.168.30.201:3260",
$createTarget=$false,
$bmpFolderPath="",
#secondary node
$imagePath2="/mnt/md0/vol1",
$imageName2="vlab",
$createImage2=$true,
$storageName2="",
$targetAlias2="vlab",
$poolName2="pool1",
$syncSessionCount2=1,
$aluaOptimized2=$false,
$cacheMode2=$cacheMode,
$cacheSize2=$cacheSize,
$syncInterface2="#p1=192.168.35.101:3260,192.168.40.101:3260",
$hbInterface2="#p1=192.168.45.101:3260,192.168.30.101:3260",
$createTarget2=$true,
$bmpFolderPath2=""
)
	
Import-Module StarWindX

try
{
	Enable-SWXLog -level SW_LOG_LEVEL_DEBUG

	$server = New-SWServer -host $addr -port $port -user $user -password $password

	$server.Connect()

	$firstNode = new-Object Node

	$firstNode.HostName = $addr
	$firstNode.HostPort = $port
	$firstNode.Login = $user
	$firstNode.Password = $password
	$firstNode.ImagePath = $imagePath
	$firstNode.ImageName = $imageName
	$firstNode.Size = $size
	$firstNode.CreateImage = $createImage
	$firstNode.StorageName = $storageName
	$firstNode.TargetAlias = $targetAlias
	$firstNode.AutoSynch = $autoSynch
	$firstNode.SyncInterface = $syncInterface
	$firstNode.HBInterface = $hbInterface
	$firstNode.PoolName = $poolName
	$firstNode.SyncSessionCount = $syncSessionCount
	$firstNode.ALUAOptimized = $aluaOptimized
	$firstNode.CacheMode = $cacheMode
	$firstNode.CacheSize = $cacheSize
	$firstNode.FailoverStrategy = $failover
	$firstNode.CreateTarget = $createTarget
	$firstNode.BitmapStoreType = $bmpType
	$firstNode.BitmapStrategy = $bmpStrategy
	$firstNode.BitmapFolderPath = $bmpFolderPath
    
	#
	# device sector size. Possible values: 512 or 4096(May be incompatible with some clients!) bytes. 
	#
	$firstNode.SectorSize = $sectorSize
    
	$secondNode = new-Object Node

	$secondNode.HostName = $addr2
	$secondNode.HostPort = $port2
	$secondNode.Login = $user2
	$secondNode.Password = $password2
	$secondNode.ImagePath = $imagePath2
	$secondNode.ImageName = $imageName2
	$secondNode.CreateImage = $createImage2
	$secondNode.StorageName = $storageName2
	$secondNode.TargetAlias = $targetAlias2
	$secondNode.AutoSynch = $autoSynch2
	$secondNode.SyncInterface = $syncInterface2
	$secondNode.HBInterface = $hbInterface2
	$secondNode.SyncSessionCount = $syncSessionCount2
	$secondNode.ALUAOptimized = $aluaOptimized2
	$secondNode.CacheMode = $cacheMode2
	$secondNode.CacheSize = $cacheSize2
	$secondNode.FailoverStrategy = $failover
	$secondNode.CreateTarget = $createTarget2
	$secondNode.BitmapFolderPath = $bmpFolderPath2
        
	$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod $initMethod
    
	while ($device.SyncStatus -ne [SwHaSyncStatus]::SW_HA_SYNC_STATUS_SYNC)
	{
		$syncPercent = $device.GetPropertyValue("ha_synch_percent")
	        Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow

		Start-Sleep -m 2000

		$device.Refresh()
	}
}
catch
{
	Write-Host $_ -foreground red 
}
finally
{
	$server.Disconnect()
}
yaroslav (staff)
Staff
Posts: 4309
Joined: Mon Nov 18, 2019 11:11 am

Thu Jul 31, 2025 6:24 am

Wrong slashes.
Please also see /headers if the HA header was created.
tanjum
Posts: 34
Joined: Mon Jul 21, 2025 12:02 pm

Thu Jul 31, 2025 9:24 am

Thanks yaroslav,

I'm unsure when you say wrong slashes, what are you referring to, all values are the same as in my original script which worked..

I renamed the original vlab directory in the headers folder to vl, and ran the script again and it creates the vlab directory again with HA files in it, but still fails with the below error..

Code: Select all

Request to  192.168.30.101 ( 192.168.30.101 ) : 3261
-
control 0x0000000002E0E1C0 -InitSynchronize:"" -SynchronizationType:"1" -SynchronizerTargetName:"iqn.2008-08.com.starwindsoftware:192.168.30.101-vlab"
-
101 Failed: operation cannot be completed..
Output from headers directory..

Code: Select all

root@vSAN1:/opt/starwind/starwind-virtual-san/drive_c/starwind/headers# root@vSAN1:/opt/starwind/starwind-virtual-san/drive_c/starwind/headers# ls -lh
total 8.0K
drwxr-xr-x 2 root root 4.0K Jul 30 19:45 vl
drwxr-xr-x 2 root root 4.0K Jul 31 10:17 vlab
root@vSAN1:/opt/starwind/starwind-virtual-san/drive_c/starwind/headers# cd vlab/
root@vSAN1:/opt/starwind/starwind-virtual-san/drive_c/starwind/headers/vlab# ls -lh
total 8.0K
-rw-r--r-- 1 root root 4.0K Jul 31 10:17 vlab_HA.swdsk
-rw-r--r-- 1 root root 4.0K Jul 31 10:17 vlab.swdsk
root@vSAN1:/opt/starwind/starwind-virtual-san/drive_c/starwind/headers/vlab#
yaroslav (staff)
Staff
Posts: 4309
Joined: Mon Nov 18, 2019 11:11 am

Thu Jul 31, 2025 10:02 am

Hi,

Remove the HA headers on the underlying storage and under /headers.
Storagename is missing. Please run EnumDevices script and fill in the field.
Please review my script once again and rework yours.
tanjum
Posts: 34
Joined: Mon Jul 21, 2025 12:02 pm

Thu Jul 31, 2025 12:16 pm

yaroslav (staff) wrote:
Thu Jul 31, 2025 10:02 am
Hi,

Remove the HA headers on the underlying storage and under /headers.
Storagename is missing. Please run EnumDevices script and fill in the field.
Please review my script once again and rework yours.
Thanks yaroslav..

Seems I'm reaching there, updated the script with the storagename, and now the web UI shows the below for Node 1 after synchronizing..

Code: Select all

The replication partner is not synchronised
https://imgur.com/H8qRHDP

https://i.imgur.com/6WGYQUZ.png

The script after running shows the below..

Code: Select all

Request to  192.168.30.201 ( 192.168.30.201 ) : 3261
-
add HAImage1 -OwnTargetName:"iqn.2008-08.com.starwindsoftware:192.168.30.201-vlab" -header:"Headers\vlab\vlab_HA.swdsk" -asyncmode:yes -readonly:no -buffering:no -reservation:no
-
110 .
yaroslav (staff)
Staff
Posts: 4309
Joined: Mon Nov 18, 2019 11:11 am

Thu Jul 31, 2025 12:53 pm

It looks like the StarWind.cfg file is referring to a broken Header (check StarWind.cfg for anything that points to HA). Try removing HA partner with the script and running AddHA Partner one.
tanjum
Posts: 34
Joined: Mon Jul 21, 2025 12:02 pm

Thu Jul 31, 2025 1:49 pm

yaroslav (staff) wrote:
Thu Jul 31, 2025 12:53 pm
It looks like the StarWind.cfg file is referring to a broken Header (check StarWind.cfg for anything that points to HA). Try removing HA partner with the script and running AddHA Partner one.
I'll check the Starwind.cfg and see what it has regarding HA..

As for the AddHApartner.ps1 it shows the below error..

Code: Select all

PS C:\Users\Administrator\Desktop> .\AddHaPartner.ps1
Method invocation failed because [System.__ComObject] does not contain a method named 'AddPartner'.

Code: Select all

param($addr="192.168.30.101", $port=3261, $user="root", $password="starwind", $deviceName="imagefile1",
	$addr2="192.168.30.201", $port2=$port, $user2=$user, $password2=$password,
#secondary node
	$imagePath2="/mnt/md0/vol1",
	$imageName2="vlab",
	$createImage2=$true,
	$targetAlias2="vlab",
	$autoSynch2=$true,
	$poolName2="pool1",
	$syncSessionCount2=1,
	$aluaOptimized2=$true,
	$syncInterface2="#p1={0}:3260" -f $addr,
    $hbInterface2="",
	$bmpType=1,
	$bmpStrategy=0,
	$bmpFolderPath="",
    $selfSyncInterface="#p1={0}:3260" -f $addr2,
    $selfHbInterface=""
	)
	
Import-Module StarWindX

try
{
    Enable-SWXLog
    
    $server = New-SWServer $addr $port $user $password
    $server.Connect()

	$device = Get-Device $server -name $deviceName
	if( !$device )
	{
		Write-Host "Device not found" -foreground red
		return
	}

    $node = new-Object Node
    $node.HostName = $addr2
    $node.HostPort = $port2
    $node.Login = $user2
    $node.Password = $password2
    $node.ImagePath = $imagePath2
    $node.ImageName = $imageName2
    $node.CreateImage = $createImage2
    $node.TargetAlias = $targetAlias2
    $node.SyncInterface = $syncInterface2
    $node.HBInterface = $hbInterface2
	$node.AutoSynch = $autoSynch2
	$node.SyncSessionCount = $syncSessionCount2
	$node.ALUAOptimized = $aluaOptimized2
	$node.PoolName = $poolName2
	$node.BitmapStoreType = $bmpType
	$node.BitmapStrategy = $bmpStrategy
	$node.BitmapFolderPath = $bmpFolderPath

    Add-HAPartner $device $node $selfSyncInterface $selfHbInterface $selfBmpFolderPath
}
catch
{
	Write-Host $_ -foreground red 
}
finally
{
	$server.Disconnect()
}
yaroslav (staff)
Staff
Posts: 4309
Joined: Mon Nov 18, 2019 11:11 am

Thu Jul 31, 2025 2:00 pm

Does the *.cfg contain any reference to HA?
The script is missing the IPs.
tanjum
Posts: 34
Joined: Mon Jul 21, 2025 12:02 pm

Thu Jul 31, 2025 2:21 pm

Thanks yaroslav,

Powershell would interpret the {0} -f $addr as the IP address, anyway I try and edit that and see..

While the StarWind.cfg shows the below, which I think might be the issue, its showing device name as

Code: Select all

HAImage1
but when the enumdevices script is run without setting up HA, it shows the device name as imagefile1.

Code: Select all

    <device name="HAImage1" OwnTargetName="iqn.2008-08.com.starwindsoftware:192.168.30.101-vlab" header="Headers\vlab\vlab_HA.swdsk" PoolName="pool1" asyncmode="yes" readonly="no" buffering="no" reservation="no"/>
    <target name="iqn.2008-08.com.starwindsoftware:192.168.30.101-vlab" devices="HAImage1" alias="vlab"/>
    <!-- CHAP authentication
root@vSAN1:/opt/starwind/starwind-virtual-san/drive_c/starwind# cat StarWind.cfg | grep vlab
    <device name="imagefile1" header="Headers\vlab\vlab.swdsk" node="0"/>
    <device name="HAImage1" OwnTargetName="iqn.2008-08.com.starwindsoftware:192.168.30.101-vlab" header="Headers\vlab\vlab_HA.swdsk" PoolName="pool1" asyncmode="yes" readonly="no" buffering="no" reservation="no"/>
    <target name="iqn.2008-08.com.starwindsoftware:192.168.30.101-vlab" devices="HAImage1" alias="vlab"/>
And when I run the enumDevices script it now does not show anby device name..

Code: Select all

PS C:\Users\Administrator\Desktop> .\enumDevicesTargets.ps1
Target:
Name                     : iqn.2008-08.com.starwindsoftware:192.168.30.201-vlab
Id                       : 0x00000000011D0E00
Alias                    : vlab
IsClustered              : True
Devices                  :
yaroslav (staff)
Staff
Posts: 4309
Joined: Mon Nov 18, 2019 11:11 am

Thu Jul 31, 2025 2:49 pm

You are right, yet the device will be misconfigured.
It means that the HA device was created. Please review the HA device header and remove the replication partner. Once removed, log to the destination node (i.e., where you intend replicating the drvices to) remove the swdsk files from /headers and underlying storage and img devices from the underlying of the destination node. Please make sure to do it only on the destination node.
Once done, run addHA partner.
Post Reply