Setting up iSCSI
iSCSI consists of two pieces: A target (server) and an initiator (client). A target is a large pool of disk space that can be accessed over IP by the initiators. Initiators use the disk space, formatting it and mounting it the same as local disk. When an initiator connects to a target a scsi device node is created (e.g. /dev/sda, /dev/sdb, etc)
The iscsitarget-X.X.apk package provides the target functionality. It includes the ietd service (ietd is the iSCSI Enterprise Target Daemon). The iscitarget-grsec package includes the kernel drivers for the grsec flavor of linux kernel. Install with:
Once the packages are installed, you can set up a target by editing two conf files.
In /etc/ietd.conf, add the following information:
Target iqn.2006-01.com.example:disk2.vol1 Lun 0 Path=/dev/sda1, Type=fileio
- literal iqn
- date (yyyy-mm) that the naming authority took ownership of the domain
- reversed domain name of the authority (org.alpinelinux, com.example, to.yp.cr)
- Optional ":" prefixing a storage target name specified by the naming authority.
From the RFC:
Naming String defined by Type Date Auth "example.com" naming authority +--++-----+ +---------+ +--------------------------------+ | || | | | | | iqn.2001-04.com.example:storage:diskarrays-sn-a8675309 iqn.2001-04.com.example iqn.2001-04.com.example:storage.tape1.sys1.xyz iqn.2001-04.com.example:storage.disk2.sys1.xyz
The "Target" line above is an example. This line really just needs to be unique. /dev/sdx refers to the disk and partition that will be presented to the initiator.
In the /etc/initiators.allow file, add the following line:
The IP address in the line above will be the initiator's ip address. Now only this ip address is allowed to access this specific target. You must use IP addresses, not hostnames.
If you don't care where the initiator is connecting from, you can use the keyword 'ALL:
The initator is in the open-iscsi package. Load this package on the client.
To configure the iSCSI initiator, add the initiator name to the file /etc/iscsi/initiatorname.iscsi The initator name follows the same iqn naming scheme as the target; but this is iderntifing the initator (client).
The 01, foo:bar:baz are arbitrary. You can enter anything (or nothing)- as long as the intiator name is a valid iqn.
Start the initiator daemon with
Connecting the Initiator to the Target
From the iSCSI initiator, first run this command:
This command contacts the target to determine which disks are available. If all is configured correctly, the target name iqn.2006-01.com.example:disk2.vol1 (from the example above) will be returned.
After the target is discovered, run this command to connect:
Replacing --login with --logout will end the connection.
To make this connection persistent (so that it will reconnect after reboot), run this command:
Any references/links to where to find more details about it?--Ncopa 16:04, 8 November 2007 (UTC)