แก้ปัญหาเมื่อ Vagrant VM ที่ทำงานอยู่ หาย!!

เคยกันมั้ยครับ อยู่ๆ Vagrant VM หายไปดื่อๆ ระหว่างทำงาน Develop environment ที่ setup ไว้หายไป ต้องเสียเวลาลง LAMP ใหม่ เหตุการณ์นี้ผมก็เจอบ่อยๆ เหมือนกัน

เรามาดูวิธีแก้ไขกันดีกว่า โดยการแก้ปัญหานี้ก็มีคนที่ได้บอกวิธีไว้แล้ว ใน GitHub

อันนี้เป็นวิธีเต็มๆ

I figured out my own workaround:
  1. Go to C:\Users\VirtualBox VMs
  2. Open up the .vbox for the good VM.
  3. Start the VM inside VirtualBox, and then shut it down.
  4. It should now be listed via "VBoxManage list vms". Copy the UUID inside the {}s.
  5. In the project directory, run this command:
    echo -n > .vagrant/machines/default/virtualbox/id
e.g.,
echo -n b5e14d9a-f416-4f2f-a989-aa4698b3613b > .vagrant/machines/default/virtualbox/id
Now "vagrant up" should work as normal, but it may fail with:
    default: Warning: Connection timeout. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
If so, run the following:
6. Kill the ruby.exe process if the error messages do not stop.
7. In Git-Bash, run the following
$ cp ~/.vagrant.d/insecure_private_key .vagrant/machines/default/virtualbox/pri
vate_key
$ vagrant halt
8. Start the VM manually via VirtualBox.
9. Log in using the credentials vagrant/vagrant.
10. Run the following commands:
$ wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub
$ cat vagrant.pub >> .ssh/authorized_keys
11. Run $ vagrant halt
12. Run $ vagrant up
Vagrant may try to provision this machine once more. It will fail at
==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
Shared folders that Chef requires are missing on the virtual machine.
This is usually due to configuration changing after already booting the
machine. The fix is to run a `vagrant reload` so that the proper shared
folders will be prepared and mounted on the VM.
If so, run:
13. Run $ vagrant halt
14. Run $ vagrant reload
15. Run $ vagrant up
Your system should now be back to normal.


อันนี้เป็นแบบย่อๆ น่ะครับ

I was able to skip a bunch of the steps with the following:
  • Ensure VM is running, and kill any running vagrant ssh sessions
  • Run VBoxManage list vms
    • Copy the UUID inside the {}s
  • Inside the git root, run:
    • echo -n __UUID__ > .vagrant/machines/default/virtualbox/id
    • Ex: echo -n b5e14d9a-f416-4f2f-a989-aa4698b3613b > .vagrant/machines/default/virtualbox/id
  • cp ~/.vagrant.d/insecure_private_key .vagrant/machines/default/virtualbox/private_key
  • curl https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub >> ~/.ssh/authorized_keys

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

CakePHP ตอนที่ 1 Introduction and Installation

MIME Types – Complete List

ลองใช้งาน Google Chart กัน