Linux raw device 裸设备
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
┌────────────────────────────────────────────────────────── 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 should preferably open the device (eg /dev/hda1)
│ with the O_DIRECT flag.
----------------------------------------------------------------
上面是在内核版本3.5.3中的RAW设备相关的配置选项。
- 在一个块设备安装到一个节点之前,对该设备的访问通常是作为一个线性的无结构的字节流来访问的,
称为“原始设备(raw device)”。设备上的文件系统是不可访问的。经过安装以后,设备上的文件系统
就以访问了。[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 particular,
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 the
process performing the I/O. If the underlying block device driver can
support DMA, then no data copying at all is required to complete the
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设备使用
在内核配置CONFIG_RAW_DRIVER打开的情况下。
#lsmod | grep raw
raw 3130 0
# ls /dev/raw/rawctl
/dev/raw/rawctl
RAW设备绑定:
插入U盘
#fdisk -l
...
/dev/sdb1 1 983 7343962 b W95 FAT32
绑定
#raw /dev/raw/raw1 /dev/sdb1
/dev/raw/raw1: bound to major 8, minor 17
查看raw设备的信息
#ls -l /dev/raw/raw1
crw------- 1 root root 162, 1 Dec 24 15:23 /dev/raw/raw1
c表明raw设备被映射为了字符设备
# blockdev --report /dev/raw/raw1
RO RA SSZ BSZ StartSec Size Device
rw 256 512 512 14687986 275410944 /dev/raw/raw1
#cat /dev/raw/raw1
查看io状况
#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
解除绑定
#raw /dev/raw/raw1 0 0
----ref ----
[1] Linux 内核源代码情景分析(上),毛德操。pg 492
[2] man raw
│ 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 should preferably open the device (eg /dev/hda1)
│ with the O_DIRECT flag.
----------------------------------------------------------------
上面是在内核版本3.5.3中的RAW设备相关的配置选项。
- 在一个块设备安装到一个节点之前,对该设备的访问通常是作为一个线性的无结构的字节流来访问的,
称为“原始设备(raw device)”。设备上的文件系统是不可访问的。经过安装以后,设备上的文件系统
就以访问了。[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 particular,
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 the
process performing the I/O. If the underlying block device driver can
support DMA, then no data copying at all is required to complete the
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设备使用
在内核配置CONFIG_RAW_DRIVER打开的情况下。
#lsmod | grep raw
raw 3130 0
# ls /dev/raw/rawctl
/dev/raw/rawctl
RAW设备绑定:
插入U盘
#fdisk -l
...
/dev/sdb1 1 983 7343962 b W95 FAT32
绑定
#raw /dev/raw/raw1 /dev/sdb1
/dev/raw/raw1: bound to major 8, minor 17
查看raw设备的信息
#ls -l /dev/raw/raw1
crw------- 1 root root 162, 1 Dec 24 15:23 /dev/raw/raw1
c表明raw设备被映射为了字符设备
# blockdev --report /dev/raw/raw1
RO RA SSZ BSZ StartSec Size Device
rw 256 512 512 14687986 275410944 /dev/raw/raw1
#cat /dev/raw/raw1
查看io状况
#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
解除绑定
#raw /dev/raw/raw1 0 0
----ref ----
[1] Linux 内核源代码情景分析(上),毛德操。pg 492
[2] man raw
GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献9条内容
所有评论(0)