WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Speed up boot time  (Read 8068 times)

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Speed up boot time
« on: July 05, 2009, 05:46:32 PM »
Hello,

I've built an appliance (an audio player) based on TCL. One of the reasons I chose TCL was the fast startup. Now I'm wondering if and how I can squeeze out even more. Until now the system looks like this:
  • TCL 2.1 started on an Intel D945GSEJT mainboard from harddisk partition (ext3) via grub
  • boot parameters are: quiet vga=normal noswap home=hda1 local=hda1 restore=hda1
  • home and local are directories
  • startup time now is about 21 seconds from grub to desktop

First thing I came up to speed up boot time is to remaster boot image and replace /init with a link to /bin/busybox, like it was in 2.0. This should reduce boot time by something from 0.5 to 1.0 second. The drawback of not "seeing" the rootfs in df is not important.

Any other ideas?

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: Speed up boot time
« Reply #1 on: July 05, 2009, 06:12:12 PM »
FYI, TC 2.2 has a new boot code of embed which will not create a tmpfs for root filesystem and will stay on initramfs.
10+ Years Contributing to Linux Open Source Projects.

Offline tim2092008

  • Newbie
  • *
  • Posts: 6
Re: Speed up boot time
« Reply #2 on: July 05, 2009, 06:24:58 PM »
Ware do i get 2.2 hopefully my sound and wifi works on it

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Speed up boot time
« Reply #3 on: July 06, 2009, 03:39:28 AM »
If you don't have a tce directory, add the bootcode "base" to skip that check.
The only barriers that can stop you are the ones you create yourself.

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: Speed up boot time
« Reply #4 on: July 06, 2009, 09:57:17 PM »
I use that board too for some of my embedded systems  :)

My startup is around 20 seconds too from grub to X.
I use nodhcp and run eth0.sh from bootlocal. That will give you a little bit of time. You may want to look into nohwsetup and loading the modules manually from bootlocal or another script at boot. This usually can speed things up but only works if the hardware doesn't change. I haven't done this for the intel board since my mainboard may change from that in the future. Also any unused modules can be removed if you haven't done so already.
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard

Offline tclfan

  • Sr. Member
  • ****
  • Posts: 286
Re: Speed up boot time
« Reply #5 on: July 08, 2009, 09:23:21 AM »
FYI, TC 2.2 has a new boot code of embed which will not create a tmpfs for root filesystem and will stay on initramfs.
Thanks very much for this option. I am too very interested in capability to going back to initramfs option to maximize performance and minimize requirements. Tempfs is not important for me at this point either, but good to have if needed, so option 'embed' is a great asset.
Looking forward to TCL 2.2...

Offline helander

  • Full Member
  • ***
  • Posts: 183
Re: Speed up boot time
« Reply #6 on: July 14, 2009, 02:59:35 PM »
I have found a way that could speed up the boot time. It was a finding that came out of a trial that had nothing to do with trying to speed up the boot time. On the contrary I would expect the boot time to increase instead of decrease.

The trial was about trying to separate the kernel modules from the root file system in order to be able to use an unmodified tinycore.gz with different kernels. As you probably know tinycore.gz contains a set of standard kernel modules built for use with the standard TC kernel. When using a custom built kernel you have to provide the same set of modules but built for use with the custom kernel instead. This is how i did it:

  • I built the custom kernel and packaged the modules that corresponds to the the modules for the standard kernel built into tinycore.gz into a tar.gz file (lets call it rootfs-modules-mykernel.tar.gz)
  • I created a minimal rootfs with no modules in it, busybox + a few other programs and packaged it into a file called tcboot.gz
  • The init script in tcboot.gz does
  • Finds out the the boot device. This is done by looking at the available partitions for a file called tcboot.gz
  • Create a tmpfs and extract the tinycore.gz located at the same device as tcboot.gz into the newly created tmpfs.
  • Copy a script file that replaces /etc/init.d/rcS in the tmpfs. The script will load the rootfs-modules-mykernel.tar.gz do a depmod and then call /etc/init.d/tc-config.
  • Perform a switch_root to the tmpfs
[/list]

In spite of all the extra work, e.g., loading two root file systems, loading the rootfs modules for the custom kernel, the total startup time is about 5 seconds shorter than booting the corresponding standard TC system. The test was made booting from a USB stick.

Why? The explanation, as far as I can see lies in that it is much faster to read data from a disk in a running kernel compared to when the boot loader loads the rootfs into the initramfs during boot. 

It seems like a long way to go to save 5 seconds, but as said I was not trying to find a solution to decrease the startup time, but this came as a nice surprise to me. For others that hunts startup seconds I just wanted to point out the potential.

Something I have not tried but could be interesting for some, could be to build a "big" rootfs with all their extensions installed into the rootfs. Using the above method might show significant increase in boot time. I am not advocating this but just pointing out that for some, the ones that always boot up with and installs the same set of extensions, might end up with shorter boot times.


/Lars

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Re: Speed up boot time
« Reply #7 on: July 14, 2009, 03:07:45 PM »
Hello Lars,

