LinuxCommandLibrary

blkdiscard

Discard sectors on a storage device

TLDR

Discard all sectors

$ blkdiscard /dev/device
copy
Secure discard
$ blkdiscard -s /dev/device
copy
Discard first 100 MB
$ blkdiscard -l 100MB /dev/device
copy

SYNOPSIS

blkdiscard [OPTIONS] device

DESCRIPTION

blkdiscard sends TRIM/DISCARD commands to a storage device to mark sectors as unused. This is particularly useful for SSDs as it allows the drive to optimize its internal storage and improve write performance.

PARAMETERS

-l, --length size

Number of bytes to discard from the offset
-o, --offset offset
Byte offset into the device to start discarding
-s, --secure
Perform a secure discard (hardware must support this)
-z, --zeroout
Zero-fill rather than discard
-f, --force
Disable all checking
-v, --verbose
Print aligned offset and length

CAVEATS

This operation destroys data and is irreversible. Not all devices support discard operations. Secure discard requires hardware support and may not be more secure than regular discard on all devices. The device must not be mounted.

HISTORY

blkdiscard is part of the util-linux package, providing SSD optimization and secure erase functionality.

SEE ALSO

fstrim(8), hdparm(8), blkid(8)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community