Fast boot without recompiling the kernel

From ArchWiki

Jump to: navigation, search

There are a bunch of guides about how to speed up your boot time, but most of them either suggest building a new kernel, or manually loading your modules. This guide talks about the 2nd method, and taking it even further. Here is how I shaved the boot time from approx. 1 minute, 13 seconds down to 34 (!) seconds on a 500mghz AMD k6-2 with 208mb of RAM. This is according to a stopwatch and including the BIOS time (about 11-12 seconds) so it isn't dead-on accurate, but regardless, this is a huge gain on such an old computer, without even needing to compile a new kernel (or anything else.) What a bargain!

As stated, this was tested on a 500mghz computer with 208mb of RAM. It runs a 2.6.18 i586 compiled kernel, and is a headless firewall, so all I need support for is my NICs and IDE disk, but the ideas I'll assume will work with even the latest setups. This requires loading every module you need yourself, if you don't know how already then read thru the wiki, thats how me and the rest of us learned how to do things. Also this guide assumes you already have mod_autoload=no and modules=() set up how you need it.

I'll just split everything I did into sections:

[edit] mkinitcpio

Making my own ramdisk for booting was the first step, read Configuring mkinitcpio if you need detailed info about doing this. My goal thru this overall project was to statically configure as much as possible, since the most time is spent detecting hardware that rarely changes. As such, I put only the modules I need, and got rid of everything else in /etc/mkinitcpio.conf:

MODULES="ide_core ide_disk sis5513 ext2 tulip"
BINARIES=""
FILES=""
HOOKS="base"

To boot, all I really need is ide_core & disk, and ext2, but after reading lots of pages claiming adding modules you don't need to the ramdisk is a waste of time, I tried it anyway. Low and behold, disabling mod_autoload, and leaving modules=() in rc.conf blank, all the modules in my ramdisk were still loaded.

I may be wrong, but I figure it would be faster to just put the modules into the ramdisk instead of in rc.conf, because udev won't try loading those modules (more on this later) and the later initscripts don't have to load them either. Those 5 modules are actually the only modules I need loaded ever, not just during boot, so this may not help you much if at all on a desktop or whatever.

[edit] UDev

I noticed that even with mod_autoload off, udev still tries loading all the modules for your hardware, and a script just rejects udev's request instead of loading the module when udev calls it. This script is at "/lib/udev/load-modules.sh" and is a rather long script. Since we arn't autoloading any modules lets just make the script not do anything instead of checking a bunch of stuff, that will end up doing nothing anyway:

cd /lib/udev/
mv load-modules.sh load-modulesold,sh
echo '#!/bin/bash' > load-modules.sh
chmod 755 load-modules.sh

Now instead of checking thru plenty of things just to end up telling udev "mod autoloading is disabled" it will just do nothing. I know there is better ways to do it, but I'm pretty lazy. Anyway on this computer, this tweak alone cut 12 seconds off the boot time. You will lose the ability to select modules to (not) load from the kernel boot commandline, but I personally didn't even know you could do that until I read through this script :p

[edit] Getting rid of un-needed modules

IMO the biggest reason a kernel recompile speeds up booting so much is because most people only compile what they need for that particular computer. Lets do basically the same thing without compiling:

cd /lib/modules/`uname -r`/drivers

Just search thru all the directories and delete all the driver modules you are *sure* you don't need, I wouldn't suggest doing this section until you are sure you have manually loaded all the modules you need correctly. In my situation the chances of my hardware ever changing on this box are next to never so I completely gutted every module except the 5 or 6 I need. If you are on a box that might change its use, has multiple users, etc. then you might want to leave modules you don't need right now, but may need in the future.

I'm not positive, but I'm pretty sure this speeds things up because UDev won't bother trying to set up hardware that has no drivers and isn't compiled into the kernel. Whatever reason, this took another few seconds off the boot time.


Thats it! I know its pretty rigged, there is a few other things I did, but they made no difference in boot speed, and I did them more for my ease of use than speed increase so I won't mention them. They can be found in the wiki pretty easily anyway. What I found the most interesting was how many people said the ramdisk modules and rc.conf modules are completely seperate, but I saw with my own eyes this isn't true. Anyway I'll edit this page if I come up with anything else.

Personal tools