Linux raw device bare

Source: Internet
Author: User

┌ ── ─ Raw Driver (/dev/raw/rawn)
│ Config_raw_driver:
│ The raw driver permits Block devices to be bound to/dev/raw/rawn.
│ Once bound, I/O against/dev/raw/rawn uses efficient zero-copy I/O.
│ See the raw (8) manpage for more details. │
│ Applications shocould preferably open the device (EG/dev/hda1)
│ With the o_direct flag.
----------------------------------------------------------------
The above is the raw device configuration option in kernel version 3.5.3.

-Before a block device is installed on a node, access to the device is usually accessed as a linear unstructured byte stream,
It is called "raw device )". The file system on the device is not accessible. After installation, the file system on the device
And then access. [1]
 
-Once bound to a block device, a raw device can be opened, read and
Written, just like the block device it is bound to. However, the raw
Device does not behave exactly like the block device. In particle,
Access to the raw device bypasses the kernel's block buffer cache
Entirely: All I/O is done directly to and from the address space of
Process discovery Ming the I/O. If the underlying block device driver can
Support DMA, then no data copying at all is required to complete
I/O.

Because raw I/O involves direct hardware access to a process's memory,
A few extra restrictions must be observed. All I/OS must be correctly
Aligned in memory and on disk: they must start at a sector offset on
Disk, they must be an exact number of sectors long, and the Data Buffer
In virtual memory must also be aligned to a multiple of the Sector
Size. The sector size is 512 bytes for most devices. [2]

-Starting with the Linux 2.6 kernel, raw devices are being phased out in favor
Of o_direct access to block devices.

-Raw device usage
When config_raw_driver is enabled in the kernel.
# Lsmod | grep raw
Raw 3130 0
# Ls/dev/raw/rawctl
/Dev/raw/rawctl

Raw device binding:
Insert USB flash drive
# Fdisk-l
...
/Dev/sdb1 1 983 7343962 B w95 FAT32

Bind
# Raw/dev/raw/raw1/dev/sdb1
/Dev/raw/raw1: bound to major 8, minor 17

View raw device information
# Ls-L/dev/raw/raw1
CrW ------- 1 Root 162, 1 Dec 24/dev/raw/raw1
C indicates that the raw device is mapped to a character device.
# Blockdev -- Report/dev/raw/raw1
RO Ra SSZ bsz startsec Size Device
RW 256 512 512 14687986/dev/raw/raw1

# Cat/dev/raw/raw1

View Io status
# Iostat-x
Linux 3.5.3 (Joseph) 12/24/2012
_ X86_64 _ (2 CPU)

AVG-CPU: % USER % nice % System % iowait % steal % idle
24.76 5.52 1.98 0.31 0.00 67.43

Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-SZ avgqu-SZ await svctm % util
HDC 0.02 0.00 0.00 0.00 0.04 0.00 9.03 0.00 2.38 0.99 0.00
SDA 0.01 4.18 1.59 1.16 31.47 42.37 26.85 0.07 26.10 3.47 0.95

SDB 0.00 0.00 0.02 0.00 0.29 0.00 15.25 0.00 14.22 13.58 0.03

Unbind
# Raw/dev/raw/raw1 0 0
---- Ref ----
[1] Linux kernel source code scenario analysis (I), Mao decao. PG 492
[2] MAN raw

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.