[root@temple rules.d]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000023cd
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 5222 41430016 8e Linux LVM
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x383bd4c4
Device Boot Start End Blocks Id System
/dev/sdb1 1 1044 8385898+ 83 Linux
以上为磁盘信息。
udevadm info -a -p /sys/block/sdb/sdb1查询硬盘信息
我们使用ATTR{start}=="63" ATTR{size}=="16771797"来唯一标识这个设备
[root@temple rules.d]# udevadm info -a -p /sys/block/sdb/sdb1
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:0d.0/host1/target1:0:0/1:0:0:0/block/sdb/sdb1':
KERNEL=="sdb1"
SUBSYSTEM=="block"
DRIVER==""
ATTR{partition}=="1"
ATTR{start}=="63"
ATTR{size}=="16771797"
ATTR{alignment_offset}=="0"
ATTR{discard_alignment}=="0"
ATTR{stat}==" 791 72121 73402 532 0 0 0 0 0 343 494"
ATTR{inflight}==" 0 0"
looking at parent device '/devices/pci0000:00/0000:00:0d.0/host1/target1:0:0/1:0:0:0/block/sdb':
KERNELS=="sdb"
SUBSYSTEMS=="block"
DRIVERS==""
ATTRS{range}=="16"
ATTRS{ext_range}=="256"
ATTRS{removable}=="0"
ATTRS{ro}=="0"
ATTRS{size}=="16777216"
ATTRS{alignment_offset}=="0"
ATTRS{discard_alignment}=="0"
ATTRS{capability}=="52"
ATTRS{stat}==" 1510 72178 79610 684 4 0 8 103 0 589 740"
ATTRS{inflight}==" 0 0"
looking at parent device '/devices/pci0000:00/0000:00:0d.0/host1/target1:0:0/1:0:0:0':
KERNELS=="1:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{device_blocked}=="0"
ATTRS{type}=="0"
ATTRS{scsi_level}=="6"
ATTRS{vendor}=="ATA "
ATTRS{model}=="VBOX HARDDISK "
ATTRS{rev}=="1.0 "
ATTRS{state}=="running"
ATTRS{timeout}=="30"
ATTRS{iocounterbits}=="32"
ATTRS{iorequest_cnt}=="0x634"
ATTRS{iodone_cnt}=="0x633"
ATTRS{ioerr_cnt}=="0x9"
ATTRS{modalias}=="scsi:t-0x00"
ATTRS{evt_media_change}=="0"
ATTRS{dh_state}=="detached"
ATTRS{queue_depth}=="31"
ATTRS{queue_ramp_up_period}=="120000"
ATTRS{queue_type}=="simple"
looking at parent device '/devices/pci0000:00/0000:00:0d.0/host1/target1:0:0':
KERNELS=="target1:0:0"
SUBSYSTEMS=="scsi"
DRIVERS==""
looking at parent device '/devices/pci0000:00/0000:00:0d.0/host1':
KERNELS=="host1"
SUBSYSTEMS=="scsi"
DRIVERS==""
looking at parent device '/devices/pci0000:00/0000:00:0d.0':
KERNELS=="0000:00:0d.0"
SUBSYSTEMS=="pci"
DRIVERS=="ahci"
ATTRS{vendor}=="0x8086"
ATTRS{device}=="0x2829"
ATTRS{subsystem_vendor}=="0x0000"
ATTRS{subsystem_device}=="0x0000"
ATTRS{class}=="0x010601"
ATTRS{irq}=="21"
ATTRS{local_cpus}=="3"
ATTRS{local_cpulist}=="0-1"
ATTRS{modalias}=="pci:v00008086d00002829sv00000000sd00000000bc01sc06i01"
ATTRS{numa_node}=="-1"
ATTRS{enable}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{msi_bus}==""
looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
绑定规则如下:
[root@temple rules.d]# pwd
/etc/udev/rules.d
[root@temple rules.d]# cat 99-oracle-asmdevices.rules
KERNEL=="sdb1", SUBSYSTEM=="block", ATTR{start}=="63", ATTR{size}=="16771797", NAME="asmdisk1", OWNER="oracle", GROUP="oinstall", MODE="0660"
然后启动udev:
[root@temple rules.d]# cat 99-oracle-asmdevices.rules
KERNEL=="sdb1", SUBSYSTEM=="block", ATTR{start}=="63", ATTR{size}=="16771797", NAME="asmdisk1", OWNER="oracle", GROUP="oinstall", MODE="0660"
[root@temple rules.d]# start_udev
Starting udev: [ OK ]
[root@temple rules.d]# cd /dev
[root@temple dev]# pwd
/dev
[root@temple dev]# ll asmdisk1
brw-rw----. 1 oracle oinstall 8, 17 Aug 4 20:18 asmdisk1
接下来就可以用来做ASM磁盘组啦~~