1836801 Members
2771 Online
110110 Solutions
New Discussion

Extending secondary swap

 
SOLVED
Go to solution
Tom Wolf_3
Valued Contributor

Extending secondary swap

Hello, we have primary (/dev/vg00/lvol2) and secondary (/dev/vg00/lvswap2) swap space on an HP-UX 11.23ia64 server as configured below:

# swapinfo -atm
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1504 0 1504 0% 0 - 1 /dev/vg00/lvol2
dev 16384 0 16384 0% 0 - 1 /dev/vg00/lvswap2
reserve - 17861 -17861
memory 24563 11263 13300 46%
total 42451 29124 13327 69% - 0 -


I'm trying to extend secondary swap space by 8 GB (we recently added more memory to this server and I want swap space to equal physical memory - which is now 24 GB).

I issued the following command to extend the logical volume used for secondary swap space:

#lvextend -L 24576 /dev/vg00/lvswap2

I issued the swapon -a command hoping that would update the swapinfo but it's still only showing 16 GB of secondary swap instead of 24.

How can I update swapinfo WITHOUT a reboot?
Did I go about this the wrong way?
Should I have instead created another logical volume that was 8 GB in size?

Please offer advice on this issue.

Thank you.

Tom Wolf
7 REPLIES 7
Patrick Wallek
Honored Contributor
Solution

Re: Extending secondary swap

>>How can I update swapinfo WITHOUT a reboot?

As far as I know, you can't.

>>Should I have instead created another logical volume that was 8 GB in size?

That is my preferred method.
Doug O'Leary
Honored Contributor

Re: Extending secondary swap

Hey;

Swap space has to be contiguous disk space so you can extend your existing swap if and only if it can be extended contiguously.

Basically, if you have any other LVs defined after the swap lv, you're not going to be able to extend it.

You can generate another swap lv though, assuming you have the disk space.

lvcreate -L ${size} -C y -n swap3 vg00
swapon -p 1 /dev/vg00/swap3

should do the trick.

HTH;

Doug

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
Tom Wolf_3
Valued Contributor

Re: Extending secondary swap

Thanks for the responses.
Now I'm trying to reduce the secondary swap space logcal volume back to 16 GB so I can reclaim that space and create another logical volume for secondary swap.

Right now, secondary swap space is 24 GB:

LV Name /dev/vg00/lvswap2
LV Status available/syncd
LV Size (Mbytes) 24576
Current LE 1536
Allocated PE 3072
Used PV 2

When I try reduce it back to 16 GB I get the following message:

# lvreduce -L 16384 /dev/vg00/lvswap2
The Logical Volume is used as a swap device.
Logical volume "/dev/vg00/lvswap2" is not reduced.

Any suggestions on how to reclaim that space without a reboot?


Thanks.
Michael Steele_2
Honored Contributor

Re: Extending secondary swap

Hi Tom:

Although you've extended your swap space illegally your probably not in bad shape as far as corrupting the O/S and causing some immediate major damage. But I'd plan on fixing this problem at the next maintenance window or sooner. Just not now.

The first three logical volumes in vg00, where the O/S resides, are boot, swap and root and are all sequential or contiguous. One address after another will be read in sequential order from address zero in the boot lvole all the way through to the end of the root lvol. But this only occurs on bootup.

So don't reboot until your ready.

I recall having made this mistake years ago and the O/S wasn't affected. But, who knows.

The work around is too reignite the O/S. Which means downtime. You can kill two birds with one stone when you do this by resizing lvol2 swap to something bigger. See the previous response which is correct except for updating /etc/fstab.

But you're not going to follow this now. Just file it away for the future.

Plan this out with pencil and paper so you know your lvol sizes before starting. If its the first time then have the response center guide you through.

Do you have an ignite tape or image? If not, then you'll have to reinstall.

Support Fatherhood - Stop Family Law
Tom Wolf_3
Valued Contributor

Re: Extending secondary swap

Thanks for the additional response.

Yes, we do have a recent ignite image of this server.

Knowing that secondary swap has to be contigous space and since /dev/vg00/lvswap2 is physically the last logical volume in volume group vg00, I'm guessing the next reboot should safely extend secondary swap.

The current logical volume and physical extent layout of vg00 is as follows:

/dev/vg00/lvol1 using phyical extent 00000 through 00031

/dev/vg00/lvol2 using physical extent 00032 through 00125

/dev/vg00/lvol3 using physical extent 00126 through 00189

/dev/vg00/lvol4 using physical extent 00190 through 00627

/dev/vg00/lvol5 using physical extent 00628 through 00690

/dev/vg00/lvol6 using physical extent 00691 through 01190

/dev/vg00/lvol7 using physical extent 01191 through 01565

/dev/vg00/lvswap2 using physical extent 01566 through 03101


Correct me if I'm wrong, but shouldn't the next reboot resize secondary swap space /dev/vg00/lvswap2 to the 24 GB I increased it to with the lvextend command?
Michael Steele_2
Honored Contributor

Re: Extending secondary swap

Verify your question with pvdisplay which will note every PE ( physical extent ) and what lvol is associated to it.

But your still missing the point, you've made swap a random accessed lvol now instead of a sequential contiguous lvol. So when you read your pvdisplay report it will show the last PEs belonging to swap. And they shouldn't be there. All the swap PEs should be around the 200 to 300 range, with boot being 0 to 199 and root being 301 to something like 500. While those new PE will be at the end with addresses something like 5000 to 5050.

Further more with vg00 active I don't think you'll be able to intervene with an lvreduce or a vgcfgrestore. Check for the date on the vg00 map file though to see if it was updated. It should have been.

Regardless, with vgcfgrestore, I don't think it will work since the map file will have been updated.

Again, ignite is your only option here.

And don't reboot til your ready to reignite the whole boot disk.

I suppose you can try to see what happens before re-igniting. Just make sure that your ready before you do.
Support Fatherhood - Stop Family Law
dclark
Occasional Advisor

Re: Extending secondary swap

Your fine for now. Unfortunately, this is swap (albeit secondary...), you can't do anything until your ready to reboot as swap is presently claimed by the kernel. One thing you could do is comment out from fstab, reboot, (you may need to additonally comment out scripts from starting if they are relying on your extra swap being available). Once your system has returned, remove the 'lvswap2' partition and just recreate it. You do not need to completely rebuild or re-Ignite vg00 just to resize secondary swap.