Page 1 of 2

How to speed up boot time if run headless?

Posted: Sat Dec 15, 2012 8:20 pm
by gaias
Hello,

are there ways to speed up the boot time of the Pi using the Raspbian image when operated headless? I ask since I use my Pi as a web radio player and the boot up time is quite long for this purpose.

Regards
gaias

Re: How to peed up boot time if run headless?

Posted: Sat Dec 15, 2012 10:25 pm
by milhouse
1) Overclocking it will improve boot time from the point at which the governor is switched to ondemand, although this occurs quite late in the boot process so isn't likely to reduce the overall boot time by very much.

2) Overclocking AND enabling force_turbo ensures the overclock is effective throughout the entire boot process and will significantly reduce boot time. However, if you need to over volt to achieve a stable overclock, this will void your warranty.

3) Removing unnecessary services will also reduce boot time. I run the following commands to remove desktop related programmes and services from a stock Raspbian install:

Code: Select all

sudo apt-get -y purge libx11-6 libgtk-3-common xkb-data lxde-icon-theme raspberrypi-artwork penguinspuzzle
# Needed by omxplayer so add back...
apt-get -y install libfreetype6
My 1GHz 512MB overclocked and force_turbo=1 Pi, with a Class 10 SDHC, all desktop cruft removed, will boot headless Raspbian in approximately 38 seconds, start to finish.

Re: How to peed up boot time if run headless?

Posted: Mon Dec 17, 2012 9:34 am
by gaias
Thanks especially for the tip to uninstall services (and the names of the packages)! Could there be anymore services I can uninstall if I only need to run mpd+mpc on the machine?

Re: How to peed up boot time if run headless?

Posted: Wed Jan 02, 2013 9:42 am
by Frans82
Bump. Interested in hearing more about this.

Does anyone know of any other services we can scrap from the boot sequence? I only need to run a simple python script on a headless pi.

Cheers.

Re: How to peed up boot time if run headless?

Posted: Wed Jan 02, 2013 10:51 pm
by MoonTEC
Does anyone know of any other services we can scrap from the boot sequence? I only need to run a simple python script on a headless pi.
It depends on what else is needed for this script(loging, internet connection, time from ntp, kernel modules ...).
I can recommend installing rcconf - Debian Runlevel Configuration tool.
Uncheck unnecessary services, confirm new configuration with OK and reboot. In Your case fake-hwclock, ntp, udev, ssh should work.
I was using RPi for playing internet radio using moc, just with alsa-utils, ssh, udev enabled, accurate time unnecessary, so no ntp and fake-hwclock.
[email protected] SDHC class4 card boots to command promt in 14 seconds.

You can add kernel option quiet to /boot/cmdline.txt. Because of slow TTY, printing less info can save some time.
Adding kernel option fastboot, not recomended, because disables filesystem check, but can save few seconds.

Re: How to peed up boot time if run headless?

Posted: Fri Jan 11, 2013 9:40 pm
by timgiles
Sandisk UHS-I SD Card - 95MBps - boots a Pi faster than you walk back to the sofa to relogin with Putty!

Re: How to peed up boot time if run headless?

Posted: Sun Jan 20, 2013 1:48 am
by dudeman
High speed raspian tweaks:

1. overclock

2. tune kernel:
http://rpitc.blogspot.com/p/docs.html

Code: Select all

/boot/cmdline.txt
dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=120,data=writeback elevator=deadline noatime nodiratime  data=writeback rootwait quiet
3. tune system:

Code: Select all

