Swap File Creation

dd if=/dev/zero of=/swapfile256GB bs=1024 count=268435456 status=progress
chmod 0600 /swapfile256GB
/usr/sbin/mkswap /swapfile256GB
/usr/sbin/swapon /swapfile256GB
echo "/swapfile256GB     none   swap    sw     0     0" | tee -a /etc/fstab

Document z260205wa, last modified 21 May, 2026
See z260205f (an earlier note related to swap file creation).

Configuring Swappiness Level

It is possible to configure the behavior of Linux with regards to the use of swap memory. The default setting is a swappiness of 60, which means the kernel begins using swap memory once processes use 40% of the system memory.

To view the current swappiness setting, use the command
cat /etc/sysctl.conf | grep swappiness or use the command
cat /proc/sys/vm/swappiness or the command
/sbin/sysctl vm.swappiness

To immediately change swappiness, use the command
sysctl vm.swappiness=1 or another number other than 1. In the case of 65536MB of RAM, a swappiness setting of 1 means that once 655MB of memory remains, the kernel will start swapping data to the disk.

To make the change permanent, add vm.swapiness=1 to /etc/sysctl.conf. It is also possible to achieve the same effect by adding the sysctl vm.swapiness=1 command to a crontab that takes effect upon reboot using @reboot /sbin/sysctl vm.swappiness=1 in the crontab editor.

Document z260521wa, last modified 21 May, 2026
See z260205f (earlier referece note on configuring swappiness)