aboutsummaryrefslogtreecommitdiff
path: root/share/man/man4/geom_zero.4
blob: 82e74618515f1d7a078cc5a840d5002438afdcc3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
.\"
.\" Copyright (c) 2019 Greg White <gkwhite@gmail.com>. All rights reserved.
.\" Copyright (c) 2025 Mateusz Piotrowski <0mp@FreeBSD.org>
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.Dd November 9, 2025
.Dt GEOM_ZERO 4
.Os
.Sh NAME
.Nm gzero ,
.Nm geom_zero
.Nd GEOM-based zero disk/block device
.Sh SYNOPSIS
.Cd "options GEOM_ZERO"
.Pp
In
.Xr loader.conf 5
or
.Xr sysctl.conf 5 :
.Cd kern.geom.zero.byte
.Cd kern.geom.zero.clear
.Sh DESCRIPTION
.Nm
is a
.Xr GEOM 4
device simulating a one-exabyte disk.
It throws away any data written to it,
and returns the value of
.Va kern.geom.zero.byte
for every byte read from it.
.Pp
.Nm
differs from
.Xr zero 4 ,
which is a regular character device and has an infinite length,
while
.Pa /dev/gzero
is a
.Xr GEOM 4
provider of large, but limited, size.
.Pp
Consult
.Xr geom 8
for instructions on how to use the supported commands of the
.Xr GEOM 4
.Nm ZERO
class.
.Pp
.Nm
is useful for benchmarking performance of GEOM and GEOM classes
where compression of the data does not affect the results
.Po blocks from
.Pa /dev/gzero
compress exceptionally well
.Pc .
Examples of such benchmarks include
comparing the speed of two disk encryption algorithms and
comparing a hardware versus software implementation
of a single encryption algorithm.
.Sh MIB VARIABLES
The following variables are available as both
.Xr sysctl 8
variables and
.Xr loader 8
tunables:
.Bl -tag -width "kern.geom.zero.clear"
.It Va kern.geom.zero.byte
This variable sets the fill byte of the
.Nm
device.
Default:
.Ql 0 .
.It Va kern.geom.zero.clear
This variable controls the clearing of the read data buffer.
If set to
.Ql 0 ,
.Nm
will not copy any data into the read data buffers
and just return the read data buffers as they are without modifying them.
In particular, it will not fill the read buffer with the value of
.Va kern.geom.zero.byte .
This is useful for read benchmarking to reduce the measurement noise
caused by extra memory initialization.
Default:
.Ql 1 .
.El
.Sh FILES
.Bl -tag -width /dev/gzero
.It Pa /dev/gzero
The
.Nm
device.
.El
.Sh EXAMPLES
Create the
.Pa /dev/gzero
device by loading the
.Nm geom_zero
kernel module:
.Bd -literal -offset indent
# geom zero load
.Ed
.Pp
Show information about the
.Nm
device:
.Bd -literal -offset indent
# geom zero list
Geom name: gzero
Providers:
1. Name: gzero
   Mediasize: 1152921504606846976 (1.0E)
   Sectorsize: 512
   Mode: r0w0egzero0
.Ed
.Pp
Set the fill byte of the
.Nm
device to 70
.Po decimal for letter
.Dq F
in
.Xr ascii 7
.Pc :
.Bd -literal -offset indent
# sysctl kern.geom.zero.byte=70
kern.geom.zero.byte: 0 -> 70
# head -c 1 /dev/gzero
F
.Ed
.Pp
Benchmark read and write throughput of
.Xr geli 8 Ap s
default encryption algorithm with a 4-KiB sector size:
.Bd -literal -offset indent
# geom zero load
# geli onetime -s 4096 gzero
# sysctl kern.geom.zero.clear=0
# dd if=/dev/gzero.eli of=/dev/zero bs=4k count=$((1024 * 256))
262144+0 records in
262144+0 records out
1073741824 bytes transferred in 1.258195 secs (853398307 bytes/sec)
# dd if=/dev/zero of=/dev/gzero.eli bs=4k count=$((1024 * 256))
262144+0 records in
262144+0 records out
1073741824 bytes transferred in 1.663118 secs (645619658 bytes/sec)
.Ed
.Sh SEE ALSO
.Xr GEOM 4 ,
.Xr zero 4 ,
.Xr geom 8 ,
.Xr sysctl 8 ,
.Xr bio 9
.Sh HISTORY
A
.Nm
device first appeared in
.Fx 6 .
.Sh AUTHORS
.An -nosplit
The
.Nm
device was written by
.An Paweł Jakub Dawidek Aq Mt pjd@FreeBSD.org .
.Pp
The
.Nm
manual page was originally written by
.An Greg White Aq Mt gkwhite@gmail.com
and rewritten by
.An Mateusz Piotrowski Aq Mt 0mp@FreeBSD.org
before landing in
.Fx .