How to Defragment an Ext3 Filesystem


Results 1 to 13 of 13

Thread: How to Defragment an Ext3 Filesystem

  1. #1
    Join Date
    Apr 2004
    Location
    New York
    Posts
    147

    How to Defragment an Ext3 Filesystem

    How do I defragment an ext3 filesystem?

    Do not tell me that I do not need to defragment; I already know that, and that is not my question.

    Thank you

  2. #2
    Join Date
    Apr 2001
    Posts
    1,496
    Okay, so, if you know you don't need to do it, why worry about it?

    http://www.biznix.org/whylinux/windows/fragment.html


    However, if you are really curious, check out this page:

    http://e2fsprogs.sourceforge.net/ext2.html

    (Please note: ext3 = ext2 + journaling -- I think )
    Distribution: Gentoo
    Kernel: 2.6.9-r9-gentoo
    Processor: Intel Pentium 4 1.3Ghz
    RAM: 256MB RAMBUS
    HD Space: 300GB (60/80/160)

    <beastmaster> eh yeah same here, used to use mandy lol
    <beastmaster> yeah damn.. that was a waste of 2 years right there lol

  3. #3
    Join Date
    Aug 2002
    Location
    Delaware
    Posts
    4,285
    there is a tool called defrag that will defragment ext2 partitions (and since ext3 is backwards compatible it would work on ext3 as well), however, I have no idea how 'helpful' this would be...
    irc.freenode.net #justlinux The Not So Official JL IRC Channel.
    ¤ Debian ¤ Apt-Get ¤

  4. #4
    Join Date
    Dec 1999
    Location
    Toronto
    Posts
    39,307
    I have nothing on my filesystem with defrag.

    locate defrag
    =nothing

    Searching freshmeat.net for 'defrag ext3' also produced nothing.

    Why would you want to defrag a filesystem that does not require defragging?
    SEARCH FIRST... ASK SECOND Read the JL 'Community Help Posting Guidelines' before posting in the forums.

    Precompiled Redhat NTFS Modules

    Linuxplanet Tutorials

    If Linux doesn't have the solution, you have the wrong problem. ... Please do not send me a PM asking for help...

    Please read the search suggestion thread in JL Ideas

  5. #5
    Join Date
    Aug 2001
    Location
    Somewhere, Texas
    Posts
    9,627
    EXT3 is a journaling version of EXT2
    EXT2 can be looked as a very fancy FAT that is more stable and less prone to fragmentation

    The journaling is what keeps anyone from needing to defrag an EXT3 drive. Think of the filesystem as a type of database, the directories are tables and the files are records. Every file that is put on the system is put into an index that is easily and quickly searchable. All files are indexed as they are created.
    ALSO, everytime the partition is mounted it re-indexes everything for optimal performance, thus there is your defrag...re-mount the drive

  6. #6
    Join Date
    Mar 2003
    Location
    Hampton, VA
    Posts
    714
    There seems to be a utility on RedHat 7.3 called defragfs available to superuser. Maybe it is available on your distribution as well. Unfortunately, man defragfs nor info defragfs yielded no additional information on how it used. The others are correct however in that you do not need to defragment your fs. In the event, or rather, if it is the case that you want to migrate data from a larger partition onto a smaller partition, then I suggest that you create the smaller partition and put the ext2 filesystem on it via the mke2fs command. After that, I would issue the command (in a general way, you will definitely need to specify additional options) dump | restore which will go through recreate the same directory structure onto a smaller fs granted that the smaller fs is large enough to accommodate the space taken up by the original file space.

    My experience with filesystems (ext2, at least) are that they occupy the entire partition and that files and data are distributed across the entire filesystem. It doesn't just conglomerate data at the very beginning or at the very end.

    -EVAC

  7. #7
    Join Date
    Apr 2001
    Posts
    1,496
    Why would you want to defrag a filesystem that does not require defragging?
    Exactly what I was wondering.
    Distribution: Gentoo
    Kernel: 2.6.9-r9-gentoo
    Processor: Intel Pentium 4 1.3Ghz
    RAM: 256MB RAMBUS
    HD Space: 300GB (60/80/160)

    <beastmaster> eh yeah same here, used to use mandy lol
    <beastmaster> yeah damn.. that was a waste of 2 years right there lol

  8. #8
    Join Date
    Jul 2002
    Location
    Vladivostok, Russia
    Posts
    9,053
    Ext2fs defrag

    * Download: ftp://ftp.uk.linux.org/pub/linux/sct/defrag/
    * Author: Stephen C. Tweedie < sct at redhat.com >
    * License: GPL

    Defragments your ext2 filesystem. Needs updated for glib libraries.
    "I was pulled over for speeding today. The officer said, "Don't you know
    the speed limit is 55 miles an hour?" And I said, "Yes, but I wasn't going
    to be out that long."

    How To Ask Questions The Smart Way
    COME VISIT ME IN RUSSIA NOW!!

  9. #9
    Join Date
    Jun 2004
    Location
    Washington, DC
    Posts
    378
    I was trying to answer this question for a windows user who didn't believe me when I said there is no need to do it...

    How much disk space do you have?

    If I remember correctly, one way that was suggested for doing this was making another partition and simply copying the partition you want to "defrag" over to this new partition...

    But like the others said, there's erally no need. The only link I have about it is in german, so I don't know if that'll help.

    Oh- but if I remember correctly, it's not wise to let your partitions get over 95% full because then information will be split up over the blocks and you'll really be in trouble!

    There might be fixes for this now- I don't know what the date on my info was...
    Di mi se mai fu fatta alcuna cosa || Vivir con miedo, es como vivir a medias

    If Linux doesn't have the solution, you have the wrong problem.

    -- mdwatts, Grand Master, >> 40000 posts
    RIP: August 25, 2004

    ***Funky stars and monkey bars***

  10. #10
    Join Date
    Oct 2001
    Location
    $HOME
    Posts
    2,879
    Doesn't 'e2fsck -c /dev/hdxy' do some kind of defragmentation? Or does it only check the partition for bad blocks etc?
    I thought it was the latter, but when you actually do it, it seems to me it does more than that (based on the output it gives).

    I know ext3 is backwards compatible with ext2 etc etc, but couldn't running this ext2 defrag utility screw up your ext3 journal? Just a thought... after all, it probably doesn't expect a journal, and it might be confused by it.
    We are proud to say that no tests have been made on animals to provide you this post. Also, we can assure you that if it would be necessary to do tests, we wouldn't use penguins for it.
    Disclaimer: the author of this post is NOT responsible for any moral and/or physical damage this post could cause to you.

    Write for the LNO magazine!
    Catalogued Collection of Annotated Examples - CodeExamples.org
    How To Ask Questions The Smart Way - definitely read this

  11. #11
    Join Date
    Aug 2001
    Location
    Somewhere, Texas
    Posts
    9,627
    ext3 get's "reindexed" everytime it is mounted, which can be considered a defrag.

    Running an ext2 tool on ext3 that will modify the data will likely fail or (as you stated) mess up the journaling, thus the data.

    You can always convert the ext3 to ext2 then run the ext2 tools and then convert back to ext3...it's really less work then it sounds

  12. #12
    Join Date
    Apr 2003
    Location
    Transplanted from beautiful La Quinta, CA to Long Beach, CA...there are no stars here at night!
    Posts
    1,240

  13. #13
    Join Date
    Jul 2002
    Location
    Vladivostok, Russia
    Posts
    9,053
    This thread should have been defragged.
    "I was pulled over for speeding today. The officer said, "Don't you know
    the speed limit is 55 miles an hour?" And I said, "Yes, but I wasn't going
    to be out that long."

    How To Ask Questions The Smart Way
    COME VISIT ME IN RUSSIA NOW!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •