Wednesday, December 15, 2010

Openfiler ISCSI LUN persistent naming using UDEV


SCSI device sda: 90275840 512-byte hdwr sectors (46221 MB)
SCSI device sda: drive cache: write back
SCSI device sda: 90275840 512-byte hdwr sectors (46221 MB)
SCSI device sda: drive cache: write back
Vendor: OPNFILER Model: VIRTUAL-DISK Rev: 0
SCSI device sdb: 4194304 512-byte hdwr sectors (2147 MB)
Vendor: OPNFILER Model: VIRTUAL-DISK Rev: 0
SCSI device sdc: 4194304 512-byte hdwr sectors (2147 MB)
Vendor: OPNFILER Model: VIRTUAL-DISK Rev: 0
SCSI device sdd: 4194304 512-byte hdwr sectors (2147 MB)
Vendor: OPNFILER Model: VIRTUAL-DISK Rev: 0
SCSI device sde: 4194304 512-byte hdwr sectors (2147 MB)
Vendor: OPNFILER Model: VIRTUAL-DISK Rev: 0
SCSI device sdf: 4194304 512-byte hdwr sectors (2147 MB)


[root@vmxdb02 ~]# lsscsi
[0:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sda
[1:0:0:0] disk OPNFILER VIRTUAL-DISK 0 /dev/sdb
[1:0:0:1] disk OPNFILER VIRTUAL-DISK 0 /dev/sdc
[1:0:0:2] disk OPNFILER VIRTUAL-DISK 0 /dev/sdd
[1:0:0:3] disk OPNFILER VIRTUAL-DISK 0 /dev/sde
[1:0:0:4] disk OPNFILER VIRTUAL-DISK 0 /dev/sdf



[root@vmxdb02 ~]# ls -l /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root 9 Dec 15 09:12 ata-VBOX_CD-ROM_VB2-01700376 -> ../../hdc
lrwxrwxrwx 1 root root 9 Dec 15 09:30 scsi-14f504e46494c45003079486253592d664130732d4d316730 -> ../../sdc
lrwxrwxrwx 1 root root 9 Dec 15 09:30 scsi-14f504e46494c45004e72793839712d444b536c2d7a453543 -> ../../sdf
lrwxrwxrwx 1 root root 9 Dec 15 09:30 scsi-14f504e46494c45005556417744532d757952702d58783772 -> ../../sde
lrwxrwxrwx 1 root root 9 Dec 15 09:30 scsi-14f504e46494c45006531506a52412d625645702d79354674 -> ../../sdd
lrwxrwxrwx 1 root root 9 Dec 15 09:30 scsi-14f504e46494c450074324f794a562d335134562d626f756e -> ../../sdb
lrwxrwxrwx 1 root root 9 Dec 15 09:12 scsi-SATA_VBOX_HARDDISK_VB3b4884d5-bc4c8fd3 -> ../../sda
lrwxrwxrwx 1 root root 10 Dec 15 09:12 scsi-SATA_VBOX_HARDDISK_VB3b4884d5-bc4c8fd3-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Dec 15 09:12 scsi-SATA_VBOX_HARDDISK_VB3b4884d5-bc4c8fd3-part2 -> ../../sda2



[root@vmxdb02 ~]# scsi_id -gus /block/sdc
14f504e46494c45003079486253592d664130732d4d316730



[root@vmxdb02 ~]# vi /etc/udev/rules.d/55-iscsi.rules
[root@vmxdb02 ~]# cat /etc/udev/rules.d/55-iscsi.rules
# /dev/iscsi/asmdisk1
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -gus %p",
RESULT=="14f504e46494c450074324f794a562d335134562d626f756e", SYMLINK+="iscsi/asmdisk1p%n", OWNER="grid", GROUP="oinstall", MODE="0660"

# /dev/iscsi/asmdisk2
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -gus %p",
RESULT=="14f504e46494c45003079486253592d664130732d4d316730", SYMLINK+="iscsi/asmdisk2p%n", OWNER="grid", GROUP="oinstall", MODE="0660"

# /dev/iscsi/asmdisk3
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -gus %p",
RESULT=="14f504e46494c45006531506a52412d625645702d79354674", SYMLINK+="iscsi/asmdisk3p%n", OWNER="grid", GROUP="oinstall", MODE="0660"

# /dev/iscsi/asmdisk4
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -gus %p",
RESULT=="14f504e46494c45005556417744532d757952702d58783772", SYMLINK+="iscsi/asmdisk4p%n", OWNER="grid", GROUP="oinstall", MODE="0660"

# /dev/iscsi/asmdisk5
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -gus %p",
RESULT=="14f504e46494c45004e72793839712d444b536c2d7a453543", SYMLINK+="iscsi/asmdisk5p%n", OWNER="grid", GROUP="oinstall", MODE="0660"



[root@vmxdb02 ~]# udevcontrol reload_rules
[root@vmxdb02 ~]# start_udev
Starting udev:
[ OK ]


[root@vmxdb02 ~]# ls -l /dev/iscsi/asmdisk*
lrwxrwxrwx 1 root root 6 Dec 15 09:57 /dev/iscsi/asmdisk1p -> ../sdb
lrwxrwxrwx 1 root root 6 Dec 15 09:57 /dev/iscsi/asmdisk2p -> ../sdc
lrwxrwxrwx 1 root root 6 Dec 15 09:57 /dev/iscsi/asmdisk3p -> ../sdd
lrwxrwxrwx 1 root root 6 Dec 15 09:57 /dev/iscsi/asmdisk4p -> ../sde
lrwxrwxrwx 1 root root 6 Dec 15 09:57 /dev/iscsi/asmdisk5p -> ../sdf



[root@vmxdb02 ~]# ls -l /dev/sd*
brw-r----- 1 root disk 8, 0 Dec 15 09:12 /dev/sda
brw-r----- 1 root disk 8, 1 Dec 15 09:12 /dev/sda1
brw-r----- 1 root disk 8, 2 Dec 15 09:12 /dev/sda2
brw-rw---- 1 grid oinstall 8, 16 Dec 15 09:57 /dev/sdb
brw-rw---- 1 grid oinstall 8, 32 Dec 15 09:57 /dev/sdc
brw-rw---- 1 grid oinstall 8, 48 Dec 15 09:57 /dev/sdd
brw-rw---- 1 grid oinstall 8, 64 Dec 15 09:57 /dev/sde
brw-rw---- 1 grid oinstall 8, 80 Dec 15 09:57 /dev/sdf