How to speed up boot time if run headless?


29 posts   Page 1 of 2   1, 2
by gaias » Sat Dec 15, 2012 8:20 pm
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
Posts: 4
Joined: Thu Oct 11, 2012 6:18 am
by milhouse » Sat Dec 15, 2012 10:25 pm
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.
Posts: 613
Joined: Mon Jan 16, 2012 12:59 pm
by gaias » Mon Dec 17, 2012 9:34 am
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?
Posts: 4
Joined: Thu Oct 11, 2012 6:18 am
by Frans82 » Wed Jan 02, 2013 9:42 am
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.
Posts: 9
Joined: Sun Dec 30, 2012 10:12 am
by MoonTEC » Wed Jan 02, 2013 10:51 pm
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.
CPU@700MHz 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.
User avatar
Posts: 28
Joined: Sat Aug 20, 2011 8:20 am
Location: Lithuania
by timgiles » Fri Jan 11, 2013 9:40 pm
Sandisk UHS-I SD Card - 95MBps - boots a Pi faster than you walk back to the sofa to relogin with Putty!
Posts: 101
Joined: Thu Jan 12, 2012 8:58 am
by dudeman » Sun Jan 20, 2013 1:48 am
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-Flash-Memory-TS32GSDHC10E/dp/B003VNKNF0/

6. rebuild kernel with patches TO DO
User avatar
Posts: 22
Joined: Sun Jan 20, 2013 1:20 am
Location: USA
by technion » Sun Jan 20, 2013 7:05 am
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:

[list=]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[/list]
Something is a service that's taking way too long to start.
Posts: 239
Joined: Sun Dec 02, 2012 9:49 am
by shuckle » Sun Jan 20, 2013 7:35 am
How do you measure boot time? 10 secs sounds unbelievable. Mine is closer to 30 secs. But we should agree how to measure it.
Posts: 559
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland
by technion » Sun Jan 20, 2013 10:44 am
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.
Posts: 239
Joined: Sun Dec 02, 2012 9:49 am
by Narf03 » Sat May 11, 2013 9:20 pm
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.
Posts: 243
Joined: Mon Jun 11, 2012 3:44 pm
Location: Malaysia
by SirLagz » Sun May 12, 2013 3:13 pm
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
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
by tom.k.cook » Mon May 13, 2013 9:08 am
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.
Posts: 44
Joined: Fri Jun 22, 2012 8:51 am
by gsh » Wed May 22, 2013 5:43 am
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
--
Gordon Hollingworth PhD
Raspberry Pi - Director of Software Engineering
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1134
Joined: Sat Sep 10, 2011 11:43 am
by shuckle » Wed May 22, 2013 11:09 am
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.
Posts: 559
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland
by milhouse » Wed May 22, 2013 4:58 pm
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.
Posts: 613
Joined: Mon Jan 16, 2012 12:59 pm
by shuckle » Wed May 22, 2013 6:14 pm
Yes, i tried it. It had no effect. I think it does something else than what it seems to imply...
Posts: 559
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland
by aaa801 » Thu May 23, 2013 10:10 am
turn off or decrease the system log level, its set to log EVERYTHING, and on sd card speed is really noticeable
Posts: 428
Joined: Mon Jun 04, 2012 9:06 pm
Location: Berkshire
by Darkness » Thu May 23, 2013 3:08 pm
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!
Posts: 20
Joined: Wed May 23, 2012 12:13 am
by shuckle » Fri May 24, 2013 7:49 am
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?
Posts: 559
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland
by aaa801 » Fri May 24, 2013 12:47 pm
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
Posts: 428
Joined: Mon Jun 04, 2012 9:06 pm
Location: Berkshire
by sdjf » Fri May 24, 2013 2:24 pm
Did you reboot after changing the log level? the new setting will not take effect until after reboot. but sync first:

sync
reboot
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || My 512MB Model B only runs Arch.
Posts: 1388
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by Joe Schmoe » Fri May 24, 2013 2:42 pm
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.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm
by shuckle » Sat May 25, 2013 6:32 am
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.
Posts: 559
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland
by DeadMonkeyX » Sat Sep 14, 2013 3:33 pm
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. ;)
Posts: 1
Joined: Sat Sep 14, 2013 3:29 pm