pdf-icon

Add Virtual Memory Instructions

  1. Create a swap file
fallocate -l 2G /swapfile
  1. Set permissions and format as swap
chmod 600 /swapfile
mkswap /swapfile
  1. Enable swap
swapon /swapfile
swapon --show
free -h
  1. Add automatic mount service
tee /etc/systemd/system/enable-swapfile.service >/dev/null <<'EOF'
[Unit]
Description=Enable swapfile via swapon
After=local-fs.target
Requires=local-fs.target

[Service]
Type=oneshot
ExecStart=/sbin/swapon /swapfile
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF
  1. Enable startup auto-start
systemctl daemon-reload
systemctl enable enable-swapfile.service
On This Page