LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-22-2007, 07:42 AM   #1
bezeek
LQ Newbie
 
Registered: Nov 2006
Posts: 18

Rep: Reputation: 0
Cool Kernel boot time optimization


So, I've got a zippy little kernel carrying my all-purpose desktop around on its 1.6M foot, the performance is great, the stability can't be beat, and I'm not lacking any features or functionality.

The problem is, my kernel takes up to 15 seconds to load, and it's not because of slow hard drive reads.

I'm not sure what causes this, though I see what seems like quite a handful of redundant hardware detection. Hello - isn't that the BIOS' job???

I'd really like to rig up the kernel to fly through the boot process, either by taking its information from the BIOS and believing it, or just skipping any hardware detection altogether and following a static boot process.

Are either of these concepts doable?

Also, could someone explain to me the sorts of things that actually drag down the boot time like this? I believe I'm on the right track with the hardware detection bit, but I'm going on intuition so I'm probably rather far off.

Thanks for any help/advice!

- Brian
 
Old 10-22-2007, 08:57 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934
A lot depends upon which "distro" you are using.

If you're using a regular distro, then it probably is designed to do auto-detection, and if it takes 15 seconds to load a kernel that's then going to be "up" for the next three months non-stop, who cares?

On my system, which is Gentoo, I've done all of the hardware-configuration in advance, setting-up all of the options needed by all of my particular hardware in advance. No "detection" is therefore needed. The systems still take about 30 seconds to get completely up-and-running, and once they're "up" they remain booted-up for months on end.

"It can be done," but perhaps you should seriously contemplate the worthiness of changing your status-quo. Does it have a return on your investment of time and hair-follicles?
 
Old 10-22-2007, 11:41 PM   #3
bezeek
LQ Newbie
 
Registered: Nov 2006
Posts: 18

Original Poster
Rep: Reputation: 0
I run Gentoo as well, and have hardly managed to cut the init time down to 36 seconds with initng (48 with the default init.) I do leave my computer on much of the time, though I am more then justified in wanting to reduce my boot time, primarily because I plan on dual-booting Windoze so I can make use of Photoshop and some other software.

I have stripped my kernel down to support only the hardware I need, though I am not familiar with how to prevent unnecessary work from being performed at boot time.

I really enjoy this sort of thing, so I'm not too worried about losing my hair over it, but any help on where to start would be much appreciated.
 
Old 12-27-2008, 08:12 PM   #4
1veedo
Member
 
Registered: Dec 2004
Location: WV, USA
Distribution: Gentoo, Debian
Posts: 186

Rep: Reputation: 34
My kernel boots in 10 seconds, full boot time is about 35. I'd like to make it faster though. Does anyone know of any tips? I'm using the lattest (git) version and have it configured for my kernel, ie no hardware drivers that I don't need. Also everything is built in.
Code:
# lsmod
Module                  Size  Used by
nvidia               7796008  26
There's some kind of bios handoff bug that takes like 5 seconds. It spends a lot of time configure USB devices as well. My keyboard uses USB 1.1 or I'd get rid of one of the usb drivers.
 
Old 12-27-2008, 08:41 PM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by bezeek View Post
I'm not sure what causes this, though I see what seems like quite a handful of redundant hardware detection. Hello - isn't that the BIOS' job???
No. It's the OS job. BIOS stands for "Basic Input/Output System", and it should just contain a few kbs of code that let the machine initialize enough stuff to be able to boot and pass the control to the OS.

The BIOS can't do everything that an OS can do, and can't deal with all the hardware like an OS can do. Otherwise, we wouldn't need any drivers at all, and we would just use BIOS calls from all OSes. Even more important, BIOSes usually have bugs and limitations, relying in the BIOS info would bring us more trouble than good. For example, the (in)famous limitations on the hard disk capacity that we have been seeing for quite a long time. Windows used to trust the BIOS, and hence you ended with unused space in your brand new hard drive. Linux, on the contrary, do what needs to be done and ignore the ignorant BIOS, giving you full access to your hardware.

