Archive

Posts Tagged ‘fdisk’

Add Swap Space to Desktop or Server

October 11, 2008 1 comment

If you add additional RAM or if you are seeing that your system is doing a lot of page swapping you may want to add SWAP space on a drive. In order to review your current SWAP space use the swapon command:

/sbin/swapon -s
Filename Type Size Used Priority
/dev/hda5 partition 771080 0 -1
/dev/hdb1 partition 771080 0 -2

The recommendation for an Enterprise Edition is to use twice as much SWAP space as RAM up to 4 GB and then use an equal amount of RAM vs. SWAP after 4 GB.

When you add SWAP space make sure the file system is 82 when you set it up with fdisk.

This is the process to create an emergency SWAP file so that you can add a drive with SWAP later. This process could slow your system down as you may be swapping to a file a great deal. However, this will get you to the point that you can make it for a short time.

The exercise shows how to setup a temporary SWAP file. Once you restart this will be gone unless you add it into the /etc/fstab file. Use this at your own risk because if you make a mistake in editing /etf/fstab your box will not start.

/sbin/swapon -s

Filename Type Size Used Priority
/dev/hda5 partition 771080 0 -1
/dev/hdb1 partition 771080 0 -2

dd if=/dev/zero of=/tmp/SWAP-TMP bs=1024 count=20000

20000+0 records in
20000+0 records out

chmod 600 /tmp/SWAP-TMP

ls -la /tmp/SWAP-TMP

-rw——- 1 root root 20480000 Jul 19 10:22 /tmp/SWAP-TMP

/sbin/mkswap /tmp/SWAP-TMP

Setting up swapspace version 1, size = 20475 kB

/sbin/swapon /tmp/SWAP-TMP

/sbin/swapon -s

Filename Type Size Used Priority
/dev/hda5 partition 771080 0 -1
/dev/hdb1 partition 771080 0 -2
/tmp/SWAP-TMP file 19992 0 -3

Follow

Get every new post delivered to your Inbox.

Join 58 other followers