Using udev to simplify HP Serviceguard for Linux configuration, March 2014

Technical white paper | Using udev to simplify HP Serviceguard for Linux configuration
4
Suppose there exists a soft link from /dev/mapper/mpath1 to /dev/dm-1 and /dev/mapper/mpath1
has a partition /dev/mapper/mpath1_part1. If there exists a softlink from /dev/mapper/mpath1_part1
to /dev/dm-2, append the following rule in /etc/udev/rules.d/10-HP-Local.rules file:
SUBSYSTEM==”block”, KERNEL==”dm*”, PROGRAM=”/bin/sh /root/myscript.sh /dev/%k”,
RESULT==”360060e80042747000000274700000315”,
SYMLINK=”hpdev/mylink-dmpart1”
Where 360060e80042747000000274700000315 is the output of
“/lib/udev/scsi_id --page=0x83 --whitelisted
--replace-whitespace /dev/dm-1” command
and the following is the output of cat /root/myscript.shcommand:
#!/bin/sh
device=$1
devname=”/dev/mapper/”`/sbin/dmsetup info ${device} | /bin/grep “Name” |
/bin/awk ‘{print $NF}’`
pat=”_part[0-9]+$”
if [[ $devname =~ $pat ]]; then
dev=`/bin/echo ${devname} | /bin/sed -r -e ‘s/_part[0-9]+$//’ –e
‘s/p[0-9]+$//’`
/lib/udev/scsi_id --page=0x83 --whitelisted --replace-whitespace ${dev}
fi
fi
Red Hat 5:
SUBSYSTEM==”block”, KERNEL==”sd*”, PROGRAM=”/sbin/scsi_id –g -u –s /block/%k”,
RESULT==”360060e80042747000000274700000315”,
SYMLINK=”hpdev/mylink-sda”
Where 360060e80042747000000274700000315 is the output of
“/sbin/scsi_id –g –u –s /block/sda” command.
If device /dev/sda has partitions, the following rule also needs to be added to the
/etc/udev/rules.d/10-HP-Local.rules file:
SUBSYSTEM==”block”, KERNEL==”sd*”, PROGRAM=”/sbin/scsi_id –g -u –s
/block/$parent”, RESULT==”360060e80042747000000274700000315”,
SYMLINK=”hpdev/mylink-sda%n”
Where 360060e80042747000000274700000315 is the output of
“/sbin/scsi_id –g –u –s /block/sda” command.
Red Hat 6:
SUBSYSTEM==”block”, KERNEL==”sd*”, PROGRAM=”/lib/udev/scsi_id
--page=0x83 --whitelisted --replace-whitespace
-–device=/dev/%k”,
RESULT==”360060e80042747000000274700000315”,
SYMLINK=”hpdev/mylink-sda”
If device /dev/sda has partitions, the following rule also needs to be added to the
/etc/udev/rules.d/10-HP-Local.rules file:
SUBSYSTEM==”block”, KERNEL==”sd*”, PROGRAM=”/lib/udev/scsi_id
--page=0x83 --whitelisted --replace-whitespace
--device=/dev/$parent”,
RESULT==”360060e80042747000000274700000315”,
SYMLINK=”hpdev/mylink-sda%n”
Where 360060e80042747000000274700000315 is the output of
“/lib/udev/scsi_id --page=0x83 --whitelisted
--replace-whitespace /dev/sda” command.