Memory swap with Debian 8.x

When having really slow digitalocean droplet (with 1Mb or even less capacity) you still can do your tests and, may be, put such instance in production (depends on what you have inside and network traffic). I like this guys as they offer SSD volumes and it is really fast. So there is no problem to extend your memory with swap.

Here is the way to set your swap to whatever number (change XXXX with your number, make sure you have enough free space).

  • Allocate file with white spaces (i.e. dd - convert and copy a file utility);
  • Set read only permissions to this file;
  • Activate swap using swapon

Ok, let do this below:

sudo dd if=/dev/zero of=/var/swap.img bs=1024k count=4000
4000+0 records in
4000+0 records out
4194304000 bytes (4.2 GB) copied, 12.0326 s, 349 MB/s
sudo mkswap /var/swap.img
Setting up swapspace version 1, size = 4095996 KiB
no label, UUID=b9da0933-f0d7-4379-8673-d527de03df22
sudo chmod 600 /var/swap.img
sudo swapon /var/swap.img

Now, to check your if you set all correctly do the following:

total       used       free     shared    buffers     cached
Mem:        506324     499648       6676        332       9220     414848
-/+ buffers/cache:      75580     430744
Swap:      4095996          0    4095996

In short, this is about:

Start discussion:
Related articles:
79 mount aws s3 bucket to your debian preview
In this very short tutorial we are going to mount S3 bucket from AWS to the local folder of Debian. ... more
35 how to install asterisk ip pbx on debian 8 x jessie preview
How to install, configure and run Asterisk 13 on Debian 8.x. From nothing to PBX in 5 minutes! ... more
almost 2 years#pbx #asterisk #debian