StarWind VSAN CreateHA_2.ps1 sample for CVM

Software-based VM-centric and flash-friendly VM storage + free version
yaroslav (staff)
Staff
Posts: 4427
Joined: Mon Nov 18, 2019 11:11 am

Fri Apr 11, 2025 3:06 pm

Please remove $addr from the sync interfaces. See more here viewtopic.php?f=5&t=6852&p=37208&hilit=HINT8#p37208.
Please also make sure that the StarWindX module and VSAN on both nodes is the same.
As a side note: I'd rather not use cache as it makes the HA devices more touch.
I will need to discuss this case internally. I will keep you posted.
Fonzies50
Posts: 3
Joined: Wed Aug 26, 2026 7:30 pm

Wed Aug 26, 2026 7:40 pm

Help for error invalid channel format [2]

Code: Select all

param(
	$addr="172.22.22.37", $port=3261, $user="root", $password="starwind",
	$addr2="172.22.22.38", $port2=3261, $user2=$user, $password2=$password,
#common
	$initMethod="Clear",
	$size=500720,
	$sectorSize=512,
	$failover=0,
	$bmpType=1,
	$bmpStrategy=0,
    [Uint32][ValidateRange(0, 4294967294)]
	$maxUnmap=128,
#primary node
	$imagePath="/mnt/[b]sdb1[/b]/vm-volume0", #IT'S RIGHT! see secondary node
	$imageName="HAVolume01",
	[bool][ValidateSet($false, $true)]
	$createImage=$true,
	$storageName="",
	$targetAlias="target-vsan01",
	$poolName="",
	$syncSessionCount=1,
	[bool][ValidateSet($false, $true)]
	$aluaOptimized=$true,
	$cacheMode="wt",
	$cacheSize=1024,
	$syncInterface="172.31.31.38:3260", # IP Partner Sincronizzazione (Nodo 2)
	$hbInterface="172.21.21.38",   # IP Partner Dati/Heartbeat (Nodo 2)
	[bool][ValidateSet($false, $true)]
	$createTarget=$true,
	$bmpFolderPath="",
#secondary node
	$imagePath2="/mnt/[b]vdb1[/b]/vm-volume0",  #IT'S RIGHT! see primary node
	$imageName2="HAVolume01",
	[bool][ValidateSet($false, $true)]
	$createImage2=$true,
	$storageName2="",
	$targetAlias2="target-vsan01",
	$poolName2="",
	$syncSessionCount2=1,
	[bool][ValidateSet($false, $true)]
	$aluaOptimized2=$false,
	$cacheMode2=$cacheMode,
	$cacheSize2=$cacheSize,
	$syncInterface2="172.31.31.37:3260", # IP Partner Sincronizzazione (Nodo 1)
	$hbInterface2="172.21.21.37",  # IP Partner Dati/Heartbeat (Nodo 1)
	[bool][ValidateSet($false, $true)]
	$createTarget2=$true,
	$bmpFolderPath2=""
	)

	
Import-Module StarWindX

try
{
	Enable-SWXLog

	$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.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
	$firstNode.MaxUnmap = $maxUnmap
	$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.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
	$secondNode.MaxUnmap = $maxUnmap
        
	Write-Host "Creazione del dispositivo HA in corso..." -ForegroundColor Cyan
	$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod $initMethod
	if(!$device) { return }
    
	# Controllo basato sulla proprieta stringa di StarWind Linux (1 = Sincronizzato)
	while ($device.GetPropertyValue("ha_synch_status") -ne "1")
	{
		$syncPercent = $device.GetPropertyValue("ha_synch_percent")
		Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow

		Start-Sleep -Seconds 5

		$device.Refresh()
	}
	Write-Host "Sincronizzazione completata con successo!" -ForegroundColor Green
}
catch
{
	Write-Host $_ -foreground red 
}
finally
{
	if ($server -and $server.Connected)
	{
		$server.Disconnect()
	}
}
What's wrong?
yaroslav (staff)
Staff
Posts: 4427
Joined: Mon Nov 18, 2019 11:11 am

Wed Aug 26, 2026 8:03 pm

Hi,

