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. Loading...

    Similar Threads - Defrag Single File Forum Date
    Single switch for multiple cables (floppy). General Hardware May 7, 2017
    Help regarding SSDs and defrag? General Hardware Jan 11, 2016
    How often do you defrag your HD? General Hardware Oct 12, 2009
    Gaming while defragging General Hardware Jun 29, 2008
    Can you defrag a flash drive? General Hardware May 15, 2008

  3. 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.
     
  4. AnonymouseUser

    AnonymouseUser Diamond Member

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

    Code:
    filefrag -v filename
     
  5. mfenn

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

    Joined:
    Jan 17, 2010
    Messages:
    22,403
    Likes Received:
    1
    :thumbsup: Let's not get crazy unless there is actually a problem. I wouldn't be worried unless the file had thousands of extents.
     
  6. 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?
     
  7. 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.
     
  8. mfenn

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

    Joined:
    Jan 17, 2010
    Messages:
    22,403
    Likes Received:
    1
    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.