1
2
3
4
5
6
7
8
# create a file named `swap`, size of 1024b*2000000=2G
sudo dd if=/dev/zero of=swap bs=1024 count=2000000
# make this file as swap partition
sudo mkswap -f swap
# set auth
sudo chmod 600 swap
# activate swap partition on this file
sudo swapon swap

dd

https://www.runoob.com/linux/linux-comm-dd.html

read, convert, or output datas. be used to create a file.

param description default
if input filename stdin
of output filename stdout
bs1 block size byte
count2 bs count 1
  1. bs: set ibs(in block size) and obs(out block size) at same time, default as byte. append k or m to set unit
  2. count: copy bs count times, so the size of of is count*bs

mkswap

https://www.runoob.com/linux/linux-comm-mkswap.html

make a swap partition

param description default
f for SPARK Architecture
c check file blocks is damaged

swapon

https://www.runoob.com/linux/linux-comm-swapon.html

enable swap partition. disable this use swapoff.