gzip with sparse output

Posted on February 13th, 2021 by whinger. Filed under Uncategorized.


So I was looking to access some old disk images that I had gzipped, and I knew the original disk was fairly large and I didn’t particularly want that space used up; I was surprised to discover that gzip doesn’t support output to sparse files.

The solution is fairly simple: output to stdout and pipe it to dd with conv=sparse:

gzip -dc myimage.gz | dd of=mysparseimage bs=10240 conv=sparse

Choose a blocksize value that makes sense based on what you know about the expected size of the empty blocks, since (I believe) dd will only create sparse holes if the whole block is empty.



Trackback URI | Comments RSS

Leave a Reply


Blogroll

Categories