whoami
Posts: 64
Joined: Fri Nov 15, 2013 1:41 pm

optimizing the raspberry pi

Sat Nov 16, 2013 1:44 pm

I thought I'd share my config with everyone. After much trial and error, this collection of tips have worked for me.

First boot

Run raspi-config and expand filesystem (can skip this step if extra partitions needed)
Advanced Options -> Memory Split -> give 1MB to GPU

Upgrade packages

sudo apt-get update && sudo apt-get upgrade && reboot

Upgrade firmware

sudo rpi-update && reboot

Setup kernel options

In config.txt

Code: Select all

# for more options see http://elinux.org/RPi_config.txt
core_freq=500
sdram_freq=600
over_voltage=6
gpu_mem=1
arm_freq=1000
emmc_pll_core=1
force_turbo=1
init_emmc_clock=500000000
In cmdline.txt, set elevator=noop

Code: Select all

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=noop rootwait
Fix fstab

Add noatime to all, mount /var/run and other fast burning partitions to tmpfs (except /var/log, will come to that in later steps).

Mount /boot in ro mode:

Code: Select all

proc            /proc           proc    defaults          0       0
none            /var/run        tmpfs   size=1M,noatime   0       0
none            /tmp            tmpfs   size=1M,noatime   0       0
none            /var/tmp        tmpfs   size=1M,noatime   0       0
/dev/mmcblk0p1  /boot           vfat    ro,noatime        0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
Setup fsck

In /etc/default/rcS:

Code: Select all

# automatically repair filesystems with inconsistencies during boot
FSCKFIX=yes
then:

Code: Select all

sudo tune2fs -c 3 /dev/mmcblk0p2
Replace syslog with inetutils-syslogd

Tip from: http://lowendbox.com/blog/bootstraping- ... t-scripts/

Code: Select all

sudo apt-get install inetutils-syslogd
Install ramlog

Code: Select all

sudo apt-get install lsof 
wget http://tremende.com/ramlog/download/ramlog_2.0.0_all.deb
dpkg -i ramlog_2.0.0_all.deb
Edit /etc/init.d/ramlog:

Code: Select all

### BEGIN INIT INFO
# Provides: ramlog
# Required-Start:
# X-Start-Before:   inetutils-syslogd
# X-Stop-After:     inetutils-syslogd
Set this up:

Code: Select all

sudo insserv
reboot twice and then check if ramlog-tmpfs is mounted

Code: Select all

df -h
ramlog-tmpfs    243M 1008K  242M   1% /var/log
Disable swapping

Code: Select all

sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
sudo update-rc.d dphys-swapfile remove
Other tweaks

Since I'm running headless with a RTK 8192, I setup the wifi card, by creating a file /etc/modprobe.d/8192cu.conf and switch off power management (fixes dropped packet issue):

Code: Select all

options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
For other configs, see : http://www.raspberrypi.org/phpBB3/viewt ... 4&p=454472

I disable other modules by adding to /etc/modprobe.d/raspi-blacklist.conf

Code: Select all

blacklist spi-bcm2708
blacklist i2c-bcm2708
blacklist ipv6
Disable all getty's since I only use ssh:

Code: Select all

#1:2345:respawn:/sbin/getty --noclear 38400 tty1
#2:23:respawn:/sbin/getty 38400 tty2
#3:23:respawn:/sbin/getty 38400 tty3
#4:23:respawn:/sbin/getty 38400 tty4
#5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6

#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Wifi config to create ad-hoc network

Suppose you take your raspberry pi to a new location within a different wifi environment and you don't have an ethernet cord to login and configure it. This setup will make the pi first search for known networks and then upon not finding them, create one of its own. Check: http://lcdev.dk/2012/11/18/raspberry-pi ... -fallback/

In short, you need to setup a dhcp server to listen on wlan0

Code: Select all

sudo apt-get install isc-dhcp-server
You will notice a failure when it tries to start up. It is normal.

Edit isc-dhcp-server config:

Code: Select all

sudo vim /etc/default/isc-dhcp-server
and add wlan0 as the interface:

