我的电脑上安装了 Debian Bullseye,我想玩一下 Vagrant。不幸的是,我偶然发现了两个乍一看毫不相关的问题,但是为了提供完整的概述,我将它们都列出来:
- 从存储库安装
vagrant
软件包时,Debian 会自动删除virtualbox
和virtualbox-qt
软件包,反之亦然!当我尝试重新安装时,virtualbox
Debian 通知我安装过程中vagrant
和vagrant-libvirt
将被删除。为什么?这些软件包无法在 Debian 上协同工作是否存在障碍?bullseye 关于 vagrant 包的网页您只能发现:“Vagrant 上游默认使用 Oracle 的 VirtualBox 来创建其虚拟机。在 Debian 上,Vagrant 将默认使用 libvirt/KVM,因为 VirtualBox 不是 Debian 主程序的一部分,但如果安装了 VirtualBox,则会使用它。”
无论如何,我通过virtualbox
从官方 Debian 存储库安装并下载独立的 appImagedvagrant
二进制文件来解决这个问题vagrant 的官方页面并将其复制到某个系统路径目录中。现在它们都正常工作了……
- 第二个问题是,即使是简单的,
Vagrantfile
例如:
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
vb.cpus = 2
vb.memory = 1024
vb.customize ["modifyvm", :id, "--vram", "128"]
vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y emacs
SHELL
end
block中的命令config.vm.provision "shell", inline
未执行!更糟糕的是,我无法vagrant ssh
进入 vm。我不断获得:
VM must be running to open SSH connection. Run `vagrant up`
to start the virtual machine.
详细信息:vagrant up
创建 vagrant box 后(我可以在 virtualbox 中看到它),virtualbox 正在启动,我得到了虚拟机登录屏幕。我可以登录,一切正常(在 virtualbox 窗口中)。
但是命令行的最后一条消息表明:
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.
命令行的完整输出如下:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'bento/ubuntu-18.04' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'bento/ubuntu-18.04'
default: URL: https://vagrantcloud.com/bento/ubuntu-18.04
==> default: Adding box 'bento/ubuntu-18.04' (v202212.11.0) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/bento/boxes/ubuntu-18.04/versions/202212.11.0/providers/virtualbox.box
==> default: Successfully added box 'bento/ubuntu-18.04' (v202212.11.0) for 'virtualbox'!
==> default: Importing base box 'bento/ubuntu-18.04'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/ubuntu-18.04' version '202212.11.0' is up to date...
==> default: Setting the name of the VM: debian-vagrant_default_1676627515085_33587
==> 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...
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.
If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.
The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.
我发现在 BIOS 中禁用 VT 功能可能会导致此类问题。我检查了一下,并在 BIOS 中启用了它们。
答案1
Vagrant 与最新版本的 VirtualBox (7.x) 不兼容。您可以在此处找到兼容的版本https://developer.hashicorp.com/vagrant/docs/providers/virtualbox