4 ms·
“Ubuntu switches from swap partitions to using swap files by default. This means a simpler partition layouts during installation, disk space savings and easier
by ausjke 10y ago
“Ubuntu switches from swap partitions to using swap files by default. This means a simpler partition layouts during installation, disk space savings and easier adjustment of swap size” -- interesting, was always unclear about the performance difference between a partition and a swap file.
the LXD and Snap are fun to watch, Canonical always does things a bit different here and there.
- hashhar 10y agoThere'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]
- ChuckMcM 10y agoNo performance issue for non-holey files, and the meaning of swap gets really really weird when you have 32 or 64GB of RAM. Ever since 16GB+ servers I've had no swap partition, and a 1GB swap file, if the swap file ever gets touched I figure out what was screwing up and fix it (I consider it an error to swap in my systems). It is perhaps not too surprising but if you ever swap to a non-SSD device you're effective computation rate is reduced by 3 orders of magnitude.
- rebootthesystem 10y agoI've been using a small dedicated SSD drive for swap file and other temp file requirements for a few years now. One example of this is Photoshop temp file space. I don't want unnecessary I/O out of system or data drives. That said, yes, we just got done upgrading all of our workstations to new self-built systems with 64 GB of RAM and I would definitely consider having to go to swap file to be an error. All of our systems have 5 SSD drives: System, Data, Library, Development, Swap. They are all 1 TB SSD's with the exception of the 256 GB Swap/Temp drive. The idea is to distribute read/writes and organize things so that no SSD, and, in particular, the system SSD, is abused. Running a large number of FEA thermal simulations or a bunch of FPGA compilation jobs can produce an amazing amount of files. This approach seems to do a decent job of spreading that out and keeping it off the System drive. That, coupled with local (network) and remote backups has worked well so far.
- alyandon 10y agoThat won't work with a btrfs file system. I wonder if the installer takes that setup into account.
- AJAlabs 10y agoSounds like Canonical is moving further and further away from it's Debian origin.