Setup swap space on a Linux machine (Debian)

Here’s how I setup a swap space on my linux box:

mkdir -p /var/swap
dd if=/dev/zero of=/var/swap/swapfile bs=1M count=4096
mkswap /var/swap/swapfile
swapon /var/swap/swapfile

# - Check settings after setup is complete
swapon -s
free

Then modify the fstab configuration after setting the swap space

vi /etc/fstab

Append the following line to the fstab file

/var/swap/swapfile swap swap defaults 0 0

The 0’s at the end indicate that the health check of swap is not required during bootup

Advertisements

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