While using Linux/Unix OS, there are various configurations that may be changed to optimize the availability of resources to Fiorano. Below sections discuss the various configuration options.
To change maximum processes per user
-
open /etc/security/limits.conf as root user
-
Write the following lines at the bottom of the page.
<Username> hard nproc unlimited <Username> soft nproc unlimited
Replace <Username> with original user name.
-
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.
<Username> hard nofile unlimited <Username> soft nofile unlimited
Replace <Username> with original user name.
-
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:
total used free shared buffers cached
Mem: 3082356 2043700 1038656 0 50976 1646268
-/+ buffers/cache: 346456 2735900
Swap: 4192956 0 4192956
# 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:
Filename Type Size Used Priority
/dev/sda2 partition 4192956 0 -1
# cat /proc/swaps
This command is same as the swapon -s command, which gives the same output:
Filename Type Size Used Priority
/dev/sda2 partition 4192956 0 -1
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
mkswapcommand:# mkswap /dev/sdc1
-
Enable the swap partition for usage using
swaponcommand:# 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/dev/sdc1 swap swap defaults 0 0
-
Verify whether the newly created swap area is available for your requirement using
swaponandfreecommands:# swapon -sFilename Type Size Used Priority /dev/sda2 partition 4192956 0 -1 /dev/sdc1 partition 1048568 0 -2
In the output of
swapon -scommand, the Type column will say "partition" if the swap space is created from a disk partition.# free -ktotal used free shared buffers cached Mem: 3082356 3022364 59992 0 55056 2645472 -/+ buffers/cache: 323836 2758520 Swap: 5241524 0 5241524
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
ddcommand:
# dd if=/dev/zero of=/root/myswapfile bs=1M count=10241024+0 records in 1024+0 records out
-
Check the user permissions set in the file using the following command:
# ls -l /root/myswapfile-rw-r--r-- 1 root root 1073741824 Aug 14 23:47 /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
mkswapcommand:
# mkswap /root/myswapfileSetting up swapspace version 1, size = 1073737 kB
-
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/dev/sdc1 swap swap defaults 0 0
-
Verify whether the newly created swap area is available for your requirement using
swaponandfreecommands:# swapon -sFilename Type Size Used Priority /dev/sda2 partition 4192956 0 -1 /dev/sdc1 partition 1048568 0 -2
In the output of
swapon -scommand, the Type column will say "file" if the swap space is created from a swap file.# free -ktotal used free shared buffers cached Mem: 3082356 3022364 59992 0 55056 2645472 -/+ buffers/cache: 323836 2758520 Swap: 5241524 0 5241524
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