2013-07-18 22 views
2

我已经开始使用Vagrant。我在重新启动虚拟机时遇到了一些问题。 我Vagrantfile是:sudo在流浪者重启后丢失连接

Vagrant.configure("2") do |config 
config.vm.box = "precise32" 
config.vm.box_url = "http://files.vagrantup.com/precise32.box" 

我通过SSH流浪汉打开SSH。现在,如果我给"sudo reboot"与虚拟机的连接已关闭。我收到以下内容:

[email protected]:~$ sudo reboot 
[email protected]:~$ 
Broadcast message from [email protected] 
    (/dev/pts/0) at 9:43 ... 

The system is going down for reboot NOW! 
Connection to 127.0.0.1 closed by remote host. 
Connection to 127.0.0.1 closed. 

如何解决此问题?这是为什么发生?

回答

4

当您运行sudo reboot时,它将重新启动vagrant虚拟机,作为重新引导过程的一部分,它将终止所有守护进程和进程。当然,sshd将会停止或被杀,因此连接到它(我的意思是vagrant ssh)将会丢失。

一旦流浪VM重新启动并再次运行,您可以再次使用vagrant ssh。使用vagrant status检查虚拟机状态。

重启盒子的无业游民的方法是:

  1. Ctrl + d退出SSH连接
  2. vagrant reload
0

我也有类似的问题。当我重新启动时,我无法重新登录。我尝试关闭。这似乎工作。

[email protected]:~$ sudo shutdown -h now 
[email protected]:~$ 
Broadcast message from [email protected] 
    (/dev/pts/0) at 5:16 ... 

The system is going down for halt NOW! 

[email protected]:~$ exit 
logout 
Connection to 127.0.0.1 closed. 
foo$ vagrant status 
Current machine states: 

default     poweroff (virtualbox) 

The VM is powered off. To restart the VM, simply run `vagrant up` 
foo$ vagrant up 
相关问题