In Linux kernel 4.1 FALLOC_FL_INSERT_RANGE
option was added. From fallocate(2)
man page:
Specifying the FALLOC_FL_INSERT_RANGE flag (available since Linux 4.1)
in mode increases the file space by inserting a hole within the file
size without overwriting any existing data. The hole will start at
offset and continue for len bytes. When inserting the hole inside
file, the contents of the file starting at offset will be shifted
upward (i.e., to a higher file offset) by len bytes. Inserting a hole
inside a file increases the file size by len bytes.
And recently this option support was added to util-linux
:
-i, --insert-range
Insert a hole of length bytes from offset, shifting existing
data.
So when util-linux
version 2.30 will be released and your linux distro will update to this version we will be able to increase file size in a flash by running:
fallocate -i -l 1G -o 128M /path/to/file
where 128M
is the current file size.