LoginSignup
5
6

More than 5 years have passed since last update.

vagrant環境で`yum update`をした後、`vagrant up`をするとエラーとなる件

Posted at

ことの発端

vagrantを利用しDockerの環境を作成しようとしていました。

Dockerをインストールする際、最初にyum updateを実行する必要があったのですが、これを実行した後に、VMを再起動(vagrant halt -> vagrant up)すると以下のようなエラーが発生してしまいました。

$ vagrant up

・・・
==> default: Machine booted and ready!
GuestAdditions seems to be installed (5.0.6) correctly, but not running.
bash: line 2: /etc/init.d/vboxadd: No such file or directory
bash: line 2: /etc/init.d/vboxadd: No such file or directory
==> 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!

/etc/init.d/vboxadd setup

Stdout from the command:



Stderr from the command:

bash: line 2: /etc/init.d/vboxadd: No such file or directory

なにやら、guest additionsのチェックで失敗しているような感じ。この時点では、さっぱり訳がわからない感じでした。

ひとまず、VMに入ってみる

ひとまず、VMに入ってみたところ無事にログインまではできていました。

そしたら、あのエラーは一体何だったのかが気になるところだったのですが、その疑問はすぐにわかりました。

それは・・・/vagrantディレクトリがホスト側とのディレクトリと共有ができていなかったようでした。(厳密には、他にも影響があった気もしますが。)

Guest Additionsをインストールしてみる。

Guest Additions機能がうまく動いていないならば、それを改めてインストールしてみることに。

インストールまでは以下の手順で行いました。

  1. VMをシャットダウン( vagrant halt )
  2. Virtual Box上から、対象のVMに対して 光学ドライブ を追加
  3. VMを起動( vagrant up )
  4. Virtual Box上から、対象のVMをダブルクリック
  5. 対象のVMのメニュー上から、Devices -> Insert Guest Additions CD images ... を選択してGuest Additions CDを挿入
  6. ゲストOS上で、Guest Additions CDをマウント( sudo mount -r /dev/cdrom /mnt )
  7. Guest Addtionsをインストール( sudo sh VBoxLinuxAdditions.run )

すると、結果として・・・

VirtualBox Guest Additions installer
Removing installed version 5.0.6 of VirtualBox Guest Additions...
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules
The gcc utility was not found. If the following module compilation fails then
this could be the reason and you should try installing it.

The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-devel-3.10.0-229.14.1.el7.x86_64

Building the main Guest Additions module[失敗]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions[  OK  ]
Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.

少し、予想はしていましたがBuilding the main Guest Additions module[失敗]が示す通り、失敗していました。

心折れずにエラーをよく読んでみる。

エラーメッセージをよく確認してみると、以下のことが書いてありました。

  1. Building the VirtualBox Guest Additions kernel modules The gcc utility was not found. If the following module compilation fails then this could be the reason and you should try installing it. (Virtual Box Guest Additionsを構築しようとしたけど、gcc utilityが見つからなかったよ。gcc utilityをインストールしてみ)

 
2. The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-devel-3.10.0-229.14.1.el7.x86_64
(現在動作しているkernelのヘッダが見つからなかったよ。yum install kernel-devel-3.10.0-229.14.1.el7.x86_64コマンドを実行してみ)

なので、エラーメッージの指示に従って以下のコマンドを実行しました。

  1. sudo yum install gcc -y
  2. sudo yum install kernel-devel-3.10.0-229.14.1.el7.x86_64 -y

そして、最後に
3. sudo sh VBoxLinuxAdditions.run
を実行すると、エラーなくGuest Additionsがインストールできました。

念のため

最後に

  • VMを再起動してもエラーメッセージが出ないこと
  • /vagrantディレクトリがホスト側とのディレクトリと共有できていること

がを確認し、問題は解消されていました。

補足情報

今回問題が発生した動作条件は以下の通りです。

  • ホストOS : OS X El Capitan
  • VM : Virtual Box 5.0.6
  • ゲストOS : Cent OS 7.1
5
6
2

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
5
6