1748182 Members
3553 Online
108759 Solutions
New Discussion юеВ

Changing Swap

 
SOLVED
Go to solution
Vito Sarducci
Regular Advisor

Changing Swap

I have the following swapinfo. I need to change my swap to 3.75gb instead of the current 3.5gb. How do I do this again? My brain is fried and im on overload?

Please advise?

# swapinfo
Kb Kb Kb PCT START/ Kb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1536000 148772 1387228 10% 0 - 1 /dev/vg00/lvol2
dev 2048000 144856 1903144 7% 0 - 1 /dev/vg00/lvswap2
reserve - 919096 -919096
memory 1171704 643264 528440 55%
Lifes too short to stress out, Enjoy every day you have on earth!
5 REPLIES 5
Michael Tully
Honored Contributor
Solution

Re: Changing Swap

Hi,

You can easily do this by adding another
logical volume and placing swap on it.

# lvcreate -n lvswap3 /dev/vg00
# lvextend -L 256 /dev/vg00/lvswap3
# swapon /dev/vg00/lvswap3

Edit your /etc/fstab file and add the
following entry.

/dev/vg00/lvswap3 ... swap pri=1 0 0

HTH
-Michael
Anyone for a Mutiny ?
Craig Rants
Honored Contributor

Re: Changing Swap

Vito,
This is from an HP LVM doc.

IX) How to increase the primary swap

Note: Because of the contiguous allocation policy, create a bigger
logical volume and modify the Boot Data Reserved Area (BDRA) to make it
primary.

1) lvcreate -C y -L 240 /dev/vg00
The name of this new logical volume will be displayed on the
screen, note it, it will be needed later. (let say it
is /dev/vg00/lvol8)
Note: This new logical volume has to be in vg00
2) lvlnboot -v /dev/vg00
This will display the current root and swap volumes
Note: lvol2 is the default primary swap.
3) lvlnboot -s /dev/vg00/lvol8 /dev/vg00
Note: use the logical volume name from step 1
4) lvlnboot -R /dev/vg00
Recover any missing links to all of the logical volumes specified
in the BDRA and update the BDRA of each bootable physical volume in
the volume group
5) reboot the system

Hope this helps,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Deshpande Prashant
Honored Contributor

Re: Changing Swap

Hi
If you have additional space, create another swap volume of required size and enable swap on it.
Remove the entry for existing swap (lvswap3) from /etc/fstab and reboot the machine to reclaim the lvol.

Thanks.
Prashant.
Take it as it comes.
Bernie Vande Griend
Respected Contributor

Re: Changing Swap

Michael's directions are correct. (although you can create the size and logical volume in 1 command: lvcreate -L 250 -n lvswap3 vg00)

If you don't want to add a third swap area and just want to expand the lvswap2 one, you will have to comment out the entry for lvswap2 in /etc/fstab and reboot. When the system comes back up, you can use lvextend to expand that logical volume (lvextend -L 2250 /dev/vg00/lvswap2) and then use swapon /dev/vg00/lvswap2
to add it back in. There is no way to remove a swap area without rebooting.
Ye who thinks he has a lot to say, probably shouldn't.
Sridhar Bhaskarla
Honored Contributor

Re: Changing Swap

Do not forget C y options while doing the lvcreate. Swap should be contiguous.

Morever you want to make sure the swap logical volume sizes are equal (not mandatory). So, I would say the preferred method is Craig's. During that process you would want to create two lvols of equal size and contiguous on different disks totalling to 3.75 GB having equal priority.

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