These are the consolidated steps from a post by Justin Ellingwood called Add Swap Space on Ubuntu.
The configuration has been tested on the current version of the NavPi, running Rapsbian GNU/Linux 8 (jessie)
For best results, it’s recommended to utilize a USB drive as your swap space, due to the fact that repeated reads/writes to the SD card will eventually wear it out. You can follow this USB swap guide or proceed with the SD swap configuration below. For example, you may just want to use the SD swap temporarily until you’re ready to move to the USB swap solution.
Before proceeding with this swap configuration, it is worth making a backup image of the SD card so if it fails, you can easily restore to this point.
To ensure you don’t lose any coins while making configuration changes to your NavPi, it’s essential to backup the wallet.dat file. This holds your private keys. With a backup of the wallet.dat you can always restore your wallet.
First, make sure your have encrypted your wallet. Then proceed with the following steps:
Backup Wallet. This will download the wallet.dat file to your preferred device (USB, HD)
`sudo swapon --show`
`sudo fallocate -l 2G /navswap`
ls -lh /navswap Output -rw-r--r-- 1 root root 1.0G Apr 25 11:14 /navswap`
`sudo chmod 600 /navswap`
ls -lh /navswap Output -rw------- 1 root root 2.0G Apr 25 11:14 /navswap
sudo mkswap /navswap Output Setting up swapspace version 1, size = 2048 MiB (1073737728 bytes) no label. UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
`sudo swapon /navswap`
sudo swapon --show Output NAME TYPE SIZE USED PRIO /navswap file 2G 0B -1
free -h Output total used free shared buff/cache available Mem: 488M 37M 96M 652K 354M 425M Swap: 2.0G 0B 2.0G
The swap has been set up successfully. Operating system will begin to use it as necessary.
First backup your
sudo cp /etc/fstab /etc/fstab.bak
Then add the swap info as follows
echo '/navswap none swap sw 0 0' | sudo tee -a /etc/fstab Output /navswap none swap sw 0 0
Configure your NavPi’s performance when dealing with swap.
The swappiness parameter configures how often your system swaps data out of RAM to the swap space. This is a value between 0 and 100 that represents a percentage.
sudo sysctl vm.swappiness=10 Ouput vm.swappiness = 10
This value is sometimes recommended to improve performance when sufficient memory exists in a system, this value 10 could be considered for the performance being expected.
Make this persist on reboot:
sudo nano /etc/sysctl.conf
Add this at bottom of file:
This setting configures how much the system will choose to cache inode and dentry information over other data.
Check the current cache pressure setting:
cat /proc/sys/vm/vfs_cache_pressure Ouput 100
By default, the system removes inode information from the cache too quickly.
Set this to a more conservative setting like 50:
sudo sysctl vm.vfs_cache_pressure=50 Output vm.vfs_cache_pressure = 50
Make it persist:
sudo nano /etc/sysctl.conf
Add this to bottom of file:
Save and close the file.
cat /proc/swaps Output Filename Type Size Used Priority /navswap file 2097418 0 -1
There are several options for checking memory use.
Built-in commands include:
`free -h` `top`
pro tip - Install htop, a nice option for monitoring interactively. It’s a nice way to filter on running processes, like ‘nav’. It combines the functionality of top and iotop into a single screen.
sudo apt-get install htop htop
You should now see the swap drive being monitored.