MetaPii 技術室

あなたの知恵と思いを検索するフラッシュメモアプリMetaPiiのエンジニアブログです。

vagrantが起動しない (file system with error)

いやぁ、もうだめかと思いました。 3−4時間かかりました、一時はPC買い替えも覚悟しました。

ここにたどり着いた皆様も、おそらくすでにいろんなパターンを試されてだめだったのでしょう。 私のケースは以下で解決しました

問題

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/ubuntu-18.04' version '201912.03.0' is up to date...
==> default: A newer version of the box 'bento/ubuntu-18.04' for provider 'virtualbox' is
==> default: available! You currently have version '201912.03.0'. The latest is version
==> default: '202003.31.0'. Run `vagrant box update` to update.
==> 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: You are trying to forward to privileged ports (ports <= 1024). Most
==> default: operating systems restrict this to only privileged process (typically
==> default: processes running as an administrative user). This is a warning in case
==> default: the port forwarding doesn't work. If any problems occur, please try a
==> default: port higher than 1024.
==> default: Forwarding ports...
    default: 80 (guest) => 80 (host) (adapter 1)
    default: 443 (guest) => 443 (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
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.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

ssh keyのところで止まるため、鍵問題かと思ったですが、vboxから直接立ち上げてみると... f:id:continue1:20200411105736p:plain

f:id:continue1:20200411105944p:plain

/dev/mapper/vagrant--vg-root contains a file system with errors, check forced.
/dev/mapper/vagrant--vg-root: UNEXPECTED INCONSISTENCY; RUN fsck manually 

そもそもファイルシステムに問題あることが原因のようでした。

対処

上図vboxの黒い画面上(ash上)で

fsck /dev/mapper/vagrant--vg-root

と打ち込み手動でファイルシステムを修復させます。 途中、いろいろ質問されますが、とりあえず私は全部Yesにしときました。 復活すればなんだっていい、言いなりです。

あとは、

vagrant up

でOK。まずはファイルシステム問題解決です

注意点

ファイルシステム修復後、vagrant upするとssh keyのところで

==> 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 reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...

というふうにかなり待たされますがご安心ください。 5分くらいまでば起動します。

参考記事

感服です。

github.com