Prevent kernel out of memory manager to kill processes on Raspberry Pi 2

I am using Raspberry Pi 2 with Xbian installed as my primary always on media-player device. Beside usual Kodi and few other services I also have MySQL, pihole, lighttpd, rtorrent, samba and few other.

Lately I am faced with kernel oops when trying to copy larger files, over 500MB. Rapsberry Pi becomes unresponsive, I can ping it but no longer connect to it.

I’ve spent a lot of time searching for the solution and there is a lot of suggestions but it takes a bit of experimenting to figure out the working one in my case.

First thing is to tweak sysctl.conf and add vm.min_free_kbytes = 32768, and vm.vfs_cache_pressure = 300 and to put in config.txt file smsc95xx.turbo_mode=N. I’ve tried several combinations and came with working one in my case.

Append to end of file /etc/sysctl.conf following lines:

vm.min_free_kbytes = 65536
vm.vfs_cache_pressure = 300

then do:

sysctl -p

There is a lot of threads suggesting to add folowing to config.txt:


In my case this caused even more instability, so for now I am leaving out of my config.txt since it works better without this parameter.

With this configuration I have tried to copy few larger files (>2GB) over network to Samba share and it worked without kernel spitting out errors.

It seems that if you are using Xbian your settings in /etc/sysctl.conf will get overwritten with files in /etc/sysctl.d/, so you need to change values in /etc/sysctl.d/00-xbian.conf.

Default values in 00-xbian.conf are:

vm.min_free_kbytes = 16384
vm.vfs_cache_pressure = 150

Change them to:

vm.min_free_kbytes = 32768
vm.vfs_cache_pressure = 300

Use “sysctl -p” to reload or simply reboot.


It seems changing these parameters is not definitive solution. Updating to latest kernel 4.4.7+ resolved the issue.

Linux xbian 4.4.7+ #1 SMP PREEMPT Mon Apr 18 14:25:36 CEST 2016 armv7l GNU/Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.