From owner-freebsd-chat@FreeBSD.ORG Sat Jul 14 01:01:47 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 B576E16A406 for ; Sat, 14 Jul 2007 01:01:47 +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 2B25013C4B7 for ; Sat, 14 Jul 2007 01:01:46 +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 l6DDkiqT082462 for ; Fri, 13 Jul 2007 15:46:44 +0200 (CEST) (envelope-from fb-chat@psconsult.nl) Received: (from paul@localhost) by phuket.psconsult.nl (8.13.1/8.13.1/Submit) id l6DDkiwM082461 for freebsd-chat@freebsd.org; Fri, 13 Jul 2007 15:46:44 +0200 (CEST) (envelope-from fb-chat@psconsult.nl) Date: Fri, 13 Jul 2007 15:46:44 +0200 From: Paul Schenkeveld To: freebsd-chat@freebsd.org Message-ID: <20070713134643.GA81991@psconsult.nl> Mail-Followup-To: freebsd-chat@freebsd.org References: <20070708191144.GA37151@psconsult.nl> <200707131202.l6DC2tWY098521@lurza.secnetix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200707131202.l6DC2tWY098521@lurza.secnetix.de> 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: Sat, 14 Jul 2007 01:01:47 -0000 On Fri, Jul 13, 2007 at 02:02:55PM +0200, Oliver Fromme wrote: > Paul Schenkeveld wrote: > > Michael Eubanks wrote: > > Paul Schenkeveld wrote: > > > > 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... > > > [...] > > > > 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 :-) > > Are you sure? ISTR once I wrote a big file to a floppy > which didn't fit. I got an error message and removed > the incomplete file, but the floppy drive continued to > write the blocks from the cache. > > I think the buffer cache works on block level, not on > file level, so the syncing and waiting shouldn't be > necessary. The zeroed data blocks schould still be > written to disk, even after the directory entry has > been unlinked. If I understand softupdates correctly then the rm prevents further flushing of data blocks from the buffercache to the disk. Somewhere in the original softupdates docs I read that softupdates are ideal for /tmp filesystems as many temporary files will never make it to the physical disk during large builds like make world. > Besides, the buffer cache is certainly _much_ smaller > than the hard disk in question, so the majority of > blocks has already been zeroed on disk when the dd > command finishes. But on a machine with lots of RAM, say 4GB, the blocks that haven't made it to the disk can still make your dd image unnecessarily huge, on a pristine system even a couple of times lager than necessary. > Best regards > Oliver -- Paul Schenkeveld