Hey, Smerrills here again, still having lots of fun working with Linux. And have been getting quite a few older games working on it. Which has been WONDERFUL going back to old games. But I just came up with an interesting question when I upgraded to 18.04 on my main machine.
Last I remembered when I first installed Linux, it was recommended to create a swap partition by everyone I asked. So I did it. But now with 18.04, when I was doing a manual partition of my drives so I had some more control, I noticed at the end of the install, that Ubuntu no longer makes a swap paritition and instead makes a swap file.
Why now of all times, is a lot of Linux distros shifting to a swap file, instead of a partition?
If I remember correctly, Windows switched to a swap file back in the early nineties. (please correct me if I’m wrong)
Why is Linux lagging behind? Or so it seems?
Would definitely love to know if anyone is in the know. Just generally curious, but if you can give a more detailed reason, I’d love to hear about it.
Swap partitions used to have advantages in both performance and features, allowing for hibernation and so on. On modern hardware you shouldn’t be actively swapping ever, and the only reason you have swap at all is so you don’t get OOMkiller killing off processes if you have a memory leak or something. So everybody switched to swap files for the obvious flexibility advantages.
Well btrfs is a bit too complicated to me, and I don’t have the need for multiple drives in a raid sort of configuration. I’m just a simple user that plays older games, and goes on netflix, and youtube alot. So that doesn’t bother me so much.
So linux isn’t laggingf behind. In truth we could always make a swap file, but until the last 10 years or so its been a lot of older machines that were popular to use linux on publicity wise.
So for example my HP NW8000 is a capable laptop, but only a pentium M and only 2GB capable for ram. So I’d want a swap partition instead of a file. This is true for a lot of users still.
We could always make a swap file, partitions are just easier.
Partitions certainly aren’t easier, exactly the opposite.
I would use swapfiles on ancient hardware too. The performance difference is small and it’s much less wasteful. Not worth reparitioning your disk if it’s already running linux though.
Depends on the drive. On a 7.2K drive totally, on an SSD not so much. More or less if you boot off an SSD use a file, if you boot off of spinning rust use a partition (unless you have a 15K or higher drive, then use a file).
You might laugh but when I used pentium 4’s still I had a specific 40GB HDD dedicated just to swap and a FAT32 partition to move files from windows to linux and vice versa. My system was stupid fast for what it was.
Yeah, but best practice is to avoid using swap (if possible) on SSD systems. None of my systems, except my server, have swap, and the server only has swap because ZFS eats ram faster than a fat chick at a buffet.
No-- best practice is to avoid swapping. That applies to both SSDs and magnetic disks. You still need to configure swap space or the first time you have a memory leak in some program OOMkiller will screw up your day.
Memory leaks are very common. All sorts of resource constraints are constantly an issue. Not trying to be confrontational or insulting in any way, so please don’t take it that way, but “you didn’t plan carefully” is what you’d expect someone without real-world IT experience to say.
So, to answer @Smerrills question. Set swappiness to 0 if you use an SSD. I usually set it to 15 if using an HDD, so it can get a head start, because transfer times are slower. I might be ill informed on the matter though.