[colug-432] creating sparse disk images

Roberto C. Sánchez roberto at connexer.com
Tue Nov 13 13:32:44 EST 2018


On Tue, Nov 13, 2018 at 07:21:38PM +0100, Rick Hornsby wrote:
>    On November 13, 2018 at 11:13:31, Matthew Hyclak ([1]hyclak at gmail.com)
>    wrote:
> 
>      Been a while since I did this, but I believe you have to make sure the
>      filesystem you want to be sparse actually contains 0's in the places
>      you'd like to be sparse before creating the sparse file.
>      [2]https://unix.stackexchange.com/questions/44234/clear-unused-space-with-zeros-ext3-ext4 looks
>      like a good starting point.
> 
>    Thanks. I had seen that thread. I used zerofree, but it didn’t seem to
>    matter. Because of your link though, I read farther down the page to some
>    information about cp with the ‘—sparse=always’ flag, and some hints about
>    reported size between ls and du.
> 
>    Interestingly enough, I messed around and got the following:
> 
>    cp —sparse=always 16GB_file sparse_file       -> 3.7GB, as per du. ls
>    still says it’s 16GB.

You need to pass the '-s' option to ls:

       -s, --size
              print the allocated size of each file, in blocks

Regards,

-Roberto
-- 
Roberto C. Sánchez
http://people.connexer.com/~roberto
http://www.connexer.com


More information about the colug-432 mailing list