Contents

To change maximum processes per user

  1. open /etc/security/limits.conf as root user
  2. Write the following lines at the bottom of the page.

    Icon

    Replace <Username> with original user name.

  3. Restart the machine.

To change maximum file handles per user

  1. open /etc/security/limits.conf as root user
  2. Write the following lines at the bottom of the page.

    Icon

    Replace <Username> with original user name.

  3. Restart the machine.

Checking the Swap Size

# free -k

The command free is used to know how much swap space is currently used by the system. It displays the memory details in KB.

Following is a sample output resulting from free -k command:

Output Sample

# swapon -s

Swapon command with option -s displays the current swap size in KB and the file name.

Following is a sample output resulting from swapon -s command:

Output Sample

# cat /proc/swaps

This command is same as the swapon -s command, which gives the same output:

Output Sample

Increasing the swap size

Additional Swap Space can be created using a:

  1. Hard Drive
  2. File

Both the methods are explained in the below sections.

Using a Hard Drive Partition

If you have an additional hard disk (or space available in an existing disk), create a partition using fdisk command.

Assume that the partition created is: /dev/sdc1 and perform the following actions:

  1. Setup this newly created partition as swap area using the mkswap command:

    # mkswap /dev/sdc1
     

  2. Enable the swap partition for usage using swapon command:

    # swapon /dev/sdc1
     

  3. Add the following line to the /etc/fstab file to make the swap space partition available even after the reboot:
    # cat /etc/fstab

  4. Verify whether the newly created swap area is available for your requirement using swapon and free commands:

    # swapon -s 

    Sample Output for # swapon -s command
    Icon

    In the output of swapon -s command, the Type column will say "partition" if the swap space is created from a disk partition.

    # free -k

    Sample Output for # free -k command

Using a File

If you do not have any additional disks, create a file somewhere on your file system and use that file for swap space.

  1. Create a swap file with the name "myswapfile" under /root  directory with a size of 1024MB (1GB) using the following dd command:
    # dd if=/dev/zero of=/root/myswapfile bs=1M count=1024

  2. Check the user permissions set in the file using the following command:
    # ls -l /root/myswapfile

  3. Create Root Permission, that is, change the permission of the swap file so that only root can access it.
    # chmod 600 /root/myswapfile
     
  4. Make this file as a swap file using mkswap command:
    # mkswap /root/myswapfile

    mkswap command output
  5. Enable the newly created swapfile.
    # swapon /root/myswapfile
     
  6. To make this swap file available as a swap area even after the reboot, add the following line to the /etc/fstab file using command:
    # cat /etc/fstab

  7. Verify whether the newly created swap area is available for your requirement using swapon and free commands:

    # swapon -s 

    Sample Output for # swapon -s command
    Icon

    In the output of swapon -s command, the Type column will say "file" if the swap space is created from a swap file. 

    # free -k

    Sample Output for # free -k command
Icon

If you don't want to reboot to verify whether the system takes all the swap space mentioned in the /etc/fstab, you can do the following, which will disable and enable all the swap partition mentioned in the /etc/fsta:

swapoff -a

swapon -a

Adaptavist ThemeBuilder EngineAtlassian Confluence