Quote:
I'd really like to rig up the kernel to fly through the boot process, either by taking its information from the BIOS and believing it, or just skipping any hardware detection altogether and following a static boot process.
I don't exactly get the idea. If a driver is not in your kernel, then the kernel shouldn't be looking for the relevant hardware either. So, you just need to strip down your kernel. If you already did that, then the only thing you can try is to identify the steps where it spends the most time, try to debug/profile them and patch them for faster performance.

You might want to check coreboot, formerly known ad "linuxbios". That would be the fastest you can get. By putting the linux kernel into your BIOS chip you completely bypass the BIOS and boot right and straight into your OS from the moment you press the power on button on your case.



Quote:
Originally Posted by sundialsvcs View Post
A lot depends upon which "distro" you are using.
Not really, unless that distro uses a revolutionary patchset that completely changes the way that the kernel boots. Note that the OP is talking about the kernel boot time, and not about init and later stages.

A kernel that has been built statically will probably be a bit faster, but nothing noticeable. Overall if the modules are contained in an initrd, because they will then be read from ram and it will be just almost as blazing fast as if they were inside the kernel.

Last edited by i92guboj; 12-27-2008 at 08:45 PM.
 
Old 12-27-2008, 08:55 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Must admit I subscribe to the "who cares" school of thought re boot time. I just go make a coffee.
Regardless, have a look at this - especially segment 1.6
 
Old 12-27-2008, 09:56 PM   #7
1veedo
Member
 
Registered: Dec 2004
Location: WV, USA
Distribution: Gentoo, Debian
Posts: 186

Rep: Reputation: 34
Lol coreboot sounds awesome. My motherboard (p5q pro) isn't supported though. It does have this expressgate thing that boots a very small linux in under 5 seconds. You can unsquash the images it uses and modify it yourself but you can't put an entire distro on it. I tried doing a debootstrap, even a chroot inside the main linux it boots, but I cant seem to get it working. Any apt-gets would be temporary of course but theoretically you could build a system, copy it to a HD, and squash that.
Quote:
Originally Posted by syg00 View Post
Must admit I subscribe to the "who cares" school of thought re boot time. I just go make a coffee.
I don't know it's fun :P?
Quote:
Regardless, have a look at this - especially segment 1.6
Compiling it now. I've been watching a timer thing you can enable in kernel hacking to see what's taking time. I'll see what this thing can do; it sounds nifty, being able to make a graph and everything.
 
Old 12-27-2008, 10:03 PM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by 1veedo View Post
Lol coreboot sounds awesome. My motherboard (p5q pro) isn't supported though. It does have this expressgate thing that boots a very small linux in under 5 seconds. You can unsquash the images it uses and modify it yourself but you can't put an entire distro on it.
You shouldn't need to. You would only need to make sure that the kernel in that image supports all the hardware you need to boot and find a way to specify the root partition, then use your linux partition in your hard disk instead of the one in the image. It *should* (TM hehe) work. But I can't be certain since I don't have the thingie to experiment with it myself.

I didn't even know about this express gate thing, so I will research a bit about it. If I can find something interesting I'll let you know.
 
Old 12-27-2008, 10:23 PM   #9
1veedo
Member
 
Registered: Dec 2004
Location: WV, USA
Distribution: Gentoo, Debian
Posts: 186

