How can I restore my vagrant VM ( all file have been deleted)?

前端 未结 1 443
情话喂你
情话喂你 2021-01-14 12:41

I don\'t know why but after doing vagrant halt then up, all my file in the VM are lost. There is only an empty data file. And when I SSH into it , putty tell me that the key

1条回答
  •  北海茫月
    2021-01-14 13:20

    In some occasions, vagrant seems to recreate a new VM while there is existing ones. If you need to re-associate an existing VM to your current vagrant project directory, you can run the following steps:

    1. find out what are the VM registered in VirtualBox: VBoxManage list vms

      fhenri@machine:~$ VBoxManage list vms
      "" {cf5c9fe6-be04-40f8-aeec-415bb0b74e37}
      "" {08732b8b-e80e-4707-9f4c-842bdcdb2442}
      "" {ced87630-c5d9-4396-9fc1-7a9277ec2f4a}
      "" {b9fc4466-2382-4629-9fcf-f414ab5093fd}
      "" {4442b12f-2b52-4edd-aa94-e87e2f4e54cd}
      "default" {650472d0-3bb7-4a64-9035-8a6c6e012eb3}
      "" {17140ebf-94f3-4434-8576-e8c19cce05f4}
      "" {4bbf157f-00d4-4ee6-8aa1-fc3b170ad1a9}
      "java_default_1460033990347_57680" {ff197c01-2f63-4e46-b8b6-98757a6f5084}
      "debian_default_1461336132946_97987" {57559b51-0446-4b62-98c6-100bd09700a0}
      "puppet-java_app_1463209753687_62581" {47779f5f-a5c2-4cda-9e6e-636173fc3dd2}
      "testboxpuppet_default_1463642283236_68875" {ab8e9fcf-2803-4301-8a75-59c6a7a3f283}
      "ud381_default_1463643058938_27416" {06d4940b-067f-4bac-b4e7-a5409340da95}
      "api.notification.guru-core-01" {311aef0a-8a34-48da-a2fb-fceef89a635a}
      "scotchio_default_1464423206546_32780" {c94b7982-5bef-4d78-9601-913606e117c6}
      "ubuntu_default_1464510147764_37768" {c8e7ffba-eac6-47a4-b293-699ac4feca2f}
      "php7_default_1464762585884_30680" {c2c73091-133b-4987-a644-90601abd1465}
      

    You will get a list of all the VMs currently registered in virtual box with their associated UUID

    1. Update your existing id file:

    The file will be located in the following folder /.vagrant/machines/default/virtualbox/id. Just copy the value you have found from step1

    From my example, if I wanted to associated VM java_default_1460033990347_57680 I will copy the value ff197c01-2f63-4e46-b8b6-98757a6f5084

    1. Thats it ! just run vagrant up and vagrant will operate the correct VM.

    0 讨论(0)
提交回复
热议问题