When working with Oracle products and especially when you are testing Oracle products you might find yourself in a position where you have to add more swap memory to your Linux system. I encounterd this 'problem' just now when I added more memory to my virtual machine which is running Oracle Enterprise Linux. Because I added more 'RAM' memory to the virtual machine the I did no longer have the double the amount of RAM as I did have swapspace.
This is a common rule, for example if you have 64MB of RAM you will like to have 128MB of swapspace. This 'rule' is not always valid and can vary per platform, operating system and software you are running on the box, it is however a good first guideline to setup your system. So I had to add 2048MB of swapspace to my system.
The most simple way is to use swapfiles, there are basilcy two ways of handling the adding of extra swapspace. The first is to add a new swap partition the second is to add swapfiles. Because this is a test enviroment I used the second.
First create a file you will be using as you swapfile, this is done by the following command:
dd if=/dev/zero of=/swapfile bs=1024 count=2097152
bs stands for block size and we set the blocksize to 1024. Because we would like to add 2048MB of swap we calculate it by multiplying the required size in MB's by the blocksize, the result is the count.
After the file is created you setup the swap file by issuing the following command
And activate it by:
Swapon is used to specify devices on which paging and swapping are to take place. The device or file used is given by the specialfile parameter. It may be of the form -L label or -U uuid to indicate a device by label or uuid. Calls to swapon normally occur in the system multi-user initialization file /etc/rc making all swap devices available, so that the paging and swapping activity is interleaved across several devices and files.
Now your new swapspace is active, however, next time you boot your system the swap files will not be mounted to the system. To make sure the next time the files are mounted and ready to use you have to add them to your /etc/fstab file where you control what is mounted at startup. Fstab stands for file systems table. The file is commonly found on Unix systems as part of the system configuration. The fstab file typically lists all available disks and disk partitions, and indicates how they are to be initialized or otherwise integrated into the overall system's file system.
The fstab file is most commonly used by the mount command, which reads the fstab file to determine which options should be used when mounting the specified device.
Traditionally, the fstab was only read by programs, and not written. However, some administration tools can automatically build and edit fstab, or act as graphical editors for it, such as the Kfstab graphical configuration utility available for KDE. Modern systems use udev to handle hot swapping devices instead of rewriting fstab file on the fly. It is the duty of the system administrator to properly create and maintain this file.