Configure raw in RedHat5

Source: Internet
Author: User
In versions earlier than RedHat5, the system configures the raw control file through/etc/sysconfig/rawdevices and manages the startup and shutdown of raw devices through/etc/init. d/rawdevices. After RedHat5, the original raw device interface has been canceled, and RedHat5 is configured through udev rules. To configure, edit the/etc/udev/rules. d/60-raw.rules file. The following is

In versions earlier than RedHat 5, the system configures the raw control file through/etc/sysconfig/rawdevices and manages the startup and shutdown of raw devices through/etc/init. d/rawdevices. After RedHat 5, the original raw device interface has been canceled, and RedHat 5 is configured through udev rules. To configure, edit the/etc/udev/rules. d/60-raw.rules file.

The following describes how to add a raw device.

1. Add a hard disk to the virtual machine. We only do the test, so the score is 10 MB.

2. Start our Vm and check the disk status after connecting it.

[Root @ CentOS ~] # Fdisk-l

Disk/dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/sda1*201 1958 14121135 83 Linux

/Dev/sda2 1 200 1606468 + 82 Linux swap/Solaris

Partition table entries are not in disk order

Disk/dev/sdb: 10 MB, 10485760 bytes

64 heads, 32 sectors/track, 10 cylinders

Units = cylinders of 2048*512 = 1048576 bytes

Disk/dev/sdb doesn' t contain a valid partition table

The/dev/sdb is not formatted because it is a newly added hard disk.

3. Format/dev/sdb

[Root @ centos ~] # Fdisk/dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

Until you decide to write them. After that, of course, the previous

Content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w (rite)

Command (m for help): n

Command action

E extended

P primary partition (1-4)

P

Partition number (1-4): 1

First cylinder (1-10, default 1 ):

Using default value 1

Last cylinder or + size or + sizeM or + sizeK (1-10, default 10 ):

Using default value 10

Command (m for help): w

The partition table has been altered!

Calling ioctl () to re-read partition table.

Syncing disks.

View the formatted Hard Disk:

[Root @ centos ~] # Fdisk-l

Disk/dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/sda1*201 1958 14121135 83 Linux

/Dev/sda2 1 200 1606468 + 82 Linux swap/Solaris

Partition table entries are not in disk order

Disk/dev/sdb: 10 MB, 10485760 bytes

64 heads, 32 sectors/track, 10 cylinders

Units = cylinders of 2048*512 = 1048576 bytes

Device Boot Start End Blocks Id System

/Dev/sdb1 1 10 10224 83 Linux

[Root @ centos ~] #

4. Modify the/etc/udev/rules. d/60-raw.rules File

[Root @ centos ~] # More/etc/udev/rules. d/60-raw.rules

# Enter raw device bindings here.

#

# An example wocould be:

# ACTION = "add", KERNEL = "sda", RUN + = "/bin/raw/dev/raw/raw1% N"

# To bind/dev/raw/raw1 to/dev/sda, or

# ACTION = "add", ENV {MAJOR} = "8", ENV {MINOR} = "1 ", RUN + = "/bin/raw/dev/raw/raw2% M % m"

# To bind/dev/raw/raw2 to the device with major 8, minor 1.

Device Name:

ACTION = "add", KERNEL ="", RUN + ="/bin/raw/dev/raw/rawX % N"

Primary/secondary number:

ACTION = "add", ENV {MAJOR} = "A", ENV {MINOR} = "B ", RUN + = "/bin/raw/dev/raw/rawX % M % m"

Replace with the name of the device you want to bind(For example,/dev/sda1 ). "A" and "B" are the device's primary/secondary numbers, and X is the raw device number used by the system. The primary and secondary numbers are optional. If this parameter is not specified, the default value starts from,

For example:/dev/raw/raw1: bound to major 1, minor 1

Now that we know/dev/sdb1 to raw1, we can add the following content to the/etc/udev/rules. d/60-raw.rules file:

ACTION = "add", KERNEL = "/dev/sdb1", RUN + = "/bin/raw/dev/raw/raw1% N"

Related Article

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.