?
Solved

swapfile on RAID, or not?

Posted on 2015-01-22
4
Medium Priority
?
294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
Frosty555 earned 2000 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

Independent Software Vendors: 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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…
Suggested Courses
Course of the Month9 days, 8 hours left to enroll

762 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