3 ms·
I recently ended up using swapfiles because I refactored my disk layout and it was just simpler to chuck the swap on an existing nvme partition. I realised an e
by asymptosis 6y ago
I recently ended up using swapfiles because I refactored my disk layout and it was just simpler to chuck the swap on an existing nvme partition. I realised an extra benefit: you can make it a sparse file, so it never even uses disk space at all until you actually need it, which could be never.
- muxator 6y ago"refactoring" means changing the (often implicit) structure of code without changing its external behaviour. In this case "reorganized" or "repartitioned" could probably be more apt. If we'd talked about software here (and not disk layout), I'd have considered less leniently the use of "refactoring", and a hint of unclear intentions. Sorry for being so nitpicky, but this is a sore thumb from too many "refactorings" that are, indeed, somenthing else.
- asymptosis 6y agoRefactoring has the meaning that we impute to it. God didn't hand down golden tablets in the 60s with the words "thou shalt only use 'refactor' in these prescribed ways". Instead of being sorry for being nitpicky, maybe just keep your nitpicks to yourself in future.
- qiqitori 6y agoBut if you suddenly need it and don't have it, you'll get segfaults (I assume). Sounds a bit too dangerous for me :p
- NavinF 6y agoYou'll get OOM killed as if you ran out of RAM. This doesn't happen unless the program is buggy. Moreover, if your working set is larger than RAM, you're screwed regardless. So don't do that. Swap exists so you can use more RAM for the disk cache. It's doesn't exist so that buggy programs can crawl instead of dying
- xyzzy_plugh 6y ago> if your working set is larger than RAM, you're screwed regardless. I mean, this is patently false. I've used 1TB swapfiles to get out of a sticky situation with some terrible research software that used a ton of memory to solve really valuable problems. There's nothing wrong with an absolute shit ton of swap when the alternative is OOM.
- cesarb 6y ago> I realised an extra benefit: you can make it a sparse file, so it never even uses disk space at all until you actually need it, which could be never. AFAIK, this cannot work. The swap code does not go through the filesystem, it bypasses the filesystem (it only asks the filesystem code for the swap file extents during the "swapon" call), and it's the filesystem that would be responsible for allocating disk space when writing to a sparse file.
- asymptosis 6y agoI don't think I follow. Check it out: $ du /swapfile 329696 /swapfile $ du --apparent-size /swapfile 33554432 /swapfile Looks to me like it's behaving as expected?