1. 创建分区
[root@ www.linuxidc.com ~]# fdisk /dev/sda
Command (m for help): p
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3916 31455238+ 83 Linux
/dev/sda2 3917 4438 4192965 82 Linux swap / Solaris
/dev/sda3 4439 4960 4192965 83 Linux
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
First cylinder (4961-5221, default 4961):
Last cylinder or +size or +sizeM or +sizeK (4961-5221, default 5221): +20m
Command (m for help): p
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3916 31455238+ 83 Linux
/dev/sda2 3917 4438 4192965 82 Linux swap / Solaris
/dev/sda3 4439 4960 4192965 83 Linux
/dev/sda4 4961 4963 24097+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
Segmentation fault
2. 创建裸设备
[root@ www.linuxidc.com ~]# raw /dev/raw/raw1 /dev/sda4
/dev/raw/raw1: bound to major 8, minor 4
3. 使用udev自动创建裸设备
[root@ www.linuxidc.com ~]# vi /etc/udev/rules.d/60-raw.rules
# Enter raw device bindings here.
#
# An example would 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.
ACTION==”add”, KERNEL==”sda4″, RUN+=”/bin/raw /dev/raw/raw1 %N”
测试一下
reboot
[root@ www.linuxidc.com ~]# ll /dev/raw
total 0
crw——- 1 root root 162, 1 Jun 6 11:09 raw1
更多RedHat相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10