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