-port is missing.
-sync type is not optimal,
-some strange characters in the script.

You can grab the script from here viewtopic.php?f=5&t=6852&p=37208&hilit=HINT8#p37208.
Fonzies50
Posts: 3
Joined: Wed Aug 26, 2026 7:30 pm

Thu Aug 27, 2026 9:25 am

Good morning,
I' have corrected and remove all unnecessary in the file. Over parameters I have restore original script from Sample dir (see below).
But invalid channel format [2] persist.

node 1: $imagePath="/mnt/sdb1/vm-volume0" - sdb1 is correct on this node (app vsan on VM Proxmox) "[b" on the script are my refused but not in the script executed
node 2: $imagePath2="/mnt/vdb1/vm-volume0" - vdb1 is correct on this node (app vsan over VM HPE VM Essentials) "[b" on the script are my refused but not in the script executed
all ping test are OK, the nodes are linked and its see viceversa on the VM (and i use the guide without problem) now I need to create LUN and iSCSI - data link and sync link directly connected no switch.
$initMethod="NotSynchronize" - now.

Code: Select all

param(
	$addr="172.22.22.37", $port=3261, $user="root", $password="starwind",
	$addr2="172.22.22.38", $port2=3261, $user2=$user, $password2=$password,
#common
	$initMethod="NotSynchronize",
	$size=500720,
	$sectorSize=512,
	$failover=0,
	$bmpType=1,
	$bmpStrategy=0,
	$maxUnmap=128,
#primary node
	$imagePath="/mnt/sdb1/vm-volume0", 
	$imageName="havolume01",
	$createImage=$true,
	$storageName="",
	$targetAlias="starwind-vsan01",
	$poolName="pool1",
	$syncSessionCount=1,
	$aluaOptimized=$true,
	$cacheMode="none",
	$cacheSize=0,
	$syncInterface="172.31.31.38:3260", # IP Partner Sincronizzazione (Nodo 2)
	$hbInterface="172.21.21.38:3260,172.31.31.38:3260",   # IP Partner Dati/Heartbeat (Nodo 2) con porta
	$createTarget=$true,
	$bmpFolderPath="",
#secondary node
	$imagePath2="/mnt/vdb1/vm-volume0", 
	$imageName2="havolume01",
	$createImage2=$true,
	$storageName2="",
	$targetAlias2="starwind-vsan01",
	$poolName2="pool1",
	$syncSessionCount2=1,
	$aluaOptimized2=$false,
	$cacheMode2=$cacheMode,
	$cacheSize2=$cacheSize,
	$syncInterface2="172.31.31.37:3260", # IP Partner Sincronizzazione (Nodo 1)
	$hbInterface2="172.21.21.37, 172.31.31.37:3260",  # IP Partner Dati/Heartbeat (Nodo 1) con porta
	$createTarget2=$true,
	$bmpFolderPath2=""
	)

	
Import-Module StarWindX

try
{
	Enable-SWXLog

	$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.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
	$firstNode.MaxUnmap = $maxUnmap
    
	#
	# 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.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
	$secondNode.MaxUnmap = $maxUnmap
        
	$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod $initMethod
	if(!$device) { return }
    
	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: 4427
Joined: Mon Nov 18, 2019 11:11 am

Thu Aug 27, 2026 10:10 am

Please take a careful look in this section of the guide:
$syncInterface="#p2=172.16.20.231:3260,172.27.21.231:3260",
$hbInterface="#p2=172.16.10.231:3260,172.27.31.199:3260",
Fonzies50
Posts: 3
Joined: Wed Aug 26, 2026 7:30 pm

Thu Aug 27, 2026 3:39 pm

Good evening Yaroslav,
the script has worked, I had to remove the second heartbeat network because it gave me an error in creation (explicit error of not being able to use network sync for heartbeat) but the LUN was created correctly... for a few hours.... now the appliances tell me that the LUN is not synchronized on the VM (appliance) installed on the HPE VM Essentials host: on the LUN it tells me "the functionality is not licensed. Request a licensed to sales@" what happened? The networks are all working, the targets had been created and I was about to start configuring the multipath (I hadn't done anything)
Post Reply