[oclug] ext2 defragmentation

Andrew Hutton ajh at finux.org
Tue Jan 23 19:01:53 EST 2001


On Tue, Jan 23, 2001 at 06:47:24PM -0500, Dan Cardamore wrote:
> Hey all,
> My server has a partition that is very fragmented at 50.7%.  This has
> sparked me into thinking of how I'm going to solve this problem :)
> 
> I have 2 questions:
> 1)  How do you check (without unmounting) how fragmented your partition


> 2)  How can I defragment this without reformatting?

50% non contigious is a sign that you have been running with your 
disk almost full (or full to non-root).

Bring your utilization below 80% and keep it there.  If you know you have
large files that were built in a very small chunk at a time way, (like
if you put /var on /) then moving them to another filesystem and back
with cp -a for example will defrag them (assuming you have enough 
space free to write them without resorting to filling holes in other
files.)

Having /var on a partition of its own is a good idea.

When doing any movement of files like this I cannot stress this enough:
DO IT IN SINGLE USER MODE! also make sure you do your syntax correctly.

Doing "echo > logfile" in /var/log/ for any huge logs would also likely
help.

-- 
Andrew J. Hutton, 
Ottawa Linux Symposium, International Linux Developers Conference
http://www.linuxsymposium.org/    July 25th-28th, 2001



More information about the OCLUG mailing list