]> git.ipfire.org Git - thirdparty/util-linux.git/blob - disk-utils/raw.8
Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
[thirdparty/util-linux.git] / disk-utils / raw.8
1 .TH RAW 8 "August 1999" "util-linux" "System Administration"
2 .SH NAME
3 raw \- bind a Linux raw character device
4 .SH SYNOPSIS
5 .B raw
6 .I /dev/raw/raw<N> <major> <minor>
7 .PP
8 .B raw
9 .I /dev/raw/raw<N> /dev/<blockdev>
10 .PP
11 .B raw \-q
12 .I /dev/raw/raw<N>
13 .PP
14 .B raw \-qa
15 .SH DESCRIPTION
16 .B raw
17 is used to bind a Linux raw character device to a block device. Any
18 block device may be used: at the time of binding, the device driver does
19 not even have to be accessible (it may be loaded on demand as a kernel
20 module later).
21 .PP
22 .B raw
23 is used in two modes: it either sets raw device bindings, or it queries
24 existing bindings. When setting a raw device,
25 .I /dev/raw/raw<N>
26 is the device name of an existing raw device node in the filesystem.
27 The block device to which it is to be bound can be specified either in
28 terms of its
29 .I major
30 and
31 .I minor
32 device numbers, or as a path name
33 .I /dev/<blockdev>
34 to an existing block device file.
35 .PP
36 The bindings already in existence can be queried with the
37 .I \-q
38 option, which is used either with a raw device filename to query that one
39 device, or with the
40 .I \-a
41 option to query all bound raw devices.
42 .PP
43 Unbinding can be done by specifying major and minor 0.
44 .PP
45 Once bound to a block device, a raw device can be opened, read and
46 written, just like the block device it is bound to. However, the raw
47 device does not behave exactly like the block device. In particular,
48 access to the raw device bypasses the kernel's block buffer cache
49 entirely: all I/O is done directly to and from the address space of the
50 process performing the I/O. If the underlying block device driver can
51 support DMA, then no data copying at all is required to complete the
52 I/O.
53 .PP
54 Because raw I/O involves direct hardware access to a process's memory, a
55 few extra restrictions must be observed. All I/Os must be correctly
56 aligned in memory and on disk: they must start at a sector offset on
57 disk, they must be an exact number of sectors long, and the data buffer
58 in virtual memory must also be aligned to a multiple of the sector
59 size. The sector size is 512 bytes for most devices.
60 .SH OPTIONS
61 .TP
62 \fB\-q\fR, \fB\-\-query\fR
63 Set query mode.
64 .B raw
65 will query an existing binding instead of setting a new one.
66 .TP
67 \fB\-a\fR, \fB\-\-all\fR
68 With
69 .B \-q
70 , specify that all bound raw devices should be queried.
71 .TP
72 \fB\-h\fR, \fB\-\-help\fR
73 Display help text and exit.
74 .TP
75 \fB\-V\fR, \fB\-\-version\fR
76 Display version information and exit.
77
78 .SH NOTES
79 Rather than using raw devices applications should prefer
80 .BR open (2)
81 devices, such as /dev/sda1, with the O_DIRECT flag.
82 .SH BUGS
83 The Linux
84 .BR dd (1)
85 command should be used without the \fBbs=\fR option, or the blocksize
86 needs to be a multiple of the sector size of the device (512 bytes usually),
87 otherwise it will fail with "Invalid Argument" messages (EINVAL).
88
89 .PP
90 Raw I/O devices do not maintain cache coherency with the Linux block
91 device buffer cache. If you use raw I/O to overwrite data already in
92 the buffer cache, the buffer cache will no longer correspond to the
93 contents of the actual storage device underneath. This is deliberate,
94 but is regarded either a bug or a feature depending on who you ask!
95 .SH AUTHORS
96 Stephen Tweedie (sct@redhat.com)
97 .SH AVAILABILITY
98 The raw command is part of the util-linux package and is available from
99 https://www.kernel.org/pub/linux/utils/util-linux/.