Having tested the read / write speed of the flash drive in the Nexus 7, I realized that it should be very beneficial to use, since the swap on an external device is a perversion.
First, create an empty file of the desired size via dd in a convenient place, namely / swap /
cd /
sudo mkdir swap
sudo dd if = / dev / zero of = / swap / swap.img bs = 1M count = 500
bs = 1M1000 x 1000 blocks
count = 500500 x 1M ~ 500MB
That is, we have created an empty 500MB file that will become our swap.
sudo mkswap /swap/swap.img
Check the performance by connecting it
swapon /swap/swap.img
swapon -s
Listed on the list? So it should be written in
/ etc / fstabfor autostart on buta.
Pin down
/swap/swap.img swap swap defaults 0 0
Now we will set the parameters for using swap
sudo gedit /etc/sysctl.conf
We attach at the end of the file
swappiness = 50
vfs_cache_pressure = 10
swappiness = 50 means that at 100-50 = 50% of the occupied RAM, we will start using swap.
vfs_cache_pressure = 10 means that under the cache we will select this value. Usually, changing this parameter does not give a special win, except in reading / writing. By default, it is 1000 in Ubuntu, but with my tests I derived the most appropriate value for our weak pseudo netbook.
You can play around with the swappiness parameter, but it seems to me that I set quite a reasonable value. Well, maybe 40-45 more values ​​should be nothing.