Monitoring fragmentation

Fragmentation reduces performance and availability. Symantec recommends regular use of the fragmentation reporting and reorganization facilities of the fsadm command.

The easiest way to ensure that fragmentation does not become a problem is to schedule regular defragmentation runs using the cron command.

Defragmentation scheduling should range from weekly (for frequently used file systems) to monthly (for infrequently used file systems). Extent fragmentation should be monitored with the fsadm command.

To determine the degree of fragmentation, use the following factors:

An unfragmented file system has the following characteristics:

A badly-fragmented file system has one or more of the following characteristics:

Fragmentation can also be determined based on the fragmentation index. Two types of indices are generated by the fsadm command: the file fragmentation index and the free space fragmentation index. Both of these indices range between 0 and 100, and give an idea about the level of file fragmentation and free space fragmentation, respectively. A value of 0 for the fragmentation index means that the file system has no fragmentation, and a value of 100 means that the file system has the highest level of fragmentation. Based on the index, you should use the appropriate defragmentation option with the fsadm command. For example if the file fragmentation index is high, the fsadm command should be run with the -e option. If the free space fragmentation index is high, the fsadm command should be run with -C option. When the fsadm command is run with the -e option, internally it performs free space defragmentation before performing file defragmentaion.

The optimal period for scheduling of extent reorganization runs can be determined by choosing a reasonable interval, scheduling fsadm runs at the initial interval, and running the extent fragmentation report feature of fsadm before and after the reorganization.

The "before" result is the degree of fragmentation prior to the reorganization. If the degree of fragmentation is approaching the figures for bad fragmentation, reduce the interval between fsadm runs. If the degree of fragmentation is low, increase the interval between fsadm runs.

The "after" result is an indication of how well the reorganizer has performed. The degree of fragmentation should be close to the characteristics of an unfragmented file system. If not, it may be a good idea to resize the file system; full file systems tend to fragment and are difficult to defragment. It is also possible that the reorganization is not being performed at a time during which the file system in question is relatively idle.

Directory reorganization is not nearly as critical as extent reorganization, but regular directory reorganization improves performance. It is advisable to schedule directory reorganization for file systems when the extent reorganization is scheduled. The following is a sample script that is run periodically at 3:00 A.M. from cron for a number of file systems:

  export PATH=$PATH:/opt/VRTS/bin
  outfile=/var/spool/fsadm.out.'/usr/bin/date +'%m%d''
  for i in /home /home2 /project /db
    /usr/bin/echo "Reorganizing $i"
    /usr/bin/timex fsadm -V vxfs -e -E -s $i
    /usr/bin/timex fsadm -V vxfs -s -d -D $i
  done > $outfile 2>&1