7

我在 vagrant 中有一个小配置 shell 配置脚本(安装木偶失败的东西..)脚本:

#!/bin/bash
echo 'provisioning librarian'
gem install librarian-puppet
librarian-puppet install

运行良好,sh prescript.sh 但从 vagrant 配置失败:

D:/HashiCorp/Vagrant/embedded/gems/gems/net-scp-1.1.0/lib/net/scp.rb:385:in `awa
it_response_state': ☺scp: /tmp/vagrant-shell: Read-only file system (RuntimeErro
r)
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-scp-1.1.0/lib/net/scp.r
b:356:in `block (3 levels) in start_command'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/c
onnection/channel.rb:311:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/c
onnection/channel.rb:311:in `process'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/c
onnection/session.rb:217:in `block in preprocess'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/c
onnection/session.rb:217:in `each'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/c
onnection/session.rb:217:in `preprocess'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/c
onnection/session.rb:200:in `process'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/c
onnection/session.rb:164:in `block in loop'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/c
onnection/session.rb:164:in `loop'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/c
onnection/session.rb:164:in `loop'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/c
onnection/channel.rb:269:in `wait'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/net-scp-1.1.0/lib/net/scp.r
b:279:in `upload!'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commu
nicators/ssh/communicator.rb:105:in `block in upload'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commu
nicators/ssh/communicator.rb:331:in `block in scp_connect'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commu
nicators/ssh/communicator.rb:139:in `connect'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commu
nicators/ssh/communicator.rb:329:in `scp_connect'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commu
nicators/ssh/communicator.rb:99:in `upload'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/provi
sioners/shell/provisioner.rb:20:in `block (2 levels) in provision'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/provi
sioners/shell/provisioner.rb:14:in `tap'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/provi
sioners/shell/provisioner.rb:14:in `block in provision'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/provi
sioners/shell/provisioner.rb:78:in `with_script_file'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/provi
sioners/shell/provisioner.rb:12:in `provision'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/builtin/provision.rb:65:in `run_provisioner'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/builtin/provision.rb:53:in `block in call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/builtin/provision.rb:49:in `each'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/builtin/provision.rb:49:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/warden.rb:34:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/provi
ders/virtualbox/action/check_accessible.rb:18:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/warden.rb:34:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/runner.rb:61:in `block in run'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/u
til/busy.rb:19:in `busy'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/runner.rb:61:in `run'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/builtin/call.rb:51:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/warden.rb:34:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/runner.rb:61:in `block in run'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/u
til/busy.rb:19:in `busy'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/runner.rb:61:in `run'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/builtin/call.rb:51:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/warden.rb:34:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/builtin/config_validate.rb:25:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/warden.rb:34:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/provi
ders/virtualbox/action/check_virtualbox.rb:17:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/warden.rb:34:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/builder.rb:116:in `call'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/runner.rb:61:in `block in run'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/u
til/busy.rb:19:in `busy'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/a
ction/runner.rb:61:in `run'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/m
achine.rb:147:in `action'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/comma
nds/provision/command.rb:26:in `block in execute'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/p
lugin/v2/command.rb:182:in `block in with_target_vms'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/p
lugin/v2/command.rb:180:in `each'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/p
lugin/v2/command.rb:180:in `with_target_vms'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/comma
nds/provision/command.rb:25:in `execute'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/c
li.rb:46:in `execute'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/e
nvironment.rb:467:in `cli'
        from D:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.2.2/bin/vagrant:8
4:in `<top (required)>'
        from D:/HashiCorp/Vagrant/bin//../embedded/../embedded/gems/bin/vagrant:
23:in `load'
        from D:/HashiCorp/Vagrant/bin//../embedded/../embedded/gems/bin/vagrant:
23:in `<main>'

遵循此处的建议,我已经更改(使用 sublimetext2)以 unix 结尾的 windows 行。但仍然没有任何想法

4

3 回答 3

7

一些可能性:

您可能在 VirtualBox 中使用不支持符号链接的共享文件夹(除非已修复)。据说VBoxManage现在有一个命令可以解决这个问题,比如

VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1

或者这个进入 Vagrant 文件(假设 SHARE_NAME 在这个文件中是 v-root ):

config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]

For more possibilities see: https://www.virtualbox.org/ticket/10085#comment:12 or a long forum on the topic at https://github.com/mitchellh/vagrant/issues/713

Another possibility is that you might be running the script so early in the boot process that the root (or possibly just the /tmp) filesystem hasn't been remounted in read/write mode, say, if the script is being run from one of the /etc/rc.2/S(num)(name) scripts and the (num) is too low.

于 2013-07-19T06:14:28.727 回答
1

I just ran into this error while vagrant uping a virtual machine. In my case, the problem appears to be that a previous copy of the virtual machine was running in the background. Some history:

  • A VM for this same project had previously crashed (hours before) and I had to close the terminal window (macOS) and restart the VM (using vagrant halt + vagrant up).
  • This appeared to fix things and I proceeded along normally and forgot about it.
  • Later, after I made a change to the Vagrantfile and wanted to make sure everything worked, I destroyed the VM and vagrant uped a new one, only to run into this error.
  • After reading the answer by @AlexNorth-Keys, I remembered the fact that the VM had previously crashed so I decided to restart my computer and then everything worked. I'm pretty sure that a copy of the crashed VM must have been running in the background and it's sharing of the project folders was causing issues.

Obviously this is just a guess, but restarting the host machine fixed the issue.

于 2017-06-26T21:39:36.083 回答
0

In my case the reason was /etc/fstab got modified on Vagrant instance. If you also played with this file and got into trouble, here is possible solution:

  1. vagrant ssh
  2. mount -o remount,rw /
  3. now edit the file /etc/fstab, eg. nano /etc/fstab
  4. provide needed changes (for example remove nolock option)
  5. exit vagrant
  6. vagrant reload
于 2020-06-24T10:03:41.850 回答