This is article 53 of the Stick to technical Writing Project (including translation). Set a small goal of 999, at least 2 articles per week.

A recent installation of Ubuntu 20.04(Ubuntu /focal64) using Vagrant was found to be unable to boot properly. Vagrant + VirtualBox series of articles

  • Pycharm + Vagrant + VirtualBox (Pycharm + Vagrant + VirtualBox)
  • 037- Vagrant automatically synchronizes files after startup (up) (rsync-auto)
  • 040- Resolve Linux sharing folder problem using VirtualBox
  • Win10 VirtualBox fails to start (VERR_NEM_VM_CREATE_FAILED)
  • 043- Resolving vagrant Permission denied to access virtualBox shared folderD)
  • 053-vagrant cannot use ubuntu20.04 issue




process

# offline download ubuntu/focal64 https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64-vagrant.box
# vagrant box add ubuntu/focal64 /path/to/focal-server-cloudimg-amd64-vagrant.box
Copy the code
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
    # Every Vagrant development environment requires a box. You can search for
    # boxes at https://vagrantcloud.com/search.
    config.vm.box_check_update = false
    config.vm.box = "ubuntu/xenial64"
    config.vm.hostname = "redis"
    config.vm.network "private_network", ip: "172.17.8.102"
    config.vm.provider "virtualbox" do |vb|
      vb.memory = "4096"
      vb.cpus = 2
      vb.name = "tdegine"
    end
  
    config.vm.synced_folder "."."/vagrant".type: "rsync",
      rsync__verbose: true,
      rsync__exclude: ['.git*'.'node_modules*'.'*.log'.'*.box'.'Vagrantfile']
  
    config.vm.provision "shell", inline: <<-SHELL sudo sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g'/etc/apt/sources list sudo apt # update install cmake Sudo apt-get install -y cmake build-essential # install docker sudo apt-get remove docker docker-engine docker. IO sudo apt-get  install-y apt-transport-https ca-certificates curl gnupg2 software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository \ "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \ $(lsb_release -cs) \ stable" sudo apt-get update sudo mkdir -p /etc/docker sudo apt-get install -y docker-ce SHELL
  end
  
  
Copy the code
$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/focal64'. ==> default: Matching MAC addressfor NAT networking...
==> default: Checking if box 'ubuntu/focal64' version '20200804.0.0' is up to date...
==> default: Setting the name of the VM: jpc_default_1597236075101_37777
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> 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: vagrant
default: SSH auth method: private key
Copy the code

If the vm is stuck in default: SSH Auth Method: private key and VirtualBox is stuck, the VM cannot be forcibly shut down or released. You need to kill the process.

The solution

I’m just going to do one of two things

Modify the vagrantFile parameter

Customize [” modifyVM “, : ID, “–uartmode1”, “file”, file ::NULL]

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
    # Every Vagrant development environment requires a box. You can search for
    # boxes at https://vagrantcloud.com/search.
    config.vm.box_check_update = false
    config.vm.box = "ubuntu/xenial64"
    config.vm.hostname = "redis"
    config.vm.network "private_network", ip: "172.17.8.102"
    config.vm.provider "virtualbox" do |vb|
      vb.memory = "4096"
      vb.cpus = 2
      vb.name = "tdegine"
      # Increase this line
      vb.customize ["modifyvm", :id, "--uartmode1"."file", File::NULL]
    end
  
    config.vm.synced_folder "."."/vagrant".type: "rsync",
      rsync__verbose: true,
      rsync__exclude: ['.git*'.'node_modules*'.'*.log'.'*.box'.'Vagrantfile']
  
    config.vm.provision "shell", inline: <<-SHELL sudo sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g'/etc/apt/sources list sudo apt # update install cmake Sudo apt-get install -y cmake build-essential # install docker sudo apt-get remove docker docker-engine docker. IO sudo apt-get  install-y apt-transport-https ca-certificates curl gnupg2 software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository \ "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \ $(lsb_release -cs) \ stable" sudo apt-get update sudo mkdir -p /etc/docker sudo apt-get install -y docker-ce SHELL
  end
  
  
Copy the code

In the mirror

App.vagrantup.com/bento/boxes…

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-20.04"
end
Copy the code

Want ads

Friends in Jinan, Shandong, welcome to join us and do things together. Long-term recruitment, Java programmer, big data engineer, operation and maintenance engineer, front-end engineer.

The resources

  • My blog
  • I’m the nuggets
  • hashicorp/vagrant#11817#SSH auth method: private key
  • Vagrant box startup timeout due to no serial port