Timeline for How to defrag an ext4 filesystem
Current License: CC BY-SA 3.0
18 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 24, 2023 at 23:59 | comment | added | Sridhar Sarnobat | i wish there was some kind of verbose progress indicator rather than what looks like it's just hanging. | |
| Apr 17, 2022 at 19:24 | comment | added | rjt |
@fuzzyTew, look at my answer below askubuntu.com/a/1171593/14413 as it describes e2fsck -D
|
|
| Dec 20, 2020 at 18:06 | comment | added | pmartycz | Why does the tool show 1 as best fragmentation scenario for iso files? A maximum extent size is 128 MiB. There's no way for such big files to use only one extent. | |
| Dec 11, 2020 at 13:35 | comment | added | fuzzyTew | To clarify the obvious, file layout does matter a lot when you are running processes bound by seek time, which is why people reach this article. For example when interleaving data between files by e.g. muxing audio and video streams together, on rotating media the speed will be affected by how distant the files are on disk. Defragging is for rotating media, which is still in common use. | |
| Apr 4, 2020 at 23:44 | comment | added | Razor | I'm running a RAID on my Synology with ext4. Any reason this wouldn't work that my type of set up? Synology will only defrag Btrfs so I'm not sure if these commands are safe... | |
| May 9, 2019 at 19:18 | comment | added | Gringo Suave | I notice that it only shows 5 files quickly, but when you run the regular command it chugs over all the files in the system. Looks like it inspected a lot more than 5. | |
| Dec 7, 2017 at 10:24 | comment | added | gerlos |
@fuzzyTew You're right about ext* and the fact that files are usually spread around so they can grow. Actually, moving file off and back on is the best approximation possible at the moment of "put them near each other". Anyways, in my experience, as long you leave enough free space, you can happily ignore fragmentation problems: in a virtualization server I run for a dozen of VMs with dynamically allocated storage, e4drfrag tells me that there's no need to defrag anything, even after 4 years of use. So, from my point of view, it's fine to just don't care about fragmentation.
|
|
| Dec 20, 2016 at 16:58 | comment | added | fuzzyTew | @gerlos If the defrag tool supported defragging directories of files together, I could tell it what files I will be accessing simultaneously by passing them to the tool. I like the idea of moving them off the drive and copying them back on, but I don't think ext* tends to write files near each other by default; are you sure of this? I thought it spread them to allow for growth without fragmentation. Similarly if there are no large contiguous blocks of free space on the drive I would have to move all files off and back on which would take an eon. | |
| Dec 20, 2016 at 15:12 | comment | added | gerlos | @fuzzyTew It's true, but it's not a problem in most cases (for sure not with SSDs). We already use preload to speed up os boot, so if we have enough free space (say 20%), disk fragmentation won't affect boot time. Anyways, if we really want a set of files to be written close to each others, we can just move them elsewhere and copy them back. They will be written close to each others. But, anyways, how can the system know what data files we want to open at a time? Being in the same dir isn't enough, cause we can use hard links to put the same file in 2 or 3 different dirs. | |
| Dec 18, 2016 at 18:47 | comment | added | fuzzyTew | This defrags only the extents insides the files themselves, but not the files among each other. That is, if I have a directory containing three files at wildly different physical locations on the disk, it will still be slow to use these files simultaneously after running this tool. Is there any way to rearrange the files on the disk, or "defragment the free space" as it is sometimes called? | |
| Nov 15, 2016 at 10:56 | comment | added | gerlos |
@PavelSayekat you just need to be root (i.e. use sudo) to run e4defrag /, and don't need to do anything special. e4defrag will check every file there, so be ready to wait for your drive to read everything. Remember that it can be a big waste of time. Most of the times, if you have enough free space in file system, you will have only a few fragmented files, and often they will be in your home dir, related to your web browser activity. For example, on my desktop PC that I use every day e4defrag reports that there are only 5 fragmented files, all in Chromium config and cache dir.
|
|
| Nov 13, 2016 at 9:34 | comment | added | Pavel Sayekat |
@gerlos What if I try to defrag the root file system /?
|
|
| Dec 18, 2015 at 15:59 | vote | accept | CommunityBot | ||
| Oct 28, 2015 at 8:47 | history | edited | gerlos | CC BY-SA 3.0 |
added clarification about needed prvileges
|
| May 11, 2015 at 16:05 | history | edited | gerlos | CC BY-SA 3.0 |
added example
|
| May 11, 2015 at 16:00 | comment | added | gerlos |
Sorry, I forgot to mention that you need to run e4defrag -c with sudo or as root to get detailed information on your files fragmentation. But don't need to be root to defrag them.
|
|
| May 11, 2015 at 8:44 | comment | added | hrzhu |
e4defrag -c returns nothing but done. Does that just mean there is no fragmentation?
|
|
| May 8, 2015 at 8:55 | history | answered | gerlos | CC BY-SA 3.0 |