The actual answer, as others have pointed out, is to buy a new drive. If the data has any value, it's worth it.
If you read the comments on the StackExchange question, the scenario that prompted it does make sense:
>> I'm migrating our company's database and this is 700GB file with profile data in JSON format, each line one profile. The process that imported the data stopped after running several days after 70% done. Now, to not repeat the full import, I want to cut the first 70% (300 million lines).
>> [One option would be] exporting the data from the old DB again, skipping the first 300 Mio entries and cp it again over to the new and import it there. It roughly takes a day. I just thought there must be a way to do it in place: the data are already there - just truncate the first part of it and continue.
So it's not as if this is the only copy of the data. It would just be nice if there was a way to cut some of it without recopying everything.
You probably don't care if it's 299M rows, so just dd over the start of the file, guessing the number of bytes to write and choosing a low number to be sure. You'll know if you're missing records when you run a count(*) on the database when it's loaded.
Use some hex editor (most support files larger than ram) to check you have the necessary opening square brace at the start of the file, and to remove whatever partial record is there.
Sure, it isn't elegant, but is a solution most people can come up with without needing to spend 20 minutes hunting through man pages.
Of course performance would suffer due to non-aligned access, but just as for regular files one could demand aligned access for optimal speed.
https://man7.org/linux/man-pages/man2/ioctl_ficlonerange.2.h...
>The immediate user for this operation would appear to be video editing applications, which could use it to quickly and efficiently remove a segment of a video file.
Do any of Linux video editor apps actually employ this feature?
Deleting a non-block-aligned segment of a file means copying the remaining data over it and then truncating the file at the end using the ancient truncate function. It's not obvious how that can be improved.
Even if the video is uncompressed you will still need to remove entire frames and then - for most formats - reconstruct a file header at the start of the file.
This is a much harder problem than throwing away x% of a file without worrying about the structure of the content.
It's fairly easy to solve that problem at the disk block level. But if you're trying to keep the data structures error-free, you're going to have to do a lot more work.