这是坚持技术写作计划(含翻译)的第53篇,定个小目标999,每周最少2篇。
最近使用vagrant安装ubuntu20.04(ubuntu/focal64)是发现无法正常启动。
vagrant+virtualbox系列文章
- 036-win10搭建python的linux开发环境(pycharm+vagrant+virtualbox)
- 037-vagrant启动(up)后自动同步文件(rsync-auto)
- 040-解决Linux使用virtualbox共享文件夹问题
- 042-解决win10 VirtualBox无法启动(VERR_NEM_VM_CREATE_FAILED)
- 043-解决vagrant访问virtualbox共享文件夹报无权限问题(Permission denied)D)
- 053-vagrant无法使用ubuntu20.04问题
过程
# 离线下载 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
# -*- 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
# 安装cmake
sudo apt-get install -y cmake build-essential
# 安装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
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/focal64'...
==> default: Matching MAC address for 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
一直卡在 default: SSH auth method: private key
并且virtualbox 也会卡死,并且无法强制关闭或者释放此vm,需要杀死进程才行。
解决办法
修改vagrantfile 参数
增加 vb.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"
# 增加这行
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
# 安装cmake
sudo apt-get install -y cmake build-essential
# 安装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
换镜像
app.vagrantup.com/bento/boxes…
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-20.04"
end
招聘小广告
山东济南的小伙伴欢迎投简历啊 加入我们 , 一起搞事情。
长期招聘,Java程序员,大数据工程师,运维工程师,前端工程师。