serial console makes boot very slow on Vagrant

Bug #1627844 reported by Greg
48
This bug affects 9 people
Affects Status Importance Assigned to Milestone
cloud-images
New
Undecided
Unassigned

Bug Description

I have been seeing very slow boot times on Ubuntu xenial CD images. After some hunting, theproblem seems to be the console logging to the serial port. Disconnecting the serial port seems to solve the problem.

Adding this to Vagrantfile drops the startup time from about 3 minutes to about 1 minute:
    config.vm.provider :virtualbox do |vb|
      vb.customize ["modifyvm", :id, "--uartmode1", "disconnected"]
    end

This only happens for xenial64. If I swap in box ubuntu/trusty64 or larryli/vivid64, then those lines have no effect on the startup time.

Complete transcript to replicate:

user@host:~/tmp/cdimage-bug$ vagrant init ubuntu/xenial64 --box-version 20160921.0.0
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

user@host:~/tmp/cdimage-bug$ time vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> default: Setting the name of the VM: cdimage-bug_default_1474921158442_93989
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: ubuntu
    default: SSH auth method: password
    default: Warning: Remote connection disconnect. Retrying...
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/user/tmp/cdimage-bug

real 3m12.105s
user 0m7.732s
sys 0m3.944s

Added this lines to Vagrantfile:
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--uartmode1", "disconnected"]
  end

user@host:~/tmp/cdimage-bug$ vagrant destroy -f
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...

user@host:~/tmp/cdimage-bug$ time vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> default: Setting the name of the VM: cdimage-bug_default_1474921400525_21103
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: ubuntu
    default: SSH auth method: password
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/user/tmp/cdimage-bug

real 1m0.079s
user 0m3.484s
sys 0m1.240s

Greg (ggbaker)
description: updated
description: updated
Revision history for this message
Brian (egee-irl) wrote :

The serial port also causes a problem when using a base image. The log file that the serial port plugs into is hardcoded so if you move the box to another machine, vagrant up will fail.

Revision history for this message
Alex (alexander-stehlik) wrote :

I also stumbled over this problem and can provide some results of my experiments:

The problem seems to occur for Ubuntu Vagrant Boxes Bionic and Xenial (Trusty does not seem to be affected).

There is always a problem, when the serial port is either disconnected or disabled. When I redirect the output to /dev/null everything seems to work fine.

Some more details of the behaviour of a Xenial Box:

When Serial 1 Port is enabled the Kernel Boot Process hangs for a while (45 Seconds) after this message was printed:

console [tty1] enabled

After that the Kernel boot process continues very slowly (383 seconds until systemd ist started, given up after 1531 seconds after the journal service was started and nothing more seems to happen). During the process the CPU usage is at about 70% the whole time.

When the Serial port is disabled the behaviour is slightly different:

The Kernel boots normal for about 3 seconds until the usbhid is loaded. Then after 13 seconds the random nonblocking pool is initialized. After that the hard disk indicator for the box is constantly on and nothing more happens.

tags: added: id-5cf13913704f6332da576e60
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.