2 ms·
The trouble is I did use a filesystem all the way to completely full, and now it's severely fragmented (despite me resizing it larger) and I have no practical w
by ars 14y ago
The trouble is I did use a filesystem all the way to completely full, and now it's severely fragmented (despite me resizing it larger) and I have no practical way of unfragmenting it.
- joejohnson 14y agoFrom the article: "If you actually need to defragment a file system, the simplest way is probably the most reliable: Copy all the files off the partition, erase the partition, then copy the files back onto the partition. The file system will intelligently allocate the files as you copy them back onto the disk."
- gouranga 14y agoIsn't that a form of defragmenting? It also contradicts the point that it is unecessary to defragment the volume.
- dredmorbius 14y agoIt's extremely rare to need to do this. It's generally a sign that you're running your disks / filesystems overutilized. Retaining 10-20% free space is generally encouraged. If you do elect to do the "copy out, wipe, copy in" method, you can do this, in general, while not completely losing the use of your system. There are some tricks (union mounts, remounting filesystems) which will allow you to flip between filesystems, in most cases. Specifics will depend on your partitioning scheme, use case, and the filesystems under consideration (usually you'd be dealing with user files under /home, spool or variable files under /var, source trees, etc.). As the article states, Linux systems generally experience very minimal fragmentation, and dynamically resolve the issue for you, unlike Windows. You can typically run a Linux system for years, given a 10-20% disk reserve, without running into appreciable fragmentation issues. The gains from any sort of manual defragmentation would be minimal compared to the cost of performing the task.
- Lerc 14y agoThat is true for any filesystem that needs defragging. The entire notion of a disk defragmentor is that it fixes the problem without needing to do this step. It's like saying "Our car never breaks down so you don't need to be able to repair it. Even if it does break down you can still walk."
- sltkr 14y agoThere are tools like Shake [1] that can semi-intelligently copy fragmented files around to defragment them, which typically results in less fragments if there is enough free space on the volume. 1. http://www.vleu.net/shake/ http://www.vleu.net/shake/
- drostie 14y agoI had that problem at one point. I vaguely recall that I unmounted my home partition and fscked it at one point to find the fragmented inodes, then there was complicated magic to find the filenames that those inodes referred to, and then there was a script which copied them all to a tmpfs (i.e. into memory), deleted the original, and copied the copy back out. One of the goals of recent ext4 work was to get support for "online defragmentation" but I don't know to what extent it's automatic, what tools exist, et cetera. It sounds like pyfragtools also has attempted to solve this problem.
- ajross 14y agoUh... attaching new media and using "tar" isn't a practical way of unfragmenting it? Hard drives are almost free in the modern world.
- shawnz 14y agoWhen compared to having a (reasonably simple) tool which will do it for free, using only one volume, while still allowing r/w access? Yes, it's impractical.
- gcr 14y agoIf your filesystem is completely full, fragmentation should be the last of your worries.
- ars 14y agoIt was full, now I expanded it, but the old data is still heavily fragmented.