4
3

More than 3 years have passed since last update.

Vagrantがマウントに失敗するときの対処法 ~mounting failed~

Last updated at Posted at 2019-08-27

内容

Vagrantまわりをいろいろと弄っているとマウントに失敗したという下記に記載の通りのエラー文が出たのでその解決の忘備録

環境

Windows10
VirtulBox 6.0.4r128413
Vagrant 2.2.4
bento/centos-6.8 (virtualbox, 2.3.4)

問題のエラー文

> 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

原因

参考にしたサイト

解決策

  • https://www.task-notes.com/entry/20150714/1436842800

    vagrant-vbguest のプラグインをいれておけば、自分の環境の VirtualBox のバージョンと Box にインストールされている Guest Addition のバージョンが違う場合に、VirtualBox のバージョンに合わせて最新化してくれるというもの

  • 上記参考URLに従い、vagrant-vbgusetというpluginをインストールしてvbguestを実行すれば解決

pluginのインストール

> vagrant plugin install vagrant-vbguest

# 出力結果
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.19.0)'!

vbguestの実行

> vagrant vbguest

# 出力結果
[default] GuestAdditions versions on your host (6.0.4) and guest (5.1.18) do not match.
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.jaist.ac.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.jaist.ac.jp
 * remi-safe: ftp.riken.jp
 * updates: ftp.jaist.ac.jp
パッケージ gcc-4.4.7-23.el6.x86_64 はインストール済みか最新バージョンです
パッケージ binutils-2.20.51.0.2-5.48.el6_10.1.x86_64 はインストール済みか最新バージョンです
パッケージ 1:make-3.81-23.el6.x86_64 はインストール済みか最新バージョンです
パッケージ 4:perl-5.10.1-144.el6.x86_64 はインストール済みか最新バージョンです
パッケージ bzip2-1.0.5-7.el6_0.x86_64 はインストール済みか最新バージョンです
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package kernel-devel.x86_64 0:2.6.32-754.11.1.el6 will be インストール
---> Package kernel-devel.x86_64 0:2.6.32-754.18.2.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

================================================================================
 パッケージ         アーキテクチャ
                                 バージョン                 リポジトリー   容量
================================================================================
インストールしています:
 kernel-devel       x86_64       2.6.32-754.11.1.el6        updates        11 M
 kernel-devel       x86_64       2.6.32-754.18.2.el6        updates        11 M

トランザクションの要約
================================================================================
インストール         2 パッケージ

総ダウンロード容量: 22 M
インストール済み容量: 52 M
パッケージをダウンロードしています:
--------------------------------------------------------------------------------
合計                                            1.0 MB/s |  22 MB     00:21
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : kernel-devel-2.6.32-754.11.1.el6.x86_64         1/2
  インストールしています  : kernel-devel-2.6.32-754.18.2.el6.x86_64         2/2
  Verifying               : kernel-devel-2.6.32-754.18.2.el6.x86_64         1/2
  Verifying               : kernel-devel-2.6.32-754.11.1.el6.x86_64         2/2

インストール:
  kernel-devel.x86_64 0:2.6.32-754.11.1.el6
  kernel-devel.x86_64 0:2.6.32-754.18.2.el6

完了しました!
Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
Installing Virtualbox Guest Additions 6.0.4 - guest version is 5.1.18
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.0.4 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.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: Building the modules for kernel
2.6.32-754.11.1.el6.x86_64.
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Starting.
chcon: can't apply partial context to unlabeled file `/opt/VBoxGuestAdditions-6.0.4/src/vboxguest-6.0.4/build_in_tmp'
Unmounting Virtualbox Guest Additions ISO from: /mnt
Guest Additions got installed. However, they seem not be loaded correctly. Please restart the box running `vagrant reload default`

リロード

  • 上記出力結果の最後にvagrant reload defaultとあるので従う
> vagrant reload default

# 出力結果
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'bento/centos-6.8' version '2.3.4' 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: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
==> default: Machine booted and ready!
[default] GuestAdditions seems to be installed (6.0.4) correctly, but not running.
VirtualBox Guest Additions: Starting.
chcon: can't apply partial context to unlabeled file `/opt/VBoxGuestAdditions-6.0.4/src/vboxguest-6.0.4/build_in_tmp'
chcon: can't apply partial context to unlabeled file `/opt/VBoxGuestAdditions-6.0.4/src/vboxguest-6.0.4/build_in_tmp'
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: Building the modules for kernel
2.6.32-754.11.1.el6.x86_64.
chcon: can't apply partial context to unlabeled file `/opt/VBoxGuestAdditions-6.0.4/other/mount.vboxsf'
VirtualBox Guest Additions: Running kernel modules will not be replaced until
the system is restarted
VirtualBox Guest Additions: Starting.
chcon: can't apply partial context to unlabeled file `/opt/VBoxGuestAdditions-6.0.4/src/vboxguest-6.0.4/build_in_tmp'
Restarting VM to apply changes...
==> default: Attempting graceful shutdown of VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/{XXX}/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.

おわり

4
3
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
4
3