Code: Select all

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="wlan0"
Edit dhcpd config

Code: Select all

sudo vim /etc/dhcp/dhcpd.conf
and add the following:

Code: Select all

DHCPDARGS=wlan0; #args for the dhcpd daemon -> limit DHCP to the wlan0 interface

option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option domain-name "RPi-network";
option routers 10.0.0.1; #default gateway
 
subnet 10.0.0.0 netmask 255.255.255.0 {
    range 10.0.0.2 10.0.0.20; #IP range to offer
}
Disable dhcpd from starting automatically

Code: Select all

sudo update-rc.d -f isc-dhcp-server remove
Edit /etc/network/interfaces. Mine looks like this:

Code: Select all

auto lo wlan0
iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wireless-power off
iface default inet dhcp
edit /etc/rc.local and add #!/bin/bash to it, and add the following code (slightly modified from original link):

Code: Select all

# RPi Network Conf Bootstrapper
createAdHocNetwork() {
    echo "Creating ad-hoc network"
    ifconfig wlan0 down
    iwconfig wlan0 mode ad-hoc
    iwconfig wlan0 key aaaaa11111 #WEP key
    iwconfig wlan0 essid RaspberryPi      #SSID
    ifconfig wlan0 10.0.0.200 netmask 255.255.255.0 up
    /usr/sbin/dhcpd wlan0
    echo "Ad-hoc network created"
}

checkConnection() {
        echo "================================="
        echo "RPi Network Conf Bootstrapper 0.1"
        echo "================================="
        echo "Scanning for known WiFi networks"
        ssids=('my wifi' 'another wlan')
        connected=false
        for ssid in "${ssids[@]}"
        do
            if iwlist wlan0 scan | grep "$ssid" > /dev/null
            then
                echo "First WiFi in range has SSID:" $ssid
                echo "Starting supplicant for WPA/WPA2"
                wpa_supplicant -s -B -i wlan0 -D nl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1
                echo "Obtaining IP from DHCP"
                if dhclient -1 wlan0
                then
                    echo "Connected to WiFi"
                    connected=true
                    break
                else
                    echo "DHCP server did not respond with an IP lease (DHCPOFFER)"
                    wpa_cli terminate
                    break
                fi
            else
                echo "Not in range, WiFi with SSID:" $ssid
            fi
        done

        if ! $connected; then
            createAdHocNetwork
        fi
}

checkConnection

exit 0
Make sure your wpa-supplicant.conf file is setup properly!

Final state
Check free memory.

Code: Select all

 $ free -m
             total       used       free     shared    buffers     cached
Mem:           485         57        427          0          8         28
-/+ buffers/cache:         21        464
Swap:            0          0          0
And thats it!

Any more tips (specially kernel cmdline and module configs) will be appreciated!

Takenover83
Posts: 166
Joined: Mon Sep 02, 2013 5:39 am

Re: optimizing the raspberry pi

Sun Nov 17, 2013 6:23 am

Thank's for sharing. Some more tweak's here.
https://extremeshok.com/2012/07/22/rasp ... ory-usage/

Edit: Note, zram module is not uncluded in the new 3.10.18 kernel.

Drefsab
Posts: 8
Joined: Fri Nov 08, 2013 11:52 am

Re: optimizing the raspberry pi

Mon Nov 18, 2013 1:56 pm

