To change maximum processes per user
- open /etc/security/limits.conf as root user
Write the following lines at the bottom of the page.
- Restart the machine.
To change maximum file handles per user
- open /etc/security/limits.conf as root user
Write the following lines at the bottom of the page.
- 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:
# 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:
# cat /proc/swaps
This command is same as the swapon -s
command, which gives the same output:
Increasing the swap size
Additional Swap Space can be created using a:
- Hard Drive
- 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:
Setup this newly created partition as swap area using the
mkswap
command:# mkswap /dev/sdc1
Enable the swap partition for usage using
swapon
command:# swapon /dev/sdc1
Add the following line to the /etc/fstab file to make the swap space partition available even after the reboot:
# cat /etc/fstab
Verify whether the newly created swap area is available for your requirement using
swapon
andfree
commands:# swapon -s
Sample Output for # swapon -s command# 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.
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
Check the user permissions set in the file using the following command:
# ls -l /root/myswapfile
- Create Root Permission, that is, change the permission of the swap file so that only root can access it.
# chmod 600 /root/myswapfile
Make this file as a swap file using
mkswap
command:# mkswap /root/myswapfile
mkswap command output- Enable the newly created swapfile.
# swapon /root/myswapfile
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
Verify whether the newly created swap area is available for your requirement using
swapon
andfree
commands:# swapon -s
Sample Output for # swapon -s command# free -k
Sample Output for # free -k command