Defrag Single File Linux ext3

Discussion in 'General Hardware' started by lambchops511, Nov 10, 2012.

  1. lambchops511

    lambchops511 Senior member

    Joined:
    Apr 12, 2005
    Messages:
    659
    Likes Received:
    0
    Sorry if wrong section.

    I have a relatively (50G) large file on ext3, I need good linear access / bandwidth times on it. Is there a way to "defrag", the way it was copied over to the server I am pretty sure was fragmented pretty badly. I don't need perfect defrag, but is there a good way to make the file "less fragmented"?

    Would a something simple like

    cp my_file /tmp/garbage
    rm my_file
    mv /tmp/garbage my_file

    do the magic?
     
  2. Cerb

    Cerb Elite Member

    Joined:
    Aug 26, 2000
    Messages:
    17,409
    Likes Received:
    0
    Tried defrag?

    There's also shake, which is probably better.

    Also, yeah, this should probably go under *nix Software.
     
  3. AnonymouseUser

    AnonymouseUser Diamond Member

    Joined:
    May 14, 2003
    Messages:
    9,281
    Likes Received:
    3
    To see how fragmented a file is, use

    Code:
    filefrag -v filename
     
  4. mfenn

    mfenn Elite Member <br> Currently on <BR> Moderator Sabb
    Super Moderator

    Joined:
    Jan 17, 2010
    Messages:
    22,403
    Likes Received:
    0
    :thumbsup: Let's not get crazy unless there is actually a problem. I wouldn't be worried unless the file had thousands of extents.
     
  5. lambchops511

    lambchops511 Senior member

    Joined:
    Apr 12, 2005
    Messages:
    659
    Likes Received:
    0
    WOW! THANKS! I did not know this command. Is 86 extents good / bad for a 30 G file? I am guessing its pretty good? That probably means if I want better IO perf I need to hit SSDs?
     
  6. Cerb

    Cerb Elite Member

    Joined:
    Aug 26, 2000
    Messages:
    17,409
    Likes Received:
    0
    Yes. Generally, anything above around 50MB/fragment is, "good enough," and that's over 300MB/fragment. Even with some tiny fragments mixed in there, that's good enough to just not worry about it. Any newish HDD (500GB/platter or denser) aught to be able to read such a file at 100MB/s, no sweat.
     
  7. mfenn

    mfenn Elite Member <br> Currently on <BR> Moderator Sabb
    Super Moderator

    Joined:
    Jan 17, 2010
    Messages:
    22,403
    Likes Received:
    0
    Agree.

    OP, the -v output from filefrag lists all the file's extents along with their length (5th column). Double-check to make sure that there aren't a bunch of really tiny extents, but you are most likely OK.