Results 1 to 10 of 10

Thread: Defragging Hard Drives

  1. #1
    Join Date
    Dec 2009
    Location
    North Carolina
    Beans
    113
    Distro
    Ubuntu 12.04 Precise Pangolin

    Thumbs down Defragging Hard Drives

    I understand that the Linux formats do not need to be defragmented, but I have an external hdd with two NTFS partitions so I can share them with Windows computers.

    So, how do I defrag them?

    Thanks
    Buck

  2. #2
    Join Date
    Sep 2006
    Location
    on the streets of Detroit
    Beans
    112
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Defragging Hard Drives

    you just answered your own question when in linux there is no thing such as defragging a drive. So no need to even worry about it. I guess when you use it with your windows machine then it may ask you to degfrag it.

  3. #3
    Join Date
    Mar 2010
    Location
    /home
    Beans
    9,397
    Distro
    Xubuntu

    Re: Defragging Hard Drives

    You might want to consider using a USB stick with a portable defragmentation tool that you could plug in and point to the external HDD.

    Here is one example:

    http://portableapps.com/apps/utiliti...efrag_portable

    Hope this helps.

  4. #4
    Join Date
    Jun 2007
    Location
    Ireland
    Beans
    308
    Distro
    Lubuntu

    Re: Defragging Hard Drives

    This is from the thread All about ureadahead, while its purpose is to explain what 'ureadahead' does doing start-up there is also a brief section on fragmentation in linux (quote below). So while it generally is not a problem, compared to other OS's, it does exist and will be further refined in future versions of ureadahead making Ubuntu even greater

    But Linux filesystems don't need defragmenting!

    Whoever told you that is deeply mistaken, this is one of the most common myths of Linux.

    What is true is that Linux filesystems avoid, where possible, fragmenting their inode tables. This means that the index of how files are split up (fragmented) across the disk, and where those parts are, tends to be kept together as a whole.

    That's a good thing; fragmentation of inode tables is a big problem for other filesystems (FATs in that filesystem, etc.) so by keeping them together, it wins a lot of performance.

    But the data itself is still fragmented, and spread all over your disk in a random order. And unfortunately during boot, it's the data we need.

    One of the future things we want to do is use the ureadahead analysis of what we need during boot to feed into a defragmenter, so everything we need is in one big block on the disk.
    Have you tried using gparted to reformat the external HDD? I have used it to reformat external drives and USB keys so I can swap between windoh's and Ubuntu without any hitches.
    Currently running LXQt on;
    - Packard-Bell Imedia S1800 PC [2010, Dual Core Pentium E5800, Nvidia GeForce GT 620, RAM 4GB]
    - Dell Inspiron 15 3521 [2013, Dual Core Intel i3-3217U, RAM 8GB]

  5. #5
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: Defragging Hard Drives

    Quote Originally Posted by n4pgw View Post
    I understand that the Linux formats do not need to be defragmented, but I have an external hdd with two NTFS partitions so I can share them with Windows computers.

    So, how do I defrag them?

    Thanks
    Buck
    Drefagment them with a defragmentation application run from Windows. Linux can rx fat/ntfs, but the linux tools to defragment or fix filesystem errors on fat or ntfs are, IMO, inferior to the tools available on Windows.

    Makes sense if you think about it, people who run Linux have less interest in maintaining a NTFS file system.Personally if I share across computers, I use FAT, sure it is "old" but it is reliable and there are FAT drivers on most os (ntfs is catching up ... ).
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  6. #6
    Join Date
    Jul 2010
    Location
    in the linux world
    Beans
    554
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Defragging Hard Drives

    I actually made a shell script to defragment the ~/ directory, and with the help of some www.commandlinefu.com members it was shrunk to one line that works fast and efficiently. the original code:

    find ~ -maxdepth 20 -type f -size -16M -print > t; for ((i=$(wc -l < t); i>0; i--)) do a=$(sed -n ${i}p < t); mv "$a" /dev/shm/d; mv /dev/shm/d "$a"; echo $i; done; echo DONE; rm t

    for flash drives ( and external hard drives ), replace the "~" in "find ~ -maxdepth" with the location of the drive.

    example:

    find /dev/sdb1 -maxdepth 20 -type f -size -16M -print > t; for ((i=$(wc -l < t); i>0; i--)) do a=$(sed -n ${i}p < t); mv "$a" /dev/shm/d; mv /dev/shm/d "$a"; echo $i; done; echo DONE; rm t

    this works in most cases. the script basically re-copies most data under 16 mb from the drive back to the drive. it works because most filesystems (including fat 32 ) will always try to keep new data contiguous when it is saved.

    one last thought ( doesn't apply in your case ), flash drives really don't need ( and shouldn't be ) defragmented. solid state I/O is very consistent even with heavy fragmentation and defragging wears out the drive. but if you must defrag this script is effective and only gives the drive 2 R/W cycles

  7. #7
    Join Date
    Dec 2009
    Location
    North Carolina
    Beans
    113
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Defragging Hard Drives

    Thank you, I recorded the script and have it in the works to test at a later date.
    Main WS: Compaq Presario/Athelon X2 4450e Dual Core/3GB RAM/G-Force 210 64bit 1024k RAM Monitors: Compaq WF 1907 & Vizio M220VA --- Ubuntu 12.04 LTS
    UbuntuGuide Help Ubuntu

  8. #8
    Join Date
    Apr 2010
    Beans
    19

    Re: Defragging Hard Drives

    Quote Originally Posted by linux18 View Post
    I actually made a shell script to defragment the ~/ directory, and with the help of some www.commandlinefu.com members it was shrunk to one line that works fast and efficiently. the original code:

    Code:
    find ~ -maxdepth 20 -type f -size -16M -print > t; for ((i=$(wc -l < t); i>0; i--)) do a=$(sed -n ${i}p < t); mv "$a" /dev/shm/d; mv /dev/shm/d "$a"; echo $i; done; echo DONE; rm t
    May I presume this will defrag a diferent OS to standard Ubuntu?
    I am using an old version of Ultimate Edition.

  9. #9
    Join Date
    Jan 2007
    Beans
    6,537
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Defragging Hard Drives

    That should work on any Linux distro. The tools that make up that command are standard Linux stuff.

  10. #10
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

Bookmarks

Posting Permissions

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