Solved

swapfile on RAID, or not?

Posted on 2015-01-22
4
251 Views
Last Modified: 2015-01-23
I've just set up my Linux boot device as a RAID-1. Seems to work OK. I've not been sure about what to do with swap space. Googling turned up this interesting statement http://tldp.org/HOWTO/Software-RAID-HOWTO-2.html

There's no reason to use RAID for swap performance reasons. The kernel itself can stripe swapping on several devices, if you just give them the same priority in the /etc/fstab file.

A nice /etc/fstab looks like:
/dev/sda2       swap           swap    defaults,pri=1   0 0
/dev/sdb2       swap           swap    defaults,pri=1   0 0
:
/dev/sdg2       swap           swap    defaults,pri=1   0 0

This setup lets the machine swap in parallel on seven SCSI devices. No need for RAID, since this has been a kernel feature for a long time.
Sounds like I don't need my swap partitions inside a RAID. But then in the very next paragraph he says,
Another reason to use RAID for swap is high availability. If you set up a system to boot on eg. a RAID-1 device, the system should be able to survive a disk crash. But if the system has been swapping on the now faulty device, you will for sure be going down. Swapping on a RAID-1 device would solve this problem.
Is this contradicting he immediate preceding statement or am I just not reading something right? Which way is he recommending? Are non-RAID swap partitions a good thing or a bad thing?

Confused!
0
Comment
Question by:jmarkfoley
  • 2
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
Frosty555 earned 500 total points
Comment Utility
It's giving you information about the pros and cons of putting the swap partition on a RAID array.

The linux kernel supports striping swap data cross multiple swap partitions without the need for a RAID-0 array to do that for you. So if you intend on putting the swap partition on a big RAID-0 array in an attempt to boost performance, is not necessary.

But that's completely besides the point if your purpose for putting it on the RAID array is for high availability. After all, even if your Linux OS is on a super-resilient RAID array, the death of your swap disk will cause the whole system to go down until you fix it. Sure you might not any actual data, but your server will certainly be down until you fix it.

Basically, you should put your swap partition on the RAID array. The article is just pointing out that striping  swap data across multiple swap partitions without using a RAID array is a native and well-supported feature of Linux.
0
 
LVL 1

Author Comment

by:jmarkfoley
Comment Utility
OK, I was suspecting that was the idea, but not sure. So, if I have the non-RAID method of multiple swap partitions on the RAID drives and one of the drives fails, I'm down, right? Which is totally NOT what I want. That's the point of the RAID (at least my point). I can create minutely backups of the main drive to a 2nd drive with rsync, so simply backing up data is not really why I want a RAID setup.

Therefore, I supposed I need to RAIDify my swap partitions.
0
 
LVL 31

Expert Comment

by:Frosty555
Comment Utility
Yep, you got it.
0
 
LVL 1

Author Comment

by:jmarkfoley
Comment Utility
Did it. It works just fine!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now