[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is there a way to make the pi use swap?



Gene Heskett <gheskett@shentel.net> writes:

> On Saturday 15 September 2018 16:16:24 Jeffrey Walton wrote:
>
>> On Fri, Sep 14, 2018 at 8:16 PM, Alan Corey <alan01346@gmail.com> 
> wrote:
>> > My /etc/fstab just has
>> >  /var/swap2 none swap sw 0 0
>> > That's for a swap file which was made by dding 0s into it, then
>> > running mkswap.
>> >
>> > You'd replace /var/swap2 with /dev/sda2
>> >
>> > Sounds like you're just not loading it from your fstab.  Should load
>> > every boot.  Nothing new or tricky there.
>>
>> In addition, it also helps to set swappiness to a low value, like 1 or
>> 3, on modern kernels. That has the effect of telling the kernel to
>> prefer to keep things in memory.
>>
>> With swapon and low swappiness I can actually run a C++ compiler with
>> multiple jobs and without an OOM kill.
>>
>> Jeff
>
> And pray tell, where does one set that swappiness?
> Sounds like something that could be handy.

When wondering that sort of thing, I generally try this sort of command
to find out:

  sudo find /sys /proc -name \*swappiness\* | less

which in this case leads you quite quickly to /proc/sys/vm/swappiness

which you can do things like:

  cat /proc/sys/vm/swappiness

and

  echo 1 > /proc/sys/vm/swappiness

with.  Of course, that will only persist until the next reboot, so you'd
then want to set things in /etc/sysctl.* to make things permanent.

There are man pages for sysctl.d, sysctl.conf and sysctl, and also a
README in /etc/sysctl.d/

Something like this (as root) would do the trick:

  echo vm.swappiness=1 > /etc/sysctl.d/local-swapiness.conf

(that's all true on Debian -- no idea how much of that applies for *bian
derivatives).

Cheers, Phil.
-- 
|)|  Philip Hands  [+44 (0)20 8530 9560]  HANDS.COM Ltd.
|-|  http://www.hands.com/    http://ftp.uk.debian.org/
|(|  Hugo-Klemm-Strasse 34,   21075 Hamburg,    GERMANY

Attachment: signature.asc
Description: PGP signature


Reply to: