LoginSignup
29
26

More than 5 years have passed since last update.

Vagrantでディスクのマウントができない

Last updated at Posted at 2016-06-16

バージョンが上がっても、同じエラーが出ていたのでアップデートしときます。
なんだか、デフォルトの状態から、yum update -yってしたら起きる気がします。

centos-7.4は、こちらの記事 [https://qiita.com/ozawan/items/9751dcfd9bd4c470cd82] を試すとうまくいきました。そもそもこチラの記事の方が公式の対処方法なのかも?

boxファイル

  config.vm.box = "bento/centos-7.1"
  config.vm.box = "bento/centos-7.4"

CentOSのバージョン

CentOS Linux release 7.1.1503 (Core)
CentOS Linux release 7.5.1804 (Core)

エラーメッセージはみなさまと同じ。

==> default: Rsyncing folder: /自分のディレクトリ/www/ => /var/www
==> default:   - Exclude: [".vagrant/", ".git/"]
==> default: Mounting shared folders...
    default: /vagrant => /自分のディレクトリ/
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

ファイルシステムであるところのvboxsfがマウントできないと言われています。
ついでに、デバイスがないって言われているので vagrantってディレクトリがないんですかね?

aidanns/vagrant-reloadのIssueで同じようにマウントできないというIssueがあったのでそれを見たところ、Virtual Boxの設定で失敗しているせいとのことでした。

vboxのセットアップをし直すといいらしいです。/etc/init.d/vboxaddが存在しなかったのですが、CentOS7なので、init.dじゃないですね。
ここにありました。

[root@dev system]# ls -l /usr/lib/systemd/system/vboxadd*
-rw-r--r--. 1 root root 516  6月  7 15:54 /usr/lib/systemd/system/vboxadd-service.service
-rw-r--r--. 1 root root 420  6月  7 15:54 /usr/lib/systemd/system/vboxadd-x11.service
-rw-r--r--. 1 root root 476  6月  7 15:53 /usr/lib/systemd/system/vboxadd.service

systemctl setup vboxaddなどと実行してみましたが、そういうことではないみたいですね、、、。

/optにあるvboxaddのsetupをします。
すると、エラーが出ます。

sudo /opt/VBoxGuestAdditions-5.0.12/init/vboxadd setup
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module                   [FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions              [  OK  ]

/var/log/vboxadd-install.logをみます。

/var/log/vboxadd-install.log
/tmp/vbox.0/Makefile.include.header:115: *** Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.  Stop.
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

エラーメッセージでカーネルがっていわれているので、カーネルアップデートします。

sudo yum -y update kernel
sudo yum -y install kernel-devel kernel-headers dkms gcc gcc-c++

この状態で、ホストに戻り

vagrant reload

すると、マウントの所まで来たらAdditional Moduleのリビルドが始まります。

==> default: Machine booted and ready!
GuestAdditions versions on your host (5.0.12) and guest (5.0.6) do not match.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
## 省略
VirtualBox Guest Additions installer
Removing installed version 5.0.12 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
Building the main Guest Additions module[  OK  ]
Building the shared folder support module[  OK  ]
Building the OpenGL support module[  OK  ]
Doing non-kernel setup of the Guest Additions[  OK  ]
Starting the VirtualBox Guest Additions [  OK  ]
Installing the Window System drivers
## 省略
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /XxxXXXXXX/www/ => /var/www
==> default:   - Exclude: [".vagrant/", ".git/"]
==> default: Mounting shared folders...
    default: /vagrant => /XxxXXXXXX
    default: /usr/local/src/settings => /XxxXXXXXX/settings

って感じでビルドされてました。
その後セットアップが続きますが作業的にはこれで終わり。

29
26
0

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
29
26