A few tips to speed up boot for your Linux box:
1. You need a tool to measure performance objectively: bootchart is very useful to track the lifetime of the processes, disk I/O and CPU load during boot. It needs no configuration whatsoever: you install it (for example using “apt-get install bootchart” in Debian-based systems) and then bootchart will create a PNG image at each successive boot in “/var/log/bootchart/” along with a compressed log. The image is very self-explaining and contains the lifetime of each process, coupled with disk and CPU activity. You can have a better understanding of which processes have more impact on the boot time in order to decide what to do with them.
2. Use readahead: if your distribution supports it (Ubuntu does, for example) there’s a kernel option (profile) that could drastically improve the performance at boot time. If you have Grub as your boot loader, follow these instructions:
- Power on your box.
- Enter in the Grub menu.
- Select your default boot choice and press ‘e’ to edit.
- Select the line starting with “kernel” and press ‘e’ to edit.
- At the end of the line, append the word ‘profile’ and press Enter.
- Press ‘b’ to boot with the temporary ‘profile’ option.
- This particular boot will take longer to complete and you will hear your hard disk grinding furiously.
- When you see the login screen, wait until the hard disk stops and then restart.
From now on, you will hear hard disk grinding only at the beginning of the boot sequence. This is called readahead, and it is improving the boot time by placing the files that should be accessed during boot in a comfortable place to read; the list of files is kept in “/etc/readahead/boot”. It is advisable to repeat this operation after each drastic change of configuration or extensive upgrade of the Linux box to have better results.
See also: http://ubuntuforums.org/showthread.php?t=565651 for more readahead tricks.
3. Exploit multiple cores parallelism: if you have a Core2Duo or any CPU with more than one core, you can speed up the boot by running processes in parallel. If you look in the directory “/etc/rc5.d/” you will find many scripts whose name start with ‘Sxx’, where ‘xx’ is a progressive number. This number indicates a sequence that takes into consideration the dependencies between the scripts: the scripts with lower numbers are executed before the scripts with higher numbers. By default those processes are started sequentially one after the other; alternatively, it is possible to start together at the same time the scripts with the same number. To enable this, edit the file “/etc/init.d/rc” and change the first line containing “CONCURRENCY=none” into “CONCURRENCY=shell”. It is very important that the start order of the scripts is correct, since this option can expose dormant problems that are usually hidden by the fact that the scripts do not run concurrently. If you touched the initialization scripts, be sure to understand this. If you have never touched those scripts but a service fails to start, then the package of that service has probably a bug that should be reported.
Edit: the 3rd advice can be effective also on single-core CPUs.