]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/blkdiscard.8
blkdiscard: use O_EXCL, add --force
[thirdparty/util-linux.git] / sys-utils / blkdiscard.8
1 .TH BLKDISCARD 8 "July 2014" "util-linux" "System Administration"
2 .SH NAME
3 blkdiscard \- discard sectors on a device
4 .SH SYNOPSIS
5 .B blkdiscard
6 [options]
7 .RB [ \-o
8 .IR offset ]
9 .RB [ \-l
10 .IR length ]
11 .I device
12 .SH DESCRIPTION
13 .B blkdiscard
14 is used to discard device sectors. This is useful for solid-state
15 drivers (SSDs) and thinly-provisioned storage. Unlike
16 .BR fstrim (8),
17 this command is used directly on the block device.
18 .PP
19 By default,
20 .B blkdiscard
21 will discard all blocks on the device. Options may be used to modify
22 this behavior based on range or size, as explained below.
23 .PP
24 The
25 .I device
26 argument is the pathname of the block device.
27 .PP
28 .B WARNING: All data in the discarded region on the device will be lost!
29 .SH OPTIONS
30 The
31 .I offset
32 and
33 .I length
34 arguments may be followed by the multiplicative suffixes KiB (=1024),
35 MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is
36 optional, e.g., "K" has the same meaning as "KiB") or the suffixes
37 KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
38 .TP
39 .BR \-f , " \-\-force"
40 Disable all checking. Since v2.36 the block device is open in exclusive mode (O_EXCL)
41 by default to avoid collision with mounted filesystem or another kernel subsystem.
42 The force option disables the exclusive access mode.
43 .TP
44 .BR \-o , " \-\-offset \fIoffset"
45 Byte offset into the device from which to start discarding. The provided value
46 will be aligned to the device sector size. The default value is zero.
47 .TP
48 .BR \-l , " \-\-length \fIlength"
49 The number of bytes to discard (counting from the starting point). The provided value
50 will be aligned to the device sector size. If the specified value extends past
51 the end of the device,
52 .B blkdiscard
53 will stop at the device size boundary. The default value extends to the end
54 of the device.
55 .TP
56 .BR \-p , " \-\-step \fIlength"
57 The number of bytes to discard within one iteration. The default is to discard
58 all by one ioctl call.
59 .TP
60 .BR \-s , " \-\-secure"
61 Perform a secure discard. A secure discard is the same as a regular discard
62 except that all copies of the discarded blocks that were possibly created by
63 garbage collection must also be erased. This requires support from the device.
64 .TP
65 .BR \-z , " \-\-zeroout"
66 Zero-fill rather than discard.
67 .TP
68 .BR \-v , " \-\-verbose"
69 Display the aligned values of
70 .I offset
71 and
72 .IR length .
73 If the \fB\-\-step\fR option is specified, it prints the discard progress every second.
74 .TP
75 .BR \-V , " \-\-version"
76 Display version information and exit.
77 .TP
78 .BR \-h , " \-\-help"
79 Display help text and exit.
80 .SH AUTHOR
81 .MT lczerner@redhat.com
82 Lukas Czerner
83 .ME
84 .SH SEE ALSO
85 .BR fstrim (8)
86 .SH AVAILABILITY
87 The blkdiscard command is part of the util-linux package and is available
88 .UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
89 Linux Kernel Archive
90 .UE .