[kwlug-disc] Add swap space while a centos server is live.

Chris Frey cdfrey at foursquare.net
Sat Oct 29 19:13:51 EDT 2011


On Sat, Oct 29, 2011 at 06:42:16PM -0400, Colin K wrote:
> Is it at all possible to resize a partition in centos and add a swap and
> enable it while a server is online.
> if so what would commands of such an action look like?

You can turn swap partitions off and on at will with the swapon/swapoff
commands.

You can also use a plain old file as swap, in a pinch, as root:

	dd if=/dev/zero of=swapfile bs=1024000 count=512
	mkswap ./swapfile
	swapon ./swapfile

So you could create this as a temporary swapfile, then turn off the main one,
and then go about doing whatever resizing you need.

Once this is changed, don't forget to update your /etc/fstab config for
the new swap location.

- Chris




More information about the kwlug-disc mailing list