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! |
Defragmenting an SSD is not such a good idea though.
|
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... |
Quote:
Also, if this is an SSD, then keep in mind that this would have no impact on performance even if it were true. |
An old, but still relevant explanation. And the follow-up.
|
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. |
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? |
Quote:
|
OK, then defragmentation should not be required.
|
Quote:
Thanks again for the help. How do I give rep points? |
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 :)
|
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 / |
Quote:
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? |
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. |
Quote:
|
All times are GMT -5. The time now is 08:28 AM. |