$ date ; ./insert_space /media/rodolico/backup/testfile 1048576 ; date Wed Oct 9 00:08:50 CDT 2019 %sizeof fstat.off_t is 8 %Sought size is 107374182400 %Adding head-end 1048576 bytes Wed Oct 9 01:43:41 CDT 2019 virt 100G mem 31.4 res 27.3G shr 27.3G cpu 2% iotop -o -p 29937 19M/s in and out never touched swap, so did it within Wed Oct 9 00:08:50 CDT 2019 fallocate -l 10G /media/rodolico/backup/testfile mkfs.ext4 -m0 -L testdisk /media/rodolico/backup/testfile mount -o loop /media/rodolico/backup/testfile /mnt rsync -av Downloads /mnt umount /mnt insert_space /media/rodolico/backup/testfile 1048576 fdisk /media/rodolico/backup/testfile # create first partition at offset 2048, which is 1M assuming 512 byte sectors # partition is 82? Linux ext save kpartx -lv /media/rodolico/backup/testfile kpartx -av /media/rodolico/backup/testfile mount /dev/mapper/testfilep1 /mnt # should be no files copied on following command rsync -av Downloads /mnt man 3 getopt would actually be more flexible if it is assumed the space was already added to the end of the file. The program would move from 0 to filesize-extendsize. In this way, a device like a zfs volume or a lv could be used, simply by appending the correct space to the end, then calling this. question? How does gpartd do it. it moves partitions.