linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doug Ledford <dledford@redhat.com>
To: Roberto Spadim <roberto@spadim.com.br>
Cc: Linux-RAID <linux-raid@vger.kernel.org>
Subject: Re: RFC swap over raid1
Date: Thu, 01 Aug 2013 19:04:37 -0400	[thread overview]
Message-ID: <51FAE985.1040809@redhat.com> (raw)
In-Reply-To: <CAH3kUhFoNKgHErujKuCLMvx_qbDa2dwhW+sMD=7W9W0hHTWB-w@mail.gmail.com>

On 08/01/2013 06:11 PM, Roberto Spadim wrote:
> hi guys, should i use raid1 with swap partitions? why?
> 
> example:
> swapon /dev/sda1
> mdadm --create /dev/md-swap --level=1 --raid-devices=2 /dev/sda /dev/sdb

You can't do this.  You've just corrupted your hard drives.  The reason
is that you've set /dev/sda1 to be used for swap, then you've made a
raid1 array from the entirety of /dev/sda and /dev/sdb, which of course
includes the space in /dev/sda1, which is already in use.

> mkswap /dev/md-swap

Here you've just turned all of /dev/sda into a swap device (as well as
/dev/sdb).

> swapon /dev/md-swap

And here you've turned on a swap device that is /dev/sda and which will
overlap with the swap you already enabled on /dev/sda1.  You're using
the same space twice.  It's definitely corrupted and broken.
Fortunately, I'm pretty sure the kernel won't even allow you to do all
of this.  You would have been stopped at the mdadm --create because
/dev/sda1 was in use so /dev/sda couldn't be allocated to the newly
created md raid array.

> what's the advantages and disvantages?
> should i use raid0, linear, raid1, raid10, raid5 or raid6?

These are all the same basic questions as if you were running something
other than swap.  The same tradeoffs exists.  Although I would never use
raid4/5/6 for swap as you don't want to have to use parity on your swap,
and raid10 is overkill.  If you use raid0 or linear and loose a drive,
you can crash your machine when the swap is needed.  I only use raid1
(if I use swap at all, which is not that often any more).

> or just two swap partitions and run this way:
> swapon /dev/sda
> swapon /dev/sdb
> ?

What exactly do you think swapon does?  Because you've just allocated
all of /dev/sda and /dev/sdb to swap and they can't be used for anything
else.

  reply	other threads:[~2013-08-01 23:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01 22:11 RFC swap over raid1 Roberto Spadim
2013-08-01 23:04 ` Doug Ledford [this message]
2013-08-02  2:01   ` Roberto Spadim
2013-08-02  7:46     ` Stan Hoeppner
2013-08-02 14:21       ` Roberto Spadim
2013-08-02 15:40         ` Doug Ledford
2013-08-02 15:59           ` Roberto Spadim
2013-08-02 16:35             ` Doug Ledford
2013-08-02 16:40               ` Roberto Spadim
2013-08-02 16:50                 ` Doug Ledford
2013-08-02 17:29                   ` Roberto Spadim
2013-08-02 17:35                     ` Doug Ledford
2013-08-02 17:38                       ` Roberto Spadim
2013-08-02 18:26                     ` keld
2013-08-02 18:39                       ` Roberto Spadim
2013-08-02 21:31                         ` Keld Jørn Simonsen
2013-08-02 15:21     ` Doug Ledford
2013-08-02  1:59 ` Brad Campbell
2013-08-02  2:02   ` Roberto Spadim
2013-08-02  2:18     ` Brad Campbell
2013-08-02  2:21       ` Roberto Spadim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51FAE985.1040809@redhat.com \
    --to=dledford@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=roberto@spadim.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).