| 1 | '\" t
|
|---|
| 2 | .\" Title: raw
|
|---|
| 3 | .\" Author: [see the "AUTHORS" section]
|
|---|
| 4 | .\" Generator: DocBook XSL-NS Stylesheets vsnapshot <http://docbook.sf.net/>
|
|---|
| 5 | .\" Date: 01/25/2022
|
|---|
| 6 | .\" Manual: System Administration
|
|---|
| 7 | .\" Source: [FIXME: source]
|
|---|
| 8 | .\" Language: English
|
|---|
| 9 | .\"
|
|---|
| 10 | .TH "RAW" "8" "01/25/2022" "[FIXME: source]" "System Administration"
|
|---|
| 11 | .\" -----------------------------------------------------------------
|
|---|
| 12 | .\" * Define some portability stuff
|
|---|
| 13 | .\" -----------------------------------------------------------------
|
|---|
| 14 | .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|---|
| 15 | .\" http://bugs.debian.org/507673
|
|---|
| 16 | .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
|---|
| 17 | .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|---|
| 18 | .ie \n(.g .ds Aq \(aq
|
|---|
| 19 | .el .ds Aq '
|
|---|
| 20 | .\" -----------------------------------------------------------------
|
|---|
| 21 | .\" * set default formatting
|
|---|
| 22 | .\" -----------------------------------------------------------------
|
|---|
| 23 | .\" disable hyphenation
|
|---|
| 24 | .nh
|
|---|
| 25 | .\" disable justification (adjust text to left margin only)
|
|---|
| 26 | .ad l
|
|---|
| 27 | .\" -----------------------------------------------------------------
|
|---|
| 28 | .\" * MAIN CONTENT STARTS HERE *
|
|---|
| 29 | .\" -----------------------------------------------------------------
|
|---|
| 30 | .SH "NAME"
|
|---|
| 31 | raw \- bind a Linux raw character device
|
|---|
| 32 | .SH "SYNOPSIS"
|
|---|
| 33 | .sp
|
|---|
| 34 | \fBraw\fR \fI/dev/raw/raw<N>\fR \fI<major>\fR \fI<minor>\fR
|
|---|
| 35 | .sp
|
|---|
| 36 | \fBraw\fR \fI/dev/raw/raw<N>\fR \fI/dev/<blockdev>\fR
|
|---|
| 37 | .sp
|
|---|
| 38 | \fBraw\fR \fB\-q\fR \fI/dev/raw/raw<N>\fR
|
|---|
| 39 | .sp
|
|---|
| 40 | \fBraw\fR \fB\-qa\fR
|
|---|
| 41 | .SH "DESCRIPTION"
|
|---|
| 42 | .sp
|
|---|
| 43 | \fBraw\fR is used to bind a Linux raw character device to a block device\&. Any block device may be used: at the time of binding, the device driver does not even have to be accessible (it may be loaded on demand as a kernel module later)\&.
|
|---|
| 44 | .sp
|
|---|
| 45 | \fBraw\fR is used in two modes: it either sets raw device bindings, or it queries existing bindings\&. When setting a raw device, \fI/dev/raw/raw<N>\fR is the device name of an existing raw device node in the filesystem\&. The block device to which it is to be bound can be specified either in terms of its \fImajor\fR and \fIminor\fR device numbers, or as a path name \fI/dev/<blockdev>\fR to an existing block device file\&.
|
|---|
| 46 | .sp
|
|---|
| 47 | The bindings already in existence can be queried with the \fB\-q\fR option, which is used either with a raw device filename to query that one device, or with the \fB\-a\fR option to query all bound raw devices\&.
|
|---|
| 48 | .sp
|
|---|
| 49 | Unbinding can be done by specifying major and minor 0\&.
|
|---|
| 50 | .sp
|
|---|
| 51 | 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\(cqs 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\&.
|
|---|
| 52 | .sp
|
|---|
| 53 | Because raw I/O involves direct hardware access to a process\(cqs 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\&.
|
|---|
| 54 | .SH "OPTIONS"
|
|---|
| 55 | .PP
|
|---|
| 56 | \fB\-q\fR, \fB\-\-query\fR
|
|---|
| 57 | .RS 4
|
|---|
| 58 | Set query mode\&.
|
|---|
| 59 | \fBraw\fR
|
|---|
| 60 | will query an existing binding instead of setting a new one\&.
|
|---|
| 61 | .RE
|
|---|
| 62 | .PP
|
|---|
| 63 | \fB\-a\fR, \fB\-\-all\fR
|
|---|
| 64 | .RS 4
|
|---|
| 65 | With
|
|---|
| 66 | \fB\-q\fR, specify that all bound raw devices should be queried\&.
|
|---|
| 67 | .RE
|
|---|
| 68 | .PP
|
|---|
| 69 | \fB\-h\fR, \fB\-\-help\fR
|
|---|
| 70 | .RS 4
|
|---|
| 71 | Display help text and exit\&.
|
|---|
| 72 | .RE
|
|---|
| 73 | .PP
|
|---|
| 74 | \fB\-V\fR, \fB\-\-version\fR
|
|---|
| 75 | .RS 4
|
|---|
| 76 | Display version information and exit\&.
|
|---|
| 77 | .RE
|
|---|
| 78 | .SH "NOTES"
|
|---|
| 79 | .sp
|
|---|
| 80 | Rather than using raw devices applications should prefer open2 devices, such as \fI/dev/sda1\fR, with the \fBO_DIRECT\fR flag\&.
|
|---|
| 81 | .SH "BUGS"
|
|---|
| 82 | .sp
|
|---|
| 83 | The Linux \fBdd\fR(1) command should be used without the \fBbs=\fR option, or the blocksize needs to be a multiple of the sector size of the device (512 bytes usually), otherwise it will fail with "Invalid Argument" messages (\fBEINVAL\fR)\&.
|
|---|
| 84 | .sp
|
|---|
| 85 | Raw I/O devices do not maintain cache coherency with the Linux block device buffer cache\&. If you use raw I/O to overwrite data already in the buffer cache, the buffer cache will no longer correspond to the contents of the actual storage device underneath\&. This is deliberate, but is regarded as either a bug or a feature, depending on who you ask!
|
|---|
| 86 | .SH "AUTHORS"
|
|---|
| 87 | .sp
|
|---|
| 88 | \m[blue]\fBStephen Tweedie\fR\m[]\&\s-2\u[1]\d\s+2
|
|---|
| 89 | .SH "NOTES"
|
|---|
| 90 | .IP " 1." 4
|
|---|
| 91 | Stephen Tweedie
|
|---|
| 92 | .RS 4
|
|---|
| 93 | \%mailto:sct@redhat.com
|
|---|
| 94 | .RE
|
|---|