System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Need to increase swap using new partition on a server

Need to increase swap using new partition on a server

I need to increase swap from 2 GB to 4 GB
I am going to create new partition.

what steps i need to do ? do i need to use swapoff command ?
5 REPLIES
TwoProc
Honored Contributor

Re: Need to increase swap using new partition on a server

create the partition and give the it the tag type for swap (using fdisk).


Run the mkswap command against your new device. Just running it with the defaults against your device created above is usually fine.

mkswap /dev/


Add a line to /etc/fstab for your new swap device:

/dev/ swap swap defaults 0 0


run the command:

swapon -a


to verify you've got it:

cat /proc/swaps

We are the people our parents warned us about --Jimmy Buffett

Re: Need to increase swap using new partition on a server

Thanks John.

After creating partition is would need reboot is it advised we can run partprobe command or should i go reboot ?
Modris Bremze
Esteemed Contributor

Re: Need to increase swap using new partition on a server

After creating a new swap partition it is not necessary to reboot. If the new swap partition is mounted and visible in 'cat /proc/swaps' output - it's all is done.
TwoProc
Honored Contributor

Re: Need to increase swap using new partition on a server

No need to reboot to increase swap. Only when you would reduce or eliminate swap would a reboot be necessary. You can stay up and do what I outlined.
We are the people our parents warned us about --Jimmy Buffett
Ishwar_1
Frequent Advisor

Re: Need to increase swap using new partition on a server


The steps to Create A new Swap Space.

1) Create A new filesystem with the partition System ID of "linux Swap"

2) Use mkswap to set up a Linux swap area on the partition.

3) If you want to make it permanant make an entry of it in /etc/fstab

4) swapon with partition name will activate that partition as Swap

You can view your newly created swap space is active or not by using Command

1) cat /proc/swaps
2) free
3) top

Regards
Ishwar