- -n, --keep-size
- Do not modify the apparent length of
the file. This may effectively allocate blocks past EOF, which can be removed
with a truncate.
- -p, --punch-hole
- Deallocates space (i.e., creates a hole) in the
byte range starting at offset and continuing for length bytes. Within the
specified range, partial filesystem blocks are zeroed, and whole filesystem
blocks are removed from the file. After a successful call, subsequent reads
from this range will return zeroes. This option may not be specified at
the same time as the --zero-range option. Also, when using this option, --keep-size
is implied.
Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0),
Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).
- -d, --dig-holes
- Detect and
dig holes. Makes the file sparse in-place, without using extra disk space.
The minimal size of the hole depends on filesystem I/O block size (usually
4096 bytes). Also, when using this option, --keep-size is implied. If no range
is specified by --offset and --length, then all file is analyzed for holes.
You can think of this as doing a "cp --sparse" and renaming the dest file
as the original, without the need for extra disk space.
See --punch-hole for
list of the supported filesystems.
- -c, --collapse-range
- Removes a byte range
from a file, without leaving a hole. The byte range to be collapsed starts
at offset and continues for length bytes. At the completion of the operation,
the contents of the file starting at the location offset+length will be
appended at the location offset, and the file will be length bytes smaller.
The option --keep-size may not be specified for colapse range operation.
Available
since Linux 3.15 for ext4 (only for extent-based files) and XFS.
- -z, --zero-range
- Zeroes
space in the byte range starting at offset and continuing for length bytes.
Within the specified range, blocks are preallocated for the regions that
span the holes in the file. After a successful call, subsequent reads from
this range will return zeroes.
Zeroing is done within the filesystem preferably
by converting the range into unwritten extents. This approach means that
the specified range will not be physically zeroed out on the device (except
for partial blocks at the either end of the range), and I/O is (otherwise)
required only to update metadata.
Option --keep-size can be specified to prevent
file length modification.
Available since Linux 3.14 for ext4 (only for
extent-based files) and XFS.
- -o, --offset offset
- Specifies the beginning offset
of the range, in bytes.
- -l, --length length
- Specifies the length of the range,
in bytes.
- -h, --help
- Display help text and exit.
- -v, --verbose
- Enable verbose mode.
- -V, --version
- Display version information and exit.