1832481 Members
2940 Online
110043 Solutions
New Discussion

swap

 
SOLVED
Go to solution
Jeff Hagstrom
Regular Advisor

swap

What is the difference of device and file system swap? What are the benefits and drawbacks of each? I only have 500 meg of device swap and I need to increase swap another 500 meg. What is the best way to accomplicsh this?
5 REPLIES 5
Santosh Nair_1
Honored Contributor
Solution

Re: swap

Filesystem swaps are swap files created in existsing filesystems and thus incurr the OS file I/O overhead when accessed. They should be used rarely and only in situations where a device swap cannot be created.

The device swap uses the raw LV device as a swap device and so does NOT go throught OS file I/O.

The best way would be to create a device swap. Make sure you have enough space on the VG to create a 500 MB LV and then edit the /etc/fstab adding a line for the swap device, i.e.:

/dev// ... swap pri=0 0 0

where and are the VG and LV names respectively of the device you're planning to use as swap.

Also make sure that the maxswapchunks kernel parameter can accomodate the additions swap swap.
So in your situation, maxswapchunks should be set to at least 500 (use kmtune -q maxswapchunks to verify).

-Santosh
Life is what's happening while you're busy making other plans
Sridhar Bhaskarla
Honored Contributor

Re: swap

Jeff,

Device swap is much faster. Once it is used as swap, it can't be used for other purposes. It is exclusively for swap. On the other hand file system swap is slower compared to device swap. It basically works the same way the file system structure by creating files for swapping and use them. You can also use it as a regular file system.

I would go for device swapping with the same priority as of the primary swap.

To add the device swap, create a logical volume with the usual process.

lvcreate -n lvswap -C y -L 500 vgxx
(don't do a newfs here)
swapon -p 0 /dev/vgxx/lvswap

Edit your fstab and place the entry
/dev/vghdsswap/lvhdsswap ... swap pri=0 0 0

You can also use SAM to accomplish this task.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Santosh Nair_1
Honored Contributor

Re: swap

Also, you can get more information on HPUX memory management from the following URL:

http://www.docs.hp.com/dynaweb/hpux10/hpuxen0a/b76/@Generic__BookTextView;hf=0

-Santosh
Life is what's happening while you're busy making other plans
A. Clay Stephenson
Acclaimed Contributor

Re: swap

Hi Jeff,

I'm the radical in this area so don't listen to me. The best thing is to not swap at all - buy the memory. My favorite way is to actually configure only about 512MB of primary swap (mirrored); I then enable pseudo-swap and as a safety blanket at enable filesystem swap at a total of about 1 - 1.5X RAM at very priority. I just can't bring myself to waste 2x-3x RAM of (4x-6x mirrored) disk that I am never going to use. I also configure separate dump (unmirrored) in case it is needed. Filesystem swap is a much better use of disk space; the space is not even used unless needed; however, if you actually do swap then device swap is faster.

If you must configure device swap; configure it on another device with priority equal toi that of primary swap. Better still, is to configure multiple swap areas on multiple disks at priority 0 (1 is primary swap priority) and then the busy root disk does not do double duty as swap. NEVER configure more than one swap area on the same device at the same priority; you will drive the head positioning mechanism nuts.

In real life, I can't remember the last time my production machines have swapped; I just don't let it happen.

Regards, Clay
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: swap

Hi Jeff:

I would also add that the best performance can be achieved when you have multiple swap devices by making the swap priorities equal and sizing the devices the same. In this fashion, swap activity will be interleaved.

Of course, in the first place, you really want sufficient memory so that you rarely do any swap I/O in the first place!

Regards!

...JRF...