Friday, November 16, 2007

Adding Extra Swap Space

There are situations where we have to expand the SWAP space after installation. For example, suppose you are upgrading RAM 512MB to 1 GB MB, but there is only 1 GB of swap space available which was created during installation. It might be an advantage to increase the amount of swap space to Double the RAM(2 GB) as per the UNIX/Linux guidance and will help you to perform memory eaters.

You have two options: add a swap partition or add a swap file. It is recommended to add a swap partition, but this is not possible if you don't have free Disk space available.

Option 1

Its better to reboot the server to SINGLE USER mode(if possible) before adding the extra SWAP Space
And you can do an optional "swapoff" command to turn off all the swap spaces.

Create the swap partition fdisk.

# fdisk /dev/hda (Assuming Hard drive is hda)
Type n ( for new partition)
Determine the size for the partition
then Toggle the partiotion label to Linux Swap.Its id is 82

Save the partition table,exit fdisk and do a "partprobe" to make it effective

# partprobe

Now you have the swap partition, use the command mkswap to setup the swap partition.
At a shell prompt as root, type the following:

# mkswap /dev/hdaX

To enable the swap partition immediately, type the following command:

# swapon /dev/hdaX

To enable it at boot time, edit /etc/fstab to include:

/dev/hdaX swap swap defaults 0 0

The next time the system boots, it will enable the new swap partition.

After adding the new swap partition and enabling it, make sure it is enabled by viewing the output of the command
# cat /proc/swaps

or
# free

Option 2

Determine the size of the new swap file and multiply it by 1024 to determine the block size. For example, the block size of a 64 MB swap file is 65536.

At a shell prompt as root, type the following command with count being equal to the desired block size:

# dd if=/dev/zero of=/swapfile bs=1024 count=65536

Make it a SWAP file

# mkswap /swapfile

To enable the swap file immediately

# swapon /swapfile

To enable it at boot time, edit /etc/fstab and insert the following

/swapfile swap swap defaults 0 0

No comments:

AT&T USA | Internet not working | Fix by custom APN

If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...