Swap File
Swap file
Swap file is more flexible than swap partition.
- Use file as swap space.
# create a 4G swap image dd if=/dev/zero of=swap.img bs=1024M count=4 mkswap swap.img # see the currently used swap space swapon -s # mount this file as swap space swapon swap.img
Optionally you can use
swapoff
to disable some swap space. - Persistent
Add this entry into
/etc/fstab
/opt/swap.img none swap defaults 0 0
∎