How to Enable Virtual Memory on Linux to Improve Performance

How to Enable Virtual Memory on Linux to Improve PerformanceLinux offers virtual memory support known as SWAP that is very common and reliable among the Linux systems. This feature is for computers with limited or minimum system resources that are being used for other processes as well. The ZSWAP is a kernel feature in the 3.8 version that compresses the swap cache and makes it possible for the system to never slow down as the SWAP file deals with the IO of HDD and if continuously used, it may result in a performance drop down of the hard disk.

RELATED: How to install FileZilla on Linux through Command Line

Setting up ZSWAP ON LINUX

The ZSWAP actually compresses the SWAP file and improves the performance of the Linux system. It is very easy to setup ZSWAP on Linux, all you need is to follow a few simple steps to enable SWAP.

For Debian/UBUNTU

It is an optional Linux kernel parameter so it is not found in the settings, you need to work with the bootloader to enable ZSWAP. While using Ubuntu, you need to use GRUB so to access the Grub configurations. It is necessary to back up the Grub configurations so if anything goes wrong, you can easily reverse back to the previous settings. It is a command-line argument.

To backup Grub, get the root access using su or sudo -s command in the terminal. In the Root shell, use the CP command to make a backup of the Grub configuration file.

cp /etc/default/grub /etc/default/grub.bak

Enabling Zswap in Ubuntu

When the Grub configurations are backed up, you need to open it in the Nano to edit.

nano -w /etc/default/grub

In the Nano editor, find the GRUB_CMDLINE_LINUX_DEFAULT.

It has different command-line arguments including quiet splash and various others. All you need is to add an additional argument at the end.Enabling Zswap in Ubuntu

zswap.enabled=1

Ubuntu Zswap Grub Configuration File

Use Ctrl + O to save the file and exit using Ctrl + X hotkeys. Update the Grub bootloader using command sudo update-grub

Reboot the Ubuntu so the changes take effect.

RELATED: HOW TO MANAGE THE BANDWIDTH ON LINUX WITH WONDERSHAPER

Disabling Zswap in Ubuntu

Open the terminal and go to root using su or sudo -s command. Delete the Grub file using rm command

rm /etc/default/grub

Restore backup that you previously created

cd /etc/default/

mv grub.bak grub

Update the grub to roll back the changes.

sudo update-grub

For Fedora or OpenSUSE

The Fedora uses RPM and Redhat tools which means that you can enable the Zswap as you update in Ubuntu using GRUB.

Enable Zswap in Fedora or OpenSUSE

Backup the Grup, get root access using su command, and backup the grub using

cd /etc/default

cp grub grub.bak

Enable Zswap using the Grub configuration file command.

nano /etc/default/grub

Find the code in Grub configuration file for GRUB_CMDLINE_LINUX_DEFAULT= or GRUB_CMDLINE_LINUX=Enable Zswap in Fedora or OpenSUSE

Now add ‘zswap.enabled=1’ at the end of the code before quotation marks. Use Ctrl + O to save and Ctrl + X to exit. Update the bootloader using the grub2-mkconfig command

grub2-mkconfig -o /boot/grub2/grub.cfg

Enable zSwap in OpenSUSE

Disable Zswap for Fedora or OpenSUSE

Gain root with the su command.

su –

move into /etc/default/ using cd command

cd /etc/default

now delete the Grub file with the rm command

rm grub

Restore the Grub backup file with the mv command

mv grub.bak grub

Update Grub with grub2-mkconfig command

grub2-mkconfig -o /boot/grub2/grub.cfg

For Arch Linux

If you are using Arch Linux, you also enable Zswap by installing the package and enabling it using the system init system.

sudo pacman -S systemd-swap

or

sudo systemctl enable systemd-swap

Reboot the computer so that changes take effect.

RELATED: HOW TO USE FTP FROM COMMAND LINE ON LINUX

Leave a Reply

Your email address will not be published. Required fields are marked *