On 23/06/2022 23:27, Pascal Hambourg wrote:
Why would it crash?
Do you really believe a program can lose some of its data and still
behave as if nothing happened ? If that were true, then why not just
discard data instead of swap them out when memory is short ?
No ...
Firstly, the system shouldn't be swapping. MOST systems, under MOST
workloads, don't need swap.
Conversely, some systems, under some workloads, do need swap. And when
they do, swap needs to be as reliable as any other storage space.
And if your system is one of the ?majority? that shouldn't swap, the
cost/benefit analysis is COMPLETELY different for swap than for main
storage. So don't treat them the same.
And secondly, the *system* should not be using swap. User space, yes.
So a bunch of running stuff might crash. But the system should stay up.
Firstly, the *system* is not only the kernel. Many user space processes
are part of the *system*. Secondly, you were the one who wrote:
"/tmp - is usually tmpfs nowadays, if you need disk backing, just make
sure you've got a big-enough swap (tmpfs defaults to half ram, make it
bigger and let it swap)."
And? /tmp is *explicitly* not to be trusted in the event of problems. If
you lose a disk and it takes /tmp out, sorry. If the tmp-cleaner decides
to do a random "rm /tmp/*" at an inconvenient moment, well, if the
system can't handle it then whoever set the system up (or wrote the
program) was incompetent. Sorry. It's true. (And, no, I'm not claiming
to be a competent person :-)
Raid is meant to protect your data. The benefit for raiding your swap
is much less, and *should* be negligible.
No, this is what backup is meant to. RAID does not protect your data
against accidental or malicious deletion or corruption. RAID is meant to
provide availabity. The benefit of having everything including swap on
RAID is that the system as a whole will continue to operate normally
when a drive fails.
And how does backup protect your data when the system crashes? You know,
all that web-shop data that is fresh and new and arrived after the most
recent backup 5mins ago? But that is probably irrelevant to most people :-)
(Oh, and I didn't tell o1bigtenor NOT to raid his swap. I asked him WHY
he would want to. Maybe he has good reason. But I know him of old, and
have good reason to suspect he's going OTT.)
You need to know what the threats are, what the mitigations are, and
what strategies are RELEVANT. And you need different strategies for
long-term, short-term, and immediate protection/threats.
I run xosview. Even with gentoo, and a massive tmpfs, swap in-use sits
at 0B practically ALL the time. Why would I want to protect it? On the
other hand, my data sits on raid-5 on top of dm-integrity - protected
against both disk corruption and disk loss.
And then I usually forget I've got a massive disk sitting there for
backup. Losing a hard drive doesn't cross my mind, because in pretty
much 30 years I personally have yet to lose a disk. I know I'm lucky,
I've recovered other people who have, but ...
As I say, different risks, different mitigations...
Cheers,
Wol