I tried this got to the reboot for installing ramlog and it kernel panics :(

Takenover83
Posts: 166
Joined: Mon Sep 02, 2013 5:39 am

Re: optimizing the raspberry pi

Mon Nov 18, 2013 5:39 pm

I did not get a kernel panic when I tried the ramlog portion, with kernel 3.10.*
Did not test it with 3.6.*

whoami
Posts: 64
Joined: Fri Nov 15, 2013 1:41 pm

Re: optimizing the raspberry pi

Mon Nov 18, 2013 11:08 pm

Drefsab wrote:I tried this got to the reboot for installing ramlog and it kernel panics :(
- which kernel?
- did you replace syslogd?

Drefsab
Posts: 8
Joined: Fri Nov 08, 2013 11:52 am

Re: optimizing the raspberry pi

Tue Nov 19, 2013 12:34 am

Linux pi 3.10.19+ #600 PREEMPT Sat Nov 16 20:34:43 GMT 2013 armv6l GNU/Linux

I did replace it, though I suspect I did something wrong on the config, I did everything again apart from the ramlog and all seams smooth atm.

whoami
Posts: 64
Joined: Fri Nov 15, 2013 1:41 pm

Re: optimizing the raspberry pi

Thu Nov 21, 2013 3:22 am

Takenover83 wrote:Thank's for sharing. Some more tweak's here.
https://extremeshok.com/2012/07/22/rasp ... ory-usage/

Edit: Note, zram module is not uncluded in the new 3.10.18 kernel.
Thanks for the link. To disable dhclient but to also keep the ad-hoc network creation functionality I've modified the rc.local script a bit. This script sets the IP address and gateway manually and then tries pinging the gateway. If the ping is unsuccessful, it moves wlan0 into ad-hoc mode. Any improvements/suggestions are welcome. I've not been able to figure out an elegant way to enable dhclient if ping failed, and then to report the error if dhclient fails too.

Code: Select all

#!/bin/bash
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

# RPi Network Conf Bootstrapper
setIP() {
  GATEWAY=10.0.0.1
  ifconfig wlan0 10.0.0.2 netmask 255.255.255.0 broadcast 10.0.0.255
  route add default gw $GATEWAY
  ping -c 2 $GATEWAY &> /dev/null
  echo $?
}

createAdHocNetwork() {
    echo "Creating ad-hoc network"
    ifconfig wlan0 down
    iwconfig wlan0 mode ad-hoc
    iwconfig wlan0 key 1234512345 #WEP key
    iwconfig wlan0 essid RPi      #SSID
    ifconfig wlan0 10.0.0.200 netmask 255.255.255.0 up
    /usr/sbin/dhcpd wlan0
    echo "Ad-hoc network created"
}

checkConnection() {
        echo "================================="
        echo "RPi Network Conf Bootstrapper 0.1"
        echo "================================="
        echo "Scanning for known WiFi networks"
        ssids=('my network' 'another wlan')
        connected=false
        for ssid in "${ssids[@]}"
        do
            if iwlist wlan0 scan | grep "$ssid" > /dev/null
            then
                echo "First WiFi in range has SSID:" $ssid
                echo "Starting supplicant for WPA/WPA2"
                #wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1
                wpa_supplicant -s -B -i wlan0 -D nl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1
                if [ 0=$(setIP) ]
                then
                    echo "Connected to WiFi"
                    connected=true
                    break
                else
                    echo "Could not set wifi IP address"
                    wpa_cli terminate
                    break
                fi
            else
                echo "Not in range, WiFi with SSID:" $ssid
            fi
        done

        if ! $connected; then
            createAdHocNetwork
        fi
}

checkConnection
exit 0
After installing dropbear and switching to dash the memory usage has dropped to about 13 MB (which includes usage by tmpfs and ramlog)

Code: Select all

$ free -m
             total       used       free     shared    buffers     cached
Mem:           485         47        437          0          7         26
-/+ buffers/cache:         13        471
Swap:            0          0          0
$


tamas4president
Posts: 2
Joined: Fri Nov 22, 2013 3:11 am

Re: optimizing the raspberry pi

Fri Nov 22, 2013 3:18 am

Apologies, double post. Please refer to next post.
Last edited by tamas4president on Fri Nov 22, 2013 10:43 am, edited 1 time in total.

tamas4president
Posts: 2
Joined: Fri Nov 22, 2013 3:11 am

Re: optimizing the raspberry pi

Fri Nov 22, 2013 6:17 am

hi thanks for the write up

Question about your fix fstab section, my fstab does not have those, is it safe to add the lines

none /var/run tmpfs size=1M,noatime 0 0
none /tmp tmpfs size=1M,noatime 0 0
none /var/tmp tmpfs size=1M,noatime 0 0

also, I am having issues with samba running out of space, can I increase the size?
cheers
Tamas

mikerr
Posts: 2783
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: optimizing the raspberry pi

Fri Nov 22, 2013 9:47 am

whoami wrote: Run raspi-config Advanced Options -> Memory Split -> give 1MB to GPU
Minimum GPU is 16MB, it'll still use 16MB if you specify less.

Drefsab
Posts: 8
Joined: Fri Nov 08, 2013 11:52 am

Re: optimizing the raspberry pi

Tue Nov 26, 2013 12:07 pm

on dash is it possible to have tab complete? I tried it and it seams like its working but I cant see what its displaying in the ssh prompt.

whoami
Posts: 64
Joined: Fri Nov 15, 2013 1:41 pm

Re: optimizing the raspberry pi

Wed Nov 27, 2013 1:34 am

I wanted to add something. I recently tried this config and corrupted my SD card (kingston 32GB 10 MB/s and Sony 16 GB 40MB/s), so obviously the kernel configs/fsck/tune2fs/fstab combo doesn't really help :|

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: optimizing the raspberry pi

Thu Nov 28, 2013 10:57 pm

I follwed the instructions for ramlog but the service refuse to start. I reboot more than twice..

Code: Select all

sudo sepi@rasp ~ $ sudo service ramlog start
[FAIL] Starting ramlog-tmpfs 2.0Error: /var/log is in use... failed!
The list of open files: (You need to close below daemons if you want to start/stop ramlog manually)

COMMAND    PID     USER   FD   TYPE DEVICE  SIZE/OFF   NODE NAME
syslogd   2266     root    5w   REG  179,2 712910178     44 /var/log/auth.log
syslogd   2266     root    6w   REG  179,2    149859   4199 /var/log/syslog
syslogd   2266     root    7w   REG  179,2    114689     50 /var/log/daemon.log
syslogd   2266     root    8w   REG  179,2    232015    380 /var/log/kern.log
syslogd   2266     root    9w   REG  179,2         0   6585 /var/log/lpr.log
syslogd   2266     root   10w   REG  179,2         0   6586 /var/log/mail.log
syslogd   2266     root   11w   REG  179,2       852   1179 /var/log/user.log
syslogd   2266     root   12w   REG  179,2         0   6587 /var/log/uucp.log
syslogd   2266     root   13w   REG  179,2         0   6588 /var/log/mail.info
syslogd   2266     root   14w   REG  179,2         0   6589 /var/log/mail.warn
syslogd   2266     root   15w   REG  179,2         0   6590 /var/log/mail.err
syslogd   2266     root   16w   REG  179,2         0   6591 /var/log/news/news.crit
syslogd   2266     root   17w   REG  179,2         0   6592 /var/log/news/news.err
syslogd   2266     root   18w   REG  179,2         0   6593 /var/log/news/news.notice
syslogd   2266     root   19w   REG  179,2      6389    389 /var/log/debug
syslogd   2266     root   20w   REG  179,2    211177   1796 /var/log/messages
nmbd      2292     root    2w   REG  179,2     10695   3688 /var/log/samba/log.nmbd
nmbd      2292     root    4w   REG  179,2     10695   3688 /var/log/samba/log.nmbd
apache2   2336     root    2w   REG  179,2      2198 138447 /var/log/apache2/error.log
apache2   2336     root    6w   REG  179,2         0 136638 /var/log/apache2/other_vhosts_access.log
apache2   2336     root    7w   REG  179,2         0 136180 /var/log/apache2/access.log
apache2   2338 www-data    2w   REG  179,2      2198 138447 /var/log/apache2/error.log
apache2   2338 www-data    6w   REG  179,2         0 136638 /var/log/apache2/other_vhosts_access.log
apache2   2338 www-data    7w   REG  179,2         0 136180 /var/log/apache2/access.log
apache2   2339 www-data    2w   REG  179,2      2198 138447 /var/log/apache2/error.log
apache2   2339 www-data    6w   REG  179,2         0 136638 /var/log/apache2/other_vhosts_access.log
apache2   2339 www-data    7w   REG  179,2         0 136180 /var/log/apache2/access.log
smbd      2659     root    2w   REG  179,2    133065   1214 /var/log/samba/log.smbd
smbd      2659     root    8w   REG  179,2    133065   1214 /var/log/samba/log.smbd
smbd      2697     root    2w   REG  179,2    133065   1214 /var/log/samba/log.smbd
smbd      2697     root   11w   REG  179,2    133065   1214 /var/log/samba/log.smbd
console-k 9657     root    7w   REG  179,2     25433   3670 /var/log/ConsoleKit/history

Test result: ramlog cannot be started or stopped at the moment.
The same happens at reboot.

/etc/init.d/ramlog

Code: Select all

### BEGIN INIT INFO
# Provides: ramlog
# Required-Start:
# X-Start-Before:   inetutils-syslogd
# X-Stop-After:     inetutils-syslogd
# Short-Description: moves /var/log into ramdisk
# Description: ramlog daemon moves /var/log to ramdisk on startup and copies it back to harddrive on shutdown or restart
### END INIT INFO

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: optimizing the raspberry pi

Mon Dec 02, 2013 9:59 pm

I follwed the guide since ramlog.
Now it's working fine but almost at each reboot I have errors that stops the boot: debugger error, kernel panic, timout waiting hardware interrupts and others...

whoami
Posts: 64
Joined: Fri Nov 15, 2013 1:41 pm

Re: optimizing the raspberry pi

Fri Aug 01, 2014 2:44 pm

I've been using this for a while now. System has been very stable. Changed tune2fs to check at every mount! i.e. instead of 3, used 1.

fourdee4d
Posts: 362
Joined: Mon Sep 17, 2012 10:31 pm
Location: East Midlands, UK
Contact: Website

Re: optimizing the raspberry pi

Fri Aug 01, 2014 11:03 pm

Try this pre-made optimized, minimal Debian image for the Pi:
http://www.raspberrypi.org/forums/viewt ... 63&t=83219

Image
DietPi.com - Lightweight justice for your Raspberry Pi. Optimized, simplified linux for everyone
DietPi's web hosting is powered by MyVirtualServer.com

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: optimizing the raspberry pi

Sat Aug 02, 2014 12:20 am

Nice post. Just wanted to post a few comments on the beginning.

1) Overclocking depends on your hardware and setup and 1 GHz is not going to work for everyone.
2) Since force turbo is set to 1, that means that your warranty is now void.

Very nice!
There are 10 types of people: those who understand binary and those who don't.

Ivan Tham
Posts: 75
Joined: Mon Jun 24, 2013 7:06 am

Re: optimizing the raspberry pi

Fri Oct 24, 2014 3:37 pm

whoami wrote: First boot

Run raspi-config and expand filesystem (can skip this step if extra partitions needed)
Advanced Options -> Memory Split -> give 1MB to GPU
This only works for a server.
whoami wrote: Setup kernel options

In config.txt

Code: Select all

# for more options see http://elinux.org/RPi_config.txt
core_freq=500
sdram_freq=600
over_voltage=6
gpu_mem=1
arm_freq=1000
emmc_pll_core=1
force_turbo=1
init_emmc_clock=500000000
In cmdline.txt, set elevator=noop

Code: Select all

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=noop rootwait
The core_freq is too low to be overclock. And adding dwc_otg.fiq_fix_enable=1 is said to gain 10% speed on the ARM side.
whoami wrote: Setup fsck

In /etc/default/rcS:

Code: Select all

# automatically repair filesystems with inconsistencies during boot
FSCKFIX=yes
[/quote]
That is already on raspbian.

[quote="whoami"]
[b]Replace syslog with inetutils-syslogd[/b]

Tip from: [url]http://lowendbox.com/blog/bootstraping-low-end-vps-with-pre-built-scripts/[/url]
[code]sudo apt-get install inetutils-syslogd
Install ramlog

Code: Select all

sudo apt-get install lsof 
wget http://tremende.com/ramlog/download/ramlog_2.0.0_all.deb
dpkg -i ramlog_2.0.0_all.deb
What does this do?
whoami wrote: Disable swapping

Code: Select all

sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
sudo update-rc.d dphys-swapfile remove
Swapping is disabled in raspbian wheezy.

User avatar
DougieLawson
Posts: 36331
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: optimizing the raspberry pi

Fri Oct 24, 2014 3:46 pm

Ivan Tham wrote:
whoami wrote: Disable swapping

Code: Select all

sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
sudo update-rc.d dphys-swapfile remove
Swapping is disabled in raspbian wheezy.
No, it is not disabled.

Look at the kernel config. zcat /proc/config.gz | grep SWAP
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Ivan Tham
Posts: 75
Joined: Mon Jun 24, 2013 7:06 am

Re: optimizing the raspberry pi

Fri Oct 24, 2014 3:48 pm

DougieLawson wrote:
Ivan Tham wrote:
whoami wrote: Disable swapping

Code: Select all

sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
sudo update-rc.d dphys-swapfile remove
Swapping is disabled in raspbian wheezy.
No, it is not disabled.

Look at the kernel config. zcat /proc/config.gz | grep SWAP
How can I reduce the default swap size?

