38 cards
View
Thomas Eisenbarth
5 years
Posted almost 6 years ago. Visible to the public.

Create swap space on Linux

Create a 1 GB file to swap to (we have sufficient space on / on this machine. Use a different partition if necessary)

Copy
sudo dd if=/dev/zero of=/var/swapfile bs=1M count=1024

If you prefer 2GB swap, chose count=2048, 4GB: count=4096

Change permissions of swap file:

Copy
sudo chmod 0600 /var/swapfile

Set up swap file and enable it:

Copy
sudo mkswap /var/swapfile sudo swapon /var/swapfile

You should see your swap space now:

Copy
thomas@machine:~$ free -m total used free shared buffers cached Mem: 7700 7655 45 0 75 1237 -/+ buffers/cache: 6342 1357 Swap: 2047 0 2047

If you want to make the changes permanent add those lines to /etc/fstab

Copy
/var/swapfile none swap sw 0 0

Owner of this card:

Avatar
Thomas Eisenbarth
Last edit:
about 2 years ago
by Marius Schuller
Keywords:
ops
This website uses cookies to improve usability and analyze traffic.
Accept or learn more