FPGA開発日記

カテゴリ別記事インデックス https://msyksphinz.github.io/github_pages , English Version https://fpgadevdiary.hatenadiary.com/

Vagrantをupしても失敗する場合の対処法調査

最近自宅で使用しているVagrantで、vagrant up中に以下のようなエラーメッセージが表示されるようになった。

$ vagrant.exe up
Bringing machine 'default' up with 'virtualbox' provider...
==> 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: Forwarding ports...
    default: 22 => 2222 (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: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. 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.

GUIモードで、何が起きているかを確認する。

このためには、Vagrantfileのvb.guiを有効化する。

    vb.gui = true

あれ、GUIモードだとログイン画面まで来てしまった。

f:id:msyksphinz:20151226133403p:plain

ちゃんとログインすることもできる(一回失敗した)

f:id:msyksphinz:20151226133502p:plain

しかし、CUIからは相変わらずログインできないし、vagrant sshでもまったく反応しない。

$ vagrant.exe ssh

$

内側でサービスを立ち上げてみたものの、変化はなかった。

環境変数を設定して何が起きているのかを確認する

今度は、VAGRANT_LOG=DEBUG環境変数を設定して、ログを観察してみよう。

VAGRANT_LOG=DEBUG vagrant up

以下のようなログが何度も表示されている。これはどういう意味だ?

GuestAdditionsVersion="4.3.26_Ubuntu r98988"
GuestAdditionsFacility_VirtualBox Base Driver=50,1451105996767
GuestAdditionsFacility_VirtualBox System Service=50,1451106000642
GuestAdditionsFacility_Seamless Mode=0,1451105996767
GuestAdditionsFacility_Graphics Mode=0,1451105996767
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 0
DEBUG virtualbox_4_3:   - [1, "ssh", 2222, 22]
DEBUG virtualbox_4_3:   - [1, "tcp2223", 2223, 22]
 INFO ssh: Attempting SSH connection...
 INFO ssh: Attempting to connect to SSH...
 INFO ssh:   - Host: 127.0.0.1
 INFO ssh:   - Port: 2222
 INFO ssh:   - Username: vagrant
 INFO ssh:   - Password? false
 INFO ssh:   - Key Path: ["C:/usr/work/vagrant-env/vagrant-mips51/.vagrant/machines/default/virtualbox/private_key"]
DEBUG ssh: == Net-SSH connection debug-level log START ==
DEBUG ssh: D, [2015-12-26T14:01:39.678660 #9644] DEBUG -- net.ssh.transport.session[13bf1f8]: establishing connection to 127.0.0.1:2222
D, [2015-12-26T14:01:39.680616 #9644] DEBUG -- net.ssh.transport.session[13bf1f8]: connection established
I, [2015-12-26T14:01:39.681594 #9644]  INFO -- net.ssh.transport.server_version[13be5a4]: negotiating protocol version
D, [2015-12-26T14:01:39.699219 #9644] DEBUG -- net.ssh.transport.server_version[13be5a4]: remote is `SSH-2.0-OpenSSH_6.7p1 Ubuntu-5ubuntu1'
D, [2015-12-26T14:01:39.700168 #9644] DEBUG -- net.ssh.transport.server_version[13be5a4]: local is `SSH-2.0-Ruby/Net::SSH_2.9.2 i386-mingw32'
D, [2015-12-26T14:01:39.721674 #9644] DEBUG -- tcpsocket[13beb20]: read 0 bytes
D, [2015-12-26T14:03:17.892737 #9644] DEBUG -- net.ssh.transport.server_version[13b2850]: local is `SSH-2.0-Ruby/Net::SSH_2.9.2 i386-mingw32'
D, [2015-12-26T14:03:17.907398 #9644] DEBUG -- tcpsocket[13b3228]: read 0 bytes

DEBUG ssh: == Net-SSH connection debug-level log END ==
 INFO ssh: SSH not ready: #<Vagrant::Errors::SSHDisconnected: The SSH connection was unexpectedly closed by the remote end. This
usually indicates that SSH within the guest machine was unable to
properly start up. Please boot the VM in GUI mode to check whether
it is booting properly.>
 INFO subprocess: Starting process: ["C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe", "showvminfo", "228964fb-bd31-4370-8e2b-a78ba3cc512e", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...

ってか、

INFO ssh: SSH not ready: #<Vagrant::Errors::SSHDisconnected: The SSH connection was unexpectedly closed by the remote end. This usually indicates that SSH within the guest machine was unable to properly start up. Please boot the VM in GUI mode to check whether it is booting properly.

って言われてもなあ。

コネクションに問題があるならば、 config.ssh.timeoutの数値をもっと上げてみようか。

blog.shibayu36.org

docs-v1.vagrantup.com

と思ったらvagrant.ssh.timeout はオプションとして無くなっていたね。残念。

とりあえず、現在では再インストールしか打つ手がない。うーん。