Making some swap space
In this post, I will share how to setup some swap space on a Linux system. The swap, or Virtual Memory, might be essential on high load systems.
To learn more about Virtual Memory, take a look at:
http://simple.wikipedia.org/wiki/Virtual_memory
Step 1: Get a swap partition
First of all, you will need a clean partition. Use the fdisk tool to create a partition. As example, lets use the /dev/sdb disk:
# fdisk /dev/sdb
Do not forget to mark the partition as a swap partition. Use the fdisk t command and set the partition type id to 82.
To confirm, use the fdisk p command, the output might be something like:
Device Boot Start End Blocks Id System /dev/sdb1 1 522 4192933+ 82 Linux swap / Solaris
Step 2: Create a swap filesystem
Now, use the mkswap tool to create a swap filesystem in your brand new partition. If you like some sophistication, you can also add a label to the partition. Adding a label, will allow you to reference this partition using the label instead the device file, something like a symbolic link:
# mkswap -L SWAP /dev/sdb1
Step 3: Edit the /etc/fstab file
Naturally, every system administrator wants to get things done when the system boots. We can use the /etc/fstab file to tell the kernel to turn on swap every time the system boots. Add these lines to the end of the file:
LABEL=SWAP swap swap defaults 0 0
Be careful! If you mess with this file, your system will not boot and you will need a recovery media.
Step 4: Turn the swap on
Now, turn on the swap:
# swapon -a
This is the same command that will be executed by the kernel on boot time.
Step 5: Check if the swap is active
Last, check if the swap is active using one of the following commands:
# cat /proc/swaps
:)












