Bootchart
From ArchWiki
i18n |
---|
English |
简体中文 |
Contents |
Introduction
Bootchart is a handy tool used for profiling the Linux boot sequence, generally used for making your computer boot faster. It consists of the bootchartd daemon and bootchart-render, which is used to generate the resulting chart.
Installing Bootchart
Install bootchart via your package manager. The package is called 'bootchart' in Arch Linux.
Running Bootchart
To make use of bootchart, you have to either set it as the init process in your boot loader or starting it manually from one of the init scripts (rc.sysinit preferrably). Note that if you start bootchartd manually, you have to stop it manually too. In general, be extra careful with this step.
Boot loader setup
This generally involves making a copy of the boot option you want to profile and adding 'init=/sbin/bootchartd' to it. When started from the boot loader, bootchart will stop when you get to the login prompt.
Grub
Open up /boot/grub/menu.lst, and copy/paste the entry you want to log. Append "init=/sbin/bootchartd" to the kernel line. Generally, you'll want your entry to look something like this:
# (1) Arch Linux Bootchart title Arch Linux root (hd0,0) kernel /vmlinuz26 root=/dev/disk/by-uuid/d531ff5b-de65-499a-9942-d18682375163 ro vga=37C init=/sbin/bootchartd initrd /kernel26.img
Lilo
TODO
Grub 2
Open up /boot/grub/grub.cfg, copy the boot option you want to profile and edit it to look like this:
# (0) Arch Linux menuentry "Arch Linux" { set root=(hd0,1) linux /boot/vmlinuz26 root=/dev/sda1 ro initrd /boot/kernel26.img } # (1) Arch Linux with Bootchart menuentry "Arch Linux with Bootchart" { set root=(hd0,1) linux /boot/vmlinuz26 root=/dev/sda1 ro init=/sbin/bootchartd initrd /boot/kernel26.img }
Now you can reboot and choose the new bootcharting option.
rc.sysinit setup
This one is dangerous (you can make your Arch Linux unbootable) - use it only when the first approach fails. When run in this way, not only you'll have to stop bootchartd manually after you boot up (or it will completely fill your harddrive) but it will start with every boot too. Also, any changes to /etc/rc.sysinit will be reverted next time you update the initscripts package. On the positive side, you'll end up with a bootchart that shows what happens after you log in.
Edit /etc/rc.sysinit
Now, we're going to add this line:
/sbin/bootchartd start
to /etc/rc.sysinit
It can't be too high up, because that would render the system unbootable, but placing it too far into the script will hide anything that happened before from the bootchart. It should be safe to put this right before the section that brings up the system clock. Look for this line:
stat_busy "Configuring System Clock"
Put this:
/sbin/bootchartd start
before it.
Stop bootchartd after login
As stated previouslt, you have to stop bootchartd manually. Either run this as root:
/sbin/bootchartd stop
Or with sudo if you have that set up:
sudo /sbin/bootchartd stop
Generating a chart
Generating a bootchart involves running:
bootchart-render
in a folder to which you have write access. This will generate a 'bootchart.png' image with your chart. You'll have to have a Java runtime installed and properly set up before you can do this.
Troubleshooting
Bootchart-render cannot generate a 'bootchart.png' image and shows the error message:
/var/log/bootchart.tgz not found
It mostly means that boothartd was unable to detect when the booting process was finished. This can happen when you are using different login manager then KDM or GDM such as SLIM or entrance. You have to open /sbin/bootchartd script and append those applications to exit_proc variable, for example:
# The processes we have to wait for local exit_proc="gdmgreeter gdm-binary kdm_greet kdm slim"
Example bootcharts
Boot in 5 seconds
LWN Article on fast booting netbooks
This article is really awesome and along with a bunch of bootcharts provides some tips on how to boot faster. Some of those improvements are beyond reach of the ordinary user though (patching X.org, kernel, etc.).