Read more

Create swap space on Linux

Thomas Eisenbarth
July 11, 2013Software engineer at makandra GmbH

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

sudo dd if=/dev/zero of=/var/swapfile bs=1M count=1024
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

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

Change permissions of swap file:

sudo chmod 0600 /var/swapfile

Set up swap file and enable it:

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

You should see your swap space now:

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

/var/swapfile  none  swap  sw  0 0
Posted by Thomas Eisenbarth to makandra Operations (2013-07-11 18:03)