]> git.ipfire.org Git - thirdparty/util-linux.git/blame - disk-utils/raw.8
col: use size_t when dealing with numbers that buffer sizes
[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
8be2cc81 37.B \-q
449a215f 38option, which is used either with a raw device filename to query that one
930f40e3 39device, or with the
8be2cc81 40.B \-a
eb63b9b8
KZ
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
8be2cc81
MK
69.BR \-q ,
70specify 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)
8be2cc81
MK
81devices, such as
82.IR /dev/sda1 ,
83with the
84.B O_DIRECT
85flag.
eb63b9b8 86.SH BUGS
69616d88 87The Linux
449a215f
BS
88.BR dd (1)
89command should be used without the \fBbs=\fR option, or the blocksize
90needs to be a multiple of the sector size of the device (512 bytes usually),
91otherwise it will fail with "Invalid Argument" messages (EINVAL).
eb63b9b8
KZ
92.PP
93Raw I/O devices do not maintain cache coherency with the Linux block
94device buffer cache. If you use raw I/O to overwrite data already in
95the buffer cache, the buffer cache will no longer correspond to the
96contents of the actual storage device underneath. This is deliberate,
8be2cc81 97but is regarded as either a bug or a feature, depending on who you ask!
a8d0d330 98.SH AUTHORS
eb63b9b8 99Stephen Tweedie (sct@redhat.com)
86d62711 100.SH AVAILABILITY
601d12fb 101The raw command is part of the util-linux package and is available from
d673b74e 102https://www.kernel.org/pub/linux/utils/util-linux/.