HP-UX System Administrator's Guide: Routine Management Tasks
Defragmenting an HFS File System
Defragmenting an HFS file system could improve throughput by reducing disk seek
time. In practice, though, most experts believe it will usually make little or no difference
to performance. You should do it only if you have good reason to believe, or have
received expert advice, that your system will really benefit.
NOTE: This applies only to HFS file systems. JFS file systems do need to be
defragmented regularly. See “Defragmenting a JFS File System” (page 199).
You can defragment an HFS file system by backing it up to tape, removing and
recreating it, then recovering the data from the tape.
The example that follows shows an alternative method, using dcopy, and assumes
you have enough disk space to create a new logical volume at least as large as
/dev/vg01/lvol8. We’ll operate on the /work file system, which resides on the
logical volume /dev/vg01/lvol8.
1. Back up the file system; for example,
tar cv /work
backs up /work to the system default tape device, /dev/rmt/0m.
2. Create a new logical volume (see HP-UX System Administrator) but do not mount
it to any file system.
We’ll assume this new logical volume is /dev/vg01/lvol9.
3. Make sure no one has files open in /work and that it is no one’s current working
directory, for example:
fuser -cu /work
4. Unmount /work:
umount /work
5. Write out the contents of /work to /dev/vg01/lvol9:
dcopy -v /dev/vg01/rlvol8 /dev/vg01/lvol9
NOTE: The source file system should be a raw device (/dev/vg01/rlvol8)
and the destination file system should be a block device (/dev/vg01/lvol9).
6. Mount the new logical volume to the mount point of the original file system,
/work:
mount /dev/vg01/lvol9 /work
You can now reuse the original logical volume /dev/vg01/lvol8) or remove it
(see “Removing a Logical Volume” (page 108)).
198 Managing System Performance