LWN.net Logo

defragmentation of swap file?

defragmentation of swap file?

Posted Feb 5, 2009 2:21 UTC (Thu) by brouhaha (guest, #1698)
Parent article: Online defragmentation for ext4

While it's obviously possible, I've never had any serious problem with the swap file getting extremely fragmented. It would be fine by me if online defragmentation of the swap file wasn't allowed. Instead of building complicated mechanisms for file systems to support that, and requiring file systems to use it, a relatively simple piece of kernel code could check whether the file in question was an active swap file, and deny the request from user space.

If you really need to do it, the user space utility could create a replacement swap file, defragment it (if necessary), enable swapping on the new file, then disable swapping on the old file and delete it. That's not significantly worse than the way the defragmentation patch works with regard to normal (non-swap) files. The user-space program could determine whether the file in question is a swap file, and deal with it appropriately.


(Log in to post comments)

defragmentation of swap file?

Posted Feb 5, 2009 12:43 UTC (Thu) by jengelh (subscriber, #33263) [Link]

>It would be fine by me if online defragmentation of the swap file wasn't allowed.

This in fact, also holds true for FAT and NTFS. (It seems possible to get it moved by removing the system attrib from it, but who knows what side effects this has on a live swap...)

defragmentation of swap file?

Posted Feb 5, 2009 22:09 UTC (Thu) by amarjan (guest, #25108) [Link]

Indeed, and there's a utility for Windows called pagedefrag that will defragment the windows pagefile and other critical system files early on boot, before the system is up and using them.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds