Solved

swapfile on RAID, or not?

Posted on 2015-01-22
4
268 Views
Last Modified: 2016-12-08
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
ID: 40565881
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
ID: 40566747
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
ID: 40567733
Yep, you got it.
0
 
LVL 1

Author Comment

by:jmarkfoley
ID: 40567766
Did it. It works just fine!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

685 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