This article describes how to add raw device mappings in Red Hat Enterprise Linux 4/5.
The raw devices interface has been deprecated in Red Hat Enterprise Linux 4/5. It is now configured via udev rules.
To add raw device mapping, add entries to /etc/udev/rules.d/60-raw.rules in the following formats:
For device names:
ACTION=="add", KERNEL="<device name>", RUN+="raw /dev/raw/rawX %N"
For major / minor numbers:
ACTION=="add", ENV{MAJOR}="A", ENV{MINOR}="B", RUN+="raw /dev/raw/rawX %M %m"
Replace <device name> with the name of the device needed to bind (such as /dev/sda1). "A" and "B" are the major / minor numbers of the device needed for binding, an "X" is the raw device number that the system wants to use.
If there is a large, pre-existing /etc/sysconfig/rawdevices file, convert it with the following script:
#!/bin/sh
grep -v "^ *#" /etc/sysconfig/rawdevices | grep -v "^$" | while read dev major
minor ; do
if [ -z "$minor" ]; then
echo "ACTION==\"add\", KERNEL==\"${major##/dev/}\",
RUN+=\"/usr/bin/raw $dev %N\""
else
echo "ACTION==\"add\", ENV{MAJOR}==\"$major\",
ENV{MINOR}==\"$minor\", RUN+=\"/usr/bin/raw $dev %M %m\""
fi
done
*
Creating persistent raw devices for single path LUNs:
If using unpartitioned LUNs, to create a single raw device for the whole LUN use this rule format:
ACTION=="add", KERNEL=="sd*[!0-9]", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="3600601601bd2180072193a9242c3dc11", RUN+="/bin/raw /dev/raw/raw1 %N"
Set the RESULT value to the output of scsi_id -g -u -s /block/sdX (where sdX is the current path to the LUN). This will create the raw device /dev/raw/raw1 that will be persistently bound to the LUN with WWID 3600601601bd2180072193a9242c3dc11.
If using partitioned LUNs, where raw devices are created for each of the partitions on the LUN, use this rule format:
ACTION=="add", KERNEL=="sd*[0-9]", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="3600601601bd2180072193a9242c3dc11", RUN+="/bin/raw /dev/raw/raw%n %N"
Again, set RESULT to the output of scsi_id -g -u -s /block/sdX. This will create the raw device(s) /dev/raw/raw1, /dev/raw/raw2, etc. for each partition on the LUN and they will be persistently bound to the LUN with WWID 3600601601bd2180072193a9242c3dc11.
*
Setting ownership and permissions on the raw devices:
To set specific ownership and/or permissions for the raw devices, add entries to /etc/udev/rules.d/60-raw.rules in the following format:
ACTION=="add", KERNEL=="raw*", OWNER=="root", GROUP=="disk", MODE=="0660"
*
Testing and implementing the udev rules:
Before implementing them, use the udevtest command to verify the udev rules work as expected. To verify that the raw device is created for a specific disk or partition, eg /dev/sdb1:
[root@rhel5 rules.d]# udevtest /block/sdb/sdb1 | grep raw
main: run: '/bin/raw /dev/raw/raw1 /dev/.tmp-8-17'
To check ownership/permission settings for a particular raw device, eg /dev/raw/raw1:
[root@rhel5 rules.d]# udevtest /class/raw/raw1 | grep mode
udev_node_add: creating device node '/dev/raw/raw1', major = '162', minor = '1', mode = '0660', uid = '0', gid = '6'
Finally, to actually create the raw device(s), use the start_udev command:
[root@rhel5 rules.d]# start_udev
Starting udev: [ OK ]
Check that the raw device(s) have been created:
[root@rhel5 rules.d]# raw -qa
/dev/raw/raw1: bound to major 8, minor 17
[root@rhel5 rules.d]# ls -l /dev/raw
total 0
crw-rw---- 1 root disk 162, 1 Jan 29 02:47 raw1
*
Creating persistent raw devices for multipathed LUNs:
Unfortunately it is not possible to write udev rules for creating raw devices on multipath devices (/dev/dm-*) without manipulating existing udev rules. Modifying existing rules for this purpose could cause unforeseen problems and is not supported by Red Hat Global Support Services.
© ALL RIGHTS RESERVED. Terms of Use Privacy Cookie Preference Center