A swap file allows Linux to simulate the disk space as RAM. When your system starts running out of RAM, it uses the swap space to and swaps some content of the RAM on to the disk space. This frees up the RAM to serve more important processes. When the RAM is free again, it swaps back the data from the disk.
RAM is 1000 times faster than SSD and 100,000 times faster than the usual HDD. If an application relies too much on the swap, its performance will degrade as it cannot access the data at the same speed as it would have in RAM. So instead of taking 1 second for a task, it may take several minutes to complete the same task. It will leave the application almost useless.
Swappiness is a Linux kernel property that defines how often the system will use the swap space. Swappiness can have a value between 0 and 100. A low value will force the kernel to avoid swapping whenever possible, while a higher value will force the kernel to use the swap space more aggressively.
Decrease the amount of hard drive use and increase memory instead. Besides the performance boost, limits the amount of writes on the ssd.
Open the terminal
Enter:
$ cat /proc/sys/vm/swappiness
Current value is listed, default value is 60
To change this value:
$ sudo xed /etc/sysctl.conf
type password
scroll to the bottom of sysctl.conf and start a new line, enter a value 10-25:
vm.swappiness=10
The optimal swappiness value depends on your system workload and how the memory is being used. You should adjust this parameter in small increments to find an optimal value. I use 10.
Save file, close and reboot system
$ sudo reboot
after reboot, check swappiness value again.
If you have 32GB or 64 GB of RAM, chances are that your system would perhaps never use the entire RAM and hence it would never use the swap partition. But will you take the chance? I am guessing if your system has 32GB of RAM, it should also be having a hard disk of 100s of GB. Allocating a couple of GB of swap won’t hurt. It will provide an extra layer of ‘stability’ if a faulty program starts misusing RAM.
Yes, you can, run your system without a swap file, especially if your system has plenty of RAM. But a little bit of swap is always advisable. In fact, a distribution based on Ubuntu automatically creates a swap file of 2 GB in size. This should give you an indication that having some swap space is recommended.
RAM is 1000 times faster than SSD and 100,000 times faster than the usual HDD. If an application relies too much on the swap, its performance will degrade as it cannot access the data at the same speed as it would have in RAM. So instead of taking 1 second for a task, it may take several minutes to complete the same task. It will leave the application almost useless.
Swappiness is a Linux kernel property that defines how often the system will use the swap space. Swappiness can have a value between 0 and 100. A low value will force the kernel to avoid swapping whenever possible, while a higher value will force the kernel to use the swap space more aggressively.
Decrease the amount of hard drive use and increase memory instead. Besides the performance boost, limits the amount of writes on the ssd.
Open the terminal
Enter:
$ cat /proc/sys/vm/swappiness
Current value is listed, default value is 60
To change this value:
$ sudo xed /etc/sysctl.conf
type password
scroll to the bottom of sysctl.conf and start a new line, enter a value 10-25:
vm.swappiness=10
The optimal swappiness value depends on your system workload and how the memory is being used. You should adjust this parameter in small increments to find an optimal value. I use 10.
Save file, close and reboot system
$ sudo reboot
after reboot, check swappiness value again.
If you have 32GB or 64 GB of RAM, chances are that your system would perhaps never use the entire RAM and hence it would never use the swap partition. But will you take the chance? I am guessing if your system has 32GB of RAM, it should also be having a hard disk of 100s of GB. Allocating a couple of GB of swap won’t hurt. It will provide an extra layer of ‘stability’ if a faulty program starts misusing RAM.
Yes, you can, run your system without a swap file, especially if your system has plenty of RAM. But a little bit of swap is always advisable. In fact, a distribution based on Ubuntu automatically creates a swap file of 2 GB in size. This should give you an indication that having some swap space is recommended.