LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-30-2020, 01:48 PM   #1
Arct1c_f0x
Member
 
Registered: Feb 2020
Posts: 123

Rep: Reputation: 24
Best way to defragment hard drives in Linux?


Hey I have a bunch of drives and I have a feeling several of them are very fragmented. You know, part of a large .mp4 is stored here and part is stored there, and when navigating through one folder, the files in that folder are spread out all through the drive. How do I correct this? Is there any open source software out there that can help me?


Thanks!
 
Old 04-30-2020, 01:59 PM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Defragmenting an SSD is not such a good idea though.
 
Old 04-30-2020, 02:00 PM   #3
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
I suppose it would depend on the file system in use (there are many) but I am pretty sure this is not necessary. Others may chime in and correct me. Keep in mind that Microsoft (IMHO) has developed terrible file systems and users have grown used to dealing with their idiosyncrasies. I have been using various Linux and BSD file systems for over 2 decades and have not defragged a drive in that entire time. I do "TRIM" on SSDs but my file system takes care of that for me and I don't have to do it manually. Not sure how this relates to fragmentation.

Again, someone that knows way more about this will I am sure add to this...
 
Old 04-30-2020, 02:03 PM   #4
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,198

Rep: Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307Reputation: 5307
Quote:
Originally Posted by Arct1c_f0x View Post
Hey I have a bunch of drives and I have a feeling several of them are very fragmented. You know, part of a large .mp4 is stored here and part is stored there, and when navigating through one folder, the files in that folder are spread out all through the drive.
What gives you this feeling?

Also, if this is an SSD, then keep in mind that this would have no impact on performance even if it were true.
 
1 members found this post helpful.
Old 04-30-2020, 02:06 PM   #5
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
An old, but still relevant explanation. And the follow-up.

Last edited by shruggy; 04-30-2020 at 02:31 PM.
 
2 members found this post helpful.
Old 04-30-2020, 02:49 PM   #6
Arct1c_f0x
Member
 
Registered: Feb 2020
Posts: 123

Original Poster
Rep: Reputation: 24
Okay so the drive I'm talking about is a mechanical 6TB drive and its housed in a external case (if that's at all relevant). I connect it to my pc by way of a USB 3.1 cable and then read documents off it or watch movies. It makes odd sounds sometimes when reading a movie like there's some sort of hesitation on the part of the drive.

Another question I have is:
Will watching movies and reading documents off the drive directly limits its overall life? So what I mean is reading the content on the drive as opposed to writing it.
 
Old 04-30-2020, 02:58 PM   #7
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
Mechanical drives under Linux filesystems do not suffer from fragmentation. That's what the link shruggy posted states, in essence.

Using a drive at all shortens its life but what good is a drive if you don't use it...make backups if there is any doubt of the drive's reliability.

Some drives make a little noise when reading and writing some are silent. My NAS drives make noise from time to time and it's normal. I have backups so if a drive fails, I can replace it and restore the data.

EDIT: what file system is the drive using? Is it NTFS or a Linux file system?

Last edited by sevendogsbsd; 04-30-2020 at 02:59 PM.
 
1 members found this post helpful.
Old 04-30-2020, 03:12 PM   #8
Arct1c_f0x
Member
 
Registered: Feb 2020
Posts: 123

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by sevendogsbsd View Post

EDIT: what file system is the drive using? Is it NTFS or a Linux file system?
The drives are using ex3/ext4 with Luks encryption
 
Old 04-30-2020, 03:16 PM   #9
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
OK, then defragmentation should not be required.
 
1 members found this post helpful.
Old 04-30-2020, 03:21 PM   #10
Arct1c_f0x
Member
 
Registered: Feb 2020
Posts: 123

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by sevendogsbsd View Post
OK, then defragmentation should not be required.
Thank you! I'm reading the document the other guy posted right now in order to gain more of a technical understanding of why it doesn't require defraging.

Thanks again for the help. How do I give rep points?
 
Old 04-30-2020, 03:22 PM   #11
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
I think there is a little icon to the right of the penguin under my name. Thanks! It was a team effort really: shruggy had the article
 
1 members found this post helpful.
Old 04-30-2020, 03:34 PM   #12
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,937

Rep: Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619
It is very possible that one may need or want to defrag. Linux filsystems in some cases may need it.

sudo e2fsck -fn /dev/sdax may offer clues on UNmounted drives.

Copy files off and copy them back to newly formatted much like the old ntbackup.

e4defrag may be installed already.

sudo e4defrag /
 
Old 04-30-2020, 03:40 PM   #13
Arct1c_f0x
Member
 
Registered: Feb 2020
Posts: 123

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by jefro View Post
Copy files off and copy them back to newly formatted much like the old ntbackup.
/
It makes sense to me somehow why that would work and be a form of consolodation of files of the same directory in one place, but I don't know why.
So let's say I finished adding all the movies I wanted to a certain movie database and I was done adding files to that directory. At that point I would want to copy that movie database to drive B, reformat drive A back into ext4 and then copy the directory back to Drive A from drive B?

Is that the general idea?
 
Old 04-30-2020, 04:35 PM   #14
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,421
Blog Entries: 7

Rep: Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535
Best way to defragment hard drives in Linux?

Yes it is... but don't be surprised if you don't see much improvement. While you can defragment drives in Linux, it is generally not necessary. They defragment themselves with use.

Modern NTFS no longer requires defragmenting either, unless you want to shrink a partition.

Accessing a large, mechanical, encrypted drive over USB is always going to be slower than if it were SATA.
 
2 members found this post helpful.
Old 04-30-2020, 04:50 PM   #15
Arct1c_f0x
Member
 
Registered: Feb 2020
Posts: 123

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by rkelsen View Post
Accessing a large, mechanical, encrypted drive over USB is always going to be slower than if it were SATA.
I totally agree but I can't find an eSATA to USB cord for less than $50 and I want this particular drive to be an external drive. Know any cheaper sources for a eSATA to USB cord?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I defragment a hard drive? Gogul Linux - Newbie 6 03-10-2006 07:24 AM
External Hard Drives/Hard Drives ddrfreak Mandriva 1 12-16-2004 06:12 PM
defragment linux glock19 Linux - General 11 09-14-2004 06:22 PM
No Defragment for Linux weronpc Linux - Newbie 6 02-11-2004 12:21 PM
filesystem: linux needs to "defragment"? sirpelidor Linux - Newbie 6 01-02-2004 08:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration