Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Nov 2008 18:12:14 +0100
From:      Fabian Keil <freebsd-listen@fabiankeil.de>
To:        freebsd-questions@freebsd.org
Subject:   Re: copying 'holey' files ...
Message-ID:  <20081103181214.1adafa2b@fabiankeil.de>
In-Reply-To: <F051A44CEADE0E79AEA7654E@ganymede.hub.org>
References:  <F051A44CEADE0E79AEA7654E@ganymede.hub.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
"Marc G. Fournier" <scrappy@hub.org> wrote:

> I have a disk img for qemu that is 4G, but disk usage is only 650M ... due to 
> how the image is created, it will grow to 4G, but only uses as much as it needs 
> ... but, if I run a simple 'cp' on the file, it goes from:
> 
> image: debian.img
> file format: raw
> virtual size: 4.0G (4294967296 bytes)
> disk size: 652M
> 
> to:
> 
> image: dtc.img
> file format: raw
> virtual size: 4.0G (4294967296 bytes)
> disk size: 4.0G
> 
> Is there a way of moving things around such that it *maintains* the holes, 
> instead of fills them in?

Quoting dd(1):

| conv=value[,value ...]
|          Where value is one of the symbols from the following list.
[...]
|          sparse   If one or more output blocks would consist solely of
|                   NUL bytes, try to seek the output file by the required
|                   space instead of filling them with NULs, resulting in a
|                   sparse file.

I haven't actually tested it with qemu images, though.

Fabian

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEARECAAYFAkkPMO4ACgkQBYqIVf93VJ1AngCfYPUvWuqNSLF4IZdINybQvgy8
MfEAoKvWf0GAzXA3PrWcKHWwh/ni1udt
=jCjf
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081103181214.1adafa2b>