ppggff / vagrant-qemu

Use Vagrant to manage machines using QEMU. Test with Apple Silicon / M1 and CentOS aarch64 image
MIT License
424 stars 33 forks source link

SSH hang on ubuntu box #5

Closed BlackLIonz closed 2 years ago

BlackLIonz commented 2 years ago

I tried use vagrant with qemu to run ubuntu vm. This box was used https://app.vagrantup.com/javiervela/boxes/ubuntu20.04-arm64 . Settings are default. vagrant up froze with:

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.

And when I'm trying to run vagrant ssh it's just hanging. And breaks with timeout.

MacOS 12.2.1 (M1 Pro) Vagrant 2.2.19 vagrant-qemu (0.1.7, global)

ppggff commented 2 years ago

This seems to be the problem with the box. I tried to solve this problem locally.

  1. updated to v0.1.8: vagrant plugin update vagrant-qemu

  2. vagrant up --provider qemu

  3. use nc to connect to the serial port

    #  get the id of this virtual machine  
    cat .vagrant/machines/default/qemu/id
    k-2sGaa94eE%
    
    # get the path to qemu_socket_serial
    ls ~/.vagrant.d/tmp/vagrant-qemu/k-2sGaa94eE/qemu_socket_serial
    
    # connect to it
    nc -U ~/.vagrant.d/tmp/vagrant-qemu/k-2sGaa94eE/qemu_socket_serial
    
    # press Enter, it may show
    ubuntu login:
  4. you may see different outputs

    • boot message, wait to login
    • login prompt, login with username/password: vagrant/vagrant
    • others, please report to this issue
  5. after login to ubuntu, enable the network

    # check network, you will see that eth0 has no ip address
    ip a
    
    # update netplan config
    sudo su -
    sed -i -e 's/enp6s0/eth0/' /etc/netplan/00-installer-config.yaml
    
    # quit nc by Ctrl+C
  6. stop machine: vagrant halt

  7. wait a few minutes, until ps -ef|grep qemu shows no running qemu process

  8. restart machine: vagrant up

Notes, you also need add config.vm.synced_folder ".", "/vagrant", type: "smb", smb_host: "10.0.2.2" to the Vagrantfile due to a know issue.

This works for me, please try it.

BlackLIonz commented 2 years ago

Awesome, it's worked for me. Thank you a lot

ppggff commented 2 years ago

Great.