BSD filesystem defragmentation question

Chris Torek chris at mimsy.UUCP
Thu Aug 10 11:12:58 AEST 1989


In article <1886 at marvin.Solbourne.COM> dce at 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 at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list