linux系统自带iscsi initiator调试
如何调试linux系统自带iscsi initiator。
1 linux主机系统自带的iscsi驱动装上后目录/usr/sbin里面没有iscsi-mountall和iscsi-umountall
2 /etc里有initiatorname.iscsi文件,但第一次添加InitiatorName=iqn.108无用
运行一下/etc/init.d/iscsi start后/etc/initiatorname.iscsi文件会重新生成。
在/etc/initiatorname.iscsi文件里添加InitiatorName=iqn.108这句话
3 在/etc/里面有fstab但没有fstab.iscsi
4 /etc/init.d/iscsi脚本里没有
# if we have an iSCSI fstab, process it
if [ -f /etc/fstab.iscsi ] ; then
echo -n " fsck/mount"
sleep 6
iscsi-mountall
fi
和
# unmount all filesystems on iSCSI devices
echo -n " umount"
iscsi-umountall -t -k
echo -n " sync"
sync
sleep 3
这两段语句。
1 虽然说在/etc/fstab里加入iscsi设备
/dev/sda1 /hlj ext3 defaults 0 0
系统重起时会加载成功。
但关闭系统或运行/etc/init.d/iscsi stop
会提示错误
如
[root@localhost init.d]# ./iscsi stop
Stopping iscsid: [ OK ]
Removing iscsi driver: ERROR: Module iscsi_sfnet is in use
[FAILED]
因为iscsi脚本里还没有mount,umount语句
系统不会自动umount掉iscsi硬盘。
2
如果scm 上的initiator name=iqn.108加上CHAP
命令:
initiator modify name = iqn.108 authentication = CHAP
New CHAP authentication key:123456789123
Retype authentication key:123456789123
主机端:
先手动umount掉iscsi硬盘然后执行。
[root@localhost init.d]# ./iscsi stop
Stopping iscsid: [ OK ]
Removing iscsi driver: [ OK ]
[root@localhost init.d]# ./iscsi start
Checking iscsi config: [ OK ]
Loading iscsi driver: [ OK ]
Starting iscsid: [ OK ]
[root@localhost init.d]# iscsi-ls
*******************************************************************************
SFNet iSCSI Driver Version ...4:0.1.11(
*******************************************************************************
可以看到无target端。
因为iscsi里还没有iscsi-mountall和iscsi-umountal所以CHAP起不了作用。
1在/sbin里拷入iscsi-mountall和iscsi-umountal文件
从windows系统的共享的 as4iscsi/iscsi_initiator/linux-iscsi-4.0.1.11/linux-iscsi-4.0.1.11/linux-iscsi-
/misc/scripts
目录下拷完后。给与文件权限
[root@localhost sbin]# chmod 777 iscsi-umountall
[root@localhost sbin]# chmod 777 iscsi-mountall
2在/etc里建立fstab.iscsi文件
添加
/dev/sda1 /hlj ext3 defaults 0 0
3 在/etc/init.d/iscsi脚本里添加
# if we have an iSCSI fstab, process it
if [ -f /etc/fstab.iscsi ] ; then
echo -n " fsck/mount"
sleep 6
iscsi-mountall
fi
和
# unmount all filesystems on iSCSI devices
echo -n " umount"
iscsi-umountall -t -k
echo -n " sync"
sync
sleep 3
这两段语句。
位置参看蓝色语句位置。如下:
# Make sure the K*iscsi scripts get called
if [ -d /var/lock/subsys ] ; then
touch /var/lock/subsys/iscsi
fi
# if we have an iSCSI fstab, process it
if [ -f /etc/fstab.iscsi ] ; then
echo -n " fsck/mount"
sleep 6
iscsi-mountall
fi
echo ""
;;
stop)
# if iSCSI network boot then exit.
if iscsi_network_boot ; then
echo "Since it is an iSCSI network boot therefore, driver cannot be stopped/restarted"
exit 1
fi
echo -n "Stopping iSCSI:"
for hba in /proc/scsi/iscsi/* ; do
echo "connfailtimeout - - $CONNFAILTIMEOUT" > $hba
echo "diskcommandtimeout - - $DISKCOMMANDTIMEOUT" > $hba
done
echo -n " sync"
sync
# unmount all filesystems on iSCSI devices
echo -n " umount"
iscsi-umountall -t -k
echo -n " sync"
sync
sleep 3
if [ -f $PIDFILE ] ; then
echo -n " iscsid"
kill -TERM `head -n 1 $PIDFILE`
sleep 2
killall $BASEDIR/sbin/iscsid > /dev/null 2>&1
killall iscsid > /dev/null 2>&1
rm -f $PIDFILE
fi
# shutdown the kernel module
if [ -d /proc/scsi/iscsi ] ; then
echo -n " iscsi"
for hba in /proc/scsi/iscsi/* ; do
5然后在/etc/iscsi.conf中加
DiscoveryAddress=192.168.10.200:3260
OutgoingUsername=iqn.108
OutgoingPassword=123456789123
and/or
如不加这段启动service iscsi restart 出现如下错误
fsck/mount[root@localhost ~]# fsck.ext3: No such file or directory while trying to open /dev/sda1
*** device not yet available, 9 retries remaining
fsck.ext3: No such file or directory while trying to open /dev/sda1
以上步骤都做好以后,重新启动iscsi服务
[root@localhost sbin]# service iscsi restart
Stopping iscsid: umount sync [ OK ]
Removing iscsi driver: [ OK ]
Checking iscsi config: [ OK ]
Loading iscsi driver: [ OK ]
Starting iscsid: [ OK ]
fsck/mount[root@localhost sbin]# mount
/dev/hda2 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
/dev/sda1 on /hlj type ext3 (rw)
可以看到iscsi硬盘正常挂接成功。
若您有关于案例的建议,请反馈:
该案例暂时没有网友评论
✖
案例意见反馈
亲~登录后才可以操作哦!
确定你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作