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

通过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",
[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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/a6bbc81a7cf72cac4389d896a0f11684.html