VERITYSETUP(8) | Maintenance Commands | VERITYSETUP(8) |
NAME¶
veritysetup - utility for configuring and managing dm-verity devices
SYNOPSIS¶
veritysetup <action> [<options>] <action args>
DESCRIPTION¶
Veritysetup is a utility for configuring and managing kernel dm-verity devices.
Kernel device-mapper dm-verity target provides read-only transparent data integrity protection of block devices.
When you configure the dm-verity device, veritysetup creates a new mapping that applications can access like any regular storage device. The kernel performs the verification transparently by comparing each block against pre-computed cryptographic hashes. The verification uses a Merkle tree and happens transparently at the kernel level without affecting applications.
Verity devices can be activated during boot through veritytab(5), which is part of systemd(1).
BASIC ACTIONS¶
Veritysetup supports these operations:
FORMAT¶
format <data_device> <hash_device>
Calculates and permanently stores hash verification data for the data_device. Hash area can be located on the same device after data, if specified by --hash-offset option.
You need to provide the root hash string for device verification or activation. Root hash must be trusted.
The data or hash device argument can be a block device or a file image. If the hash device path doesn’t exist, it will be created as a file.
<options> can be [--hash, --no-superblock, --format, --data-block-size, --hash-block-size, --data-blocks, --hash-offset, --salt, --uuid, --root-hash-file].
If option --root-hash-file is used, the root hash is stored in hex-encoded text format in <path>.
OPEN¶
open <data_device> <name> <hash_device>
<root_hash>
open <data_device> <name> <hash_device> --root-hash-file
<path>
create <name> <data_device> <hash_device> <root_hash>
(OBSOLETE syntax)
Creates a mapping with <name> backed by device <data_device> and using <hash_device> for in-kernel verification.
The <root_hash> is a hexadecimal string.
<options> can be [--hash-offset, --no-superblock, --ignore-corruption or --restart-on-corruption, --panic-on-corruption, --ignore-zero-blocks, --check-at-most-once, --root-hash-signature, --root-hash-file, --use-tasklets, --shared].
If option --root-hash-file is used, the root hash is read from <path> instead of the command line parameter. Expects hex-encoded text, without a terminating newline.
If --no-superblock is used, you must use the same options as in the initial format operation.
VERIFY¶
verify <data_device> <hash_device>
<root_hash>
verify <data_device> <hash_device> --root-hash-file
<path>
Verifies data on data_device using hash blocks stored on hash_device.
This command performs userspace verification; no kernel device is created.
The <root_hash> is a hexadecimal string.
If option --root-hash-file is used, the root hash is read from <path> instead of the command line parameter. Expects hex-encoded text, without a terminating newline.
<options> can be [--hash-offset, --no-superblock, --root-hash-file].
If --no-superblock is used, you must use the same options as in the initial format operation.
CLOSE¶
close <name>
remove <name> (OBSOLETE syntax)
Removes existing mapping <name>.
<options> can be [--deferred] or [--cancel-deferred].
STATUS¶
status <name>
Reports status for the active verity mapping <name>.
DUMP¶
dump <hash_device>
Report parameters of the verity device from the on-disk stored superblock.
<options> can be [--hash-offset].
OPTIONS¶
--batch-mode, -q
--cancel-deferred
--check-at-most-once
WARNING: It provides a reduced level of security because only offline tampering of the data device’s content will be detected, not online tampering.
--data-blocks blocks
--data-block-size bytes
--debug
--deferred
--error-as-corruption
--fec-device device
The FEC device argument can be a block device or a file image. For format, if the FEC device path doesn’t exist, it will be created as a file.
Block sizes for data and hash devices must match. Also, if the verity data_device is encrypted, the fec_device should be too.
FEC calculation covers data, hash area, and optional foreign metadata stored on the same device as the hash tree (additional space after the hash area). The size of this optional additional area protected by FEC is calculated from image sizes, so you must use the same images for activation.
If the hash device is in a separate image, metadata covers the entire image after the hash area.
The metadata ends on the FEC area offset if the hash and FEC device are in the image.
--fec-offset bytes
--fec-roots number
--format number
--hash hash
--hash-block-size bytes
--hash-offset bytes
--help, -?
--ignore-corruption, --restart-on-corruption, --panic-on-corruption
Without these options, the kernel fails the I/O operation with an I/O error. With --ignore-corruption option, the corruption is only logged. With --restart-on-corruption or --panic-on-corruption, the kernel is restarted (panicked) immediately. (You have to provide a way to avoid restart loops.)
Use these options only for very specific cases.
--ignore-zero-blocks
Use this option only in very specific cases.
--no-superblock
--root-hash-file file*
--root-hash-signature file*
--salt=hex string
--shared
--usage
--use-tasklets
--uuid UUID
The UUID must be provided in standard UUID format, e.g., 12345678-1234-1234-1234-123456789abc.
--verbose, -v
--version, -V
RETURN CODES¶
Veritysetup returns 0 on success and a non-zero value on error.
Error codes are: 1 wrong parameters, 2 no permission, 3 out of memory, 4 wrong device specified, 5 device already exists or device is busy.
EXAMPLES¶
veritysetup --data-blocks=256 format <data_device> <hash_device>
Calculates and stores verification data on hash_device for the first 256 blocks (of block size). If hash_device does not exist, it is created (as a file image).
veritysetup format --root-hash-file <path> <data_device> <hash_device>
Calculates and stores verification data on hash_device for the whole data_device, and stores the root hash as hex-encoded text in <path>.
veritysetup --data-blocks=256 --hash-offset=1052672 format <device> <device>
Verification data (hashes) is stored on the same device as data (starting at hash-offset). Hash offset must be greater than the number of blocks in the data area.
veritysetup --data-blocks=256 --hash-offset=1052672 create test-device <device> <device> <root_hash>
Activates the verity device named test-device. Options --data-blocks and --hash-offset are the same as in the format command. The <root_hash> was calculated in the format command.
veritysetup --data-blocks=256 --hash-offset=1052672 verify <data_device> <hash_device> <root_hash>
Verifies device without activation (in userspace).
veritysetup --data-blocks=256 --hash-offset=1052672 --root-hash-file <path> verify <data_device> <hash_device>
Verifies device without activation (in userspace). Root hash is passed via file rather than inline.
veritysetup --fec-device=<fec_device> --fec-roots=10 format <data_device> <hash_device>
Calculates and stores verification and encoding data for the data_device.
DM-VERITY ON-DISK SPECIFICATION¶
The on-disk format specification is available on the DMVerity <https://gitlab.com/cryptsetup/cryptsetup/wikis/DMVerity> page.
AUTHORS¶
The first implementation of veritysetup was written by Chrome OS authors.
This version is based on verification code written by Mikulas Patocka <mpatocka@redhat.com> and rewritten for libcryptsetup by Milan Broz <gmazyland@gmail.com>.
REPORTING BUGS¶
Report bugs at cryptsetup mailing list <cryptsetup@lists.linux.dev> or in Issues project section <https://gitlab.com/cryptsetup/cryptsetup/-/issues/new>.
Please attach the output of the failed command with --debug option added.
SEE ALSO¶
Cryptsetup FAQ <https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions>
CRYPTSETUP¶
Part of cryptsetup project <https://gitlab.com/cryptsetup/cryptsetup/>.
2025-08-19 | veritysetup 2.8.1 |