1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
'\" t
.\" Title: blkdiscard
.\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.20
.\" Date: 2023-11-21
.\" Manual: System Administration
.\" Source: util-linux 2.39.3
.\" Language: English
.\"
.TH "BLKDISCARD" "8" "2023-11-21" "util\-linux 2.39.3" "System Administration"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
.nh
.ad l
.de URL
\fI\\$2\fP <\\$1>\\$3
..
.als MTO URL
.if \n[.g] \{\
. mso www.tmac
. am URL
. ad l
. .
. am MTO
. ad l
. .
. LINKSTYLE blue R < >
.\}
.SH "NAME"
blkdiscard \- discard sectors on a device
.SH "SYNOPSIS"
.sp
\fBblkdiscard\fP [options] [\fB\-o\fP \fIoffset\fP] [\fB\-l\fP \fIlength\fP] \fIdevice\fP
.SH "DESCRIPTION"
.sp
\fBblkdiscard\fP is used to discard device sectors. This is useful for solid\-state drivers (SSDs) and thinly\-provisioned storage. Unlike \fBfstrim\fP(8), this command is used directly on the block device.
.sp
By default, \fBblkdiscard\fP will discard all blocks on the device. Options may be used to modify this behavior based on range or size, as explained below.
.sp
The \fIdevice\fP argument is the pathname of the block device.
.sp
\fBWARNING: All data in the discarded region on the device will be lost!\fP
.SH "OPTIONS"
.sp
The \fIoffset\fP and \fIlength\fP arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
.sp
\fB\-f\fP, \fB\-\-force\fP
.RS 4
Disable all checking. Since v2.36 the block device is open in exclusive mode (\fBO_EXCL\fP) by default to avoid collision with mounted filesystem or another kernel subsystem. The \fB\-\-force\fP option disables the exclusive access mode.
.RE
.sp
\fB\-o\fP, \fB\-\-offset\fP \fIoffset\fP
.RS 4
Byte offset into the device from which to start discarding. The provided value must be aligned to the device sector size. The default value is zero.
.RE
.sp
\fB\-l\fP, \fB\-\-length\fP \fIlength\fP
.RS 4
The number of bytes to discard (counting from the starting point). The provided value must be aligned to the device sector size. If the specified value extends past the end of the device, \fBblkdiscard\fP will stop at the device size boundary. The default value extends to the end of the device.
.RE
.sp
\fB\-p\fP, \fB\-\-step\fP \fIlength\fP
.RS 4
The number of bytes to discard within one iteration. The default is to discard all by one ioctl call.
.RE
.sp
\fB\-q\fP, \fB\-\-quiet\fP
.RS 4
Suppress warning messages.
.RE
.sp
\fB\-s\fP, \fB\-\-secure\fP
.RS 4
Perform a secure discard. A secure discard is the same as a regular discard except that all copies of the discarded blocks that were possibly created by garbage collection must also be erased. This requires support from the device.
.RE
.sp
\fB\-z\fP, \fB\-\-zeroout\fP
.RS 4
Zero\-fill rather than discard.
.RE
.sp
\fB\-v\fP, \fB\-\-verbose\fP
.RS 4
Display the aligned values of \fIoffset\fP and \fIlength\fP. If the \fB\-\-step\fP option is specified, it prints the discard progress every second.
.RE
.sp
\fB\-h\fP, \fB\-\-help\fP
.RS 4
Display help text and exit.
.RE
.sp
\fB\-V\fP, \fB\-\-version\fP
.RS 4
Print version and exit.
.RE
.SH "EXIT STATUS"
.sp
\fBblkdiscard\fP has the following exit status values:
.sp
\fB0\fP
.RS 4
success
.RE
.sp
\fB1\fP
.RS 4
failure; incorrect invocation, permissions or any other generic error
.RE
.sp
\fB2\fP
.RS 4
failure; since v2.39, the device does not support discard operation
.RE
.SH "AUTHORS"
.sp
.MTO "lczerner\(atredhat.com" "Lukas Czerner" ","
.MTO "kzak\(atredhat.com" "Karel Zak" ""
.SH "SEE ALSO"
.sp
\fBfstrim\fP(8)
.SH "REPORTING BUGS"
.sp
For bug reports, use the issue tracker at \c
.URL "https://github.com/util\-linux/util\-linux/issues" "" "."
.SH "AVAILABILITY"
.sp
The \fBblkdiscard\fP command is part of the util\-linux package which can be downloaded from \c
.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."
|