Recent Changes - Search:




Adding Swap Space

Sometimes it is necessary to add more swap space after installation. For example, you may upgrade the amount of RAM in your system.

Determine the size of the new swap file and multiple 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

Setup the swap file with the command:

mkswap /swapfile

To enable the swap file immediately but not automatically at boot time:

swapon /swapfile

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

/swapfile swap swap defaults 0 0

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

After adding the new swap file and enabling it, make sure it is enabled by viewing the output of the command cat /proc/swaps or free.

:~$ man -k swap
mkswap (8)           - set up a Linux swap area
multiload_applet (1) - Multiload (cpu, load average, memory, net, swap) apple...
swapoff (8)          - enable/disable devices and files for paging and swapping
swapon (8)           - enable/disable devices and files for paging and swapping


mkswap sets up a Linux swap area on a device or in a file.

(After creating the swap area, you need the swapon command to start using it. Usually swap areas are listed in /etc/fstab so that they can be taken into use at boot time by a swapon -a command in some boot script.) The device argument will usually be a disk partition (something like /dev/hda4 or /dev/sdb7) but can also be a file. The Linux ker- nel does not look at partition Id's, but many installation scripts will assume that partitions of hex type 82 (LINUX_SWAP) are meant to be swap partition.

(Warning: Solaris also uses this type. Be careful not to kill your Solaris partitions.)

The size parameter is superfluous but retained for backwards compatibility. (It specifies the desired size of the swap area in 1024-byte blocks. mkswap will use the entire partition or file if it is omitted. Specifying it is unwise - a typo may destroy your disk.)

Edit - History - Print - Recent Changes - Search
Page last modified on April 24, 2009, at 06:33 PM