Boot fedora unusually faster.

1

Posted in


Everyone wants a quick boot time, from the beginner user to the advanced user, this is a issue that bothers us all. As Linux has advanced it has increasingly become slower to boot. I have tested on my machine 5 Linux distributions: Linspire, Fedora 3 & 4, Suse 9.2 & 9.3, ubuntu and Debian. And on average between all these distributions Linux needs around a minute to 1 and half minutes to go from boot loader to graphical login screen. So I decided to look into reducing the time it takes to boot my current setup, which is Fedora 4. In doing so I was able to reduce the boot time of my Fedora 4 installation to less than 25 seconds (just above 24 seconds on average). Below I have documented what I did, and what you can use to potentially reduce your boot up time for Linux.

Of course we will be dealing with advanced Linux know how, so this is not for beginners. Also results may vary on your end since there are a lot of factors involved.

My Initial Setup

My initial setup was pretty much standard Fedora 4 with nvidia driver loaded. My PCs hardware is an Athlon64 3000+, 1GB RAM, 80GB SATA 7200 rpm hard drive, and Nvidia Video Card. I was getting about a minute for booting Fedora 4 on this setup. I decided to benchmark in two ways, the first was using a standard stopwatch and manually starting / stopping, and the second way was using bootchart software which you can download here (bootchart.org). Bootchart will capture you boot time from when init starts (init? See below) till its finished loading your system up. It also provides visualization so you can see potential bottlenecks. My initial setups bootchart is below.



Note: I will describe a basic simplified overview of the boot process. When you turn on your computer the BIOS starts up and after initializing some parts of your PC, it hands over control to the bootloader. The bootloader then loads the Linux kernel and hands control to the kernel. The kernel then executes init a program that starts and manages services. After its finished loading up all services specified a login prompt is displayed. To reduce the time it takes to boot we need to reduce the time it takes in any of these stages. For the most part there is little you can do to reduce the time it take for the BIOS to go from power on to bootloader though generally this is only a 1-2 seconds anyway. And the bootloaders life is extremely short lived since it only loads and executes the kernel, so all the optimization tips I will discuss in this article are going to center on the kernel and init parts of the boot sequence.

The First Step

As you can see X gets started twice, which is a major time waster. So I decided to look into disabling that, and as I was googling I found an interesting feature disable by default in Fedora 4 called “early-login”. This enables you to only start X once and allows a user to start logging in while other services are still starting in the background. This both reduces the actual boot up time and the user impression of boot time (Since they can log in earlier it seems to boot up faster even though it still booting up in the background). To enable, type the following:

[As root]
# chkconfig --add gdm-early-login
# chkconfig --add gdm-allow-login
# chkconfig gdm-early-login on
# chkconfig gdm-allow-login on


I also wanted to reduce the number of services I was running there by reducing the number of things that need to start at boot. Below is a list of services I decided was only needed for what I do on my personal desktop Fedora machine. The services you need may vary:
acpid
anacron
atd
crond
cups
cups-config-daemon
gpm
haldaemon
iptables
messagebus
netfs
network
portmap
syslog


As you can see I disabled kudzu (bootup hardware detection, saves a second of time), auditd (I also disabled selinux), rhnsd (red hat network update daemon), and sendmail. I personally use yum to do updates and will weekly check for them, I rarely make changes to my hardware but can add hardware on my own if needed, and I think selinux is overkill for a personal desktop machine. You can do this by going to Desktop->System Tools->Server Settings->Services and de-selecting services to disable. Then when you are done click done.

Below is what the boot looked with these changes. Wow, as you can see we went from 41 seconds in bootchart to 25 seconds. But with my stopwatch we where looking at 34 seconds of boot time from boot loader to login screen. Definitely better, but can we see even quicker boot times? I wanted to find out.



Note: What was interesting with my system is in the time X took to start and display a login screen, it was finished loading up all background services. So I could literally log in right away as soon as the login prompt was displayed. Since I did not test this on any other machines this behavior maybe localized to my system or similarly configured PCs as mine.
Drivers and Modprobe

The boot up time is also consumed by loading additional kernel modules as you can see with the modprobe bar in the boot chart. So I decided to reduce the number of kernel modules that had to be loaded by compiling them into the kernel. To do this you will need kernel source of course, and will need to take an inventory of what drivers you need on your machine. I also compiled the ext3 file system into the kernel so this didn’t need to be loaded either. I also reduced the number of drivers / modules in my kernel, by disabling the ones I did not use (for starters wireless lan, SCSI raid controllers, console frame buffer [they use to conflict with nvidia driver, do not know if this is still the case], selinux, and some of the misc. filesystems (amiga fs?). Below is an overview of the changes I made to the kernel:
Ext3
USB driver (on my system OHCI, EHCI)
Removed Selinux and auditing system calls feature
Compiled in Drivers, Ex. Parallel Port, Floppy, and others
Compiled in some features that where originally in module form.


This distribution was based on the latest kernel release for Fedora, 2.6.12-390.
So I compiled, rebooted, and below the results…24 and change. I am now at 18 seconds in boot chart, but now we are at little more than 24 seconds for total boot time using my stopwatch.



Did I stop there? Of course not, but nothing else more I tried worked. So I will have to write a follow-up article if I find anything more. Below are some things I tried which had little effect:
Recompiled the X server with custom optimization for my processor. My aim was to reduce the X servers start time, but this did very little.
Compiled the kernel with size optimization instead. My aim here was to reduce the size of the kernel (which it did) and to potentially speed up the kernel load time (less of a kernel to load). This did nothing either.


Conclusion

And there is my story for 24 second boot time in Fedora on standard PC hardware. I really think I’m onto something with compiling some of the kernel modules into the kernel. Why would ext3 filesystem not be compiled in anyway? It is the default file system for Fedora. Ext2 is compiled in.Hope you enjoyed!!

Comment (1)

Very useful information. I wonder why you still use older versions of Fedora. I understand that having the bleeding edge installed sometimes kill your rig, but with newer kernels and drivers I'd suspect you should be able to squeeze more time out of the boot.