Should operate on a physical separate lan and VLAN 200 has been set aside for this.
Server
Install net/istgt
from ports and set istgt_enable="YES"
in /etc/rc.conf
.
iSCSI uses an addressing scheme called iqn which is built up by the reverse domainname along with the founding date. In this case the address is iqn.2004-06.net.strahlert.home
/usr/local/etc/istgt/auth.conf
- Set up an authgroup for the iqn and the disks
/usr/local/etc/istgt/istgt.conf
- Set the iqn by modifying NodeBase
- Set the IP of the server on VLAN 200 for the various Portal entries and set an appropriate Netmask
- For each LUN, define a LogicalUnitX group
- Set a unique TargetName and TargetAlias
- Set LUN0 pointing to the device. For ZFS volume usage;
LUN0 Storage /dev/zvol/zpoolname/volumename Auto
[Global]
Comment "Global section"
# node name (not include optional part)
NodeBase "iqn.2004-06.net.strahlert.home"
# files
PidFile /var/run/istgt.pid
AuthFile /usr/local/etc/istgt/auth.conf
# directories
# for removable media (virtual DVD/virtual Tape)
MediaDirectory /var/istgt
# syslog facility
LogFacility "local7"
# socket I/O timeout sec. (polling is infinity)
Timeout 30
# NOPIN sending interval sec.
NopInInterval 20
# authentication information for discovery session
DiscoveryAuthMethod None
# reserved maximum connections and sessions
# NOTE: iSCSI boot is 2 or more sessions required
MaxSessions 16
MaxConnections 4
# maximum number of sending R2T in each connection
# actual number is limited to QueueDepth and MaxCmdSN and ExpCmdSN
# 0=disabled, 1-256=improves large writing
MaxR2T 32
# iSCSI initial parameters negotiate with initiators
# NOTE: incorrect values might crash
MaxOutstandingR2T 16
DefaultTime2Wait 2
DefaultTime2Retain 60
FirstBurstLength 262144
MaxBurstLength 1048576
MaxRecvDataSegmentLength 262144
# NOTE: not supported
InitialR2T Yes
ImmediateData Yes
DataPDUInOrder Yes
DataSequenceInOrder Yes
ErrorRecoveryLevel 0
[PortalGroup1]
Comment "SINGLE PORT TEST"
Portal DA1 192.168.100.13:3260
[InitiatorGroup1]
Comment "Initiator Group1"
InitiatorName "ALL"
Netmask 192.168.100.0/24
[LogicalUnit1021]
TargetName dustballL1
Mapping PortalGroup1 InitiatorGroup1
UnitType Disk
QueueDepth 64
LUN0 Storage /dev/zvol/san/volumes/dustballL1 Auto
[LogicalUnit1071]
TargetName coolmasterL1
Mapping PortalGroup1 InitiatorGroup1
UnitType Disk
QueueDepth 64
LUN0 Storage /dev/zvol/san/volumes/coolmasterL1 Auto
[LogicalUnit1501]
TargetName esxiL1
Mapping PortalGroup1 InitiatorGroup1
UnitType Disk
QueueDepth 64
LUN0 Storage /dev/zvol/san/volumes/esxiL1 Auto
[LogicalUnit1502]
TargetName esxiL2
Mapping PortalGroup1 InitiatorGroup1
UnitType Disk
QueueDepth 64
LUN0 Storage /dev/zvol/san/volumes/esxiL2 Auto
[LogicalUnit1503]
TargetName esxiL3
Mapping PortalGroup1 InitiatorGroup1
UnitType Disk
QueueDepth 64
LUN0 Storage /dev/zvol/san/volumes/esxiL3 Auto
[LogicalUnit1901]
TargetName esxi2L1
Mapping PortalGroup1 InitiatorGroup1
UnitType Disk
QueueDepth 64
LUN0 Storage /dev/zvol/san/volumes/esxi2L1 Auto
Client
/etc/iscsi.conf
Sample:
nasse {
initiatorname = iqn.2004-06.net.strahlert.home
targetname = iqn.2004-06.net.strahlert.home:coolmasterL1
targetaddress = 192.168.100.13:3260,1
}
/usr/local/etc/rc.d/iscsi
#!/bin/sh
# PROVIDE: iscsi
# REQUIRE: NETWORKING
# BEFORE: mountcritremote
# KEYWORD: shutdown
. /etc/rc.subr
name="iscsi"
start_cmd="iscsi_start"
stop_cmd="iscsi_stop"
rcvar="iscsi_enable"
required_modules="iscsi_initiator:iscsi"
iscsi_start()
{
${iscsi_command} -c ${iscsi_config} -n ${iscsi_nickname}
if [ -f ${iscsi_fstab} ]; then
devs=`sed -e '/^#/d' < ${iscsi_fstab} | cut -f 1`
for xdev in $devs
do
i=10
echo "Wait for $xdev"
while [ $i -ne 0 ]
do
[ -c $xdev ] && break
sleep 1
i=$(($i-1))
done
done
echo "mount -a -F ${iscsi_fstab}"
mount -a -F ${iscsi_fstab}
fi
}
iscsi_stop()
{
if [ -f ${iscsi_fstab} ]; then
echo "umount -a -F ${iscsi_fstab}"
umount -a -F ${iscsi_fstab}
fi
killall -HUP ${iscsi_command}
}
load_rc_config $name
: ${iscsi_enable="NO"}
: ${iscsi_command="iscontrol"}
: ${iscsi_nickname="idisk1"}
: ${iscsi_config="/etc/iscsi.conf"}
: ${iscsi_fstab="/etc/iscsi.fstab"}
run_rc_command "$1"
VirtualBox
VirtualBox has its own iSCSI initiator. To add a disk to a vm, use the following:
Port begins with 0 for SATA controllers. The example below is for adding a second disk.
VBoxManage storageattach dustball-v30 --storagectl "SATA Controller" --port 1 --type hdd --medium iscsi --server coolmaster --target "iqn.2004-06.net.strahlert.home:raid5-volume2"
For volume management through zfs, see also Volume management in ZFS and Copying a volume across a server
Recent Comments