‘vagrant up’ fails to mount linked directory /vagrant
7 月.07, 2015 in MIS
在 vagrant 啟動 CentOS 6 的 VM 時,忽然出現了無法掛載 /vagrant 目錄的錯誤訊息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | $ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'chef/centos-6.6' 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: Forwarding ports... default: 80 => 8080 (adapter 1) default: 22 => 2222 (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 timeout. Retrying... default: Warning: Remote connection disconnect. Retrying... default: Warning: Remote connection disconnect. Retrying... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => /Users/bestlong/projects/vagrant_vms/chef-centos-66 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=<code>id -u vagrant |
,gid=
1 | getent group vagrant | cut -d: -f3 |
vagrant /vagrant
mount -t vboxsf -o uid=
1 | id -u vagrant |
,gid=
1 | id -g vagrant |
vagrant /vagrant
The error output from the last command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
這是因為在 Guest os 環境內有執行系統更新,因為更新的範圍有包含到 kernal 的部分,所以造成 VirtualBox 的系統工具程式就出問題了。
這時只需要重新安裝一次 VirtualBox Guest Additions kernel modules 應該就可以解決,首先要確認相關的套件都有安裝免得編譯失敗,請執行下列指令:
1 2 | [root@localhost ~]# yum update -y [root@localhost ~]# yum install kernel-devel-$(uname -r) kernel-headers-$(uname -r) dkms -y |
再來就是安裝 VirtualBox Guest Additions kernel modules
1 2 3 4 5 6 7 | [root@localhost ~]# /etc/init.d/vboxadd setup Removing existing VirtualBox DKMS kernel modules [ OK ] Removing existing VirtualBox non-DKMS kernel modules [ OK ] Building the VirtualBox Guest Additions kernel modules [ OK ] Doing non-kernel setup of the Guest Additions [ OK ] Starting the VirtualBox Guest Additions [ OK ] [root@localhost ~]# |
再來就可以重新啟動 Guest OS 確認啟動過程,應該就可以正常掛載 /vagrant 目錄了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | $ vagrant reload ==> default: Attempting graceful shutdown of VM... ==> default: Checking if box 'chef/centos-6.6' 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: Forwarding ports... default: 80 => 8080 (adapter 1) default: 22 => 2222 (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 timeout. Retrying... default: Warning: Remote connection disconnect. Retrying... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => /Users/bestlong/projects/vagrant_vms/chef-centos-66 ==> default: Machine already provisioned. Run <code>vagrant provision |
or use the
1 | --provision |
==> default: to force provisioning. Provisioners marked to run always will still run.
參考資料
Tags: vagrant