From owner-freebsd-questions Sun Jun 16 17:34:15 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id RAA01322 for questions-outgoing; Sun, 16 Jun 1996 17:34:15 -0700 (PDT) Received: from jraynard.demon.co.uk (jraynard.demon.co.uk [158.152.42.77]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id RAA01314; Sun, 16 Jun 1996 17:34:07 -0700 (PDT) Received: (from fqueries@localhost) by jraynard.demon.co.uk (8.7.5/8.6.12) id XAA00571; Sun, 16 Jun 1996 23:33:50 GMT Date: Sun, 16 Jun 1996 23:33:50 GMT Message-Id: <199606162333.XAA00571@jraynard.demon.co.uk> From: James Raynard To: gpalmer@FreeBSD.ORG CC: valtech@caribnet.net, terry@lambert.org, questions@FreeBSD.ORG In-reply-to: <21696.834938615@palmer.demon.co.uk> (message from Gary Palmer on Sun, 16 Jun 1996 16:23:35 +0100) Subject: Re: defrags Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > You guys said I shouldn't worry about the 0.7% but its now > > 0.9% and increasing each time I shutdown the software down > > and restart. > > This is because you are using more disk space, no doubt ... I REALLY > wouldn't worry. I think you are getting confused between DOS > fragmentation and FFS fragmentation ... It's unfortunate that they use the same word is used for rather different things. DOS fragmentation means that a file is split into parts because DOS wasn't intelligent enough to work out how to write it as a single, contiguous file. FFS fragmentation means that, instead of being wasted, unused space in a block is used for storing small files, which would otherwise need a block of their own and waste even more space. Let's look at an example:- Suppose we have to write two files. File A is 15360 bytes long and file B 512 bytes. Blocks are normally 4096 bytes on FFF, so file A needs four blocks to be stored - three full blocks and 3072 bytes of the fourth block. Now without fragmentation, the other 1024 bytes in the fourth block would be wasted. The file B would have to go in a block of its own, using only 512 out of the 4096 bytes available. By my arithmetic, that makes five blocks in use, of which 4608 bytes are wasted. Block: 1 2 3 4 5 ------ ------ ------ ------ ------ |XXXX| |XXXX| |XXXX| |XXX | |X | |XXXX| |XXXX| |XXXX| |XXX | |X | |XXXX| |XXXX| |XXXX| |XXX | | | |XXXX| |XXXX| |XXXX| |XXX | | | ----- ------ ------ ------ ------ File A is stored here File B However, if we allow fragmentation, we can put file B in the spare bytes at the end of the fourth block:- Block: 1 2 3 4 ------ ------ ------ ------ |XXXX| |XXXX| |XXXX| |XXXX| |XXXX| |XXXX| |XXXX| |XXXX| |XXXX| |XXXX| |XXXX| |XXX | |XXXX| |XXXX| |XXXX| |XXX | ----- ------ ------ ------ File A is stored here | |--------- File B goes in the free space at the end of block 4 Now we're using four blocks, instead of five, and the wasted space is only 512 bytes. If we can find another 512 byte file to put in it, even that space doesn't have to be wasted! Hope this helps. -- James Raynard, Edinburgh, Scotland james@jraynard.demon.co.uk