GEOM_ZERO(4)

NAME
gzero, geom_zero - GEOM-based zero disk/block device

SYNOPSIS
options GEOM_ZERO

In loader.conf(5) or sysctl.conf(5):
kern.geom.zero.byte
kern.geom.zero.clear

DESCRIPTION
gzero is a GEOM(4) device simulating a one-exabyte disk. It throws away any data written to it, and returns the value of kern.geom.zero.byte for every byte read from it.

gzero differs from zero(4), which is a regular character device and has an infinite length, while /dev/gzero is a GEOM(4) provider of large, but limited, size.

Consult geom(8) for instructions on how to use the supported commands of the GEOM(4) ZERO class.

gzero is useful for benchmarking performance of GEOM and GEOM classes where compression of the data does not affect the results (blocks from /dev/gzero compress exceptionally well). 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.

MIB VARIABLES
The following variables are available as both sysctl(8) variables and loader(8) tunables:

kern.geom.zero.byte
    This variable sets the fill byte of the gzero device. Default: ‘0’.

kern.geom.zero.clear
    This variable controls the clearing of the read data buffer. If set to ‘0’, gzero 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 kern.geom.zero.byte. This is useful for read benchmarking to reduce the measurement noise caused by extra memory initialization. Default: ‘1’.

FILES

/dev/gzero
    The gzero device.

EXAMPLES
Create the /dev/gzero device by loading the geom_zero kernel module:

    # geom zero load

Show information about the gzero device:

    # geom zero list
    Geom name: gzero
    Providers:
    1. Name: gzero
       Mediasize: 1152921504606846976 (1.0E)
       Sectorsize: 512
       Mode: r0w0egzero0

Set the fill byte of the gzero device to 70 (decimal for letter “F” in ascii(7)):

    # sysctl kern.geom.zero.byte=70
    kern.geom.zero.byte: 0 -> 70
    # head -c 1 /dev/gzero
    F

Benchmark read and write throughput of geli(8)'s default encryption algorithm with a 4-KiB sector size:

    # 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)

SEE ALSO
GEOM(4), zero(4), geom(8), sysctl(8), bio(9)

HISTORY
A gzero device first appeared in FreeBSD 6.

AUTHORS
-nosplit The gzero device was written by Paweł Jakub Dawidek <pjd@FreeBSD.org>.

The gzero manual page was originally written by Greg White <gkwhite@gmail.com> and rewritten by Mateusz Piotrowski <0mp@FreeBSD.org> before landing in FreeBSD.