Setting Up iSCSI Using YaST
In this article you may learn how to create an iSCSI target on a SLES 10 server and how to use its storage on another.
The following packages needed:
- For the target: iscsitarget and yast2-iscsi-server
- For the initiator: open-iscsi and yast2-iscsi-client
Setting up the target
In the iSCSI terminology, the target is the server side while the initiator is the client. First we set up the target. I use the ncurses UI for Yast (I found it faster to use).
Note: You can navigate by using Tab and the arrows on your keyboard or by pressing Alt + the highlighted characters.
Let’s start YaST and select Network Services / iSCSI Target. If the iscscitarget package was not installed, YaST offers you to install it. The following screen appears:
Select When Booting to automatically start the service. If you have enabled the firewall, check Open Port in Firewall so the initiators can access your system. After it we’re ready to add our first target.
Select the Targets on the upper bar. The following appears:
There might be a default target set, you can delete it. Click on the Add button. A new dialog appears:
First setup the Target. Its format is iqn.<yyyy-mm>.<tld>.<domain>, which in my case is iqn.2007-03.hu.albacomp (my domain is albacomp.hu).
The Identifier is a unique number for all targets, you don’t have to modify it. The Target and the Identifier together creates the iSCSI address. To make it easier to understand: An iSCSI Identifier is functionally equivalent to a Uniform Resource Identifier (URI), an iSCSI Name is functionally equivalent to a Uniform Resource Name (URN), and an iSCSI Address fulfils the same function as a Uniform Resource Locator (URL). 
The LUN means the same as the it was in case of traditional SCSI disks. If you don’t have any specific reason, you don’t have to modify it.
Now we have to specify the Path. According to the YaST help (this is very handy though many people forget to read it) on the left panel: For Path, use block devices, regular files, LVM, or RAID. It means you can use almost anything. I used LVM so my path points to /dev/mapper/vm-data (vm is the name of the logical volume, data is the partition).
When you set everything, click Next to access the 2nd screen:
Here you can set authentication for this target (you can set global authentication as well, that applies to all connections). It’s great because you wouldn’t let anyone access your data, do you? I’ve set test user with password as password for incoming authentication. You can set outgoing authentication as well (however, you can set only one user for outgoing authentication while you can add many users for incoming connections).
When you’re finished, press Next.
You can add more targets if you want to. Press Finish when you’re ready. YaST warns you that the service has to be restarted to apply the modifications. This means all sessions will be aborted so use it carefully in a production environment! Press Yes to restart the services, press No to save the configuration and restart the service later manually.
Now your system is ready to serve iSCSI initiators.
Setting up the initiator
As I wrote before, the initiator is the client in the iSCSI terminology. To configure it select Network Services / iSCSI Initiator. The following screen appears:
Select When Booting for automatic start just like we did for the iSCSI target. Now select the Connected Targets tab. The list is empty so let’s fill it. Press the Add button. The following screen appears:
Here you have to set the IP address of the target machine, and optionally the authentication information. The incoming/outgoing authentication is in pair with the target system: the target’s incoming has to be the same as the initiator’s outgoing and vice versa. In out example we set the user test with password as password.
After pressing Next, our newly discovered target appears in the list. Press Connect to connect to the target and press Next again. We have to give the credentials again, so do it and press Next twice after it.
The Connected Targets menu appears again. Here you can disconnect from a connected target by pressing Log Out. You can also set to connect automatically by pressing Toggle Start-Up. This doesn’t mean the service starts automatically! It means the target will be automatically connected when you start the service. Press Finish and we’re done!
Testing our connection, mounting
Quit from yast and run the /etc/init.d/open-iscsi status command from the console. If everything was okay you’ll get similar output to this:
adosztal-nb:~ # /etc/init.d/open-iscsi status Checking for iSCSI initiator service: running Active connections: iqn.2007-03.hu.albacomp:355642b3-990d-4b8f-8164-9a260e04e181 adosztal-nb:~ #
Now let’s take a look at our connection’s device:
adosztal-nb:~ # lsscsi [0:0:0:0] disk IET VIRTUAL-DISK 0 /dev/sda adosztal-nb:~ #
You can see that it is /dev/sda. Let’s mount it with the mount /dev/sda /mnt command. You can use the target’s storage now! Of course you can mount it somewhere else, you may put an entry to /etc/fstab, and so on. By running df, you can see how much space left on your storage:
adosztal-nb:/mnt # df -h Filesystem Size Used Avail Use% Mounted on [...] /dev/sda 5.0G 129M 4.6G 3% /mnt [...] adosztal-nb:/mnt #
: Internet Draft: iSCSI Naming and Discovery (IETF, http://tools.ietf.org/html/draft-ietf-ips-iscsi-name-disc-02)
If you have questions, comments, feel free to drop me a line to doszy <@> t-online <.> hu.