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