Thanks
Tuximus
> How do you defragment a linux filesystem? Thanks
Depends on what type of filesystem you are using, but in general you
don't need to do it.
Most linux systems use ext2, which is fairly immune to fragmentation.
When it does get fragmented, the best way to fix it is to back
everything up, do a mkfs on the filesystem and restore the backup.
> How do you defragment a linux filesystem?
Short answer: you don't.
This is a FAQ, so look for a longer answer in the linux FAQ. It should
be on your disk (I'm not going to do the lookup for you, but believe
me, the answers to such things are there or thereabouts). Basically,
most filesystems don't fragment, and if they do it's a good thing.
It's only the ancient msdos FS that has this problem.
Peter
It is not required. Remember this is Linux not Windows.
>
>How do you defragment a linux filesystem?
>
You don't... the ext2 filesystem is rather clever, and *generally*
doesn't require you to defragment the hard drive. I believe there are
utilities out there that do a similar thing, but none spring to mind.
If you're really getting into problems, you may want to try on of
those...
Dan Sarginson
[Quite new to 'ux by the way]
> How do you defragment a linux filesystem?
Why would you want to?
Jan Eric
NTFS has major problems with defragmentation too.
Texstar wrote:
>
> It is not required. Remember this is Linux not Windows.
>
>
>
--
linux inside
Because anyone used to Windows would be concerned about fragmentation, even
if using Windows NT or 2000.
Roy
Let's explain this again..... <g>
In general, fragmentation is a concern when one (and only one) process
access data from one (and only one) file. When more than one file is
involved, the disk addresses being requested are 'fragmented' wrt the
sequence that the driver has to service them, and thus it doesn't
matter to the device driver whether or not a file was fragmented.
To illustrate:
I have two programs executing simultaneously, each reading two
different files. Assume that the file system contains four files (file
1, file 2, file 3, and file 4) allocated in ascending contigious
blocks. The filesystem would be in an 'unfragmented' state, and would
look like
|-File 1-|-File 2-|-File 3-|--File 4---|
|b1,b2,b3|b1,b2,b3|b1,b2,b3|b1,b2,b3,b4|
+--------+--------+--------+-----------+
The programs access files in the following manner:
Program 1 reads file 1, block 1
file 1, block 2
file 2, block 1
file 2, block 2
file 2, block 3
file 1, block 3
Program 2 reads file 3, block 1
file 4, block 1
file 3, block 2
file 4, block 2
file 3, block 3
file 4, block 4
The OS scheduler causes the programs to be scheduled and executed such
that the device driver receives requests
file 3, block 1
file 1, block 1
file 4, block 1
file 1, block 2
file 3, block 2
file 2, block 1
file 4, block 2
file 2, block 2
file 3, block 3
file 2, block 3
file 4, block 4
file 1, block 3
As you can see, the accesses are already 'fragmented' and we haven't
even reached the disk yet. I have to stress this, the above situation
is _no different_ from an MSDOS single file access against a
fragmented file.
So, how do we minimize the effect seen above? If you are MSDOS, you
reorder the blocks on disk to match the (presumed) order in which they
will be requested. OTOH, if you are Linux, you reorder the _requests_
into a regular sequence that minimizes disk access. You also buffer
most of the data in memory, and you only write dirty blocks. In other
words, you minimize the effect of 'disk file fragmentation' as part of
the other optimizations you perform on the _access requests_ before
you execute them.
Now, this is not to say that 'disk file fragmentation' is a good
thing. It's just that 'disk file fragmentation' doesn't have the
*impact* here that it would have in MSDOS-based systems. The
performance difference between a 'disk file fragmented' Linux file
system and a 'disk file unfragmented' Linux file system is minimal to
none, where the same performance difference under MSDOS would be huge.
Under the right circumstances, fragmentation is a neutral thing,
neither bad nor good.
As to defraging a Linux filesystem (ext2fs), there are tools
available, but (because of the design of the system) these tools are
rarely (if ever) needed or used. That's the impact of designing up
front the multi-processing/multi-tasking multi-user capacity of the OS
into it's facilities, rather than tacking
multi-processing/multi-tasking multi-user support on to an inherently
single-processing/single-tasking single-user system.
Lew Pitcher
Information Technology Consultant
Toronto Dominion Bank Financial Group
(Opinions expressed are my own, not my employer's.)
You can get it from sunsite @:
ftp://sunsite.unc.edu/pub/Linux/system/filesystems/defrag-0.70.tar.gz
If you are defragging a runtime necessary file system, put this utility on
your emergency recovery media. Boot from the recovery media and then do
the defrag on the filesystem(s) you wish. Never, I repeat, NEVER do this
to a mounted filesystem. I don't know about now, but it used to let you.
(Yes, *evil*.)
*TheDarb
tuximus <tux...@my-deja.com> wrote:
> Thanks
> Tuximus
--
Only Mickeysoft doesn't supply a defragger with NT :^)
Jan Eric
Yeah, but Linux ain't windoze :^)
Jan Eric
> Let's explain this again..... <g>
Thanks for a very clear explanation, Lew, much better than I could have
explained it myself :^)
I hope you don't mind if I save it and use it next time someone asks me
about this issue?
Jan Eric
Not at all; that's what I did <g>.
I originally wrote that response to another "where's the Linux defrag"
question, and the response was encouraging enough that I kept it
around.
> Not at all; that's what I did <g>.
Good, good, quite in the spirit of open source :^)
> I originally wrote that response to another "where's the Linux defrag"
> question, and the response was encouraging enough that I kept it
> around.
I do know about this, and I explained it[1] to my wife when she asked me
about it[2] after I weaned her from the dark side :^)
I'm considering making a new section of my website[3] to deal with these
common kinds of questions that I see here all the time[4], I'll put it
there as well, along with any other answers and fixes I think will be
useful.
Jan Eric
[1] Not as clearly, I fear, but she got the point
[2] She was accustomed to defragging at least weekly
[3] When I get it up and running again[5]
[4] Like that "I have no sound as a user" thing and "how do I upgrade to
KDE 2.1" and so on
[5] I've changed both countries and ISP's since it last was up, and I
haven't gotten around to it[6] yet.
[6] Anyone got a round tuit they could spare? I always seem to be running
out of them :^)
> On Sun, 25 Mar 2001 16:42:51 GMT, tuximus <tux...@my-deja.com> wrote:
> >
> >How do you defragment a linux filesystem?
> >
> >Thanks
> >Tuximus
> Let's explain this again..... <g>
[big snip]
Hi Lew
that was very nice. Thanks for taking the trouble :-)
Regards
Hannibal
>>> NTFS has major problems with defragmentation too.
>>
>>Only Mickeysoft doesn't supply a defragger with NT :^)
>
>
> But they do in Win2k (which is really NT5) :-)
Still not enough to induce me to use win2k, though :^)
Jan Eric