4 ms·
There's no performance difference as long as the swap file doesn't have "holes" (meaning that the file is contiguous on-disk). There's the convenience of being
by hashhar 10y ago
There's no performance difference as long as the swap file doesn't have "holes" (meaning that the file is contiguous on-disk).
There's the convenience of being able to re purpose the storage as long as swap isn't being used.
- loup-vaillant 10y agoDoes this have to hold for SSDs as well, or is performance unconditionally the same?
- hashhar 10y agoPerformance is unconditionally the same (last time I checked on an 840 EVO) given that the swap file DOESN'T HAVE HOLES. http://www.faqs.org/docs/linux_admin/x1762.html http://www.faqs.org/docs/linux_admin/x1762.html
- loup-vaillant 10y agoIt's unconditionally the same if it satisfy the very condition I was asking about. Riiight.
- jabl 10y agoIIUC the kernel bypasses all the filesystem code when swapping (except during swapon when getting the starting block address and size of the swap file).
- hashhar 10y agoI don't know but doesn't that mean that if a swap file had holes, the kernel will write to the holes hence corrupting any data present in the files stored at those holes? We need a kernel maintainer here.
- jabl 10y agoFrom http://www.man7.org/linux/man-pages/man8/swapon.8.html http://www.man7.org/linux/man-pages/man8/swapon.8.html: > The swap file implementation in the kernel expects to be able to write to the file directly, without the assistance of the filesystem. So apparently it can work with a file that has holes, but then it cannot entirely bypass the filesystem, I guess.
- tinus_hn 10y agoIf by a file with holes you mean a file that has unallocated blocks (a sparse file, which is quite rare) such a file cannot be used as a swap file, the kernel will refuse it. If you mean a fragmented file, it works but it is slightly slower but not by a relevant amount. The kernel just remembers which blocks are in the file and uses these. As the swap file typically is created during installation it is unlikely to be fragmented anyway.
- deleted 10y ago[deleted]