13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vagrant up時にGuestAdditionsがnot runningになる場合、ゲストマシンのkernelをupdateすることで解決できる可能性がある

Last updated at Posted at 2017-06-10

version

ホストマシン
  • windows7
  • Vagrant 1.9.0
  • VirtualBox 5.1.22
  • GuestAdditions 5.1.22
ゲストマシン
  • CentOS 7
  • kernel すみません不明です
  • GuestAdditions 5.1.22

エラーの内容

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'lamudi/centos-7.0' 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: 3000 (guest) => 3000 (host) (adapter 1)
    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: Machine booted and ready!
[default] GuestAdditions seems to be installed (5.1.22) correctly, but not running.
Redirecting to /bin/systemctl start  vboxadd.service
chcon: can't apply partial context to unlabeled file ‘/usr/lib64/VBoxGuestAdditions/mount.vboxsf’
vboxadd.sh: Starting the VirtualBox Guest Additions.
vboxadd.sh: failed: modprobe vboxsf failed.

Could not find the X.Org or XFree86 Window System, skipping.
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: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> 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:/projects/hoge
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=1001,gid=1001 vagrant /vagrant

The error output from the command was:

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

  • GuestAdditions seems to be installed (5.1.22) correctly, but not running.となっている
  • この状態ではゲストマシン側で共有フォルダの設定(mount)が出来ない

原因

  • ホストマシンとゲストマシンのそれぞれのGuestAdditionsのversionが異なっていた
  • ホストマシンとゲストマシンのそれぞれのGuestAdditionsのversionが異なる場合、vagrant up時に自動でゲストマシン側がホストマシン側のversionに合わせるように更新される(※上記のエラー内容は何度か再起動を繰り返したものなので更新に関するログは含まれていないです)
  • これだけではGuestAdditionsが機能するには十分ではない場合がある
  • 自分の場合はゲストマシンのkernelのversionも更新しないと上記のエラーが出るようだった

回避策

  • ゲストマシンに入ってkernelのversionの更新する
[vagrant@localhost ~]$ sudo yum update
  • ゲストマシンを再起動
$ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'lamudi/centos-7.0' 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: 3000 (guest) => 3000 (host) (adapter 1)
    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: Machine booted and ready!
[default] GuestAdditions 5.1.22 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/projects/hoge
    default: /home/hoge => C:/projects/hoge
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

  • GuestAdditions 5.1.22 running --- OK.となったのが確認できた
13
11
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
13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?