2012年12月27日星期四

Speed up Fedora boot time

I bought a MacBook Air for my wife and she was surprised that it boots in seconds! So I think I should do something to my Favorite Fedora17 on Thinkpad as well. (Notice that I've no SSD attached)

Diagnostic

Generally the boot time of my Fedora17 is around 100 seconds and I even don't know what's wrong with it. So the first time is diagnostic.

The first tool is systemd-analyze that I found from the article "Fedora 17 Boot optimization from 15 to 3 seconds". You can get:

time spends in each phases (kernel, ramdisk and userspace):

$ sudo systemd-analyze

the time that each service takes via:

$ sudo systemd-analyze blame

A pretty sequence diagram of system boot time:

$ sudo systemd-analyze plot > ~/Desktop/boottime.svg

Follow up actions


  • disable ramdisk. where it will save u 5 seconds. see this article for details.
  • remove unused packages. You can use the following commands to list those orphan/leaves packages:
$ sudo package-cleanup --orphans
$ sudo package-cleanup --leaves
  • remove unused services. here's mine:
$ sudo systemctl disable bluetooth.service
$ sudo systemctl disable avahi-daemon.service
$ sudo systemctl disable cups.service
$ sudo systemctl disable nfs-lock.service
$ sudo systemctl disable abrtd.service
$ sudo systemctl disable abrt-oops.service
$ sudo systemctl disable udev-settle.service


After the above actions, the boot time reduced to 20 seconds:


$ sudo systemd-analyze
Startup finished in 3192ms (kernel) + 17428ms (userspace) = 20621ms


Runtime optimization


  • mount /tmp to tmpfs. Please edit your /etc/fstab file by appending this line (you can adjust the size on your own):

tmpfs  /tmp                    tmpfs   size=512m       0 0

Please comment if you had more!