News for hackers. Stuff that matters.
Re:Remove first 300M lines from 700 GB file on 1TB disk by nybble41 on Tuesday September 22, 2020 @02:41PM (#24558252)
> 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.

There are no comments on this comment yet.