ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 创建永久性本地SCSI设备名称

创建永久性本地SCSI设备名称

原创 Linux操作系统 作者:zzhen163 时间:2010-12-27 16:01:43 0 删除 编辑
Normal 0 7.8 pt 0 2 false false false EN-US ZH-CN X-NONE创建永久性本地SCSI设备名称

[root@racdb1 tmp]# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 5.5 (Tikanga)

[root@racdb1 tmp]#

 

[root@racdb1 rules.d]mkdir -p /etc/udev/scripts

[root@racdb1 rules.d]mkdir -p /etc/udev/rules.d

[root@racdb1 rules.d]#touch /etc/udev/rules.d/55-openiscsi.rules

[root@racdb1 rules.d]# cat /etc/udev/rules.d/55-openiscsi.rules

# /etc/udev/rules.d/55-openiscsi.rules

KERNEL=="sd*", BUS=="scsi", PROGRAM="/etc/udev/scripts/iscsidev.sh %b",SYMLINK+="iscsi/%c/part%n"

 

[root@racdb1 rules.d]#

[root@racdb1 scripts]#touch /etc/udev/scripts/iscsidev.sh

 

[root@racdb1 scripts]# 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##*.}"

 

[root@racdb1 scripts]#

[root@racdb1 rules.d]# ll /etc/udev/scripts/iscsidev.sh

-rwxr-xr-x 1 root root 335 Oct 13 14:20 /etc/udev/scripts/iscsidev.sh

[root@racdb1 rules.d]#

 

Restart ISCSI services.

The target devices:

[root@racdb1 tmp]# ll /dev/iscsi/asm1/part
lrwxrwxrwx 1 root root 9 Dec 22 14:35 /dev/iscsi/asm1/part -> ../../sdc
[root@racdb1 tmp]#

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/223555/viewspace-682661/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-09-27

  • 博文量
    35
  • 访问量
    64239