linux共享磁盘配置,rh436 - 通过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", 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服务后权限正常。0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值