1832616 Members
3711 Online
110043 Solutions
New Discussion

Re: Increasing SWAP

 
SOLVED
Go to solution
Barry_10
Occasional Contributor

Increasing SWAP

Hi There,

Were running an IA64 on HPUX B.11.22 and I need to increase my swap file as I've seen it grow to 98% full. How can I do this and still have the swap file contiguious.

Thanks.
"Can you whiteboard that for me please"
18 REPLIES 18
Patrick Wallek
Honored Contributor

Re: Increasing SWAP

There is no easy way to increase you primary swap and have it remain contiguous.

The better way would be to create another LV to use as swap space.

However, if you are using that much swap then you really need to add more RAM instead of adding more swap. If you truly are paging out, then I'm your machine is performing rather poorly.

If you could attach your 'swapinfo -tam' output so we can verify you usage that would be great.
Jeff Schussele
Honored Contributor

Re: Increasing SWAP

Hi Barry,

Basically you can't extend the current swap. You'll never be able to keep it contiguous.
But what you CAN do is add secondary swap on another disk device & that'll work just fine.
You'll need to check your maxswapchunks kernel parm - it'll probably have to be increased to accomodate the extra swap. This will require a reboot.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Brian Markus
Valued Contributor

Re: Increasing SWAP

Have you considered adding secondary swap?

Here is how if you want to:

Adding secondary swap:

USING LVM:

1.) pvcreate /dev/rdsk/cXtXdX (The disk that will be used for swap)

2.) vgcreate /dev/vgXX /dev/dsk/cXtXdX (Creating a volume group)
or vgextend /dev/vg00 /dev/dsk/cXtXdX (to add the disk)

3.) lvcreate -L (size in mb) -C y -r n /dev/vgXX (Creating a logical
volume for swap)

4.) edit the fstab file ..ie /dev/vgXX/lvolX ... swap pri=1 0

5.) swapon -a

6.) swapinfo -tam (should show new swap)

To remove swap

1.) edit the fstab file -> remove the swap line

2.) reboot the system

If you want this new swap to be dump as well, it must be in vg00 and then
run the command lvlnboot -d /dev/vg00/lvolX

To check it -> lvlnboot -v

USING WHOLE DISK PARTITION:

1.) edit the fstab file ..ie /dev/dsk/cXtXdX ... swap pri=1 0

2.) swapon -a

3.) swapinfo -tam (should show new swap)



Hope this helps

-Brian.
When a sys-admin say's maybe, they don't mean 'yes'!
Brian Bergstrand
Honored Contributor

Re: Increasing SWAP

If your swap is really 98% full, then you need more memory ASAP. That being said, you can't extend your primary swap (as you've said, it has to be contiguous), but you can add swap from another disk.

Just create a new swap partition and activate it, easiest way to do this is with SAM -> Disks and Filesystems -> Swap.

HTH.
Barry_10
Occasional Contributor

Re: Increasing SWAP

Thanks for the prompt reply:

Here is my 'swapinfo -tam'

Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 4096 1226 2870 30% 0 - 1 /dev/vg00/lvol2
reserve - 2310 -2310
memory 1463 448 1015 31%
total 5559 3984 1575 72% - 0 -


Right now it's at about 30% but I've seen it increase to as high 98%, unfortunatley I can't recall what was happening at that time to increase swap to that point.


"Can you whiteboard that for me please"
Patrick Wallek
Honored Contributor

Re: Increasing SWAP

OK, you definitely are swapping. I would *SERIOUSLY CONSIDER* adding more RAM. Since you have 4GB of swap space, and you say you see it go up to 98%, I would consider adding at least 4GB of RAM, ideally I would add maybe 6GB to try to give a bit of breathing room.

You, and your users, will probably see a performance increase when you do, since you won't swapping anymore.

Barry_10
Occasional Contributor

Re: Increasing SWAP

Okay I'm a little unclear on how adding memory is going to help. Since if I add memory I have to add swap space anyways to match the memory size, is that correct?

Barry
"Can you whiteboard that for me please"
Steven E. Protter
Exalted Contributor
Solution

Re: Increasing SWAP

Adding a secondary, lower priority(higher number on swapinfo) swap area will alleviate peformance problems related to inadequate swap space.

The general strategy now is the A. Clay Stephenson plan which involes a smaller primary swap and a larger secondary that only gets used when loads get high.

As Patrick notes, swap is no substitute for adequate memory. If you need to increase swap beyond twice memory, performance will suffer and thats a good indicator its time to get your hands on some RAM.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Patrick Wallek
Honored Contributor

Re: Increasing SWAP

Processes are being paged-out to your swap area because you have no free memory to allow other processes to run. Ideally you should never see your %used on your swap rise above 0%.

If you add memory, that will give you more room for processes to run, without other processes having to be paged-out to disk first, thus making things run a whole lot faster.

