#環境
ホストOS:windows10
ゲストOS:CentOS
#発生現象
vagrant up
の際、仮想環境立ち上げは成功するが、エラーが出ている。
共有フォルダのマウントに失敗しているようだ。
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=500,gid=500 vagrant /vagrant
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
「Guest Additions
がインストールされているか確認してくれ。」と言っております。
#やること
新しいバージョンのGuest Additions
に更新してくれる「vagrant-vbguest
」というプラグインをインストールする。
#vagrant-vbguest のインストール
念のため、インストールされているか確認
ホストOS
vagrant vbguest --status
実行結果
[default] No installation found.
では、インストールだ。
インストールは以下のコマンドで行う。
ホストOS
vagrant plugin install vagrant-vbguest
実行結果
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Fetching: vagrant-share-1.1.9.gem (100%)
Fetching: micromachine-2.0.0.gem (100%)
Fetching: vagrant-vbguest-0.15.0.gem (100%)
Installed the plugin 'vagrant-vbguest (0.15.0)'!
インストールしたらvbguestを起動する。
これでGuest Additions
の最新版がインストールされるはず。
ホストOS
vagrant vbguest
実行結果(一部抜粋)
Mounting Virtualbox Guest Additions ISO to: /mnt
Installing Virtualbox Guest Additions 5.2.2 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.2 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 5.1.18 of VirtualBox Guest Additions...
vboxadd.sh: Stopping VirtualBox Additions.
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Starting.
/etc/init.d/vboxadd: line 256: : No such file or directory
Unmounting Virtualbox Guest Additions ISO from: /mnt
ちなみに、kernel-devel
というモジュールもインストールしてくれた模様。
#ゲストのvboxをリビルドする
ゲストOSに入る。
ホストOS
vagrant ssh
vboxをリビルドする。
ゲストOS
$ sudo /etc/init.d/vboxadd setup
実行結果
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted
VirtualBox Guest Additions: Starting.
そして、仮想マシンからexitして、vagrant
を再upする。
ホストOS
vagrant reload
実行結果
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'bento/centos-6.8' 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: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> 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: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection aborted. Retrying...
==> default: Machine booted and ready!
[default] GuestAdditions 5.2.2 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Mounting shared folders...
default: /vagrant => C:/Users/toki/MyVagrant/MyCentOS
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
ということで、エラーが解消!
#参考