わたるの備忘録

エンジニア志望の文系大学生の備忘録

Vagrantが遅すぎるときの解決方法。

1.フォルダ共有形式を変える。

nfsプラグインのインストール

vagrant plugin install vagrant-winnfsd

また、立ち上げるときに、

vagrant up --provision

とする。

2.ネットワークドライバの変更

vagrantfileに以下を記述

config.vm.provider "virtualbox" do |vb|
  vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
  vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end

【追記】
vb.customize1、2行目を追加すると

An error occurred in the underlying SSH library that Vagrant uses.
The error message is shown below. In many cases, errors from this
library are caused by ssh-agent issues. Try disabling your SSH
agent or removing some keys and try again.

と吐かれたので、そういう場合は代わりに"on"の部分を"off"にしてみる。それでも無理なら

vb.customize ["modifyvm", :id, "--nictype1",  "virtio"]
vb.customize ["modifyvm", :id, "--nictype2",  "virtio"]  

を代わりに書く。
最適解は個々の環境によって違うみたい。
参照:
https://www.webnoha.work/blog/20190504-vagrant-speed-up/
https://stackoverflow.com/questions/50614748/laravel-homestead-vagrant-virtualbox-is-slow-on-windows
https://akamist.com/blog/archives/520
https://hacknote.jp/archives/17915/