Matthew Rosewarne on 19 Dec 2007 13:29:38 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Pros and cons of swap in a partition vs. in a file in the file system


On Wednesday 19 December 2007, K.S. Bhaskar wrote:
> Does anyone have any opinions on putting swap in a partition vs. in a
> file (e.g., /home/swap) in the file system?  Thank you very much.

I enquired about a similar topic quite a while ago, seeing if there was any 
disadvantage to using swap on LVM.  The answer from the kernel guys was 
essentially:
Swap is always slow, the difference in performance between putting your swap 
in a partition, LV, or file is entirely negligible.  If you find yourself 
swapping often, get more RAM.

I use swap in an LV (set to contiguous allocation), since I can expand it 
easily if I need to.


For a desktop or laptop system, I would recommend having the same amount of 
swap as you have RAM, and putting the swap on either a partition or LV.  That 
way, you can ensure that you can suspend to disk, and even if you upgrade 
your RAM, you'll probably still be able to suspend without adding swap (due 
to page-freeing & compression).  If you find you need more swap than that, 
just add swap files until you have enough.

You might want to try the "swapspace" program, which will dynamically allocate 
& free swap files as usage changes.  The only downside of this approach is 
that it can take a while for that rare occasion where some buggy program goes 
into a RAM-gobbling infinite loop to be killed by the OOM killer.


%!PS: The whole swap = 2*RAM tradition is largely pointless at this stage.  
When you have 512MB of RAM, that gives you a full gig of swap, which will 
spend almost all of its time empty and thus wasted.  When you have even more 
RAM than that, it's just throwing away disk space.

Attachment: signature.asc
Description: This is a digitally signed message part.

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug