Samstag, 13. September 2014

Taming the Nokia-770's OOM-Killer

The Nokia 770's kernel (2.6.16.27-omap1) does seem to have some issues with the OOM killer. Even with tons of free swap space availabe, it decides to kill larger processes, as I reported back in 2009 on the llkm: http://comments.gmane.org/gmane.linux.kernel/886095

Kernel devs thought this was a bug, however without the possibility updating to a more recent kernel, this didn't help.

However, I recently came across a message of another 770 user who had issues with debian's locale generation process on the 770, also killed by the OOM killer despite free swap. He found out that setting swappiness to 100 solved the issues: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=185010

So, although modifying swappiness still doesn't fix the actual kernel bug, the tendency of the kernel to keep more memory available for the  page-cache with a higher swappiness-value seems to make the issue appear a lot less frequently (at the cost of decreased SD life).

Therefore, if you experience OOM issues on your Nokia-770 despite free swap, try:

echo 100 > /proc/sys/vm/swappiness 

Donnerstag, 11. September 2014

Running debian wheezy ( chroot ) on the Nokia 770

After updating my Nokia 770 to OS2008HE and playing arround with it a bit, I thought about using it as home server (again). However, instead of installing Mer, I decided to go for a fully-fledged Debian and use it in a chroot-environment - as I do with my OpenWRT router. This way I get (security) updates timely, and also packages are typically well tested - while not touching the kernel or the device specific drivers.

Thanks to debootstrap, creating a minimum debian root-fs for ARMel is really easy:
debootstrap --foreign --arch=armel wheezy deb770   ftp://ftp.at.debian.org/debian/

However, when trying to chroot on the 770, the 2.6.16.27' kernel shows its age:
chroot /media/mmc/debian
FATAL: kernel too old
The most recent version of debian still supporting 2.6.16 is debian Lenny, which is unsupported as of mid 2012. The main incompatibility stems from the minimum kernel version debian's glibc is compiled with - for debian wheezy userland it doesn't make much sence to support 2.6.16 when wheezy was shipped with Linux-3.2.

However, thanks to debian's excellent build system (and linux' flexibility in general) it is no big deal to re-build glibc with support for older kernels (if you have an ARM based system with a recent kernel, don't know about cross compilation).
Therefore, I simply chrooted into wheezy on my raspberry Pi, downloaded the source package (eglibc) and modified the following config files:

debian/sysdeps/linux.mk -> MIN_KERNEL_SUPPORTED = 2.6.16
debian/debhelper.in/libc.preinst -> replace every kernel version starting with 2.6. with 2.6.16

and followed the building tutorial: https://wiki.debian.org/BuildingTutorial

After a few hours, you'll find debian packages of your rebuilt glibc, which can be installed with "dpkg -i". A good idea is to lock those packages for updates, otherwise upgrading your system using apt might break everything again. After you've built a working rootfs once, you can also re-compile and update glibc directly on the N770.

Update:
For those of you not eager to spend hours compiling glibc, I made the nokia770 compatible eglibc-packages (linux-2.6.16+, ARMv4te) available here: http://93.83.133.214/nokia770/eglibc-2.13-38_linux2.6.16_arv4te.tar.gz
However, for installation a system with newer kernel is still required (as dpkg requires glibc too), therefore I'll prepare a patched rootfs soon.