Vagrant, Installing Virtualbox Guest Additions 5.0.30 - guest version is unknown


作者: 我不是鱼 (2016-12-28 13:44) 分类: Linux   标签: Vagrant VirtualBox Guest Additions guest version is unknown shared folders

不知道咋地,启动 vagrant 突然出错,昨天还是好好地,今天 vagrant up 后出现这个错误:

Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 5.0.30 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.30 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.30 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 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-327.22.2.el7.x86_64

Building the main Guest Additions module[FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)

主要是 Installing Virtualbox Guest Additions 5.0.30 - guest version is unknown 直接导致共享文件夹不成功

==> default: Rsyncing folder: /Users/Thomas/projects/lnmp.cn/ => /home/vagrant/sync
==> default: Mounting shared folders...
    default: /vagrant => /Users/Thomas/projects/lnmp.cn
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 dmode=755,fmode=755,uid=1000,gid=1000 vagrant /vagrant

The error output from the command was:

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

文件共享不进去,这个无法用vagrant的环境做开发,其实错误信息中有提示到如何解决:

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-327.22.2.el7.x86_64

Building the main Guest Additions module[FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)

重点是 yum install kernel-devel-3.10.0-327.22.2.el7.x86_64 其中 3.10.0-327.22.2.el7.x86_64  是 linux 操作系统的发行版号,所以这个和 uname -r 的结果是一致的,根据自己实际情况,不同的发行版会不同。

这个需要在 vagrant box 里边运行,虽然共享文件夹失败,但 box 是已经启动了的

登录 vagrant box

Thomass-MacBook-Pro:lnmp.cn Thomas$ vagrant ssh

切换到 root 或者 sudo 执行

[vagrant@localhost ~]$ sudo -s
[root@localhost vagrant]# yum install kernel-devel-3.10.0-327.22.2.el7.x86_64
No package kernel-devel-3.10.0-327.22.2.el7.x86_64 available.
Error: Nothing to do

发现没有这个安装包,后来我尝试了一下 kernel-devel, yum install kernel-devel 发现有,但是是不同的版本:kernel-devel-3.10.0-514.2.2.el7.x86_64 先安装看看吧,原以为问题解决,但还是一样的问题。那这就说明 不同的版本应该不行。那只能将它删掉 yum remove kernel-devel 然后再在网上找这个 rpm 包来安装。

下载

[root@localhost vagrant]# wget -c ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/7.0/x86_64/updates/security/kernel-devel-3.10.0-327.22.2.el7.x86_64.rpm

安装

[root@localhost vagrant]# rpm -ivh kernel-devel-3.10.0-327.22.2.el7.x86_64.rpm

完成后退出 vagrant, 再 reload vagrant

Thomass-MacBook-Pro:lnmp.cn Thomas$ vagrant reload

Virtualbox Guest Additions 安装成功,共享文件夹成功

Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 5.0.30 - guest version is 5.0.30
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.30 Guest Additions for Linux............
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module[  OK  ]
Building the shared folder support module[  OK  ]
Building the graphics driver module[  OK  ]
Doing non-kernel setup of the Guest Additions[  OK  ]
You should restart your guest to make sure the new modules are actually used


==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /Users/Thomas/projects/lnmp.cn/ => /home/vagrant/sync
==> default: Mounting shared folders...
    default: /vagrant => /Users/Thomas/projects/lnmp.cn

问题解决

前一篇: 从 PHP 7.0 升级到 PHP 7.1
后一篇: VirtualBox 静态文件(js, css 等)无法更新并在最后出现乱码


添加评论

昵称:


验证码