Boot time/Break It Down

From openSUSE

WORK IN PROGRESS!

Feel free to help out :-)


In order for us to analyze the boot times, we need to break it down in smaller parts.

We have the initrd process, the boot process and the runlevel process.

We can insert a simple timer mechanism in these different stages to get us started.

Let's start with the easy part, the runlevel process.

All runlevels are execute from the /etc/init.d/rc script.

At the top of the file, we can add a function as follows;

myTimer() {
  if [ xyz"$1" = xyz"start" ]; then
    start_date=`date`
  else
    echo "========="
    echo "$1"
    echo "Start time: $start_time"
    echo " Stop time: `date`"
    echo "========="
  fi
}

Then, immediatly following the above, we add;

myTimer start

Then go to the end of the file, before exit 0, add;

myTimer "rc is done"


We can do exactly the same for /etc/init.d/boot

In order for us to do this with the initrd, we need to unpack it. Follow the steps below;

mkdir /tmp/initrd-unpacked
cp -a /boot/initrd /tmp/initrd.gz
gzip -dc /tmp/initrd.gz >/tmp/initrd.img
cd /tmp/initrd-unpacked
cpio -i < /tmp/initrd.img

Now, modify /tmp/initrd-unpacked/init according to the instructions above, then do;

find . | cpio -H newc -o > /tmp/initrd.img
gzip -c /tmp/initrd.img >/tmp/initrd
mv /tmp/initrd /boot/initrd.timed-boot

Then, you need to edit /boot/grub/menu.lst to start with this new initrd. Copy an entire section like this;

title openSUSE 10.3 (/dev/sda6)
   kernel (hd0,5)/boot/vmlinuz-2.6.20-6-default root=/dev/disk/by-id/ata-Maxtor_6Y120M0_Y3L2LLXE-part6 vga=0x31a resume=/dev/sda2 splash=silent showopts
   initrd (hd0,5)/boot/initrd-2.6.20-6-default

Then change the initrd line to be;

   initrd (hd0,5)/boot/initrd-timed-boot

You can now reboot your computer. After each step (initrd, boot and runlevel), it will print out the time the step took, and then wait for 5 seconds.


On my Thinkpad T43P, with openSUSE 10.3 Alpha2Plus, I get the following

Kernel (manual timing) - 2 seconds Initrd - 2-3 seconds Boot - 8-9 seconds Runlevel 5 - 8-9 seconds

Note! The timing when going to runlevel 5 doesn't mean a working desktop. It means that all processes has started to load. There's an additional 15-25 seconds before my Desktop is fully functional.

Note2! Not sure if this is only on 10.3A2P, but SaX2 adds a line to the font section of /etc/X11/xorg.conf which makes X take 10-12 seconds to start. This has been reported as a bug and is currently being worked on. You can remark that line;

# FontPath     "unix/:7100"

Note3! There's another bug in 10.3A2P, where the file /etc/init.d/Makefile is missing. This causes the boot process to not use parallel start, which adds ~2 seconds to the boot up process. This has also been reported.