Now, if you add more memory, you don't necessarily need to add more swap space. If you set the kernel parameter swapmem_on to 1 then HP-UX will use 75% of your RAM as pseudo-swap, thus allowing processes to run and reserve their little piece of swap space without actually having to have a 1:1 ratio of available swap to RAM. Having swapmem_on set to 1 will not impact the amount of RAM you have available for processes.

doug mielke
Respected Contributor

Re: Increasing SWAP

the adding of swap related to ram size is just a guideline. If you add ram, you'll actually need less swap space.

However, you want swap at least as large as ram so that you can capture mem dumps, if necessary.

In that ram is 1000 times as fast as disk access, it you're really paging out that much, more ram is the performance answer.

also, if you ever really do run out of swap, things canget ugly ( swap mem off protects against this, but if on, some things just wont get done., = ugly)
Brian Markus
Valued Contributor

Re: Increasing SWAP

Check out the HP-UX Kernel Tuning and Performance Guide by Stephen Ciullo. He goes over SWAP in depth. How much, why etc..

http://docs.hp.com/cgi-bin/otsearch/getfile?id=/hpux/onlinedocs/os/11.0/tuningwp.html&searchterms=Ciullo%7cStephen&queryid=20031029-095623

By the way, if you have a support contract, I HIGHLY recommends having him check out your system. You send him a few files; he sends you a report and BAMN!! I thought our systems were tuned pretty well; the things he recommended boosted our performance by over 50% on some of our machines.

Hope this helps!

-Brian.
When a sys-admin say's maybe, they don't mean 'yes'!
Barry_10
Occasional Contributor

Re: Increasing SWAP

Management says no budget for Memory. So I guess I'll have to look at increasing swap via disk.

B
"Can you whiteboard that for me please"
Joshua Scott
Honored Contributor

Re: Increasing SWAP

How much RAM do you currently have? HP recommends no more than 4 GB of SWAP no matter how much RAM you have. Unless you have over 16GB, then you would never need more that 4GB of swap.
What are the chances...
Patrick Wallek
Honored Contributor

Re: Increasing SWAP

How much is having a machine that performs decently worth?

If the budget it tight, have a look at Kingston memory. It works just fine in HP machines and has a lifetime warranty.

http://www.kingston.com

Other companies also do 3rd party RAM for HP machines. Crucial and Dataram come to mind.
Barry_10
Occasional Contributor

Re: Increasing SWAP

These IA Boxes currently have 2 gigs of memory.

"Can you whiteboard that for me please"
Jeff Schussele
Honored Contributor

Re: Increasing SWAP

Hi Barry,

You have to explain to mgmnt that if that swap usage ever reaches 100%, then the game's over & everything will grind to a halt.

They basically have ONLY two choices:
1) Increase RAM
2) Decrease RAM demand

What apps are you running? 2GB for anything serious is woefully short. If they can decrease the app's RAM demand - then you can limp along w/o adding RAM. But they *must* understand that when you're paging out the performance hit can be in the tens of thousands percent.

My 2 cents,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Brian Lee_4
Regular Advisor

Re: Increasing SWAP

If you can get a chance to bring down the server, you can extend swap if you take the following procedures.

1) Put "#" in front of swap area in /etc/fstab file
3) reboot the system
4) remove swap file system
# lvremove /dev/vg00/lvol2
5) re-create swap file system
# lvcreate -L xxxx /dev/vg00
6) activate swap file system
# swapon /dev/vg00/lvol2
7) add swap file system into /etc/fstab

For the best performance, you had better create device swap with one physical disk.

1) Device Swap:
a. A disk area or logical volume that is used exclusively for swap.
b. Device swap is faster than file system swap.
c. When using the whole disk approach, you can either use an entire disk for swap, or reserve space at the end of the disk after the file system by using the â R option of newfs. For example, the following command creates a file system on a disk and reserves 200 MB for swap:

# newfs â R 200 /dev/rdsk/c0t2d0

When using LVM you create a separate logical volume for device swap. The following is an example of an lvcreate command used to create 200 MB swap logical volume:

# lvcreate â L 16 â n myswap /dev/vg01

1)Swap on a logical volume (device swap)
# lvcreate â L 12 â n myswap vg00
#swapon /dev/vg01/myswap

2)Swap on a whole disk ( whole disk swap)
# swapon /dev/dsk/c0t2d0

3)Swap on a file system
# swapon -p 4
brian lee
Rory R Hammond
Trusted Contributor

Re: Increasing SWAP

You need to fix the paging problem. It might not just be a hardware issue. It can be a configuration issue.
For example
Are you running ORACLE?

Look at your at your SGA area. you might be able to reduce it. I have seen some oracle parms set so hight that the cache hit rates were wonderful. The benifit was lost because the OS was paging.

Check your tunable parameters to see if you can free up memory.

Consider setting ulimits. See if you have a program that is "leaking" memory

Find out who your bad boys are
ps -fel (check the SZ column)
then see what can be done to tune them.

Regrading no money in the budget. If you don't fix this problem your company will loose money becuase of downtime and lost productivity.

Good Luck
Rory
There are a 100 ways to do things and 97 of them are right