User avatar
DougieLawson
Posts: 36331
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: optimizing the raspberry pi

Fri Oct 24, 2014 3:52 pm

Disable it as suggested. There's nothing to be gained by swapping to the SDCard on a RPi. If you have a USB hard drive or SSD then swapping is less of a problem. The SDCard I/O rate is too slow and your RPi will behave like it is wading in treacle when swapping starts to happen.

The real answer is to stop letting tasks over commit the RAM and to reduce the share of RAM given to the GPU (unless you're doing GPU based image processing). So hitting things like MySQL's buffer sizes (which are set-up for a system with about 4GB of RAM in the default configuration) will have a much better effect than worrying about swapping.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Ivan Tham
Posts: 75
Joined: Mon Jun 24, 2013 7:06 am

Re: optimizing the raspberry pi

Fri Oct 24, 2014 3:54 pm

DougieLawson wrote:Disable it as suggested. There's nothing to be gained by swapping to the SDCard on a RPi. If you have a USB hard drive or SSD then swapping is less of a problem. The SDCard I/O rate is too slow and your RPi will behave like it is wading in treacle when swapping starts to happen.

The real answer is to stop letting tasks over commit the RAM and to reduce the share of RAM given to the GPU (unless you're doing GPU based image processing). So hitting things like MySQL's buffer sizes (which are set-up for a system with about 4GB of RAM in the default configuration) will have a much better effect than worrying about swapping.
Sometimes, when the RAM is full, my pi freezes.

User avatar
DougieLawson
Posts: 36331
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: optimizing the raspberry pi

Fri Oct 24, 2014 3:56 pm

Ivan Tham wrote: Sometimes, when the RAM is full, my pi freezes.
Don't fill it. The ideal working set for most multi-tasking/multi-processing computer systems is about 67%. The warning bells should sound when you reach 85%. As soon as you get to 100% you'll land in swapping hell and it appears to freeze.

The only answer is to tune the memory hogs so that they don't hog memory or hit them hard with the OOM.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Ivan Tham
Posts: 75
Joined: Mon Jun 24, 2013 7:06 am

Re: optimizing the raspberry pi

Fri Oct 24, 2014 4:01 pm

DougieLawson wrote:
Ivan Tham wrote: Sometimes, when the RAM is full, my pi freezes.
Don't fill it. The ideal working set for most multi-tasking/multi-processing computer systems is about 67%. The warning bells should sound when you reach 85%. As soon as you get to 100% you'll land in swapping hell and it appears to freeze.

The only answer is to tune the memory hogs so that they don't hog memory or hit them hard with the OOM.
Is that something to do with cgroup?

User avatar
DougieLawson
Posts: 36331
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: optimizing the raspberry pi

Fri Oct 24, 2014 4:03 pm

systemd with cgroup is part of the out of memory killer.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Raspbian”