Vagrant GuestAdditions似乎正确安装(5.1.20),但未运行

时间:2017-08-15 14:59:33

标签: oracle vagrant virtual-machine virtualbox

我想将我的Windows机器上的整个文件夹复制到vm托管的ubuntu / trusty64。

但是每当我试图把我的流浪汉带上来时,我都会收到以下错误信息。

vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' 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: 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: Configuring proxy for Apt...
==> default: Configuring proxy environment variables...
[default] GuestAdditions seems to be installed (5.1.20) correctly, but not running.
vboxadd: unrecognized service
vboxadd-service: unrecognized service
bash: line 4: setup: command not found
==> default: Checking for guest additions in VM...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

 setup

Stdout from the command:



Stderr from the command:

bash: line 4: setup: command not found

注意:
Ubuntu版本是最新的,你可以在第三行看到。
Vagrant版本:Vagrant 1.9.3
Windows版本:Windows 7企业服务包1 Oracle VirtualBox版本:版本5.1.20 r114628(Qt5.6.2)

在运行命令vbguest status i get

$ vagrant vbguest --status
[default] GuestAdditions seems to be installed (5.1.20) correctly, but not running.

我的流浪文件内容是

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "ubuntu/trusty64"
  config.ssh.insert_key = false
  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.vm.network "private_network", ip: "xxxxx"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  #config.vm.synced_folder "../data", "/vagrant_data" , "/vagrant"
  config.vm.synced_folder ".", "/mydata", :mount_options => ['dmode=775','fmode=664']
  #config.vm.synced_folder "./", "/vagrant", id: "vagrant-root", type: "nfs"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
  # such as FTP and Heroku are also available. See the documentation at
  # https://docs.vagrantup.com/v2/push/atlas.html for more information.
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
  if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy.http      = "xxxxx"
    config.proxy.https     = "xxxxx"
    config.proxy.ftp       = "xxxxx"
    config.apt_proxy.http  = "xxxxx"
    config.apt_proxy.https = "xxxxx"
    config.proxy.no_proxy  = "xxxxx"
  end

  if !Vagrant.has_plugin?("vagrant-proxyconf") 
    system('vagrant plugin install vagrant-proxyconf')     
    raise("vagrant-proxyconf installed. Run command again.");
  end

end

请建议
1.我该如何纠正这个错误?
2.将完整文件夹从Windows共享到vm?

1 个答案:

答案 0 :(得分:0)

使用WinSCP连接来宾VM。从主机复制VBoxGuestAddition.iso。在我的例子中,VBoxGuestAddition存在于C:\ ProgramFiles \ Oracle \ VirtualBox中。

将iso文件复制到Guest VM后,使用putty登录GUest VM。

mkdir /media/GuestAdditionsISO

然后执行以下命令

mount -o loop /path/of/VBoxGuestAddition.iso /media/GuestAdditionsISO

成功执行mount命令后,

cd /media/GuestAdditionsISO
sudo ./VBoxLinuxGuestAddition.run

然后重新启动VM。这对我有用