每个人电脑上安装的Virtualbox版本很可能不一样,vagrant up可能会有提示版本不兼容,导致host到guest共享目录模块失败,最终导致启动虚拟机后无法挂载共享目录。以下是启动时终端日志:
➜ homestead git:(master) vagrant up ==> default: Attempting graceful shutdown of VM... ==> default: Checking if box 'laravel/homestead' is up to date... ==> default: A newer version of the box 'laravel/homestead' is available! You currently ==> default: have version '0.4.4'. The latest is version '0.5.0'. Run ==> default: `vagrant box update` to update. ==> 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: 80 (guest) => 8000 (host) (adapter 1) default: 443 (guest) => 44300 (host) (adapter 1) default: 3306 (guest) => 33060 (host) (adapter 1) default: 5432 (guest) => 54320 (host) (adapter 1) default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> 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: Setting hostname... ==> default: Configuring and enabling network interfaces... ==> default: Mounting shared folders... default: /vagrant => /Users/feng/homestead 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
执行以下命令安装vagrant-vbguest,这个是vagrant的一个插件,需要联网下载,可能要等几分钟。
vagrant plugin install vagrant-vbguest
直到出现下面信息,即完成安装。
➜ homestead git:(master) vagrant plugin install vagrant-vbguest Installing the 'vagrant-vbguest' plugin. This can take a few minutes... Installed the plugin 'vagrant-vbguest (0.12.0)'!
然后重启即可
vagrant reload
好东西啊!收藏