This article will describe improving boot time.
Table of Contents
1 System environment and boot time before speed up
This article runs VirtualBox on OSX and use below spec.
CPU Core Number | 1 |
RAM | 1GB |
Video Memory | 128MB |
Storage | IDE DVD Drive + SATA 40GB HDD |
Ubuntu 16.04 is installed by ubuntu-16.04-desktop-amd64.iso and formatted by LVM + ext4.
A boot time after installation is as below.
$ systemd-analyze Startup finished in 9.372s (kernel) + 5.721s (userspace) = 15.093s
2 Change BIOS timeout
BIOS timeout of VirtualBox is about 3 seconds by default. "Adjusting the VirtualBox F12 BIOS Boot Prompt Timeout" explains how to change BIOs timeout. Change the minimum 1 for improving boot time, change 3000 when you need BIOS operation.
3 Add Floppy Controller
VirtualBox 5.0.20 r106931 may have a issue with bus for floppy. This issue is that bus controller always treats floppy be exists without adding floppy controller.
Linux kernel will know floppy with probe function and run init function for floppy. The init function will be failed, sleep and try again, which will cause boot time delay.
[ 2.038893] sd 2:0:0:0: [sda] Attached SCSI disk [ 4.311960] floppy0: no floppy controllers found [ 4.312010] work still pending
Add floppy controller for making init function to be succeed. Add floppy controller can be done when Ubuntu 16.04 is shutdowned.
Settings -> Storage -> Adds new storage controller -> Add Floppy Controller
It decreased kernel boot time about 2 seconds.
$ systemd-analyze Startup finished in 6.980s (kernel) + 5.235s (userspace) = 12.216s
4 Fix /etc/initramfs-tools/conf.d/resume
Activating LVM swap causes boot time delay.
$ sudo su -c 'echo RESUME=/dev/mapper/ubuntu--vg-swap_1 > \ /etc/initramfs-tools/conf.d/resume' $ sudo update-initramfs -u $ sudo reboot
It decreased kernel boot time about 5 seconds.
$ systemd-analyze Startup finished in 2.223s (kernel) + 5.999s (userspace) = 8.223s
5 Disable vboxadd-x11.service
vboxadd-x11.service uses CPU power but does nothing.
$ systemd-analyze blame | head 2.795s vboxadd.service 1.770s vboxadd-x11.service 1.235s dev-mapper-ubuntu\x2d\x2dvg\x2droot.device 1.035s networking.service 930ms accounts-daemon.service 819ms NetworkManager.service 802ms avahi-daemon.service 673ms systemd-logind.service 590ms apport.service 577ms grub-common.service
Disable vboxadd-x11.service.
$ sudo systemctl disable vboxadd-x11 $ sudo reboot
It decreased userland boot time about 1 second.
$ systemd-analyze Startup finished in 2.165s (kernel) + 4.389s (userspace) = 6.555s
6 In case of 2 CPU cores
The systemd runs parallel and it improves userlan boot time.
$ systemd-analyze Startup finished in 2.175s (kernel) + 2.837s (userspace) = 5.012s