BLKDISCARD(8) System Manager's Manual BLKDISCARD(8)

blkdiscardtool to discard portions of a device or file

blkdiscard [-h] [-l length] [-p chunksize] [-n] [-o firstbyte] [-R] [-s] [-V] [-v] [-z] file

fdiscard [-f firstbyte] [-h] [-l length] [-m chunksize] [-n] [-R] [-s] [-V] [-v] [-z] file

The blkdiscard program can be used to discard portions of storage, and works on either device files directly or upon files inside of a mounted file-system. It provides access to the fdiscard(2) system call, and relies upon the backing device to have support in both the blkdiscard driver and in the hardware itself.

The fdiscard interface defaults to the “no-run” mode and requires the -R option to perform any actions.

Available options:

firstbyte
Set the first byte to be discarded. The default is 0.
Display built-in help.
length
Limit the length to be discarded. The default is the full device or file size, or the rest of the device or file when the start offset has been set.
chunksize
Set the per-operation chunksize. The default is 32 MiB.
Set the “no-run” option, and do not actually call fdiscard(2), secure erase, or write zeroes to the file.
firstbyte
This flag is an alias for the -f flag.
chunksize
This flag is an alias for the -m flag.
Turn off the “no-run mode.”
Use secure erase operation. This requires specific hardware support and is not currently supported.
Display the program version and exit.
Set the verbose flag.
Write zeroes instead of calling fdiscard(2).

To have a dry-run cleaning of any particular file or device:

# blkdiscard -n -v filename
# blkdiscard -n -v /dev/rwd0b

To discard all the blocks on a swap device:

# blkdiscard -v /dev/rwd0b

To discard all but the first 256MiB of a device, using 128MiB increments:

# blkdiscard -v -f 256m -m 128m /dev/rwd0c

To zero out the contents of a file or device:

# blkdiscard -v -z filename
# blkdiscard -v -z /dev/device

fdiscard(2)

The blkdiscard command first appeared linux-util. This implementation was originally called fdiscard-stuff and has been converted to be blkdiscard(8) compatible and appeared in NetBSD 10.0.

The blkdiscard command was written by Matthew R. Green ⟨mrg@eterna23.net⟩.

The secure erase functionality of the -s option is not yet implemented.

January 13, 2024 NetBSD 10.99