I am using in this example SLES 11 as iSCSI client
# cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (i586)
VERSION = 11
PATCHLEVEL = 3
and Arch Linux as iSCSI server
# cat /etc/os-release
NAME="Arch Linux"
ID=arch
PRETTY_NAME="Arch Linux"
ANSI_COLOR="0;36"
HOME_URL="https://www.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
For the client I need to install and start open-iscsi:
# zypper se open-iscsi
Loading repository data...
Reading installed packages...
S | Name | Summary | Type
--+------------+--------------------------------------+-----------
i | open-iscsi | Linux* Open-iSCSI Software Initiator | package
# /etc/init.d/open-iscsi start
Loading iscsi modules: tcp done
Starting iSCSI initiator service: done
I can now use iscsiadm to discover the target:
# iscsiadm -m discovery -t sendtargets -p 172.16.41.132:3260
172.16.41.132:3260,1 iqn.20140912.ovi
I use the command to login to this target to be able to see the LUNs as disks:
# iscsiadm -m node --targetname=<targetname> --login
or to login to ALL discovered targets:
# iscsiadm -m node -L all
# iscsiadm -m node --targetname=iqn.20140912.ovi --login
Logging in to [iface: default, target: iqn.20140912.ovi, portal: 172.16.41.132,3260] (multiple)
Login to [iface: default, target: iqn.20140912.ovi, portal: 172.16.41.132,3260] successful.
I use fdisk to check if my LUNs are visible and mkfs to create new file systems:
# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000b1de
Device Boot Start End Blocks Id System
/dev/sda1 2048 4208639 2103296 82 Linux swap / Solaris
/dev/sda2 * 4208640 41943039 18867200 83 Linux
Disk /dev/sdb: 4294 MB, 4294967296 bytes
133 heads, 62 sectors/track, 1017 cylinders, total 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
Sdb is my exported LUN in this case.
# mkfs.ext4 /dev/sdb
Just for fun, I can check the size of my LUN on the server.
Before creating the file system:
# du --apparent-size -h lun.img && du -h lun.img
4.0G lun.img
0 lun.img
After I created a file system:
# du --apparent-size -h lun.img && du -h lun.img
4.0G lun.img
194M lun.img
Last step is to mount the device:
# mount /dev/sdb /media/lun/
That's it. I have now mounted an iSCSI LUN in SLES form a Linux iSCSI server.