thanks for thinking of this when you discovered this. It gave me an idea: when loading of the initramfs is taking quite some time, then it might be worth a try to unpack the initrd to a harddisk partition completely and not use the initrd option at all. I'll give it a shot for sure...

Edit:
I gave it a shot: boot time was roughly the same.
What bootloader did you use? grub or syslinux/extlinux?
« Last Edit: July 14, 2009, 03:31:44 PM by SvOlli »

Offline helander

  • Full Member
  • ***
  • Posts: 183
Re: Speed up boot time
« Reply #8 on: July 14, 2009, 03:43:47 PM »
I used syslinux. However in my first discoveries I was running TC in VirtualBox (under Windows) and there I was using grub (both legacy grub and grub2).

So you actually made a hardware install? Did you try with the "base" boot option?
I guess you did set root= to point to your partition and did not specify any initrd (just checking, hope no offense is taken)

/Lars

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Re: Speed up boot time
« Reply #9 on: July 14, 2009, 05:00:12 PM »
I used syslinux. However in my first discoveries I was running TC in VirtualBox (under Windows) and there I was using grub (both legacy grub and grub2).

Syslinux is rather slow when loading kernel and initrd, but grub seems to be significantly faster.

Quote
So you actually made a hardware install? Did you try with the "base" boot option?
I guess you did set root= to point to your partition and did not specify any initrd

Yes I did. And I also double-checked running "mount" after boot. Both took about 7.5-8.5 seconds running in VMware Workstation on a Linux host. /boot/grub/menu.lst looks like this:
Code: [Select]
default 0
timeout 5
title Tiny Core InitRD
kernel /boot/bzImage quiet vga=0x341 base norestore nolocal root=/dev/ram
initrd /boot/tinycore.gz
title Tiny Core HD
kernel /boot/bzImage quiet vga=0x341 base norestore nolocal root=/dev/hda1

Quote
(just checking, hope no offense is taken)
None taken. ;)

Offline clausmuus

  • Newbie
  • *
  • Posts: 1
    • www.clausmuus.de
Re: Speed up boot time
« Reply #10 on: July 20, 2009, 12:45:14 PM »
Hi,

I have two ideas how to speed up the boot process.
If you use tce extensions, and you have a slow old system, try to update the .tce files by unpack them with the command
advdef -z0 /mnt/hda1/tce/*.tce*
I have already not test this, but I think this can help, because slow systems need much more time to uncompress tgz archives then to load bigger tar archives from disk.
The second idea needs a change on the core system and is for tcz extensions. I'm not sure, how the tcz-symlinker work, but I think this tool makes for every file in the extension a symlink from the mountpoint to the root file system. If I'm right, than the follow idea will speed up the link process.
The tcz-symlinker should link whole directories, if a directory does not exists in the root file system. If a second extension like to link further files to such a linked directory, the directory must be create and the containing files must be linked separate. Since most big extensions contain big private directory, this should speed up the installing process quite a few.

Claus
Maintainer of the MiniDVBLinux Distribution

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Re: Speed up boot time
« Reply #11 on: July 20, 2009, 03:06:02 PM »
The fastest I came up with so far was to unpack tinycore.gz and the tce's onto a partition and drop all the initrd stuff and boot from that partition. And still the result was only "measurable" with about one second to spare, compared to using a tclocal directory. That one second out of slightly above 30 seconds startup time from hitting the power-on button could not be "felt", which means I couldn't tell the difference which one was booting just from waiting to finish booting.

But for a non-initrd installation some slight changes to the tc-config.sh should be made, that allow for an automated fsck on startup, like any distro using ext3 does. And it would be also nice to sum up some parameters like "base", "norestore", etc. if the boot parameter "root" if not /dev/ram. But again, compare to the gain, I think it's too much effort. At least for me to hack something up that's "submittable".

Imho, the best thing you can get to decrease boot time is a system that support coreboot. The rest of the startup-time using embed and a tclocal directory is the best you can squeeze out of TCL without rewriting major parts. And rewriting will probably come up with a system that's not for general use anymore.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Speed up boot time
« Reply #12 on: July 20, 2009, 03:12:36 PM »
If the tcz-symlinker linked whole directories instead of creating directories and linking files, the directories would not be writable. 

The tcz-symlinker is wickedly fast compared to doing the same through shell scripting, and keeping the entire system writable is an important TC concept.
« Last Edit: July 20, 2009, 03:16:53 PM by Jason W »

Offline Coburn64

  • Newbie
  • *
  • Posts: 5
Re: Speed up boot time
« Reply #13 on: July 24, 2009, 01:48:13 AM »
Why bother squeezing some more load time out of TCL? It's already fast on a clean boot - faster than Windows, I'll give you that.  ;)

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Re: Speed up boot time
« Reply #14 on: July 24, 2009, 02:14:16 PM »
Why bother squeezing some more load time out of TCL? It's already fast on a clean boot - faster than Windows, I'll give you that.  ;)
Someone really competent with Windows can start it up in about the same time. And the startup time is good for a computer. I want to use TCL with the SLART package as an mp3 player. And for that use - even though startup is fast - it's still not nice to wait ~35 seconds for the first tone to appear.