1 |
On Fri, 28 Nov 2008 13:46:01 +0200 |
2 |
Alan McKinnon <alan.mckinnon@×××××.com> wrote: |
3 |
|
4 |
> On Friday 28 November 2008 13:14:42 Dale wrote: |
5 |
> > If this is a little high, what would be the best way to defrag it? |
6 |
> |
7 |
> By not defragging it. |
8 |
|
9 |
I beg to defer. The simplest way to defrag a partition is to make |
10 |
backup and restore. If it's worth the effort is another story. |
11 |
|
12 |
> |
13 |
> It's not Windows. Windows boxes needs defragging not because |
14 |
> fragmentation is a huge problem in itself, but because windows |
15 |
> filesystems are a steaming mess of cr@p that do little right and most |
16 |
> things wrong. Defrag treats the symptom, not the cause :-) |
17 |
> |
18 |
|
19 |
Personally I think NTFS is one of the things MS have done right. It is |
20 |
fast, stable and has the features of the Linux FSes and even more. It |
21 |
has journal, quotas, permissions, mount points, symbolic links. Does |
22 |
any of ext, reiserfs or xfs have compression and/or encryption |
23 |
capabilities? I don't think so. |
24 |
I have some experience with MS Windows and I've never seen data |
25 |
corruption after a system crash or power loss, a thing I can't say |
26 |
about ReiserFS or ext3 (when not mounted with data=journal). |
27 |
|
28 |
|
29 |
> Reiser tends to self-balance itself out. What is especially |
30 |
> noteworthy is that none of the general purpose Linux filesystems |
31 |
> provide a defrag utility. Theodore 'Tso and Hans Reiser are both |
32 |
> exceptional programmers, if there was a need for such a tool they |
33 |
> would assuredly have written one. They did not, so there probably |
34 |
> isn't. |
35 |
|
36 |
|
37 |
It would be just as easy to pull the exactly opposite argument out: |
38 |
since they like to experiment and "to boldly go where no man has gone |
39 |
before", they won't bother to write a defrag tool, because it would |
40 |
be too trivial and no fun. (just an example speculation on my part). |
41 |
|
42 |
|
43 |
Now let's put the assumptions aside and do a test. |
44 |
|
45 |
root@localhost # test $ cat /usr/portage/packages/All/* > test1 |
46 |
root@localhost # test $ cp test1 test2 |
47 |
root@localhost # test $ ls -lah |
48 |
total 2.3G |
49 |
drwxr-xr-x 2 root users 4.0K 2008-11-29 01:38 . |
50 |
drwxr-xr-x 44 root users 4.0K 2008-11-29 01:36 .. |
51 |
-rw-r--r-- 1 root users 1.2G 2008-11-29 01:38 test1 |
52 |
-rw-r--r-- 1 root users 1.2G 2008-11-29 01:40 test2 |
53 |
localhost test # filefrag * |
54 |
test1: 1125 extents found, perfection would be 10 extents |
55 |
test2: 1923 extents found, perfection would be 10 extents |
56 |
localhost test # time cat test1 > /dev/null |
57 |
|
58 |
real 0m26.747s |
59 |
user 0m2.110s |
60 |
sys 0m1.450s |
61 |
localhost test # time cat test2 > /dev/null |
62 |
|
63 |
real 0m29.825s |
64 |
user 0m1.780s |
65 |
sys 0m1.690s |
66 |
|
67 |
|
68 |
All this with ext3 (rw,noatime,nodiratime,data=journal,commit=1) on |
69 |
a partition with 84% free space. |
70 |
|
71 |
It took 29.825-26.747=3.078 seconds more to read the same data, when |
72 |
the file has |
73 |
1923-1125=798 additional fragments. So, the fragmentation led to ~10% |
74 |
performance |
75 |
decrease in this case and it appears the dogma "Linux FS-es are smart |
76 |
and don't need |
77 |
to be de-fragmented" is not quite true, right? Unfortunately I have no |
78 |
Windows at hand |
79 |
to make a similar test for comparison, but I believe the results won't |
80 |
be quite different. |
81 |
BTW fiflefrag is written by Mr T'so. |
82 |
|
83 |
|
84 |
> Any Linux defrag tool you encounter will have been written by a third |
85 |
> party separate from the developers. It will move blocks around and |
86 |
> update superblocks, the drive will have to be unmounted for that to |
87 |
> work and a slight misunderstanding of how to do it will ruin data. |
88 |
> |
89 |
> Are you willing to take the very real risk of data corruption? |
90 |
|
91 |
|
92 |
Who says it has to work that way? :) |
93 |
I have seen on the Net a defrag tool written by Mr Con Kolivas [1]. It |
94 |
was just a bash script which basically only copies the file into a new |
95 |
one, checks the number of fragments of both files and deletes the one |
96 |
that has more extents. :) |
97 |
|
98 |
[1] http://en.wikipedia.org/wiki/Con_Kolivas |
99 |
|
100 |
|
101 |
-- |
102 |
Best regards, |
103 |
Daniel |