Turning on swap with a page file

From Leo's Notes
Revision as of 04:14, 5 January 2020 by Leo (talk | contribs) (Created page with "To enable swap on a system that has no dedicated swap partition (such as a really small VPS or VM), create a swap file: {{highlight|lang=terminal|code= # dd if=/dev/zero of=/...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page was last edited on 5 January 2020, at 04:14.

To enable swap on a system that has no dedicated swap partition (such as a really small VPS or VM), create a swap file:

# dd if=/dev/zero of=/swap bs=1M count=1024
# chmod 600 /swap
# mkswap /swap
# swapon /swap
# echo "/swap swap swap defaults 0 0" >> /etc/fstab

Naturally, the swap space here incurs the filesystem overhead as well.