FreeBSD iSCSI Initiator Installation and Configuration
Q. How do I install and configure iSCSI initiator service under FreeBSD server?
A. FreeBSD 7.x has full support for iSCSI. Older version such as FreeBSD 6.3 requires backport for iSCSI. Following instruction are known to work under FreeBSD 7.0 only.
FreeBSD iscsi_initiator driver
The iscsi_initiator implements the kernel side of the Internet SCSI (iSCSI) network protocol standard, the user land companion is iscontrol and permits access to remote virtual SCSI devices via cam.
Compile driver
Please note that FreeBSD 7.x has this driver compiled by default. You can skip this step if driver exists at /boot/kernel/iscsi_initiator.ko. To compile this driver into the kernel,
# cd /usr/src/sys/i386/conf
# cp GENERIC ISCSIKERNEL
# vi ISCSIKERNEL
Place the following lines in your kernel configuration file:
device iscsi_initiator
Save and close the file. Building a Kernel, type the following commands:
# cd /usr/src
# make buildkernel KERNCONF=ISCSIKERNEL
Install the new kernel:
# make installkernel KERNCONF=ISCSIKERNEL
Now reboot the system:
# reboot
Install iSCSI Initiator driver under FreeBSD
You need FreeBSD kernel driver for the iSCSI protocol. You need to use driver called /boot/kernel/iscsi_initiator.ko. You can load this driver by typing following command as root user:
# kldload -v iscsi_initiator.ko
Output:
Loaded iscsi_initiator.ko, id=6
Alternatively, to load the driver as a module at boot time, place the following line in /boot/loader.conf:
# vi /boot/loader.conf
# Beginning of the iSCSI block added by Vivek
iscsi_initiator_load="YES"
# End of the block added by Vivek
Save and close the file.
FreeBSD iscontrol command to login / negotiator / control for an iSCSI initiator session
Now, you need to use iscontrol command. First, do a discovery session and exit:
# iscontrol -d targetaddress=iSCSI-SERVER-IP-ADDRESS initiatorname=nxl
# iscontrol -v -d targetaddress=192.168.1.100 initiatorname=nxl
Please note down the list of available targetnames/targetadresses. Once you know the target name, edit /etc/iscsi.conf file:
# vi /etc/iscsi.conf
Append config directives as follows:
officeiscsi {
authmethod = CHAP
chapIName = YOUR-ISCSI-USERNAME
chapSecret = YOUR-ISCSI-PASSWORD
initiatorname = nxl
TargetName = iqn.XYZZZZZZZZZZZZZ # whatever "iscontrol -v -d " gives you
TargetAddress = 192.168.1.100:3260,1 # your iscsi server IP
}
Save and close the file.
Where,
- officeiscsi { : Start config for iSCSI.
- authmethod : Set authentication method to chap
- chapIName : Your username
- chapSecret : Your password
- initiatorname : if not specified, defaults to iqn.2005-01.il.ac.huji.cs:<hostname>
- TargetName : is the name by which the target is known, not to be confused with target address, either obtained via the target administrator, or from a discovery session.
- TargetAddress : is of the form domainname[:port][,portal-group-tag] to quote the RFC: The domainname can be specified as either a DNS host name, a dotted-decimal IPv4 address, or a bracketed IPv6 address as specified in [RFC2732].
- } : End of config
Start an iSCSI session
The following command will read options from /etc/iscsi.conf, use the targetaddress found in the block nicknamed myiscsi, login and negotiate whatever options are specified, and start an iscsi-session.
# iscontrol -c /etc/iscsi.conf -n officeiscsi
Once you run the iscontrol command it should create a new device in /dev directory. To see the device name run dmesg command:
# dmesg
Format iSCSI volume
Now run sysinstall command to format just discovered iSCSI device name at /dev location:
# sysinstall
Select Custom > 3 Partition > Select iSCSI device name such as da1. Once formatted just mount device, enter:
# mkdir /iscsi
# mount /dev/da1s1 /iscsi
You may also need to update /etc/fstab file:
/dev/ad1s1 /iscsi ufs rw 3 3
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- Debian / Ubuntu Linux Connect to an iSCSI Volume
- Accessing A Single iSCSI LUN From Multiple Linux Systems
- Linux Change Default User Home Directory While Adding A New User
- FreeBSD Display Environment Settings
- FreeBSD admin book / handbook
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
Tags: /etc/fstab, /etc/iscsi.conf, boot kernel, boot loader, boot time, bsd iscsi, configuration file, discovery session, freebsd cluster, freebsd iscsi, FreeBSD iSCSI Initiator, freebsd nas, freebsd san, freebsd storage, iscsi backup, iscsi fibre channel, iscsi initiator, iscsi san, iscsi storage, kernel configuration, ko, negotiator, network protocol, root user, scsi devices, target ~ Last updated on: March 11, 2008



April 14th, 2008 (4 weeks ago) at 4:39 am
Great information. Hard to find this amount of details anywhere on the web for FBSD iSCSI. Totally appreciate the efforts
May 6th, 2008 (3 days ago) at 11:25 am
Hi,
great guid, but how do you automate the part below
iscontrol -c /etc/iscsi.conf -n officeiscsi
and do you get fstab part to work without the above?
thanks