Quote from this answer :
As of Linux 4.1, fallocate(2) supports the
FALLOC_FL_INSERT_RANGE flag, which allows one to insert a hole of a
given length in the middle of a file without rewriting the following
data. However, it is rather limited: the hole must be inserted at a
filesystem block boundary, and the size of the inserted hole must be a
multiple of the filesystem block size. Additionally, in 4.1, this
feature was only supported by the XFS filesystem, with Ext4 support
added in 4.2.
From fallocate(1) :
fallocate -d [-o offset] [-l length] filename
Detect and dig holes. This makes the file sparse in-place, without using extra disk space. The minimum 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 the entire file is analyzed for holes.
You can think of this option as doing a "cp --sparse" and then renaming the destination file to the original, without the need for extra
See --punch-hole for a list of supported filesystems.
Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0), Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).