Saturday, October 30, 2010

Speedy Boot


A live CD or USB key starts up using syslinux, casper, then upstart. My efforts to speed up the boot process have been centered around grapling with these tools.

Syslinux is the first-stage bootloader, starting a Linux kernel from a FAT filesystem like our sticks. Casper is a set of scripts packaged in the initial ramdisk file(initrd) which facilitate booting off of live media. Upstart is the designed-for-Ubuntu startup manager. 

All of these software systems have significant room for improvement and specialization, especially Casper. 
Out of the box, casper is designed to provide the best possible user experience for an Ubuntu livecd. This, however, does not mean that it is well-documented or efficient. In this case, it is neither. I have been unable to turn up official or unofficial documentation on the internals of casper.

The Casper scripts are located in a folder aptly titled "scripts" in the root of the initrd. They are split up by category, with the scripts located in "casper-bottom" doing most of the work, and the rest serving largely as hooks to other boot steps.
In the "scripts/casper-bottom" folder, there are scripts for everything from checking the integrity of the boot media to configuring x. Many of the scripts located in casper-bottom are single-purpose. I'm having a hard time figure out what to keep and what's acting as an unnecessary load on the startup process.
In addition, there are a few scripts in casper-bottom that are actively interfering with progress. Scripts "10adduser," "15autologin," and "25configure_init" appear to be responsible for a bug I've observed. Upon boot, Linux TTYs 0-6 are locked down with security errors. These scripts appear to be attempting to automatically log in the [non-existent] user "ubuntu" to these terminals. For deployment and testing purposes, we most definitely do not want third parties have access to user's account. I've been working on figuring out how[and where!] to disable the autologin without breaking casper or weakening some other aspect of the system.

Another significant time-suck in both the boot and development process is the upstart system. De-crufting the startup tasks requires more knowledge of upstart than I have right now, and would greatly improve the startup speed and user experience. Many of programs started on boot are only occasionally used by the average user. On a modern computer, this results in a baseline increase in RAM usage. On a live system, this can result in an unacceptable slowdown.


1 comment:

  1. One of the reasons we are focusing on boot speed at this time is the school system of the town we are working in has donated 400 computers. The specs on them vary and we are only going to accept Pentium IV with > 500M of Ram.

    The first batch were taking 6 minutes to boot which is unacceptable.

    Ian, what is our current boot time?
    What are the exact specs of the machine you are currently testing on?

    ReplyDelete