[lug] Convertion of ext4 Sparse Files

Lee Woodworth blug-mail at duboulder.com
Fri Jan 5 16:02:52 MST 2018


What happens if you preallocate the destination with
      dd if=/dev/zero of=... bs=... count=...
and dd with if=src of=dest conv=nocreat,notrunc

On 01/05/2018 03:48 PM, stimits at comcast.net wrote:
> Unfortunately this does not work (currently testing on Fedora 27), at least not for this file which was originally a dd of a GPT partition and then converted to sparse at a later time. Output and input files are both the sparse file size.
>   
> It may be a matter of dd or other tools not detecting this as sparse for whatever reason, but I keep running into options for creating sparse files and not the reverse, e.g., dd has "conv=sparse", but not the reverse, so I can't force it to do a sparse to non-sparse conversion.
>   
> ----- Original Message -----From: Will <will.sterling at gmail.com>To: Boulder (Colorado) Linux Users Group -- General Mailing List <lug at lug.boulder.co.us>Sent: Fri, 05 Jan 2018 22:09:51 -0000 (UTC)Subject: Re: [lug] Convertion of ext4 Sparse Files
> 
> dd if=/path/sparse_file of=/path/nonsparse_file
> 
> On Fri, Jan 5, 2018 at 2:55 PM, <stimits at comcast.net> wrote:
> 
> Hi,
>   
> I've been looking all over and am stumped. Files can be "sparse" where space isn't allocated until needed, and it is easy to create a sparse file. What I'm wondering...and am stumped about...there must be a way to take an image and convert it back to non-sparse...but how?
>   
> cp with "--sparse=never" does not work (I'm trying on Fedora 23 through 27, plus Ubuntu 16.04). This may be a property of the file in question though...some people will have a large file with content such as text...this is an embedded system dd of a partition...it is a binary image containing an ext4 partition which can be copied via dd back onto other embedded systems...but this was converted to sparse format to save space. Is there a way to take such an image and put it back to its original size without the sparse attribute?
>   
> Thanks!
> _______________________________________________
> 
> Web Page:  http://lug.boulder.co.us
> 
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> 
> Join us on IRC: irc.hackingsociety.org port=6667 channel=#hackingsociety
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: irc.hackingsociety.org port=6667 channel=#hackingsociety
> 



More information about the LUG mailing list