Three ways to map the Linux platform block device to the character device (Raw device) (reprint)

Source: Internet
Author: User

In the build process of the Linux platform Oracle RAC, if you use Asm+raw storage, because ASM does not support block devices and supports character access devices, you need to configure the conversion of block device drive to character device How drive is accessed.
But in the Linux platform, unlike Aix and HP-UX, the default is to provide a block device corresponding to the character device file, we need to manually map the block device as a character device.
Here, we offer three ways to block devices bound to bare devices, these three ways to create a bare device exactly the same way, the difference is that the permissions of the Oracle user is handled differently, it is recommended to use the third way to block device to character device binding

The first way:
Binding a block device to a character device using the Rawdevices service
# vim/etc/sysconfig/rawdevices
/dev/raw/raw1/dev/sdb1
/dev/raw/raw2/dev/sdb2
/dev/raw/raw3/dev/sdb3
/dev/raw/raw4/dev/sdb4
#/etc/init.d/rawdevices Start
or service rawdevices restart
# chkconfig--level 235 rawdevices on
The flags that were successfully opened are:
#/etc/init.d/rawdevices Status
/dev/raw/raw1:bound to Major 8, minor 17
/dev/raw/raw2:bound to Major 8, minor 18
/dev/raw/raw3:bound to Major 8, minor 19
/dev/raw/raw4:bound to Major 8, minor 20
Give the Oracle user the available permissions for the bare device:
# chown ORACLE:OINSTALL/DEV/RAW/RAW1/DEV/RAW/RAW2/DEV/RAW/RAW3/DEV/RAW/RAW4
# ls-l/dev/raw
CRW-------1 Oracle Oinstall 162, 1 Nov 4 00:34/DEV/RAW/RAW1
CRW-------1 Oracle Oinstall 162, 2 Nov 4 00:33/dev/raw/raw2
CRW-------1 Oracle Oinstall 162, 3 Nov 4 00:33/DEV/RAW/RAW3
CRW-------1 Oracle Oinstall 162, 4 Nov 4 00:34/DEV/RAW/RAW4
At this point, the bare device mapping is successful, but there is a problem with the configuration of this approach: these bare devices are created when the Rawdevices service is started, and Rawdevices is running as the root user, so the default user for these bare devices is root:root, so Each time the service is restarted, the permissions of these character devices need to be re-modified to Oracle:oinsall.
You can add a permission modification statement to a raw device in/etc/rc.local to respond to changes in the permissions of the bare device files after rebooting the system. After restarting the service, you need to manually execute the chown command.

The second way:
To address the above, use Mknod to create a file that is accessed in advance by a character, and then bind the file to a block device and set the owner of the file to Oracle, since these mapped character device files are created manually, So the owner of this file does not change because of the service restart:
# MKNOD/DEV/RAW/RAW1 C 162 1
# MKNOD/DEV/RAW/RAW2 C 162 2
# MKNOD/DEV/RAW/RAW3 C 162 3
# MKNOD/DEV/RAW/RAW4 C 162 4
Note that the 162 here cannot be changed, this is the primary device number of the raw device, the following number is the secondary device number of the raw device, this secondary device number can be changed sequentially
# ll/dev/raw/*
crw-r--r--1 root root 162, 1 Nov 4 01:02 RAW1
crw-r--r--1 root root 162, 2 Nov 4 01:02 raw2
crw-r--r--1 root root 162, 3 Nov 4 01:03 raw3
crw-r--r--1 root root 162, 4 Nov 4 01:03 raw4
# chown oracle:oinstall/dev/raw/*
# ll/dev/raw/*
crw-r--r--1 Oracle Oinstall 162, 1 Nov 4 01:02 RAW1
crw-r--r--1 Oracle Oinstall 162, 2 Nov 4 01:02 raw2
crw-r--r--1 Oracle Oinstall 162, 3 Nov 4 01:03 raw3
crw-r--r--1 Oracle Oinstall 162, 4 Nov 4 01:03 raw4
# vim/etc/sysconfig/rawdevices
/dev/raw/raw1/dev/sdb1
/dev/raw/raw2/dev/sdb2
/dev/raw/raw3/dev/sdb3
/dev/raw/raw4/dev/sdb4
# Service Rawdevices Restart
# chkconfig--level 235 rawdevices on


The Third Way:
Permissions to manage devices using Udev
# Vi/etc/udev/rules.d/60-raw.rules
action== "Add", KERN

Three ways to map the Linux platform block device to the character device (Raw device) (reprint)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.