|
|
Log in / Subscribe / Register

Swap across multiple storage hardware

Swap across multiple storage hardware

Posted Apr 10, 2025 14:51 UTC (Thu) by Wol (subscriber, #4433)
In reply to: Swap across multiple storage hardware by aeden
Parent article: Three ways to rework the swap subsystem

To the best of my knowledge, (by default) swap is allocated a priority based on its order in fstab. So you should list devices in order of speed.

Or you can explicitly assign a priority to each, and the kernel will stripe (aka create a raid-0) across all devices of equal priority. So no, actually creating your own raid-0 is not a good idea.

The other thing is there's two types of raid-0 - there's the striping you're thinking of, and there's sequential (which iirc is what swap does by default) where raid will fill one device before moving on to the next.

The only time raid'ing swap makes sense is if you do a raid-1, so the system is hardened against swap-device-failure.

Cheers,
Wol


to post comments

Swap across multiple storage hardware

Posted Apr 22, 2025 7:00 UTC (Tue) by mathstuf (subscriber, #69389) [Link] (1 responses)

> To the best of my knowledge, (by default) swap is allocated a priority based on its order in fstab. So you should list devices in order of speed.

Is this just "mount order"? How else are manually-mounted swap devices or systemd `.mount` swap units prioritized? It feels strange (to me) that the kernel would read `/etc/fstab` and make such policy decisions based on it.

Swap across multiple storage hardware

Posted Apr 22, 2025 18:52 UTC (Tue) by edgewood (subscriber, #1123) [Link]

"swapon" on the command line accepts a priority option, and passes that priority to the kernel. "pri=" in fstab does the same thing, and systemd presumably also does the same. So the kernel tracks the priority, no matter where it came from originally.

The swapon(2) man page describes what the kernel does with priorities if there is more than one swap device.


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