Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What are the advantages of swap on a raid-1 (mirror) device?

(in a server environment running linux)

I mean, you can just use multiple disk devices in linux for swap. And with swap devices that have the same priority, the kernel has the possibility to optimize reads and writes (i.e. striping).

I can think of one: With raid-1 and hot-swappable drives you can change a failed leg of the swap-mirror without rebooting. Assuming that the kernel did not already read and use a corrupted page from the failing leg.

Without raid1 you would have to either reboot or swap-off the failed device and hope that only unimportant processes (with now unavailable paged-out memory) are terminated.

Is this one advantage, and are there others?

share|improve this question
Nope, you got them all. Its all about being able to survive drive failure. – Patrick Jun 16 '11 at 1:20
up vote 3 down vote accepted

You've mostly got them: slightly faster reads (but slower writes), and the ability to survive a failed drive without losing all the swapped-out processes. There's another: if your machine only has RAID-1 filesystems (or RAID-1 for the OS and RAID-5 for data, or similar arrangements), you might not want to complicate your setup further by having yet another drive arrangement just for swap.

Note that RAID-1 doesn't catch data errors, so “the kernel did not already read and use a corrupted page from the failing leg” doesn't come into play. The assumption behind RAID-1 is that a sector read either succeeds and returns the last-stored data, or fails with an error code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.