3 ms·
> playing russian roulette with work data by adjusting files in-place That can be avoided if your filesystem supports reflinks / copy_file_range (BTRFS, XFS, O
by nybble41 6y ago
> playing russian roulette with work data by adjusting files in-place
That can be avoided if your filesystem supports reflinks / copy_file_range (BTRFS, XFS, OCFS2). Just create a reflink of the file, drop all the blocks at the beginning of the reflink "copy" up to the one containing the line you want to start with using fallocate --collapse-range, and overwrite the remaining data up to the first line with some suitable fill character. For the JSON-encoded lines in this case spaces should work. Total disk space used: one data block for the padding plus some metadata for the reflink. No changes to the original file. No copying or relocating 700 GB of data. Quick, easy, and and safe. But you have to start with the right filesystem for it to work.