🗳️
macOS Montereyでvagrant upに失敗する
- TCP/IPの本で環境構築をVagrant/Virtualboxで行っていたのでmacOS Montereyで行ったところ、失敗したのでメモを残しておく
事象
環境
- VagrantもVirtualboxもhomebrewでインストールしたものになります
$ sw_vers
ProductName: macOS
ProductVersion: 12.0.1
BuildVersion: 21A559
$ vagrant -v
Vagrant 2.2.18
$ brew -v
Homebrew 3.3.2-33-gcb32066
Homebrew/homebrew-core (git revision 1e9d510578e; last commit 2021-11-03)
Homebrew/homebrew-cask (git revision d5198633bb; last commit 2021-11-03)
エラー内容
-
Vagrantfile
が作成されている状態で、vagrant up
を実行すると以下のようなエラーになり仮想マシンが起動しませんでした
$ vagrant init ubuntu/focal64
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.
$ ls
Vagrantfile
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/focal64' version '20211026.0.0' is up to date...
==> default: Clearing any previously set forwarded ports...
==> 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...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "3e336932-d167-496b-83ed-537b6fa52468", "--type", "headless"]
Stderr: VBoxManage: error: The virtual machine 'ubuntu2004_default_1635924448821_54833' has terminated unexpectedly during startup because of signal 10
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine
試したこと
- 検索したところ、近い例として”Oracleのソフトウェアの実行許可を出す必要がある”というものがあったが、こちらはHomebrewでインストールする際にクリアしていたので、今回の事象の原因ではなかった
解決方法
Vagrantfileを編集
- 起動に使用する
Vagrantfile
内のconfig.vm.provider
の設定ブロックでvb.gui
をtrueにする
# `config.vm.provider` のブロックと`vb.gui=true`のコメントアウトを外す
$ vim Vagrantfile
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# Customize the amount of memory on the VM:
# vb.memory = "1024"
end
結果
- (
GUI
をtrueにしたためか)GUIが起動して、vagrant up
のコマンドが無事完了する
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/focal64' version '20211026.0.0' is up to date...
==> default: Clearing any previously set forwarded ports...
==> 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: vagrant
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
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 => ...
$ vagrant status
Current machine states:
default running (virtualbox)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
原因
- Vagrantにそれらしいissueがあった
- headlessモードに問題があるみたいなので、これを回避する手段がGUIでの起動みたい
参考
Discussion