.TH fmap "" "" Command
.PC "Measure fragmentation of the free list"
\fBfmap \fIdevice\fR
.PP
Command
.B fmap
tests how fragmented the free list is on \*(CO file system
.IR device .
It briefly displays its results and returns an exit status
that is equivalent to the percent of fragmentation found on
.IR device .
.PP
You can use the amount of fragmentation of the free list to
decide whether to de-fragment
.IR device .
When the freelist is fragmented, writing a file creates a file that
is not physically contiguous; and this, in turn, slows disk I/O.
.PP
.I device
must be a partition on your hard disk or a floppy disk
rather than an entire hard drive.
It can be either the raw or the ``cooked'' (block) device.
For example, the command
.DM
	fmap /dev/rat0a
.DE
.PP
tells
.B fmap
to map the free list on the first partition on the first drive.
.PP
Because
.B fmap
returns an exit status equal to the integer portion of the
percentage of fragmentation found,
you can use it in a shell script
to alert the system administrator when the file system needs attention.
For example, the following shell script tests the level of 
fragmentation on the device given as an argument;
if the fragmentation exceeds 5%, it sends mail to the superuser
.BR root :
.DM
fmap /dev/$1
a=$?
if expr $a \> 5
then
	echo  -n "fmap of " >/tmp/rootmail
	echo -n $1 >>/tmp/rootmail
	echo -n " shows " >>/tmp/rootmail
	echo -n $a >>/tmp/rootmail
	echo " percent fragmentaion" >>/tmp/rootmail
	echo -n $a >>/tmp/rootmail
	echo " is greater than 5"  >>/tmp/rootmail
	echo -n "therefore, it is time to defrag " >>/tmp/rootmail
	echo $1 >>/tmp/rootmail
	echo "bye" >>/tmp/rootmail
	mail root </tmp/rootmail
	rm /tmp/rootmail
fi
exit 0
.DE
.SH "See Also"
.Xr "commands," commands
.Xr "dpac," dpac
.Xr "fsck," fsck
.Xr "qpac," qpac
.Xr "upac" upac
.SH Notes
.II "Wright, Randy"
.B fmap
was written by Randy Wright (rw@rwsys.wimsey.bc.ca). 
