系统设置 -> 存储空间总管 -> iSCSI选项卡
入口管理: 启动iSCSI目标服务
iSCSI目标管理:创建一个iSCSI目标并挂载一个iSCSI LUN
iqn.2004-04.com.qnap:ts-212p:iscsi.quqiSCSI.d5ad13
目标名称:quqiSCSI
目标别名:quqiSCSI
启用CHAP认证:username/password
动态配置:quqiSCSI, 800G
hua@node1:~$ sudo /etc/init.d/open-iscsi start
hua@node1:~$ sudo update-rc.d open-iscsi enable
vi /etc/iscsi/iscsid.conf
node.startup = automatic
node.session.auth.authmethod = CHAP
node.session.auth.username = username
node.session.auth.password = password
hua@node1:~$ sudo iscsiadm -m discovery -t st -p 192.168.99.122
192.168.99.122:3260,1 iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13
10.8.0.1:3260,1 iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13
hua@node1:~$ sudo cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13
hua@node1:~$ sudo iscsiadm -m node -T iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13 -p 192.168.99.122 --op new
New iSCSI node [tcp:[hw=,ip=,net_if=,iscsi_if=default] 192.168.99.122,3260,-1 iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13] added
hua@node1:~$ sudo iscsiadm -m node -T iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13 -p 192.168.99.122 --login
Logging in to [iface: default, target: iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13, portal: 192.168.99.122,3260] (multiple)
Login to [iface: default, target: iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13, portal: 192.168.99.122,3260] successful.
hua@node1:~$ sudo iscsiadm -m node -T iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13 -p 192.168.99.122 --op update -n node.startup -v automatic
hua@node1:~$ ls -l /dev/disk/by-path/ip-192.168.99.122\:3260-iscsi-iqn.2004-04.com.qnap\:ts-212p\:iscsi.quqiscsi.d5ad13-lun-0
lrwxrwxrwx 1 root root 9 Dec 28 10:22 /dev/disk/by-path/ip-192.168.99.122:3260-iscsi-iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13-lun-0 -> ../../sdb
hua@node1:~$ cat /sys/class/iscsi_host/host16/device/session11/iscsi_session/session11/targetname
iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13
hua@node1:~$ sudo cat /etc/udev/rules.d/55-openiscsi.rules
KERNEL=="sd*", BUS=="scsi", PROGRAM="/etc/udev/scripts/iscsidev.sh %b",SYMLINK+="iscsi/%c"
hua@node1:~$ sudo cat /etc/udev/scripts/iscsidev.sh
#!/bin/sh
# FILE: /etc/udev/scripts/iscsidev.sh
BUS=${1}
HOST=${BUS%%:*}
[ -e /sys/class/iscsi_host ] || exit 1
file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/targetname"
target_name=$(cat ${file})
# This is not an open-scsi drive
if [ -z "${target_name}" ]; then
exit 1
fi
echo "${target_name##*.}"
hua@node1:~$ sudo fdisk -l
...
Disk /dev/sdb: 859.0 GB, 858993459200 bytes
255 heads, 63 sectors/track, 104433 cylinders, total 1677721600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 1048576 bytes / 1048576 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
hua@node1:~$ sudo mkfs.ext4 /dev/sdb
mke2fs 1.42.9 (4-Feb-2014)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=256 blocks, Stripe width=256 blocks
52428800 inodes, 209715200 blocks
10485760 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
6400 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
hua@node1:~$ sudo mkdir /qnap
hua@node1:~$ sudo mount -t ext4 /dev/sdb /qnap
hua@node1:~$ df -h |grep sdb
/dev/sdb 788G 69M 748G 1% /qnap
hua@node1:~$ sudo tune2fs -l /dev/sdb |grep UUID
Filesystem UUID: 30aa3ef9-698b-41c2-9637-dc79be91eb79
hua@node1:~$ sudo cat /etc/fstab |grep qnap
UUID=30aa3ef9-698b-41c2-9637-dc79be91eb79 /qnap ext4 defaults 0 2