hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.28k stars 4.43k forks source link

Virtualbox 5.1.28 regression with Vagrant 2.0.0 failed to mount VirtualBox shared folders #8990

Closed MacFlurry closed 7 years ago

MacFlurry commented 7 years ago

Hello,

OS :macOS Sierra

Vagrant 2.0.0 vagrant-share (1.1.9, system)

Virtualbox Version 5.1.28 r117968 (Qt5.6.2)

vagrant up failed to mount VirtualBox shared folders.

this is the message :

 Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
 Mounting Virtualbox Guest Additions ISO to: /mnt
 mount: /dev/loop0 is write-protected, mounting read-only
 Installing Virtualbox Guest Additions 5.1.28 - guest version is unknown
 Verifying archive integrity... All good.
 Uncompressing VirtualBox 5.1.28 Guest Additions for Linux...........
 VirtualBox Guest Additions installer
 Copying additional installer modules ...
 Installing additional modules ...
 vboxadd.sh: Starting the VirtualBox Guest Additions.
 Failed to set up service vboxadd, please check the log file
 /var/log/VBoxGuestAdditions.log for details.
 An error occurred during installation of VirtualBox Guest Additions 5.1.28. Some functionality may not work as intended.
 In most cases it is OK that the "Window System drivers" installation failed.
 Redirecting to /bin/systemctl start  vboxadd.service
 Job for vboxadd.service failed because the control process exited with error code. See "systemctl status vboxadd.service" and "journalctl -xe" for details.
 Unmounting Virtualbox Guest Additions ISO from: /mnt
 ==> default: Checking for guest additions in VM...
     default: No guest additions were detected on the base box for this VM! Guest
     default: additions are required for forwarded ports, shared folders, host only
     default: networking, and more. If SSH fails on this machine, please install
     default: the guest additions and repackage the box to continue.
     default:
     default: This is not an error message; everything may continue to work properly,
     default: in which case you may ignore this message.
 ==> default: Setting hostname...
 ==> default: Configuring and enabling network interfaces...
     default: SSH address: 127.0.0.1:2222
     default: SSH username: vagrant
     default: SSH auth method: private key
 ==> default: Rsyncing folder: /Users/lion/web/VirtualBOX/Vagrant_projects/prog_php/ => /vagrant
 ==> default: Mounting shared folders...
     default: /var/www/html/yii2 => /Users/lion/web/VirtualBOX/Vagrant_projects/prog_php/yii2

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=1000,gid=1000 var_www_html_yii2 /var/www/html/yii2

The error output from the command was:

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

This is my vagrant file:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = "centos/7"
    config.vm.hostname = "vagrantbox"

    config.vm.network :forwarded_port, host: 80, guest: 80, auto_correct: true # web
    config.vm.network :forwarded_port, guest: 443, host: 443, auto_correct: true # ssl
    config.vm.network :forwarded_port, guest: 3306, host: 3306, auto_correct: true # mysql
    config.vm.network :private_network, ip: "10.0.0.15"
    config.vm.synced_folder "yii2/", "/var/www/html/yii2", create: true

    config.vm.provider "virtualbox" do |vb|
        vb.gui = false
        vb.customize ['modifyvm', :id, '--memory', '512']
        vb.customize ["modifyvm", :id, "--cpus", "1"]
        vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
    end

    config.vm.provision "ansible" do |ansible|
        ansible.playbook = "ansible/playbook.yml"
        ansible.sudo = true
        #ansible.inventory_path = "playbooks"
    end
    class RedHatGuestAdditionsInstaller < VagrantVbguest::Installers::Linux
      def install(opts = nil, &block)
        communicate.sudo('yum update -y && yum install -y kernel-headers kernel-devel gcc make perl bzip2', opts, &block)
        super
      end
    end
    config.vm.provision :shell, inline: "check it on http://10.0.0.5"
end
chrisroberts commented 7 years ago

It is likely the guest additions are not available within that box. Using a bento box will likely resolve this issue (bento/centos-7.2 or bento/centos-7.3)

Cheers!

MacFlurry commented 7 years ago

Hello Chris,

I tried bento/centos-7.2 and 7.3

failed on timeout trying to connect to ssh.

default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

I added this in my vagrant file vb.customize ["modifyvm", :id, "--cableconnected1", "on"] according to several issues encountered with bento, but no way.

:(

MacFlurry commented 7 years ago

So I switched back to centos/7 and added the type to my config.vm.synced_folder config.vm.synced_folder "yii2/", "/var/www/html/yii2", create: true, type: "nfs" now it works.

Conclusion: it's really a regression because it worked before without changing the synced_folder to nfs.

cheeseplus commented 7 years ago

Bento maintainer here, the problem with using 7.2 is that it's fairly old and was built with almost definitely incompatible guest tooling. It's not just using bento/centos-7.3 even as you need to make sure you have the latests (or at least compatible) version with current tooling. The cableconnected workaround only matters if you're using older versions of Vagrant.

I've just validated the following configuration: macOS 10.12.6 Vagrant 2.0.0 VirtualBox 5.1.28 bento/centos-7.3 201708.22.0 (2.3.8 also works fine)

Asserting this is a regression because it worked before here is very tricky as the version of VirtualBox Guest Tools of the specific version of box plus Virtualbox + Vagrant versions all must align.

Also, vagrant-vbguest causes as many problem as it solves often and that appears to be the issue in your first posting.

MacFlurry commented 7 years ago

an Update. ( @cheeseplus you're not in High Sierra )

macOS 1O.13 High Sierra ( works before in 10.12 ) Vagrant 2.0.0 VirtualBox 5.1.28 bento/centos-7.3 201708.22.0 => timeout issue With centos/7 box ( version 1708.01 => newly updated) and it works.

So the issue was on centos/7 boxes and their update solved the issue.

Sorry for not spotting on it earlier https://seven.centos.org/2017/09/updated-centos-vagrant-images-available-v1708-01/

Best regards

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.