-->

Failed to mount folders in Linux guest - mesg: tty

2019-07-27 21:58发布

问题:

Vagrant won't mount folders. Tried so many solutions, nothing worked.

Versions: Vagrant 1.8.1 / Ubuntu 15.10 / Virtualbox 5.0.16

vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/wily64' 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: 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: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
GuestAdditions 5.0.16 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/User/www/magento-box
    default: /vagrant-magento-box-folder => C:/Users/User/www/magento-box-folder
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 www-data | cut -d: -f3`,dmode=775, fmode=664 vagrant-magento-box-folder /vagrant-magento-box-folder
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g www-data`,dmode=775, fmode=664 vagrant-magento-box-folder /vagrant-magento-box-folder

The error output from the last command was:

mesg: ttyname failed: Inappropriate ioctl for device

In Vagrantfile.config.yml synced folders:

synced_folder:
  host_path: "/Users/User/www/magento-box-folder"
  guest_path: "/vagrant-magento-box-folder/"

Vagrantfile

require 'yaml'
vagrantConfig = YAML.load_file 'Vagrantfile.config.yml'
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"

config.vm.network "private_network", 
ip: vagrantConfig['ip']

    config.vm.synced_folder "#{vagrantConfig['synced_folder']['host_path']}", 
    "#{vagrantConfig['synced_folder']['guest_path']}", 
    owner: "vagrant", 
    group: "www-data", 
    mount_options:["dmode=775, fmode=664"]

# VirtualBox specific settings
    config.vm.provider "virtualbox" do |vb|
    vb.gui = false
    vb.memory = "2048"
    vb.cpus = 2
end

In vagrant ssh I did

sudo ln -s /opt/VBoxGuestAdditions-5.0.16/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions 

I replaced VBoxGuestAdditions.iso in tmp

Copy iso fileC:\Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso

Installed vbguest. Have no idea how to solve it..

回答1:

Here is one important reason why error occurred vagrant up

If you use Virtual Box to Vagrant's provider, you have to reinstall 'Guest Additions' that everytime you create virtual machine's kernel.

vbguest plugin is a good solution for solving this issue.

( about vbguest plugin - https://github.com/dotless-de/vagrant-vbguest )

first, you have to install vbguest plugin.

$ vagrant plugin install vagrant-vbguest

and run Vagrant

$ vagrant halt

$ vagrant up

or use too

vagrant reload



回答2:

This seems to be a problem with vagrant <= 1.8.4. I did an update to the latest vagrant version (in my case 1.9.3) and everything seems fine again.

  1. Get the latest vagrant version here: https://www.vagrantup.com/docs/installation/upgrading.html

2.

vagrant halt

3. Install upgrade.

4.

vagrant up