1BLKDISCARD(8)                System Administration               BLKDISCARD(8)
2
3
4

NAME

6       blkdiscard - discard sectors on a device
7

SYNOPSIS

9       blkdiscard [options] [-o offset] [-l length] device
10

DESCRIPTION

12       blkdiscard is used to discard device sectors. This is useful for
13       solid-state drivers (SSDs) and thinly-provisioned storage. Unlike
14       fstrim(8), this command is used directly on the block device.
15
16       By default, blkdiscard will discard all blocks on the device. Options
17       may be used to modify this behavior based on range or size, as
18       explained below.
19
20       The device argument is the pathname of the block device.
21
22       WARNING: All data in the discarded region on the device will be lost!
23

OPTIONS

25       The offset and length arguments may be followed by the multiplicative
26       suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB,
27       EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning
28       as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for
29       GB, TB, PB, EB, ZB and YB.
30
31       -f, --force
32           Disable all checking. Since v2.36 the block device is open in
33           exclusive mode (O_EXCL) by default to avoid collision with mounted
34           filesystem or another kernel subsystem. The --force option disables
35           the exclusive access mode.
36
37       -o, --offset offset
38           Byte offset into the device from which to start discarding. The
39           provided value must be aligned to the device sector size. The
40           default value is zero.
41
42       -l, --length length
43           The number of bytes to discard (counting from the starting point).
44           The provided value must be aligned to the device sector size. If
45           the specified value extends past the end of the device, blkdiscard
46           will stop at the device size boundary. The default value extends to
47           the end of the device.
48
49       -p, --step length
50           The number of bytes to discard within one iteration. The default is
51           to discard all by one ioctl call.
52
53       -q, --quiet
54           Suppress warning messages.
55
56       -s, --secure
57           Perform a secure discard. A secure discard is the same as a regular
58           discard except that all copies of the discarded blocks that were
59           possibly created by garbage collection must also be erased. This
60           requires support from the device.
61
62       -z, --zeroout
63           Zero-fill rather than discard.
64
65       -v, --verbose
66           Display the aligned values of offset and length. If the --step
67           option is specified, it prints the discard progress every second.
68
69       -h, --help
70           Display help text and exit.
71
72       -V, --version
73           Print version and exit.
74

EXIT STATUS

76       blkdiscard has the following exit status values:
77
78       0
79           success
80
81       1
82           failure; incorrect invocation, permissions or any other generic
83           error
84
85       2
86           failure; since v2.39, the device does not support discard operation
87

AUTHORS

89       Lukas Czerner <lczerner@redhat.com>, Karel Zak <kzak@redhat.com>
90

SEE ALSO

92       fstrim(8)
93

REPORTING BUGS

95       For bug reports, use the issue tracker at
96       https://github.com/util-linux/util-linux/issues.
97

AVAILABILITY

99       The blkdiscard command is part of the util-linux package which can be
100       downloaded from Linux Kernel Archive
101       <https://www.kernel.org/pub/linux/utils/util-linux/>.
102
103
104
105util-linux 2.39.2                 2023-06-14                     BLKDISCARD(8)
Impressum