Optimize Fedora Booting Process

When I’m checking the performance of my fedora, I found that my fedora takes 36 seconds to boot completely which is double the value of expected (15s) boot-up time. I decided to optimize my fedora boot process to achieve the standard boot-up time.

* Install the ‘systemd-analyze’ package :
$ yum install systemd-analyze

* Check the total boot time :
$ systemd-analyze time | tee total-boot-time.log

Output should look like :
Startup finished in 3167ms (kernel) + 4318ms (initramfs) + 29511ms (userspace) = 36998ms

* Kernel took 3 secs
* RAM Disk took 4 secs
* Userspace programs took nearly 30 secs

We can optimize the userspace programs first.
Note : ‘tee’ command prints & copies the output to a file (for comparison purpose).

* Check the detailed boot time :
$ systemd-analyze blame | tee detailed-boot-time.log

Output should look like :
10583ms udev-settle.service
4762ms fedora-loadmodules.service
3857ms NetworkManager.service
3300ms avahi-daemon.service
2794ms systemd-binfmt.service
2571ms fedora-storage-init.service
1942ms media.mount
1922ms systemd-vconsole-setup.service
1911ms sys-kernel-debug.mount
1894ms dev-hugepages.mount
1863ms fedora-storage-init-late.service
1862ms dev-mqueue.mount
1657ms fedora-readonly.service
1643ms mdmonitor-takeover.service
1587ms udev-trigger.service
1580ms home.mount
1534ms udev.service

To plot these output to a graph :

$ systemd-analyze plot > boot-graph.png

Fedora boot-up time graph

* Find the failed boot process & fix it :
$ systemctl --failed

Output should look like :
systemd-tmpfiles-clean.service loaded failed failed Cleanup of Temporary Directories
systemd-tmpfiles-setup.service loaded failed failed Recreate Volatile Files and Directories
tcsd.service loaded failed failed LSB: Init script for TCSD
vmware.service loaded failed failed SYSV: This service starts and stops VMware services

To fix these failed services, check the status of each one which gives the reason for the failure.

For example :
$ systemctl status systemd-tmpfiles-clean.service
systemd-tmpfiles-clean.service - Cleanup of Temporary Directories
Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.service; static)
Active: failed (Result: exit-code) since Mon, 22 Oct 2012 12:33:18 +0530; 57min ago
Docs: man:tmpfiles.d(5)
Main PID: 2745 (code=exited, status=1/FAILURE)
CGroup: name=systemd:/system/systemd-tmpfiles-clean.service

Oct 22 12:33:18 fedora systemd-tmpfiles[2745]: [/etc/tmpfiles.d/jetty.conf:1] Unknown user 'jetty'.
Oct 22 12:33:18 fedora systemd-tmpfiles[2745]: stat(/run/user/sriram/gvfs) failed: Permission denied

$ [[email protected] ~]$ sudo /usr/bin/systemd-tmpfiles --create --remove
[/etc/tmpfiles.d/jetty.conf:1] Unknown user 'jetty'.

Then, I reinstalled the jetty package which fixed ‘jetty’ user issue.

* Disable the unnecessary services (including non-native services) :

$ systemctl disable mdmonitor.service mdmonitor-takeover.service fcoe.service lldpad.service vmware.service iscsid.service iscsi.service tcsd.service livesys.service livesys-late.service lvm2-monitor.service spice-vdagentd.service

mdmonitor & mdmonitor-takeover – service for RAID devices
fcoe & lldpad – Fiber Channel Over Ethernet service
iscsi & iscsid – service for iSCSI devices
tcsd – Trusted Computing Service
livesys & livesys-late -service for live CD

Again I removed few more services
$ systemctl disable jetty.service sendmail.service ip6tables.service vmware-USBArbitrator.service

* Check the performance again by doing step 2 & 3. :

After these above steps, improved the performance in userspace by 6 secs.
>> Startup finished in 3164ms (kernel) + 4571ms (initramfs) + 22200ms (userspace) = 29937ms

But my expectation was, kernel : 3secs, initramfs : 3secs, userspace programs : 15 secs

If you are not using LVM, RAID or Multipath, then disable the udev-settle, fedora-storage-init, fedora-storage-init-late & fedora-wait-storage services.
$ systemctl mask fedora-wait-storage.service fedora-storage-init-late.service fedora-storage-init.service udev-settle.service
$ systemctl disable plymouth-start.service avahi-daemon.service

Remove abrt completely
$ yum remove abrt*

Advanced Optimization : Skipping RAM disk
Kernel can boot directly from an ext4 partition without initramfs.
Comment the initrd line and add these parameter ‘root=/dev/sda3 rootfstype=ext4’ to your kernel
linux /boot/vmlinuz-3.6.2-4.fc17.i686.PAE root=/dev/sda3 rootfstype=ext4 libahci.ignore_sss=1 raid=noautodetect ro rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 KEYTABLE=us SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8
#initrd /boot/initramfs-3.6.2-4.fc17.i686.PAE.img

>> Startup finished in 4389ms (kernel) + 22460ms (userspace) = 26850ms

So, Boot-up time reduced upto 10 secs.

Fedora Boot-up time graph after optimization
Fedora Boot-up time graph after optimization

* More Aggressive Optimization :
1) Disable SELinux and auditing services
2) Mask fedora-autoswap.service fedora-configure.service fedora-loadmodules.service fedora-readonly.service
3) Don’t use debug kernels
4) Don’t use LVM


“Cannot open font file True” in Fedora

When you start the fedora 16/17, it will show you an message “Cannot open font file True” in boot screen for few seconds. To fix this, we need to change the sysfont to default.
Steps :
1) Open the grub configuration
** sudo vi /etc/default/grub
2) Update the SYSFONT to latarcyrheb-sun16 and save the file.
** Look for "SYSFONT=True" and replace it with "SYSFONT=latarcyrheb-sun16"
3) Generate the grub configuration
** sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Bugzilla URL : https://bugzilla.redhat.com/show_bug.cgi?id=799401