How to create holes in files ?

Ben RUBSON ben.rubson at gmail.com
Thu Sep 28 16:47:08 UTC 2017


> On 28 Sep 2017, at 18:34, Bob Eager <rde at tavi.co.uk> wrote:
> 
> On Thu, 28 Sep 2017 17:26:09 +0200
> Fabian Keil <freebsd-listen at fabiankeil.de> wrote:
> 
>> Ben RUBSON <ben.rubson at gmail.com> wrote:
>> 
>>> I'm trying to make holes in files in C.
>>> Goal is to deallocate huge files on ZFS while (randomly) reading
>>> them.  
>> 
>> My interpretation of the above is that you want to create holes
>> without changing the file size and without affecting data that
>> is located before or after the holes that you want to create.
>> 
>> Otherwise you could simply "deallocate" the content with
>> truncate(1).
> 
> If he doesn't mind copying the files, dd(1) will do the job. However, I
> expect that doesn't meet his criteria.

Thank you Bob for your suggestion.
You're right goal is to avoid copying data : free space would not necessarily
allow this, and as the files I'm working on are some hundreds of GB in size,
it would really be a counterproductive long stressing storage operation.

Ben


More information about the freebsd-fs mailing list