Create Swapfile on Raspberry Pi and Miniban

While using Bittorrent Sync on my Raspberry Pi, I had some issues with BTSync using too much RAM. To solve this problem I decided to create a 2GB (count=2097152) swap file and see how it would perform. To do this follow these steps:

  1. Create a swap file in your filesystem replace “/PATH/FILENAME” and “SWAP_SIZE” with desired values. “SWAP_SIZE” is in kilobytes:
    the “dd” command can take up to 5 minutes, depending on how big¬†“SWAP_SIZE” is.

    dd if=/dev/zero of=/PATH/FILENAME bs=1024 count=SWAP_SIZE
    chmod 600 /PATH/FILENAME
    mkswap /PATH/FILENAME
    swapon /PATH/FILENAME
  2. Add the swap file to the fstab list:
    sudo nano /etc/fstab
    #Swap file
    /PATH/FILENAME none swap sw 0 0

I’m using RPi-Monitor and can easily see if the Swap file is in use now

Statistics

raspimonitor_noSwap
Before without swap file
raspimonitor_Swap
After with swap file

RAM usage

SWAP usage

So I created a Swap partition on the 8th of February, this reduced RAM usage significantly.

Advertisements
Create Swapfile on Raspberry Pi and Miniban