Iscsi
From FoppaWiki
The following is a short copy/paste + description from the experince I've had with isci. This was done on Centos 5.4 and opensolaris 10.x, but it should be fairly similar on other distributions. Check stuff like label and fstab for your chosen OS.
CENTOS
- Install on Centos 5.x
yum -y install iscsi-initiator-utils.i386
- When you have to find available targets on iscsi device, you use discovery
iscsiadm -m discovery -t sendtargets -p 192.168.1.5
- List discovered iscsi target nodes and sessions
iscsiadm -m node iscsiadm -m session
- Login and logout iscsi node and check your new mount. The -T is the unique target id, and --portal is the iscsi device
iscsiadm -m node -T iqn.2004-04.com:iSCSI.slice01.BA9B62 --portal "192.168.1.5:3260" --login fdisk -l iscsiadm -m node -T iqn.2004-04.com:iSCSI.slice02.BA9B62 --portal "192.168.1.5:3260" --logout
- Make partitions and filesystem, again this is for Centos 5.x
fdisk /dev/sdb n for new p for primary 1 for first partition default cylinders for full use w for write mkfs -t ext3 /dev/sdb1
- Remove the default ext3 disk space reservation
tune2fs -m 0 /mount/point
- In order to be able to manage the iscsi targets in a sane way, I use label to keep track of the mounted iscsi targets, and obviously put them in fstab. This is for ext3 filesystem, and it will be different for different filesystem
e2label /dev/sdd1 /data7 "LABEL=/data7 /data7 ext3 defaults 0 0" >> /etc/fstab
- On Centos 5.x I found out that the /dev/disk/by-path dir was the best place to find the relationship between the target and what device number it got, and next line is to print it out nicer
(cd /dev/disk/by-path; ls -l | awk '{FS=" "; print $9 " " $10 " " $11}')
OPENSOLARIS
- Install
root@server# pkg install SUNWiscsi
- Configure the Solaris client to see the target
- You get the static IQN name from the iscsi host/server. Syntax is IQN,PORTAL(:PORT)
root@server# iscsiadm modify discovery --static enable
root@server# iscsiadm add static-config iqn.2004-04.com.qnap:ts-809u:iscsi.122testdata.8d508d,192.168.110.122:3260
root@server# iscsiadm list static-config
Static Configuration Target: iqn.2004-04.com.qnap:ts-809u:iscsi.122testdata.8d508d,192.168.110.122:3260
root@server# iscsiadm list target
Target: iqn.2004-04.com.qnap:ts-809u:iscsi.122testdata.8d508d
Target Portal Group Tag: default
Connections: 0
- Info on the iscsi targets.
iscsiadm list target iscsiadm list target -v iqn.2004-05.com.abcStorage:Tgt-1 iscsiadm list target -S iqn.2004-05.com.abcStorage:Tgt-1
- Create the iSCSI device links for the Solaris IO subsystem.
root@server# devfsadm -i iscsi
root@server# format
root@bfzfs1-1:~# format
Searching for disks...
c0t600140501E2A26ED1855D40B7D87B7DFd0: configured with capacity of 2047.89GB
AVAILABLE DISK SELECTIONS:
0. c0t600140501E2A26ED1855D40B7D87B7DFd0 <QNAP-iSCSIStorage-3.1 cyl 53467 alt 2 hd 255 sec 315>
/scsi_vhci/disk@g600140501e2a26ed1855d40b7d87b7df
1. c7t0d0 <DEFAULT cyl 19454 alt 2 hd 255 sec 63>
/pci@0,0/pci8086,340e@7/pci1000,3140@0/sd@0,0
2. c7t1d0 <DEFAULT cyl 19454 alt 2 hd 255 sec 63>
<snip>
- If this is a new "disk" you should create filesystem. If this is old data from ext3 or else look below for FSWpart.
root@server# newfs /dev/rdsk/c0t600140501E2A26ED1855D40B7D87B7DFd0s2
newfs: construct a new file system /dev/rdsk/c6t7d0s2: (y/n)? y
Warning: 11340 sector(s) in last cylinder unallocated
/dev/rdsk/c6t7d0s2: 83859300 sectors in 5547 cylinders of 240 tracks, 63 sectors
40946.9MB in 793 cyl groups (7 c/g, 51.68MB/g, 6272 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 105936, 211840, 317744, 423648, 529552, 635456, 741360, 847264, 953168,
Initializing cylinder groups:
...............
super-block backups for last 10 cylinder groups at:
82873712, 82979616, 83085520, 83191424, 83297328, 83403232, 83509136,
83615040, 83720944, 83826848,
root@server# mkdir /iscsi
root@server# mount /dev/dsk/c0t600140501E2A26ED1855D40B7D87B7DFd0s2 /iscsi
- "Uninstall"
iscsiadm remove static-config iqn.2004-04.com.qnap:ts-809u:iscsi.122testdata.8d508d,192.168.110.122:3260 iscsiadm modify discovery --static disable
- FSWpart for ntfs and ext support
HOW TO Install -------------- 1) Install the FSWpart package Download http://www.belenix.org/binfiles/FSWpart.tar.gz Uncompress: gunzip -c FSWpart.tar.gz | tar xvf - Install: pkgadd -d . FSWpart 2) Install the FSWfsmisc package Download http://www.belenix.org/binfiles/FSWfsmisc.tar.gz Uncompress: gunzip -c FSWfsmisc.tar.gz | tar xvf - Install: pkgadd -d . FSWfsmisc
root@server# prtpart Available disk devices: /dev/rdsk/c0t600140501E2A26ED1855D40B7D87B7DFd0p0 /dev/rdsk/c7t0d0p0 /dev/rdsk/c7t1d0p0 /dev/rdsk/c9t0d0p0 /dev/rdsk/c9t1d0p0 /dev/rdsk/c9t2d0p0 /dev/rdsk/c9t3d0p0 /dev/rdsk/c9t4d0p0 /dev/rdsk/c9t5d0p0 /dev/rdsk/c9t6d0p0 /dev/rdsk/c9t7d0p0 Use /usr/bin/prtpart <disk device> to get partition details Use /usr/bin/prtpart -help for usage help root@server# prtpart /dev/rdsk/c0t600140501E2A26ED1855D40B7D87B7DFd0p0 -ldevs Fdisk information for device /dev/rdsk/c0t600140501E2A26ED1855D40B7D87B7DFd0p0 ** NOTE ** /dev/dsk/c0t600140501E2A26ED1855D40B7D87B7DFd0p0 - Physical device referring to entire physical disk /dev/dsk/c0t600140501E2A26ED1855D40B7D87B7DFd0p1 - p4 - Physical devices referring to the 4 primary partitions /dev/dsk/c0t600140501E2A26ED1855D40B7D87B7DFd0p5 ... - Virtual devices referring to logical partitions Virtual device names can be used to access EXT2 and NTFS on logical partitions /dev/dsk/c0t600140501E2A26ED1855D40B7D87B7DFd0p1 Linux native root@bfzfs1-1:~# mount -F ext2fs /dev/dsk/c0t600140501E2A26ED1855D40B7D87B7DFd0p1 /mnt/qnapmount/