/etc/sysctl.conf:
vm.dirty_background_ratio = 20
vm.dirty_expire_centisecs = 0
vm.dirty_ratio = 80
vm.dirty_writeback_centisecs = 1200
vm.overcommit_ratio = 2
vm.laptop_mode = 5
vm.swappiness = 10
4. check services (I didn't see much to stop) using

Code: Select all

sysv-rc-conf
and be sure to read the man page first

5. get a fast SDHC card http://www.amazon.com/Transcend-Class-F ... 003VNKNF0/

6. rebuild kernel with patches TO DO

Re: How to peed up boot time if run headless?

Posted: Sun Jan 20, 2013 7:05 am
by technion
People are offering a lot of performance tips but I'm concerned there's a bigger picture here.

Being headless has no impact on boot time.

My Pi, which is headless (not that that matters), can reboot in literally about ten seconds. When I knock the cable out accidentally, it's back online before putty drops a session.

I'm curious as to where yours is lagging. Some possible suggestions:
  • You don't have a NIC connected, but the interface is configured to look for a DHCP server
    You are running Apache or a mail client without working DNS
    The web radio software takes a long time to start
Something is a service that's taking way too long to start.

Re: How to peed up boot time if run headless?

Posted: Sun Jan 20, 2013 7:35 am
by shuckle
How do you measure boot time? 10 secs sounds unbelievable. Mine is closer to 30 secs. But we should agree how to measure it.

Re: How to peed up boot time if run headless?

Posted: Sun Jan 20, 2013 10:44 am
by technion
shuckle wrote:How do you measure boot time? 10 secs sounds unbelievable. Mine is closer to 30 secs. But we should agree how to measure it.
In my case it's a mental estimate of how long it takes to start responding it pings.
It's certainly possible that it takes longer, and certainly possible that some services are still on their way up at that time.

Even if it was 30 seconds though, it's significantly faster than most desktops, which brings me to the question of how long does it take the original poster to start his pi?

If he says "four minutes" it's all a moot point - something would be wrong.

Re: How to speed up boot time if run headless?

Posted: Sat May 11, 2013 9:20 pm
by Narf03
Hi all, how do we know which file Pi will execute during boot ? ie /etc/rc.local only print "My IP address is ...", what else it will execute ? ie if i install MySQL server and it auto-start, but im not sure which file do call it.

Re: How to speed up boot time if run headless?

Posted: Sun May 12, 2013 3:13 pm
by SirLagz
Narf03 wrote:Hi all, how do we know which file Pi will execute during boot ? ie /etc/rc.local only print "My IP address is ...", what else it will execute ? ie if i install MySQL server and it auto-start, but im not sure which file do call it.
Have a look in /etc/rc1.d 2.d 3.d etc etc and you will see symlinks that starts with either a S or a K
Symlinks that start with an S means that the program linked starts at that runlevel
Symlinks that start with a K means that the program will stop at that runlevel

Re: How to speed up boot time if run headless?

Posted: Mon May 13, 2013 9:08 am
by tom.k.cook
I don't have any numbers to put to it, but it's almost universally true that linux boot times are IO-bound. Faster storage will give you faster boots.

This seems to be borne out by other comments here - people with a class 10 SDHC card have 10 seconds boots, people with a rotten class 2 SD card have 30 or 40 second boots.

The speed difference is not trivial - the 'class' number is actually a transfer rate for writes in MB/s. A class 10 card is five times faster than a class 2 card.

So the biggest difference you can make is to shell out $25 on a high performance SDHC card.

The other tip on here I'd agree with is making the kernel shut up during boot - the default log level seems to be 7 - 'shout about everything' level. Try adding 'loglevel=1' or 'quiet' to cmdline.txt. Or turn off the serial console in cmdline.txt. By default, the kernel dumps several kB of text on the console during boot, which probably adds a couple of seconds.

Re: How to speed up boot time if run headless?

Posted: Wed May 22, 2013 5:43 am
by gsh
The fastest way to boot is to build yourself an initird ramdisk. That way you can be up in 5 seconds

Check out berryboot as an example of how quick it is to boot linux

Gordon

Re: How to speed up boot time if run headless?

Posted: Wed May 22, 2013 11:09 am
by shuckle
I tested different ways to improve boot time and noticed the following:
Adding noatime nodiratime to /boot/cmdline.txt improved about 0.1 sec
Adding quiet to /boot/cmdline.txt improved about 1.0 sec
Overclocking improved about 0.1 sec

Total improvment with all these settings was about 1.1 secs

(Removing connected keyboard improved about 0.2 sec)

Now my raspberry boots about in 18 seconds.I am measuring it like this:

Code: Select all

$ dmesg | grep full-duplex
[   18.245983] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
For comparison:

Code: Select all

$ dmesg | grep led0
[    3.963521] Registered led device: led0
What timings can you get? And any ideas how to improve?
Any easy ways to utilize that initrd ramdisk? getting form 18 secs to 5 secs sounds almost unbelievable.

Re: How to speed up boot time if run headless?

Posted: Wed May 22, 2013 4:58 pm
by milhouse
shuckle wrote:I tested different ways to improve boot time and noticed the following:
Adding noatime nodiratime to /boot/cmdline.txt improved about 0.1 sec
Adding quiet to /boot/cmdline.txt improved about 1.0 sec
Overclocking improved about 0.1 sec

Total improvment with all these settings was about 1.1 secs
Did you try "initial_turbo=30" and see what effect that has? It should mean the Pi is overclocked from the very beginning, rather than the overclock kicking in near the end of the boot sequence.

Re: How to speed up boot time if run headless?

Posted: Wed May 22, 2013 6:14 pm
by shuckle
Yes, i tried it. It had no effect. I think it does something else than what it seems to imply...

Re: How to speed up boot time if run headless?

Posted: Thu May 23, 2013 10:10 am
by aaa801
turn off or decrease the system log level, its set to log EVERYTHING, and on sd card speed is really noticeable

Re: How to speed up boot time if run headless?

Posted: Thu May 23, 2013 3:08 pm
by Darkness
I know it's an old topic, but I think there might be some interesting info in these slides for some hardcore tweaking: http://www.slideshare.net/andrewmurraympc/elce-the

This is not raspberry PI and a very specific use case, but he managed to get power-to-UI time from 19 seconds to 0.77 seconds!

Re: How to speed up boot time if run headless?

Posted: Fri May 24, 2013 7:49 am
by shuckle
aaa801 wrote:turn off or decrease the system log level, its set to log EVERYTHING, and on sd card speed is really noticeable
I set loglevel=0 to /boot/cmdline.txt, but that did not cause any effects to anywhere. I am surprised. How should it be done then?

Re: How to speed up boot time if run headless?

Posted: Fri May 24, 2013 12:47 pm
by aaa801
shuckle wrote:
aaa801 wrote:turn off or decrease the system log level, its set to log EVERYTHING, and on sd card speed is really noticeable
I set loglevel=0 to /boot/cmdline.txt, but that did not cause any effects to anywhere. I am surprised. How should it be done then?
http://linux.die.net/man/5/syslog.conf

Re: How to speed up boot time if run headless?

Posted: Fri May 24, 2013 2:24 pm
by sdjf
Did you reboot after changing the log level? the new setting will not take effect until after reboot. but sync first:

sync
reboot

Re: How to speed up boot time if run headless?

Posted: Fri May 24, 2013 2:42 pm
by Joe Schmoe
I have not had good luck with (trying to shut up the messages by) changing the "loglevel" thing, either.

I think it is one of those things that only works if the various bits and pieces of the kernel that generate output "play by the rules" - that is, recognize the loglevel setting. My experience is that some drivers don't do this.

Re: How to speed up boot time if run headless?

Posted: Sat May 25, 2013 6:32 am
by shuckle
sdjf wrote:Did you reboot after changing the log level? the new setting will not take effect until after reboot. but sync first:

sync
reboot
Yes, i did. I am testing booting speed, so this comes automatically and often.

Re: How to speed up boot time if run headless?

Posted: Sat Sep 14, 2013 3:33 pm
by DeadMonkeyX
Would it help on the boottime by changing the sysvinit to systemd. On a regular computer you'll gain a lot of boot time improvement. i have seen netbooks go from 2minuts in boottime to 30sec. ;)