From owner-freebsd-chat@FreeBSD.ORG Mon Jul 9 01:02:38 2007 Return-Path: X-Original-To: freebsd-chat@freebsd.org Delivered-To: freebsd-chat@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 77E0D16A400 for ; Mon, 9 Jul 2007 01:02:38 +0000 (UTC) (envelope-from fb-chat@psconsult.nl) Received: from ps226.psconsult.nl (ps226.psconsult.nl [213.222.19.226]) by mx1.freebsd.org (Postfix) with ESMTP id E2B6D13C48C for ; Mon, 9 Jul 2007 01:02:37 +0000 (UTC) (envelope-from fb-chat@psconsult.nl) Received: from phuket.psconsult.nl (localhost [127.0.0.1]) by phuket.psconsult.nl (8.13.1/8.13.1) with ESMTP id l68JBjC5037242 for ; Sun, 8 Jul 2007 21:11:45 +0200 (CEST) (envelope-from fb-chat@psconsult.nl) Received: (from paul@localhost) by phuket.psconsult.nl (8.13.1/8.13.1/Submit) id l68JBjgR037241 for freebsd-chat@freebsd.org; Sun, 8 Jul 2007 21:11:45 +0200 (CEST) (envelope-from fb-chat@psconsult.nl) Date: Sun, 8 Jul 2007 21:11:45 +0200 From: Paul Schenkeveld To: freebsd-chat@freebsd.org Message-ID: <20070708191144.GA37151@psconsult.nl> Mail-Followup-To: freebsd-chat@freebsd.org References: <20070708112413.GA27077@psconsult.nl> <452829.7742.qm@web58108.mail.re3.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <452829.7742.qm@web58108.mail.re3.yahoo.com> User-Agent: Mutt/1.5.6i Subject: Re: compressed HDD image using dd...clearing unused blocks X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2007 01:02:38 -0000 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 filesystem is > filled? In the past, the system became unstable when > the filesystem was full. I'm guessing that's why a > blocksize 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@yahoo.com -- Paul Schenkeveld