Friday, August 7, 2009

OpenBSD tips and tricks - adding swap on the fly

******* Adding swap on fly *******

# dd if=/dev/zero of=/usr/swap0 bs=1024k count=64

This will create basically a 64MB file that we will use for adding some swap space.

set the proper permissions on (/usr/swap0)

# chmod 0600 /usr/swap0

Now to add the swap file on fly

# swapctl -a /usr/swap0

Check to make sure you are using swap by running top or:

# swapctl -l

You can then further add swap at boot time in /etc/rc.local by adding the swapctl command.

** Note there maybe some security implications with this ...so I won't advise you to do that for production system. This is for those times when you forgot to create proper swap partition and now one of you programs is causing segmentation faults etc cuz you are running out of physical memory. ** You've been cautioned, please use at your own risk.

No comments: