概述
背景
类型
环境
概述
思路
配置
# vagrant init 已经执行
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64"
# 这是我添加的共享目录
config.vm.synced_folder "vagrant-data", "/vagrant_data",
create: true,
id: "data"
end
命令
> vagrant up
结果
配置
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64"
# 这是我添加的共享目录
config.vm.synced_folder "vagrant-data", "/vagrant_data",
create: true,
id: "data"
# 关闭默认的共享目录
config.vm.synced_folder ".", "/vagrant",
disabled: true
end
命令
> vagrant reload
结果
概述
问题
概述
问题
尝试1: destroy 后再 up
操作
> vagrant destroy
> vagrant up
> vagrant ssh
结果
结论
尝试2: 百度
操作
结果
各路结果都是要检查 ssh
但是 ssh 我碰都没碰过
概述
尝试3: 既然虚拟机启动了, 为什么不 ssh 去看看
操作
结果
概述
初步结论
下一步
概述
操作
结果
概述
操作
结果
概述
操作
结果
概述
操作
结果
一下操作, 可能会使得 vagrant 重启时, 卡在 fsck
所以, 这是为啥呢?
概述
准备
mount
fstab
vagrant 的启动日志
概述
比对: 启动超时 和 启动成功 的日志
概述
结论
原因
机制
办法
建议
修改存储配置
场景
解决
后续
ref
日志
vagrant
# 失败: ssh 超时
$ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box ‘hashicorp/precise64‘ version ‘1.1.0‘ 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: 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: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. 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.
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.
# 成功: 我赶在超时之前, 登上了 vagrant 虚机, 手动跳过了 fsck
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box ‘hashicorp/precise64‘ version ‘1.1.0‘ 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: 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: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 4.2.0
default: VirtualBox Version: 6.1
==> default: Mounting shared folders...
default: /vagrant => G:/VagrantVMs/vagrant_book_example
default: /vagrant_data => G:/VagrantVMs/vagrant_book_example/vagrant-data
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
precise64
# 虚机启动时, 卡住的日志
fsck from util-linux 2.20.1
fsck from util-linux 2.20.1
dev/mapper/precise64-root: clean, 61688/5185536 files, 597883 20711424 blocks
/dev/sda1: clean, 230/124496 files, 40607/248832 blocks
rpcbind: Cannot open ‘/run/rpcbind/rpcbind.xdr‘ file for reading, errno 2 (No such file or directory)
rpcbind: Cannot open ‘/run/rpcbind/portmap.xdr‘ file for reading, errno 2 (No such file or directory)
/sbin/mount.vboxsf : mounting failed with the error: Protocol error
mountall: mount /uagrant [458] term inated with status 1
mountall: Filesystem could not be mounted: /vagrant
Am error occurred while mounting /uagrant.
Press S to skip mounting or M for manual recovery
vagrant - 问题: 修改 共享目录, 导致 vagrant ssh 失败
原文:https://www.cnblogs.com/xy14/p/13974940.html