Tuning swap partition my result into a good system performance. You can tune swap by editing /etc/fstab file.
For example if you have two partitions as follows:
Now Linux system will only use one partition at a time. It will use next partition only if first partition exhausted. Each swap area has a priority, either high or low. The default priority is low. Within the low-priority areas, newer areas are even lower priority than older areas.
According to swap man page: All priorities set with swapflags are high-priority, higher than default. They may have any non-negative value chosen by the caller. Higher numbers mean higher priority. Swap pages are allocated from areas in priority order, highest priority first. For areas with different priorities, a higher-priority area is exhausted before using a lower-priority area. If two or more areas have the same priority, and it is the highest priority available, pages are allocated on a round-robin basis between them.
This may result into performance issue as a new process needs to be swapped to disk it may have to wait until another process is swapped out. So open your /etc/fstab:
# vi /etc/fstab
Find out line that read as follows:
/dev/sdb3 swap swap default 0 0
/dev/sdc3 swap swap default 0 0
Replace it as follows:
/dev/sdb3 swap swap pri=0 0 0
/dev/sdc3 swap swap pri=0 0 0
Restart the system or turn on and off swap to take effect with swapon command:
# sync;sync;swapoff -a
# swapon -a
The result of above tuning is that your system should able to use any one of the swap partition independently. Please note that this hack is only useful if your system uses swap.
- How do I monitor what my MySQL server is doing?
- MySQL, Linux, FreeBSD, and Swap Space Ã¢â‚¬â€œ an excellent article that explains the importance of swap space by Jeremy Zawodny
- Read man page of fstatb, mount and swapon(2) for more information.
🐧 0 comments... add one ↓
|Category||List of Unix and Linux commands|
|Disk space analyzers||df • duf • ncdu • pydf|
|File Management||cat • cp • mkdir • tree|
|Firewall||Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Modern utilities||bat • exa|
|Network Utilities||NetHogs • dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop|
|Searching||ag • grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|