• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Create A Swap File

February 16, 2021

How to create a swap file.

A 2GB swap file.

dd if=/dev/zero of=/swapfile bs=1k count=2048k

dd if=/dev/zero of=/swapfile bs=1k count=2048k

Activate.

mkswap /swapfile
chmod 0600 /swapfile
systemctl daemon-reload
swapon /swapfile

mkswap /swapfile chmod 0600 /swapfile systemctl daemon-reload swapon /swapfile

To make swap permanent, add to /etc/fstab.

/swapfile  swap   swap    defaults   0 0

/swapfile swap swap defaults 0 0

Check if swap is working.

cat /proc/swaps
free -h

cat /proc/swaps free -h

Filed Under: Linux Tagged With: activate, create, file, swap

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023