Summary : Defragmentation

From: Ramesh Pathak <>
Date: Tue Sep 02 2003 - 02:24:05 EDT
Please excuse me for the delaid summary.
The inputs were coming a bit slow and hence the delay.

Here is the summary:
1. Fragmentation doesnt deteriorate performance to appreciable extent. It can
be very well ignored.
2. Degree of fragmentation can be determined by using "fsck -n" while the
filesystem is unmounted.
3. The only way to defragment a Unix FS is ufsdump/ufsrestore. ( I wonder
whether we require newfs as
suggested by Andrew !)

I am attatching all the responses that I got ..

Thanks all of you once again.



Fragmentation is not as great a performance issue in Unix/Solaris as it is
in Windows, but will occur over time, especially if the disks are nearly
full.  The time-honored method of defragmenting a Unix file system is to
back up the data to another disk or tape, then remake the file system (which
is destructive to the data) and restore the data.  This method, of course,
cannot be done on-line, but it shouldn't need to be done very often.

1. Unix systems don't need to have their disk defragmented.  I'd suggest
reading any introductory on the architecture of modern Unix filesystems
to understand this.

>1. Can fragmentation of the used space and the free space on the
>disks affect performance.


>If yes 1.1) t owhat extent.

That depends on the extent of the fragmentation, your mix of read vs.
write, and access patterns.

>1.2) How t odetect that the disk is fragmented a lot?

To be clear, filesystems get fragmented, not disks.

Do a "fsck -n" on each filesystem, and the last line will give you a
percentage fragmentation.  This isn't the whole story, but it's a
convenient metric.

>2. Can we defragment the disks which have got fragmented over the years
>of use.

There may be someone selling a commercial defragmenter, but I wouldn't
trust it.

The traditional answer has been to use ufsdump/ufsrestore

First, it's worth mentioning that UFS* is different from most of the
filesystems found on MS platforms and is, in general, a much more capable
filesystem and isn't generally affected by "fragmentation" in the way that
certain MS filesystems are. Hence the idea of "defragmentation" really
doesn't apply.

> 1. Can fragmentation of the used space and the free space on the
> disks affect performance. If yes

Yes, but only in the extreme case of a very full filesystem.

> 1.1) t owhat extent.

If you are down to only enough space on a filesystem to store a single
file, then as you add and remove files it will take the system a bit
longer to allocate and write blocks.

The space/time `optimisation' of the filesystem may have some effect on
the performance, according to your minfree setting. See newfs(1M) and

> 1.2) How t odetect that the disk is fragmented a lot?

fsck will report it.

> 2. Can we defragment the disks which have got fragmented over the years of
> use.
> This defragmentation can be thot of in 2 ways :
> 2.1 defragmentation of the free space.
> 2.2 Defragmentation of the used space.

If you feel that a filesystem is too fragmented, you can ease your mind by
using the only real method of UFS defragmentation: ufsdump; newfs;

> 3. Can we do it online ? mean with the online applications not getting
> affected.
> In windows there is a tool for the job and I was wondering if Solaris or
> that matter any other unix flavours also has similar utilities !!

No and no, not that there is any need.

* UFS has many implementations, all based originally on the Berkeley Fast
  Filesystem (FFS). Note that there are other types of filesystems which
  you can use on unix platforms.

Yes, fragmentation will affect performance.
The degree will vary according to the level of
fragmentation but it can become quite severe.

Detection is not easy without the correct tools.

Veritas comes with it's own on-line defragger which will
show you the degree of fragmentation and fix it without
any service outage.

Other unix flavours eg Tru64 come with their own
defragger but you can get Veritas for most systems.


Yes, fragmentation can seriously affect performance. Luckly the UFS file
system is not prone to fragmentation (Unlike certian desktop OS'es). You
will normally only get fragmentation is you let you file system run full and
the system had no other option but to start fragmenting.

To view the fragmentation, do an fsck on the file system. (The file sysytem
must not be in use and unmounted). At the end of the check, the system
states how much fragmentation there is.

To defragemnt, a backup and restore is normally required. If your disks are
mirrored, backup (for safety), detach one mirror and copy from remaining
mirror to detached mirror with ufsdump or cpio (tar can be used, but with
caution. It does not understand certain device types) Once done, use copied
mirror as the primary and reattach the old to the new forcing a resync. This
will typically require downtime.

As for other systems have these utitlities, they despartately need them,
unlike Solaris and UFS ;-)

Dear Mr. Ramesh C Pathak

Please summarize if you get any valuable
responses. I'm greatly interested in this subject.


Ramesh C Pathak
Vinciti Networks Pvt. Ltd.,
#1109, 24th Main Road,
JP Nagar 1st Phase,
Bangalore - 560 078

Ph: +91-80-6556830
Fax: +91-80-6556820

sunmanagers mailing list
Received on Tue Sep 2 02:23:24 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:18 EST