hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.02k stars 4.42k forks source link

[SOLVED] Can't boot virtual machines via vagrant but works well with virtualbox GUI(vagrant 2.4.0/virtualbox 7.0.12) #13288

Closed dhay3 closed 4 months ago

dhay3 commented 8 months ago

I post the question(may be a bug) on hashicorp formua[^1] as well but it seems no one answer that, so I post it here.

Attempts I tried

  1. google it, not much the same case
  2. Downgrade virtualbox from 7.0.12 to 7.0.10
  3. Try to use others Vagrantfile
  4. Boot the virtual machine in virtualbox GUI, it works. But some errors come up after triggering vagrant up. You could check the detail in the link[^1] below

Debug output

https://gist.github.com/dhay3/18276a1344cb292e9dd6b379baff9f90

Expected behavior

Boot virtual machines via vagrant up normally

Actual behavior

Can't boot any of virtual machines via vagrant

Reproduction information

Vagrant version

(base) 0x00 in ~ λ vagrant -v                   
Vagrant 2.4.0

Vitualbox version

(base) 0x00 in ~ λ vboxmanage -v
7.0.12r159484

Host operating system

(base) 0x00 in ~ λ uname -a                  
Linux 0xff1 6.1.60-1-MANJARO #1 SMP PREEMPT_DYNAMIC Wed Oct 25 13:06:34 UTC 2023 x86_64 GNU/Linux

Guest operating system

centos/7 from vagrant cloud boxes

Steps to reproduce

  1. Just run vagrant up

Vagrantfile

(base) 0x00 in ~/hypervisor/vagrant-machines λ grep -Nve "^\s*#|^\s*$" Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
end

[^1]: hashicorp formua

chrisroberts commented 6 months ago

I'm unable to reproduce this behavior. If possible, can you provide the virtualbox log for this guest. Thanks!

Related: #13318

dhay3 commented 5 months ago

@chrisroberts Sorry for the late reply, and the question is still there. Here is the log of the virtual machine in virtualbox https://gist.github.com/dhay3/81419d8298f54cadd9820919d7a6e18a

dhay3 commented 4 months ago

If I add the following snippets in the Vagranfile, and do vagrant reload( or vagrant up ).

config.vm.provider "virtualbox" do |vb|
   vb.gui = true
end

The guest machine starts without any errors in GUI( though the state of the guest machine shows powered off in GUI ) but the same error comes up in the terminal.

The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.

If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.

Any hints for workaround will be highly appreciated.

dhay3 commented 4 months ago

I read some source code, and try to start the guest machine manually via vboxmanage startvm <UUID>. It started normally, but the status of the guest machine shows powered off both in virtualbox GUI and vboxmanage showinfo <UUID>. So it is the Virtualbox problem :question:

dhay3 commented 4 months ago

@chrisroberts Thanks For days I find the root cause is the abnormal username called 0x00 which cuase the ps command do not list VBoxSVC process mentioned in VBox script, on the contrary root's are listed.

Close this issues as solved.

andresbott commented 4 months ago

@dhay3 could you give some more details about your findings, where did you find this or how to check? i'm experiencing similar issues myself

dhay3 commented 4 months ago

@andresbott I'm glad to offer some more details about my findings if helps.

In the vagrant source code that the command vagrant up will trigger vboxmanage startvm to start the machine which is a shell script that you can use less readlink -f $(which vboxmanage) to check the content. And virtualbox will check the VboxSVC process's owner if match the current user or not, If not it will create another VboxSVC process until it's matched. And In my circumstances is the unusual username 0x00 cause the ps command show the root processes list which is unexpected.

I post the same question on the virtualbox forums, you can check the link below for some details.

https://forums.virtualbox.org/viewtopic.php?t=111131