This instruction will be revised to add more detailed discussion. Below are the basic steps to create a swap file and activate it.
1. Create the swap file of 512MB at the rootfs top directory
cd /
dd if=/dev/zero of=swapfile1 bs=1024 count=524288
mkswap swapfile1
chmod 0600 swapfile1
2. Turn on swap
swapon /swapfile1
3. Check the swap space
free -h
total used free shared buff/cache available
.....
Swap: 511Mi 0B 511Mi
swapon
NAME TYPE SIZE USED PRIO
/swapfile1 file 512M 0B -2
4. Add swapfile1 entry to fstab so that it will be automatically on during boot.
cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
LABEL=rootfs / ext3 noatime,user_xattr,acl,errors=remount-ro 0 1
/swapfile1 swap swap defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
-bodhi
===========================
Forum Wiki
bodhi's corner
Edited 4 time(s). Last edit at 12/27/2022 08:03PM by bodhi.