Path: utzoo!utgpu!watmath!iuvax!uxc.cso.uiuc.edu!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: BSD filesystem defragmentation question Message-ID: <18968@mimsy.UUCP> Date: 10 Aug 89 01:12:58 GMT References: <1886@marvin.Solbourne.COM> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 37 In article <1886@marvin.Solbourne.COM> dce@Solbourne.COM (David Elliott) writes: >Assume I have an 8k/1k filesystem and create a file with 789 >bytes in it. This gives me one fragment. Good so far. >Now, let's say I add to the file so it grows to be 3875 bytes, >taking 4 fragments, and that these fragments are not all in >the same block. Not possible. All fragments are always in the same block. >OK, let's increase the file size to 10486 bytes, which is 11 >fragments. > >At this point, is the data moved on the disk so that my file >comprises one block and 3 fragments, or is it left as fragments? The file will occupy one block and 3 fragments-within-one-block. The exact mechanism by which a fragment expands, or becomes a block, depends on which version of 4BSD and on how many blocks and fragments are free and on whether the process is `well-behaved' when it comes to writing files. (A well-behaved process writes full blocks on full-block boundaries. This is most common, although in 4.2BSD [but not 4.3BSD] /usr/ucb/vi was ill-behaved, writing 1K at a time.) >Do new files tend to get placed in available blocks, >or do they go in partially-used blocks? A new fragment (for a file where no fragments existed before) is always placed in an existing fragmented block, if any, within the appropriate cylinder group. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris