LFCS 3.5: Swap space
Swap files and swap partitions, priorities, removing swap, and swappiness.
Before you start
The lab adds an empty 1 GiB spare disk, /dev/loop40 (partitions show up
as /dev/loop40p1 and so on). It comes back at every boot before swap is
turned on, so /etc/fstab lines for it keep working. The lab also adds a
128 MiB swap file, /var/swap.old, in use and listed in /etc/fstab.
Tasks
- Add a 1 GiB swap file at
/swapfilethat's used after every reboot. - Add a 512 MiB swap partition on
/dev/loop40with priority 10, and give the swap file/swapfilepriority 5, both after every reboot too. - Turn off the swap file
/var/swap.oldwithout rebooting, and remove it for good. - Set swappiness to 10 persistently.
Hints
ddorfallocate,chmod 600,mkswap,swapon;swapon --show,free -h.fdisk,gdiskorparted(type Linux swap);mkswap,blkid. In/etc/fstabswap has mount pointnone, typeswap, andpri=among the options;swapon -a.swapoff, then clean up/etc/fstab.sysctl vm.swappiness; a file in/etc/sysctl.d/,sysctl --system.