Solved

swapfile on RAID, or not?

Posted on 2015-01-22
4
264 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Rate limit for DNS queries 7 83
Impact of disabling SMB v1 on Mac and Linux clients 4 538
DELL RAID MD 3260 Expansion 9 54
LogmeIn using Linux Ubuntu 16.04 6 63
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…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

856 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