in reply to Slow startup on raspberry pi

PAR/pp will have a startup hit on first run as it unpacks lots of things. The Raspberry Pi is a fairly low power SoC, however there are optimisations to be made. If you are running the OS from SD card, it's going to be slow, installing the OS to a USB disk (or memory stick) is significantly faster in my experience.

Consider profiling your code, perhaps there is room for improvement (see Devel::NYTProf). In situations where hardware is 'slow' in comparison to what most people are used to, and resources are scarce performance hogs become more apparent.

I've not worked with the default installation of Raspbian (Debian built for the Pi) in some time. Here are some notes I made* a long time ago and intended to post (on the topic of Perl on the Pi). The notes are far from complete, some or all items may no longer be current, so please proceed with caution:

Recently I ordered Raspberry Pi colocation with PC Extreme (I'm sure many others will offer such deals). I opted to order a Pi and 16GB SD card through them, and have them install it in their data centre, rather than configure my own and send it to them through the post (given that at the time the available colocation spaces were limited).

Tweaking the base install

Initially I had one 256MB RAM Raspberry Pi running XBMC (via raspbmc), it's streaming audio and video (including 1080p 5.1 audio) over my network, I also have a 512MB version I'm tweaking for audio work. The base install of Raspbian (a Debian variant) comes with a window manager and all sorts of other bells and whistles that I don't need. Disk space and precious RAM can be recovered by making a few changes. Feel free to skip the section below if you're not interested in doing so, but the metrics stated here are based on this setup.

* Note: A lot of these ideas are not unique to the Raspberry Pi, you can find similar discussions on many forums. Some steps below were taken for such sources.

Warning: I am not responsible for any damage or loss of data. If you choose to follow these instructions do so in on a test system first.

Once connected to the Pi via ssh, become root:

sudo su

Remove window manager (openbox), desktop (LXDE), and desktop applications:

apt-get purge consolekit desktop-base* desktop-file-utils* gnome-icon- +theme* gnome-themes-standard* hicolor-icon-theme* leafpad* lxde* lxde +-core* midori* xserver-common* xserver-xorg* xserver-xorg-core* xserv +er-xorg-input-all* xserver-xorg-input-evdev* xserver-xorg-input-synap +tics* xserver-xorg-video-fbdev*

Ensure the Pi is running the latest software:

apt-get -y update && apt-get -y dist-upgrade && apt-get -y autoremove +&& apt-get -y autoclean

Switch from openSSH to Dropbear_(software), recover ~10MB RAM:

install dropbear

apt-get install dropbear openssh-client

Stop openSSH (your existing connection will remain functional)

/etc/init.d/ssh stop

Start dropbear at boot:

sed -i 's/NO_START=1/NO_START=0/g' /etc/default/dropbear

Start dropbear:

/etc/init.d/dropbear start

At this point test you can ssh into your pi, note that a new key will have been generated, your ssh client should warn you about this change.

Once you've successfully connected remove openSSH:

apt-get purge openssh-server

Replace bash with dash, save ~1MB:

dpkg-reconfigure dash

Remove extra ttys, save ~4MB:

sed -i '/[2-6]:23:respawn:\/sbin\/getty 38400 tty[2-6]/s%^%#%g' /etc/i +nittab

The GPU requries at minimum 16MB of RAM to load the binary blob of propriatary firmware. Ensure that the /boot/config.txt is configured to use this minimal value:


Remove IPV6 support:

echo "net.ipv6.conf.all.disable_ipv6=1" > /etc/sysctl.d/ +nf

Blacklist the kernel module:

echo 'blacklist ipv6' >> /etc/modprobe.d/blacklist

Comment out the hosts:

sed -i '/::/s%^%#%g' /etc/hosts

Reboot for some changes to take effect:


Check memory use after boot:

pi@shemp ~ $ free -h total used free shared buffers cac +hed Mem: 485M 38M 447M 0B 7.4M +17M -/+ buffers/cache: 14M 471M Swap: 99M 0B 99M

Update: I forgot this section.

Memory usage prior to changes:

pi@raspberrypi ~ $ free -h total used free shared buffers cac +hed Mem: 438M 107M 330M 0B 9.5M +74M -/+ buffers/cache: 24M 414M Swap: 99M 0B 99M

Update: I forgot to include the pre change memory usage.