Hibernate with LVM Swap

Lamont R. Peterson lamont at gurulabs.com
Sat Jun 10 20:57:07 UTC 2006


On Saturday 10 June 2006 01:30pm, Nicolas Mailhot wrote:
> Le samedi 10 juin 2006 à 11:08 -0600, Lamont R. Peterson a écrit :
> > Swap works best when you don't have extra layers of abstraction and when
> > the swap device is contiguous storage.  I know; LVM only adds a tiny bit
> > of overhead, but when you start hammering on swap, every last ounce
> > helps.
>
> When you have multi-disk systems an LVM swap can be faster than a
> separate swap, it only has to extend through several disks. And even the
> rest of the time, the ease of administration LVM brings justifies swap
> LVM nowadays IMHO. Dedicated swap partitions are pretty much a PITA when
> the hardware (disks) changes - either you systematically add a swap
> partition to every single disk, or you pray the one your swap is on will
> never be pulled from the box.

I don't see where the benefits of LVM enhance the use of swap, other than the 
example you gave of spanning multiple disks.  But, you can get that benefit 
by creating swap partitions of the same priority (depending on the speed 
variations in your disks, of course) and allowing the swap code to use them 
all.  IIRC (someone feel free to correct me on this if I'm wrong), the kernel 
swap code will distribute swapped pages amongst all available swap devices at 
the same priority level, when that level is the one it's currently working 
with.

Simply put, LVM doesn't bring any benefit to the use of swap, because we don't 
care what's on swap (other than, perhaps, for security reasons, that is).

Besides suspend-to-disk/hibernate software that uses a swap partition to get 
the job done, any data stored on swap is completely abandoned from session to 
session.

Let's say I'm upgrading my system to a new disk.  LVMs pvmove is great and 
takes care of anything on LVM.  If swap is separate, then I simply have to 
run this series of commands:

# fdisk /dev/sdb   # assuming the new disk is /dev/sdb, create the swap 
partition and the rest of the disk can be LVM
# mkswap /dev/sdb2   # assuming /dev/sdb2 is the new swap partition
# swapon /dev/sdb2
# swapoff /dev/sda2   # assuming that /dev/sda2 is the old swap partition; you 
reall don't *have* to do this step

At this point, the system is using the new swap device.  I don't see why you 
would say that a swap partition is a PITA.  The only other thing you might 
need to do is to edit /etc/fstab and change the entry for the old swap to the 
new one.

What if I decide later on that my one swap partition isn't big enough?  I'll 
create a swap file or a swap LV (probably making it a lower swap priority) 
and use that until I upgrade the hard drive again.  Easy.

What it I find myself having to regularly increase (or otherwise alter) the 
size of my swap device(s)?  Well, then I've got bigger problems, probably, 
and should most likely be looking at more RAM rather than or in conjunction 
with reorganizing swap.  Or perhaps, I should be adding a dedicated swap 
disk.
-- 
Lamont R. Peterson <lamont at gurulabs.com>
Senior Instructor
Guru Labs, L.C. [ http://www.GuruLabs.com/ ]
GPG Key fingerprint: F98C E31A 5C4C 834A BCAB  8CB3 F980 6C97 DC0D D409
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-devel-list/attachments/20060610/dc556fa9/attachment.sig>


More information about the fedora-devel-list mailing list