compressed HDD image using dd...clearing unused blocks

Michael Eubanks mse0206 at yahoo.com
Tue Jul 10 06:01:35 UTC 2007


Paul Schenkeveld <fb-chat at psconsult.nl> wrote:   On Sun, Jul 08, 2007 at 11:11:36AM -0700, Michael Eubanks wrote:
> 
> --- Paul Schenkeveld wrote:
> 
> > On Sat, Jul 07, 2007 at 10:28:01PM -0700, Michael
> > Eubanks wrote:
> > > Hello all,
> > > 
> > > I am updating a system that has been around for
> > some
> > > time now. I would like to make a compressed disk
> > > image after the final setup is complete, although,
> > I'm
> > > guessing that the unused blocks will not allow me
> > to
> > > compress the image as well as I could with a
> > > previously clean disk (considering the disk has
> > been
> > > in use for some time now). Is there a way to do
> > this
> > > - zero out unused blocks to optimize compression? 
> > I
> > > generally do this with Windows machines using the
> > > cipher command (killing cipher after it has
> > finished
> > > writing zeroes). After running cipher I use dd to
> > > create a compressed HDD image for later use. I'd
> > like
> > > to be able to do the same with FreeBSD.
> > 
> > What about:
> > 
> > # dd < /dev/zero > BIG_EMPTY_FILE bs=128k
> > # rm BIG_EMPTY_FILE
> > 
> > Comes close to what you want, only a couple of
> > indirect blocks are
> > not zeroed this way but the majority of unused
> > blocks will be.
> > 
> 
> ...snip...
> 
> I'll give it a shot. That is a great idea. I'm
> wondering, though, what happens when the file system is
> filled? In the past, the system became unstable when
> the file system was full. I'm guessing that's why a
> block size of 128k bytes was used - all blocks but the
> last (<128k) will be filled? Is that a correct
> assumption? What if I just bumped that number up to
> 4m or something to speed things up?

The bs=128k is just for speed. Dd will write an incomplete block at the
end of the file to fill up just whatever space you need. If you fear
system instability, run this in single user mode.

Oh, do a sync and wait a while between the dd and the rm to allow the
kernel some time to flush out blocks to disk, otherwise you've only
efficiently zeroed out the buffer cache :-)

# dd < /dev/zero > BIG_EMPTY_FILE bs=128k
# sync
# sleep 30
# rm BIG_EMPTY_FILE

> -Michael S. Eubanks
> mse0206 at yahoo.com

-- Paul Schenkeveld
_______________________________________________
freebsd-chat at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-chat
To unsubscribe, send any mail to freebsd-chat-unsubscribe at freebsd.org
  
 
  Okay.  Thanks for the info.  I'll repost when I see how it goes.  I'm generally able to get an entire 70GB drive compressed down to <2 GB on a fresh install.  That wasn't the case after the last update and I imagine that is the only thing that is causing increase in image size.
   
  -Michael S. Eubanks
   mse0206 at yahoo.com
   

       
---------------------------------
Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's on, when. 


More information about the freebsd-chat mailing list