LoginSignup
26
17

More than 5 years have passed since last update.

Vagrantで共有フォルダがマウントされない

Posted at

TL;DR

Vagrant内にvboxaddが存在しないのが原因です。
下記コマンドを打っていくと直ると思います。

$ sudo /etc/rc.d/init.d/vboxadd setup
sudo: /etc/rc.d/init.d/vboxadd: command not found
$ cd /tmp
$ wget http://download.virtualbox.org/virtualbox/4.3.20/VBoxGuestAdditions_4.3.20.iso
$ sudo mount -t iso9660 /tmp/VBoxGuestAdditions_4.3.20.iso /mnt
$ cd /mnt/
$ sudo ./VBoxLinuxAdditions.run
$ ls /etc/init.d/ | grep vboxadd
vboxadd
$ sudo reboot

現象

ある日Vagrantを立ち上げようとしたら下記のエラーが出ました、世知辛いのじゃ。

terminal.app
$ vagrant up
(中略)
==> default: Machine booted and ready!
[default] GuestAdditions seems to be installed (5.1.32) correctly, but not running.
vboxadd: unrecognized service
vboxadd-service: unrecognized service
bash: line 3: setup: command not found
==> default: Checking for guest additions in VM...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

 setup

Stdout from the command:


Stderr from the command:

bash: line 3: setup: command not found

この状態でもSSHでつなぐことはできるのですが、Vagrant内の共有フォルダ以下が空でした。

対処方法

GuestAdditionsが動いていないとのことなのでvbguestコマンドで見てみます。

terminal.app
$ vagrant vbguest --status
[default] GuestAdditions seems to be installed (5.1.32) correctly, but not running.

上記のエラーと同じエラーが出ました。
念の為vbguestをインストールしてみます。

terminal.app
$ vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.15.2)'!

インストールされています!知ってた!

ここから先はTD;DRで書いたことの解説です。
まず、vboxaddコマンドが動作しないかの確認です。

$ sudo /etc/rc.d/init.d/vboxadd setup
sudo: /etc/rc.d/init.d/vboxadd: command not found

いい感じにコマンドが存在しないのでインストールしていきます。

$ cd /tmp
$ wget http://download.virtualbox.org/virtualbox/4.3.20/VBoxGuestAdditions_4.3.20.iso

--2018-05-28 02:23:15--  http://download.virtualbox.org/virtualbox/4.3.20/VBoxGuestAdditions_4.3.20.iso
Resolving download.virtualbox.org... 103.2.50.86
Connecting to download.virtualbox.org|103.2.50.86|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 58343424 (56M) [application/octet-stream]
Saving to: `VBoxGuestAdditions_4.3.20.iso'

100%[======================================>] 58,343,424  1.46M/s   in 16s     

2018-05-28 02:23:32 (3.39 MB/s) - `VBoxGuestAdditions_4.3.20.iso' saved [58343424/58343424]

インストールできたのでマウントして実行します。

$ sudo mount -t iso9660 /tmp/VBoxGuestAdditions_4.3.20.iso /mnt
$ cd /mnt/
$ sudo ./VBoxLinuxAdditions.run

vboxaddが存在することを確認したら、vagrantを再起動します。

$ ls /etc/init.d/ | grep vboxadd
vboxadd
$ sudo reboot

再起動すると正常に共有フォルダがマウントされていました!やったね!

参考リンク

Mac(Yosemite)でVagrant環境を構築する

26
17
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
17