Free Core How to Create LUN

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

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

Post Reply
PhillyCheeseMan
Posts: 1
Joined: Tue May 23, 2017 7:40 pm

Tue May 23, 2017 7:46 pm

Any quick guides we can develop and sticky to this forum ?

If anyone is reading this:

1) Would be great to know how to create LUN
2) Remove LUN

I see powershell scripts but I don't see these functions there. Also I see a folder with C# and do see the functions there. Can those be executed ?

Yeah, probably a newbie question. I'm don't code. But for this software I will learn.

Would love to know the basic two functions listed above nevertheless.

Thanks!
Ivan (staff)
Staff
Posts: 172
Joined: Thu Mar 09, 2017 6:30 pm

Wed May 24, 2017 5:08 pm

Hello PhillyCheeseMan,
Thanks for interesting in StarWind solution
You can find Creating/Removing script by following next path: C:\Program Files\StarWind Software\StarWind\StarWindX\Samples\powershell
How to create LUN:
1) Open CreateHA(two nodes).ps1 and modify them like on the example below:
Default script is:

Code: Select all

Import-Module StarWindX

try
{
    $server = New-SWServer -host 192.168.1.155 -port 3261 -user root -password starwind

    $server.Connect()

    $firstNode = new-Object Node

    $firstNode.ImagePath = "My computer\C"
    $firstNode.ImageName = "masterImg1"
    $firstNode.Size = 256
    $firstNode.CreateImage = $true
    $firstNode.TargetAlias = "targetha1"
    $firstNode.AutoSynch = $true
    $firstNode.SyncInterface = "#p2=10.10.10.2:3260"
    $firstNode.HBInterface = "#p2=192.168.1.156:3260"
    $firstNode.CacheSize = 64
    $firstNode.CacheMode = "wb"
    $firstNode.PoolName = "pool1"
    $firstNode.SyncSessionCount = 1
    $firstNode.ALUAOptimized = $true
    
    #
    # device sector size. Possible values: 512 or 4096(May be incompatible with some clients!) bytes. 
    #
    $firstNode.SectorSize = 512
	
	#
	# 'SerialID' should be between 16 and 31 symbols. If it not specified StarWind Service will generate it. 
	# Note: Second node always has the same serial ID. You do not need to specify it for second node
	#
	$firstNode.SerialID = "050176c0b535403ba3ce02102e33eab" 
    
    $secondNode = new-Object Node

    $secondNode.HostName = "192.168.1.156"
    $secondNode.HostPort = "3261"
    $secondNode.Login = "root"
    $secondNode.Password = "starwind"
    $secondNode.ImagePath = "My computer\C"
    $secondNode.ImageName = "partnerImg1"
    $secondNode.Size = 256
    $secondNode.CreateImage = $true
    $secondNode.TargetAlias = "partnerha1"
    $secondNode.AutoSynch = $true
    $secondNode.SyncInterface = "#p1=10.10.10.1:3260"
    $secondNode.HBInterface = "#p1=192.168.1.155:3260"
    $secondNode.ALUAOptimized = $true
        
    $device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod "Clear"
    
    $syncState = $device.GetPropertyValue("ha_synch_status")

    while ($syncState -ne "1")
    {
        #
        # Refresh device info
        #
        $device.Refresh()

        $syncState = $device.GetPropertyValue("ha_synch_status")
        $syncPercent = $device.GetPropertyValue("ha_synch_percent")

        Start-Sleep -m 2000

        Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow
    }
}
catch
{
    Write-Host "Exception $($_.Exception.Message)" -foreground red 
}

$server.Disconnect()
Already modified:

Code: Select all

Import-Module StarWindX

try
{
    $server = New-SWServer -host 172.16.10.1 -port 3261 -user root -password starwind

    $server.Connect()

    $firstNode = new-Object Node

    $firstNode.ImagePath = "My computer\C\CSV1"
    $firstNode.ImageName = "masterImg1"
    $firstNode.Size = 1024
    $firstNode.CreateImage = $true
    $firstNode.TargetAlias = "csv1"
    $firstNode.AutoSynch = $true
    $firstNode.SyncInterface = "#p2=172.16.20.2:3260"
    $firstNode.HBInterface = "#p2=172.16.10.2:3260"
    $firstNode.CacheSize = 64
    $firstNode.CacheMode = "none"
    $firstNode.PoolName = "pool1"
    $firstNode.SyncSessionCount = 1
    $firstNode.ALUAOptimized = $true
    
    #
    # device sector size. Possible values: 512 or 4096(May be incompatible with some clients!) bytes. 
    #
    $firstNode.SectorSize = 4096
	
	#
	# 'SerialID' should be between 16 and 31 symbols. If it not specified StarWind Service will generate it. 
	# Note: Second node always has the same serial ID. You do not need to specify it for second node
	#
	$firstNode.SerialID = "050176c0b535403ba3ce02102e33eab" 
    
    $secondNode = new-Object Node

    $secondNode.HostName = "172.16.10.2"
    $secondNode.HostPort = "3261"
    $secondNode.Login = "root"
    $secondNode.Password = "starwind"
    $secondNode.ImagePath = "My computer\C\CSV1"
    $secondNode.ImageName = "partnerImg1"
    $secondNode.Size = 1024
    $secondNode.CreateImage = $true
    $secondNode.TargetAlias = "csv1"
    $secondNode.AutoSynch = $true
    $secondNode.SyncInterface = "#p1=172.16.20.1:3260"
    $secondNode.HBInterface = "#p1=172.16.10.1:3260"
    $secondNode.ALUAOptimized = $true
        
    $device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod "Clear"
    
    $syncState = $device.GetPropertyValue("ha_synch_status")

    while ($syncState -ne "1")
    {
        #
        # Refresh device info
        #
        $device.Refresh()

        $syncState = $device.GetPropertyValue("ha_synch_status")
        $syncPercent = $device.GetPropertyValue("ha_synch_percent")

        Start-Sleep -m 2000

        Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow
    }
}
catch
{
    Write-Host "Exception $($_.Exception.Message)" -foreground red 
}

$server.Disconnect()
NOTE: The folders should be created before.

2) Change strings regarding your configuration
3) Run this script as admin

Removing LUN:
1) Open RemoveDevice.ps1 and modify them

Code: Select all

Import-Module StarWindX

$server = New-SWServer 127.0.0.1 3261 root starwind

$server.Connect()

if ( $server.Connected )
{
    Remove-Device -server $server -deviceId $server.GetDeviceID("ImageFile1") -force $true
    
    $server.Disconnect()
}
Where
$server.GetDeviceID("ImageFile1")
is your ImageFile or HAImage
Post Reply