Volume Manager and swap space

My question is whether or not to mirror swap space.

I have a V240 with an SE3310 JBOD attached, running Solaris 10.

My predecessor set up RAID 1+0 on all partitions except swap.

I presume not mirroring swap was decided for performance reasons.

We currently have complete failover coverage (mirror + hotspare)

on everything but swap. We have plenty of swap space:

$ swap -l

swapfile dev swaplo blocksfree

/dev/dsk/c1t0d0s132,116 16780208 16780208

/dev/dsk/c1t1d0s132,916 16780208 16780208

Should we mirror swap?

Thank you!

[594 byte] By [LarryBreyera] at [2007-11-27 9:33:31]
# 1
mirroring swap isn't a bad ideaif you were to drop your disk that is used for your swap device, you'd crash - if it's mirrored, you should be protected from that possibility
jeffrey.sa at 2007-7-12 22:55:21 > top of Java-index,General,Installation...
# 2
> My question is whether or not to mirror swap space.Why are you mirroring the rest of the space on your disks? What are you trying to gain?-- Darren
Darren_Dunhama at 2007-7-12 22:55:21 > top of Java-index,General,Installation...
# 3

> > My question is whether or not to mirror swap

> space.

>

> Why are you mirroring the rest of the space on your

> disks? What are you trying to gain?

>

> --

> Darren

Well, we are mirroring the rest of the space for reliability.

But, some sources say its not necessary to mirror swap.

Having multiple swap partitions, if one fails, the OS will

automagically switch over to using another partition.

Other sources seem to indicate the system will crash if

a swap partition fails.

So, I guess the question is, will Solaris crash if it loses

a swap partition?

Is it better to have a single mirrored swap partition,

or to have two unmirrored swap partitions?

Our priority is reliability. I figure, once the system

starts swapping, the performance hit from mirroring

becomes a secondary consideration.

I might add, this system has a lot more RAM than it

appears will ever be used. Its unlikely swap will ever

be used. If mirroring will prevent a crash on disk

failure, it seems to be the best way to go.

What do you think?

-- Larry

LarryBreyera at 2007-7-12 22:55:21 > top of Java-index,General,Installation...
# 4

> > > My question is whether or not to mirror swap

> > space.

> >

> > Why are you mirroring the rest of the space on

> your

> > disks? What are you trying to gain?

> >

> > --

> > Darren

>

> Well, we are mirroring the rest of the space for

> reliability.

What kind of reliability? There are various things you might be trying to accomplish and mirroring may or may not be appropriate. It's excellent if you're trying to prevent a hardware failure from causing unplanned downtime. It's not good if you're trying to prevent changes to the filesystem from leaving the machine in an unbootable state...

So the specific reason there will will point to what you should do with swap. If you're trying to prevent unplanned downtime, then you should probably be mirroring swap spaces.

> But, some sources say its not necessary to mirror

> swap.

It's not necessary to mirror anything. It depends on what you're trying to do.

> Having multiple swap partitions, if one fails, the OS

> will

> automagically switch over to using another

> partition.

How would that happen?

If data has been paged to disk and that disk goes away, you can't get the data back from some other disk unless you've written it there beforehand.

> Other sources seem to indicate the system will crash

> if

> a swap partition fails.

More like "if data has been paged to disk, and it is needed again, then you're going to run into problems when the system realizes it can't page it back in". Whether that will cause a crash in every instance, I'm not sure. It's very likely to, though.

> So, I guess the question is, will Solaris crash if it

> loses

> a swap partition?

It probably depends on whether or not it's in use, and what portion of the machine is using it. I would certainly expect at least a hang if anything is needed from it and it couldn't be read.

> Is it better to have a single mirrored swap

> partition,

> or to have two unmirrored swap partitions?

"better"? The mirrored partition is more resilient to single-disk failures without downtime. The unmirrored partitions give you more space at the same price.

Is your system actually a big consumer of disk paging space? It's generally so slow that you don't expect any paging at all on production systems.

> Our priority is reliability. I figure, once the

> system

> starts swapping, the performance hit from mirroring

> becomes a secondary consideration.

I would definitely agree.

> I might add, this system has a lot more RAM than it

> appears will ever be used. Its unlikely swap will

> ever

> be used. If mirroring will prevent a crash on disk

> failure, it seems to be the best way to go.

Yup.

--

Darren

Darren_Dunhama at 2007-7-12 22:55:21 > top of Java-index,General,Installation...
# 5

"I might add, this system has a lot more RAM than it

appears will ever be used. Its unlikely swap will ever

be used. If mirroring will prevent a crash on disk

failure, it seems to be the best way to go."

one thought here, you probably will still want a dump partition in the event your system crashes - recommendations are for a primary swap file partition of at least 1/3 the size of physical ram to be able to accomodate the biggest crash dumps that your machine can create (1/3 is the max recommendation nowadays due to gains that were made in crash dump processing) - man dumpadm

regards - jeff

jeffrey.sa at 2007-7-12 22:55:21 > top of Java-index,General,Installation...
# 6

Thank you Darren and Jeff,

Sounds like, at least in my case, mirroring swap is the prudent course.

I am hoping someone could answer one more question. Since I have

two swap partitions, and seeing -d and -a options in swap(1m), is it

possible to implement the mirror without rebooting the system?

$ swap -l

swapfile dev swaplo blocksfree

/dev/dsk/c0t0d0s132,116 4100912 4100912

/dev/dsk/c0t1d0s132,916 4100912 4100912

# swap -d /dev/dsk/c0t0d0s1

# metainit -f d11 1 1 c0t0d0s1

# metatinit d1 -m d11

# vi /etc/dfstab # to replace the two swap entries with /dev/md/dsk/d1

# swap -a /dev/md/dsk/d1

# swap -d /dev/dsk/c0t1d0s1

# metatinit -f d12 1 1 c0t1d0s1

# metattach d1 d12

Should this work? If not, what do you recommend?

Thank you!

LarryBreyera at 2007-7-12 22:55:21 > top of Java-index,General,Installation...
# 7

not sure about the disksuite stuff - however considering you don't have any apparent mounted swap file usage happening, the answer is that you should be able to swap -d both of your swap slices and make them into mirrors

remember, if you're really paranoid, just do a quick mkfile somewhere that isn't going away for 10 minutes, add a new 1gb swap file, and then remove the other two, mirror them, then add them back and remove the swing file - jeff

jeffrey.sa at 2007-7-12 22:55:21 > top of Java-index,General,Installation...