Skip to contentSkip to conversation

drill: Make a file sparse without using extra disk space

DISCUSSION Rodrigo Campos 3 participants 5 messages Jan 23, 2014 – Jan 24, 2014 Util-Linux package

lore
Share & tools
lore
#0 lore raw

Hi!

I've written a small simple tool to make a file sparse without using extra disk space, it just digs holes on the file when possible. To dig the hole uses the Linux-specific fallocate(2) syscall with FALLOC_FL_PUNCH_HOLE. So, also, it only works on some file-systems.

Do you think that util-linux would be a good place for such a simple, linux-only program ? The case I see it can be useful is to use on VM images file backed (or I wrote it with this in mind, at least :)).

The code is quite simple, it's written in plain C (C99 actually) and doesn't have any external dependencies. You can see the gitweb here:

	http://sdfg.com.ar/git/?p=drill.git

or just clone it from:

	git://sdfg.com.ar/drill.git

Given that there is a fallocate tool that uses the other mode of fallocate(2) already, all the detection for fallocate is already there. So it should, I guess, be easy to integrate to the code-base, adding also the #ifndef fallocate.c has and that compatibility stuff.

Also, as you can see in the commits, I just started it some days ago. So if you think it should have some other feature, or something else, please let me know :)

I'm not sure how this work, but I can write a patch against util-linux if you think it can be added. If you know there is something I should particulary take into account for that, I will really appreciate if you let me know :)

Thanks a lot,
Rodrigo

#1 lore raw
Quoted 37 lines · Rodrigo Campos

Hi!

I've written a small simple tool to make a file sparse without using extra disk space, it just digs holes on the file when possible. To dig the hole uses the Linux-specific fallocate(2) syscall with FALLOC_FL_PUNCH_HOLE. So, also, it only works on some file-systems.

Do you think that util-linux would be a good place for such a simple, linux-only program ? The case I see it can be useful is to use on VM images file backed (or I wrote it with this in mind, at least :)).

The code is quite simple, it's written in plain C (C99 actually) and doesn't have any external dependencies. You can see the gitweb here:

	http://sdfg.com.ar/git/?p=drill.git

or just clone it from:

	git://sdfg.com.ar/drill.git

Given that there is a fallocate tool that uses the other mode of fallocate(2) already, all the detection for fallocate is already there. So it should, I guess, be easy to integrate to the code-base, adding also the #ifndef fallocate.c has and that compatibility stuff.

Also, as you can see in the commits, I just started it some days ago. So if you think it should have some other feature, or something else, please let me know :)

I'm not sure how this work, but I can write a patch against util-linux if you think it can be added. If you know there is something I should particulary take into account for that, I will really appreciate if you let me know :)

Quoted 7 lines

Thanks a lot,
Rodrigo
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

This functionality is useful.
Would it be possible to just add to fallocate with --punch-hole=sparse or something? Also dd has the conv=sparse option, so maybe this functionality can be added there. We're currently discussing that on the GNU coreutils mailing list.

thanks,
Pádraig.

#2 lore raw
Quoted 8 lines · Pádraig Brady
Quoted 7 lines · Rodrigo Campos

Hi!

I've written a small simple tool to make a file sparse without using extra disk space, it just digs holes on the file when possible. To dig the hole uses the Linux-specific fallocate(2) syscall with FALLOC_FL_PUNCH_HOLE. So, also, it only works on some file-systems.

Quoted 6 lines
Quoted 4 lines

Do you think that util-linux would be a good place for such a simple, linux-only program ? The case I see it can be useful is to use on VM images file backed (or I wrote it with this in mind, at least :)).

This functionality is useful.
Would it be possible to just add to fallocate with --punch-hole=sparse or something?

Totally, that's an option too :)

Quoted 1 line

Also dd has the conv=sparse option, so maybe this functionality can be added there.

But how are you going to do a hole in-place in a portable fashion ? I don't know of any

Quoted 1 line

We're currently discussing that on the GNU coreutils mailing list.

You mean the thread "making a file sparse - in-place?" started after this thread ?

Thanks a lot,
Rodrigo

maintainer
#3 lore raw
Quoted 4 lines · Rodrigo Campos
Quoted 3 lines · Pádraig Brady
Quoted 2 lines · Rodrigo Campos

I've written a small simple tool to make a file sparse without using extra disk space, it just digs holes on the file when possible.

Nice idea.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

To dig the hole uses the
Linux-specific fallocate(2) syscall with FALLOC_FL_PUNCH_HOLE. So, also, it only works on some file-systems.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Do you think that util-linux would be a good place for such a simple, linux-only program ? The case I see it can be useful is to use on VM images file backed (or I wrote it with this in mind, at least :)).

This functionality is useful.
Would it be possible to just add to fallocate with --punch-hole=sparse or something?

Totally, that's an option too :)

It would be the best way for util-linux, I really don't want to add another util for fallocate.

Maybe we can use a new option --dig-holes [ --length <size> ] or so.

Quoted 1 line
Quoted 1 line

Also dd has the conv=sparse option, so maybe this functionality can be added there.

IMHO would be possible to add this functionality to both places ;-)

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#4 lore raw
Quoted 7 lines · Karel Zak
Quoted 4 lines · Rodrigo Campos
Quoted 3 lines · Pádraig Brady
Quoted 2 lines · Rodrigo Campos

I've written a small simple tool to make a file sparse without using extra disk space, it just digs holes on the file when possible.

Nice idea.

Thanks! Not really original, though :)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

To dig the hole uses the
Linux-specific fallocate(2) syscall with FALLOC_FL_PUNCH_HOLE. So, also, it only works on some file-systems.

Do you think that util-linux would be a good place for such a simple, linux-only program ? The case I see it can be useful is to use on VM images file backed (or I wrote it with this in mind, at least :)).

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

This functionality is useful.
Would it be possible to just add to fallocate with --punch-hole=sparse or something?

Totally, that's an option too :)

It would be the best way for util-linux, I really don't want to add another util for fallocate.

Great!

Quoted 2 lines

Maybe we can use a new option --dig-holes [ --length <size> ] or so.

Sounds fine, but needs to be mutually exclusive with the options it takes now, I think. Or maybe something can be shared...

Will try to come up with a patch during the weekend or next week. Thanks!

Quoted 3 lines
Quoted 1 line
Quoted 1 line

Also dd has the conv=sparse option, so maybe this functionality can be added there.

IMHO would be possible to add this functionality to both places ;-)

:-D

Thanks a lot,
Rodrigo