Rep: Reputation: 34
I think it selects the OS internally. Like when you flash the bios (there's no kernel line or anything like that). It has a utility that auto-searches for squashfs files in the directory and runs an init script inside each one.

Now that you mention that, however, it might be possible to modify the first init script to physically mount a partition at / and then execute the init script on that partition (while removing all the other squash files so it never executes the scripts on them). That or you could do the thing that slax livetools (whatever it's called) does; mount it somewhere else, chroot, and executie init.

I think I tried to actually mount my gentoo install once but it's on reiserfs and iirc the thing doesn't even have ext support (it does have ntfs support though). I gave up using it several months ago primarily because I couldn't access my main linux or data drives. It was kind of fun while it lasted but even being able to modify the filesystem yourself it still has its limitations (like the video drivers couldn't run at a very high screen resolution). I think asus needs to open up their utility because it's entirelly possible to boot a full linux install using expressgate. It might not boot in 5 seconds but expressgate skips all the bios stuff which on my board takes something like 10 seconds to complete.

Last edited by 1veedo; 12-27-2008 at 10:24 PM.
 
Old 12-27-2008, 10:54 PM   #10
1veedo
Member
 
Registered: Dec 2004
Location: WV, USA
Distribution: Gentoo, Debian
Posts: 186

Rep: Reputation: 34
Wow I've cut ~13 seconds off my boot time. I did some research about the ehci bios handoff and found the option in my bios to enable the handoff. That was costing me 6.4 seconds right there. I also removed my non-root drives from /etc/fstab and wrote another script to mount them (without fsck). Even if you want to check all your drives every time you boot it'd probably save you a lot of time to write two scripts. Almost everything depends on fsck, because they need / mounted, and you end up wasting time fscking non-important drives when the rest of your system could be booting.

http://img88.imageshack.us/img88/2923/bootchartob0.png

Boot tracer:
http://img201.imageshack.us/img201/7271/outputkf3.png

I have xdm starting at boot with all the /sbin/telinit commented out. By the time I log in and xfce4 is done all the other rc stuff is complete.

The longest kernel call is ahca_init. I'm going to look at all the ahca options and see if I can find ways to make that shorter. If I do I'll post updates. From what I'm seeing though there isn't a whole lot of imporvement possible from the kernel side. I already have an optimized kernel of course but 3.57 seconds just isn't that long compared to the total 22 second boot time.
 
Old 12-27-2008, 10:58 PM   #11
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by 1veedo View Post
I also removed my non-root drives from /etc/fstab and wrote another script to mount them (without fsck). Even if you want to check all your drives every time you boot it'd probably save you a lot of time to write two scripts.
Maybe there's something that I am not considering. But as far as I know, if you set the sixth field in fstab to "0" (zero) for a given volume, it will not be checked.
 
Old 12-27-2008, 11:15 PM   #12
1veedo
Member
 
Registered: Dec 2004
Location: WV, USA
Distribution: Gentoo, Debian
Posts: 186

Rep: Reputation: 34
Quote:
Originally Posted by i92guboj View Post
Maybe there's something that I am not considering. But as far as I know, if you set the sixth field in fstab to "0" (zero) for a given volume, it will not be checked.
I'm going to assume that it does (will find out next reboot). I was wondering why such a feature didn't exist already because it seems like something that should be implimented.
 
Old 12-27-2008, 11:21 PM   #13
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
From my experience and the fstab man page, it should work. If all you want is to bypass fsck that what it does. No need to say that you are the one to keep the integrity of your file systems manually, since they will never be checked unless you do it manually.
 
Old 12-27-2008, 11:28 PM   #14
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
"man tune2fs" - other f/s will (should) have equivalent.
 
Old 11-10-2009, 01:49 PM   #15
lewc
Member
 
Registered: Nov 2009
Distribution: Gentoo, Slackware or Debian
Posts: 60
Blog Entries: 1

Rep: Reputation: 18
content removed

Last edited by lewc; 11-27-2009 at 03:52 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel boot time Synesthesia Linux - General 10 05-24-2006 11:11 AM
kernel compile time and boot time lordofring Programming 1 11-13-2005 02:04 AM
Kernel compiling and optimization? bruno buys Debian 5 08-22-2005 03:22 PM
optimization flags and kernel compiling kpachopoulos Linux - Newbie 2 08-26-2004 07:29 AM
Kernel Optimization Quirks Moltag Slackware 5 07-15-2003 02:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 05:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration