你好,游客 登录 注册 搜索
背景:
阅读新闻

rh436 - 通过udev配置iscsi共享磁盘名称及权限(rhel5.5)

[日期:2012-05-26] 来源:Linux社区  作者:t0nsha [字体:大 中 小]

通过udev配置iscsi共享磁盘名称:

[root@localhost ~]# udevinfo -q path -n /dev/sdb
/block/sdb
[root@localhost ~]# /sbin/scsi_id -g -s /block/sdb
1IET     00020001
[root@localhost ~]# vim /etc/udev/rules.d/99-iscsi.rules 
KERNEL=="sd*", PROGRAM="/sbin/scsi_id -g -s %p", RESULT=="1IET     00020001", NAME="sharedisk%n"
[root@localhost ~]# vim /etc/udev/rules.d/99-myiscsi.rules 
[root@localhost ~]# service iscsi restart
Logging out of session [sid: 1, target: iqn.2012-05.com.example:ex333server.target244, portal: 192.168.221.254,3260]
Logout of [sid: 1, target: iqn.2012-05.com.example:ex333server.target244, portal: 192.168.221.254,3260]: successful
Stopping iSCSI daemon:
iscsid dead but pid file exists                            [  OK  ]
Starting iSCSI daemon:                                     [  OK  ]
                                                           [  OK  ]
Setting up iSCSI targets: Logging in to [iface: default, target: iqn.2012-05.com.example:ex333server.demo, portal: 192.168.221.254,3260]
Logging in to [iface: default, target: iqn.2012-05.com.example:ex333server.target244, portal: 192.168.221.254,3260]
Login to [iface: default, target: iqn.2012-05.com.example:ex333server.demo, portal: 192.168.221.254,3260]: successful
Login to [iface: default, target: iqn.2012-05.com.example:ex333server.target244, portal: 192.168.221.254,3260]: successful
                                                           [  OK  ]
[root@localhost ~]# fdisk -l

Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          25      200781   83  Linux
/dev/sda2              26        1330    10482412+  83  Linux
/dev/sda3            1331        1591     2096482+  82  Linux swap / Solaris

Disk /dev/sdb: 4 MB, 4194304 bytes
1 heads, 8 sectors/track, 1024 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/sdb doesn't contain a valid partition table
[root@localhost ~]# fdisk -l /dev/sharedisk

Disk /dev/sharedisk: 4 MB, 4194304 bytes
1 heads, 8 sectors/track, 1024 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/sharedisk doesn't contain a valid partition table
[root@localhost ~]#


fdisk -l列出的是系统默认磁盘名称,要列出我们给定的磁盘名词需要写全(fdisk -l /dev/sharedisk)。


配置iscsi共享磁盘的权限:

[root@localhost rules.d]# cat /etc/passwd | grep nobody
nobody:x:99:99:Nobody:/:/sbin/nologin
[root@localhost rules.d]# vim 99-myiscsi.rules
KERNEL=="sd*", PROGRAM="/sbin/scsi_id -g -s %p", RESULT=="1IET     00020001", SYMLINK+="sharedisk%n", OWNER="nobody", GROUP="nobody", MODE="0660"
[root@localhost rules.d]# service iscsi restart
Logging out of session [sid: 1, target: iqn.2012-05.com.example:ex333server.demo, portal: 192.168.221.254,3260]
Logging out of session [sid: 2, target: iqn.2012-05.com.example:ex333server.target244, portal: 192.168.221.254,3260]
Logout of [sid: 1, target: iqn.2012-05.com.example:ex333server.demo, portal: 192.168.221.254,3260]: successful
Logout of [sid: 2, target: iqn.2012-05.com.example:ex333server.target244, portal: 192.168.221.254,3260]: successful
Stopping iSCSI daemon:
iscsid dead but pid file exists                            [  OK  ]
Starting iSCSI daemon:                                     [  OK  ]
                                                           [  OK  ]
Setting up iSCSI targets: Logging in to [iface: default, target: iqn.2012-05.com.example:ex333server.demo, portal: 192.168.221.254,3260]
Logging in to [iface: default, target: iqn.2012-05.com.example:ex333server.target244, portal: 192.168.221.254,3260]
Login to [iface: default, target: iqn.2012-05.com.example:ex333server.demo, portal: 192.168.221.254,3260]: successful
Login to [iface: default, target: iqn.2012-05.com.example:ex333server.target244, portal: 192.168.221.254,3260]: successful
                                                           [  OK  ]
[root@localhost rules.d]# fdisk -l

Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          25      200781   83  Linux
/dev/sda2              26        1330    10482412+  83  Linux
/dev/sda3            1331        1591     2096482+  82  Linux swap / Solaris

Disk /dev/sdb: 4 MB, 4194304 bytes
1 heads, 8 sectors/track, 1024 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 4 MB, 4194304 bytes
1 heads, 8 sectors/track, 1024 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/sdc doesn't contain a valid partition table
[root@localhost rules.d]# fdisk -l /dev/sharedisk

Disk /dev/sharedisk: 4 MB, 4194304 bytes
1 heads, 8 sectors/track, 1024 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/sharedisk doesn't contain a valid partition table
[root@localhost rules.d]# ll /dev/sh
sharedisk  shm/      
[root@localhost rules.d]# ll /dev/sharedisk
lrwxrwxrwx 1 root root 3 May 27 02:58 /dev/sharedisk -> sdc
[root@localhost rules.d]# ll /dev/sd*
brw-r----- 1 root   disk   8,  0 May 26 21:26 /dev/sda
brw-r----- 1 root   disk   8,  1 May 26 21:26 /dev/sda1
brw-r----- 1 root   disk   8,  2 May 26 21:26 /dev/sda2
brw-r----- 1 root   disk   8,  3 May 26 21:26 /dev/sda3
brw-r----- 1 root   disk   8, 16 May 27 02:58 /dev/sdb
brw-rw---- 1 nobody nobody 8, 32 May 27 02:58 /dev/sdc
[root@localhost rules.d]#

链接sharedisk的权限没变,不过其所指向的sdc权限已经变为我们所需要的了。

注意:双等于和单等于号不要搞混了,所有等于后面的值都要用双引号括起来,
刚开始我在写MODE这个选项时(MODE=0660)时没有用双引号,结果权限一直是-rw-r-----,
像是从umask(0022)继承过来的,但是改了umask重启iscsi服务权限确又没有随着umask走,
后面改成带引号(MODE="0660")的,然后重启iscsi服务后权限正常。

linux
相关资讯       RHEL5 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款