I've done some tweaks on my T61 to make xubuntu startup and run faster. These tricks are mostly collected from different forums/blogs.
Part I. Boot Up
One easy way to measure boot time is to install bootchart:
sudo apt-get install bootchart
Once installed, a png image will be generated at /var/log/bootchart every time the system reboots, showing the starting up processes and how long they each take. You probably don't want it after you have done tweaks with the start-up process.
I.1 Clean installed packages (
http://www.linuxine.com/2008/06/speed-up-ubuntu-boot-speed.html )
Delete residual config packages: in Synaptic package manager, check status and remove all residual config packages.
Delete incomplete packages:
sudo apt-get autoclean
Delete isolated libraries:
sudo apt-get install deborphan
sudo deborphan | xargs sudo apt-get -y purge
sudo apt-get autoremove --purge
This is more like a help on the overall performance than booting only. But it will clean out some broken packages that might be loaded during booting.
I.2 Disable unnecessary services (
http://ubuntuforums.org/showthread.php?t=89491)
IMPORTANT! Since we're going to mess up with some critical system files, I would back them up:
mkdir ~/sysbak
cp -rPp /etc/rc?.d ~/sysbak
The -P option in cp tells it to copy symbolic links rather than files they point to, the -p option tells it to preserve all file properties.
A quick introduction on the symbolic links in the rc*.d directory. Each rc*.d directory corresponds to a runlevel (S, 0-6). S/1 are the single user runlevel, 0 is shutdown, 6 is reboot, 2-5 are multiuser runlevels. In ubuntu, runlevels 2-5 are the same by default. In each rc*.d directory, there are two type of symbolics: those begin with "K??" and those with "S??". Upon entering each runlevels, the system will kill all services beginning with "K??", then start those beginning with "S??", in order of the two digits "??". In the default boot process, after the kernel is loaded, the system enters runlevel S, then 2 and stay in 2. To enable/disable a service at a certain runlevel, simply add/remove a S?? symbolic link to the service script in /etc/init.d. To learn more about Ubuntu boot process and runlevels, see
this two-part article by Aaron Toponce.
Here is a list of services available by default on my T61 laptop:
must enable, critical,
should enable,
may disable.
letter and numbers in parenthesis shows ubuntu default runlevels.
NetworkManager (S): Automate switching between different network connections.
acpi-support, acpid (2,3,4,5): power management
alsa-utils (2,3,4,5): sound
anacron (2,3,4,5): excute delayed cron jobs
apparmor (S): application security, I don't need it on my laptop
apport (2,3,4,5): Automatic crash report. Safe to turn off.
atd (2,3,4,5): excute commands assigned by at.
aumix (2,3,4,5): Turn off if you are using alsa-utils.
avahi-daemon (2,3,4,5): MS/Apple Zeroconf implementation.
binfmt-support (2,3,4,5): Support non-native binary format. If you run Windows program through wine, you'll need it.
bluetooth (2,3,4,5): Bluetooth support, turn off if you don't connect to a BT device regularly.
bootlogd (S),
stop-bootlogd (2,3,4,5): Record boot messages, but currently it's broken in Ubuntu.
cron (2,3,4,5):
cups (2,3,4,5): turn off if you don't connect to a printer regularly.
dbus (2,3,4,5): Message bus system.
dkms_autoinstaller (2,3,4,5): Kernal module auto generator and installer.
dns-clean (S): Mainly for cleaning up the dns info when using dial-up connection
gdm (2,3,4,5): Gnome desktop manager
hal (2,3,4,5):
halt (0):
hotkey-setup (2,3,4,5): Setup some hotkeys for HP, Acer, ASUS, Sony, Dell, and IBM laptops.
killprocs (1):
klogd (2,3,4,5): Kernel logging
laptop-mode (2,3,4,5): laptop battary managing. not needed for desktops
linux-restricted-modules-common (0,6,S): needed if restricted modules are used, e.g., nVidia driver.
loopback (S): providing loopback device.
module-init-tool (S): load extra modules in /etc/modules.
networking (0,6,S):
pcmciautils (S): pcmcia card support. I don't have any pcmcia devices.
policykit (2,3,4,5): defining and handling the policy that allows unprivileged processes to speak to privileged processes
powernowd, powernowd-early (2,3,4,5): manage CPU frequency
pppd-dns (2,3,4,5): dial-up service
procps (S): provide infomation about /proc
rc.local (2,3,4,5)
readahead (S), readahead-desktop (S),
stop-readahead (2,3,4,5): Speed up booting by read all needed files into the memory. Use this with kernel profiling reduce the startup time on my T61 from 27 seconds to 20 seconds.
reboot (6)
rmnologin (2,3,4,5): remove nologinrsync (2,3,4,5): Rsync service
screen-clean (S):
sendsigs (0,6): send signals during reboot or shutdown
single (1): single user mode
sysklogd (2,3,4,5): kernel logging
system-tools (2,3,4,5)
udev, udev-finish (S): udev service
ufw (S): uncomplicated firewall, you may want a firewall to protect you computer, but I don't.
umountfs (0,6)umountroot (0,6)urandom (0,6,S): random number generatorusplash (S): splash screen during booting
vbesave (2,3,4,5): Video card BIOS configration
wpa-ifupdown (0,6): secured wireless connection
x11-common (S): start xserver, I changed it to runlevel 2 since I sometimes want to boot to non-graphical terminal windows.
xserver-xorg-input-wacom (2,3,4,5): Wacom tablet input device support, I don't have one.
Now we are going to remove/add symbolic links in the /etc/rc*.d directories. If you haven' t backed up the original links yet, DO IT NOW.
Generally, you don't want to mess up with anything in runlevels 0, 1, and 6. But I would remove the K scripts in 0 and 6 which are not started in any other runlevels. Runlevels 0 and 6 are identical except the last script excuted: halt in 0, but reboot in 6.
Here are what these directories look like in my T61 after all the modifications:
$ ls /etc/rcS.d
README
S01mountkernfs.sh
S01readahead
S02hostname.sh
S06keyboard-setup
S07linux-restricted-modules-common
S08hwclockfirst.sh
S08loopback
S10udev
S11hwclock.sh
S11mountdevsubfs.sh
S13pcmciautils
S15module-init-tools
S17procps
S20checkroot.sh
S22mtab.sh
S30checkfs.sh
S35mountall.sh
S36mountall-bootclean.sh
S37mountoverflowtmp
S37udev-finish
S39readahead-desktop
S40networking
S45mountnfs.sh
S46mountnfs-bootclean.sh
S49console-setup
S55bootmisc.sh
S55urandom
S70screen-cleanup
S90console-screen.kbd.sh
$ ls /etc/rc0.d
K01gdm
K20apport
K25hwclock.sh
K50alsa-utils
K63mountoverflowtmp
K74dkms_autoinstaller
K86avahi-daemon
K99laptop-mode
README
S01linux-restricted-modules-common
S15wpa-ifupdown
S20sendsigs
S30urandom
S31umountnfs.sh
S35networking
S40umountfs
S60umountroot
S90halt
$ ls /etc/rc2.d
README
S01policykit
S01x11-common
S05vbesave
S10acpid
S10powernowd.early
S10sysklogd
S11klogd
S12dbus
S14avahi-daemon
S20apport
S20dkms_autoinstaller
S20hotkey-setup
S20powernowd
S20rsync
S24hal
S28NetworkManager
S30gdm
S30system-tools-backends
S50alsa-utils
S89anacron
S89cron
S99acpi-support
S99laptop-mode
S99rc.local
S99rmnologin
S99stop-bootchart
S99stop-readahead
hat's it for now. I will cover how to take advantage of runlevels 3-5 in a separate topic.
I.3 Profile the boot up process.
This will work only if you enable readahead service in previous section. The kernel parameter
"profile" tells it to record all disk access during the booting process, then readahead can load all the files at once to save from random access of harddrive. This might not help much for SSD since SSDs have the advantage of fast random access.
The kernal parameter can be added in your /boot/grub/menu.lst, but since we only need it once, it's better to add it in the grub boot menu. At the boot menu, press "e" will allow you to change booting parameters. Highlight the kernel line, press "e" again, and append "profile" at the end of the line. Hit "b" to reboot, and wait for the computer to start. It will be slow, probably 5 times slower than an normal boot, but remember that we only need to do this once.
I.3 Concurrent booting (
http://www.my10sen.com/2007/10/05/ubuntu-a-speedup-guide/)
Concurrent booting allows Ubuntu to take full advantage of dual-core processors, as well as processors that hyperthread or multithread.
These settings are located in your /etc/init.d/rc file. Change
CONCURRENCY=none
to
CONCURRENCY=shell
To be frankly, this change does not help me much although I have Intel Core Duo processers.
I.4 Remove extra virtual terminals (
http://paulsdigitalworld.blogspot.com/2008/01/complete-ubuntu-speed-up-tweak-guide.html)
cd /etc/event.d
sudo mv tty3 tty3.bak
sudo mv tty4 tty4.bak
sudo mv tty5 tty5.bak
sudo mv tty6 tty6.bak
I.5 Reduce forced disk check
By defaults, ext2/ext3 partitions are forced to do disk check about every 30 mounts, or every 6 months. I typically turn off my laptop every day, so the 30 mounts cap reaches rather often. Since laptop's harddrives are subject to more potential damage than desktop's or server's, I prefer to have it checked every 3 months or 100 mounts. This can be done with
tune2fs:
sudo tune2fs -c 101 -i 3m /dev/sda1
The -c option is the mount count cap, and -i option is for time interval. Do this for all ext2/ext3 partitions. Be sure not to use the same numbers for all partitions. Otherwise your boot time might prolong to an hour if all partition checks are synchronized.