Creating a swap space


Sometime you need extra swap space, I am not sure if you should use this in a production environment but to get up and running then it is ideal.

As root

mkdir /var/swap
chown root:root /var/swap
chmod 700 /var/swap
dd if=/dev/zero of=/var/swap/01.swp bs=1024 count=1M
chown root:root /var/swap/01.swp
chmod 600 /var/swap
mkswap /var/swap/01.swp

In this example the file will be 1GB

Add the following to the fstab

vi /etc/fstab

/var/swap/01.swp none swap sw 0 0

Run

swapon -av

This allows it to mount when booting up

To use it immediately

mount -a



Advertisements

One Comment on “Creating a swap space”

  1. eric says:

    chown root.root /var/swap should be chown root:root /var/swap


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s