vagrant shell脚本失败,出现无法解释的错误```只读文件系统(runtimeerror)```

时间:2013-07-10 16:15:49

标签: vagrant

我在vagrant中有一个小的配置shell配置脚本(安装一些puppet无法...) 脚本:

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

sh prescript.sh运行正常 但是从流浪汉配置失败了:

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>'

以下建议here我已经改变了(使用sublimetext2)windows行结束到unix。但仍然失败 任何想法

3 个答案:

答案 0 :(得分: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"]

有关更多可能性,请参阅:https://www.virtualbox.org/ticket/10085#comment:12或关于此主题的长篇论坛https://github.com/mitchellh/vagrant/issues/713

另一种可能性是你可能在启动过程中如此早地运行脚本,以至于根目录(或者可能只是/ tmp)文件系统尚未以读/写模式重新装入,例如,如果脚本正在运行从/etc/rc.2/S(num)(name)脚本之一和(num)太低。

答案 1 :(得分:1)

我在 vagrant up 虚拟机时遇到此错误。就我而言,问题似乎是虚拟机的先前副本在后台运行。一些历史:

  • 此同一个项目的虚拟机之前已经崩溃(数小时前),我不得不关闭终端窗口(macOS)并重新启动虚拟机(使用vagrant halt + vagrant up)。
  • 这似乎解决了问题,我正常地继续前进并忘记了它。
  • 后来,在我对Vagrantfile进行了更改并想确保一切正常后,我销毁了VM并vagrant up编了一个新的,只是遇到了这个错误。
  • 在阅读@ AlexNorth-Keys的答案之后,我记得虚拟机先前已经崩溃,所以我决定重新启动计算机然后一切正常。我非常确定崩溃的VM的副本必须在后台运行,并且它共享项目文件夹会导致问题。

显然这只是猜测,但重新启动主机可以解决问题。

答案 2 :(得分:0)

在我的情况下,原因是在Vagrant实例上修改了/ etc / fstab。 如果您还玩了这个文件并且遇到麻烦,可以采取以下解决方法:

  1. 无用的ssh
  2. mount -o remount,rw /
  3. 现在编辑文件/ etc / fstab,例如。 nano / etc / fstab
  4. 提供所需的更改(例如,删除 nolock 选项)
  5. 流浪汉
  6. 无用重新加载