There are a few things you can do to reduce the time it takes for Ubuntu to boot, given a default installation. This page documents three ways.
Disable unused network interfaces
By default, Ubuntu (Server) enables all network interfaces and tries to use DHCP on them.
You can significantly reduce the boot time (in testing of a Mt. Snow machine with an Ampere Altra Max M128-30 CPU the boot time reduced from 2:32 to 0:34) by telling it to only configure the interface(s) which are plugged in:
Look at the output of ip a
:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 18:c0:4d:0d:a3:c4 brd ff:ff:ff:ff:ff:ff
altname enP2p1s0f0
3: eno2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 18:c9:65:13:a3:c9 brd ff:ff:ff:ff:ff:ff
altname enP2p1s0f1
4: enP1p1s0f0np0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 0c:42:a1:c1:d8:ca brd ff:ff:ff:ff:ff:ff
5: enP1p1s0f1np1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 0c:42:a1:c1:d1:db brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 metric 100 brd 192.168.1.255 scope global dynamic enP1p1s0f1np1
valid_lft 3304sec preferred_lft 3304sec
inet6 fe80::e42:a1ff:fec1:d1db/64 scope link
valid_lft forever preferred_lft forever
6: enx0afea452cd6a: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
link/ether 0a:fe:a4:52:cd:1b brd ff:ff:ff:ff:ff:ff
inet6 fe80::8fe:a4ff:fe52:cd1b/64 scope link
valid_lft forever preferred_lft forever
In this example, we have 5 physical network interface, of which 1 (enP1p1s0f1np1) is configured.
Edit /etc/netplan/00-installer-config.yaml - sudo nano /etc/netplan/00-installer-config.yaml
- and change all of the 'dhcp4' entries to 'false' and add 'activation-mode: off' on the interfaces which don't have an IP address:
# This is the network config written by 'subiquity'
network:
ethernets:
enP1p1s0f0np0:
dhcp4: false
activation-mode: off
enP1p1s0f1np1:
dhcp4: true
eno1:
dhcp4: false
activation-mode: off
eno2:
dhcp4: false
activation-mode: off
enx0afea452cd6a:
dhcp4: false
activation-mode: off
version: 2
Press ctrl-x, save the modifications, ('y') and reboot.
Reduce output to the serial port
To save a further 14 seconds or so, you can stop printing all the boot messages to the serial port (since it's slow, at 115200bps).
Edit /etc/default/grub and edit the GRUB_CMDLINE_LINUX_DEFAULT
line to read:
GRUB_CMDLINE_LINUX_DEFAULT="quiet console=tty0"
Run sudo update-grub
and reboot.
Disable cloud-init
You can further save a second or two by disabling cloud-init
if you don't use it:
# Disable all services (uncheck everything except "None")
sudo dpkg-reconfigure cloud-init
sudo apt-get purge cloud-init
sudo rm -rf /etc/cloud/ && sudo rm -rf /var/lib/cloud/