p4lang / tutorials

P4 language tutorials
Apache License 2.0
1.33k stars 878 forks source link

VM Booting Issue in Windows 11 Home #566

Closed Anshul-Johri-1 closed 5 months ago

Anshul-Johri-1 commented 6 months ago

Windows 11 Home Git version 2.43.0.windows.1 Vagrant 2.4.1 Virtual Box Version 7.0.14 r161095 (Qt5.15.2)

I ran vagrant up command in vm-ubuntu-20.04 directory. GUI Interface has opened previously (I even completed few exercises), but it opens probably like 1/7 times. Rest of the times I get this timeout.

Click to expand/collapse ``` $ vagrant up Bringing machine 'release' up with 'virtualbox' provider... ==> release: Checking if box 'bento/ubuntu-20.04' version '202401.31.0' is up to date... ==> release: Clearing any previously set forwarded ports... ==> release: Clearing any previously set network interfaces... ==> release: Preparing network interfaces based on configuration... release: Adapter 1: nat ==> release: Forwarding ports... release: 22 (guest) => 2222 (host) (adapter 1) ==> release: Running 'pre-boot' VM customizations... ==> release: Booting VM... ==> release: Waiting for machine to boot. This may take a few minutes... release: SSH address: 127.0.0.1:2222 release: SSH username: vagrant release: SSH auth method: private key 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. ``` ![Screenshot (672)](https://github.com/p4lang/tutorials/assets/156458037/4e9cb56c-26cc-400b-93a7-bc97b0a74278)

When this timeout occurs, I try to run vagrant ssh command, and it works fine sometimes, I could even use ping command. But this is successful only about 3/7 times. Rest of the times, vagrant ssh don't give any output (while VM is running, but no GUI). Then eventually I use vagrant halt + vagrant up or vagrant reload, but no results.

I followed README-install-troubleshooting.md but couldn't solve this issue.

I have a sufficient RAM/ROM/Processor in my laptop. How do I fix this? How about using WSL? Maybe I need to increase config.vm.boot_timeout, but where do I config it?

jafingerhut commented 6 months ago

Two thoughts:

Anshul-Johri-1 commented 6 months ago

but where do I config it?

I asked this because I looked up config.vm.boot_timeout in directory, but couldn't find it. Then I realized I had to add it in Vagrantfile by my own.

I added config.vm.boot_timeout = 600, but even after 10 mins, it didn't boot. Then I added config.vm.boot_timeout = 900, but even after 15 mins, it didn't boot.

Now I'm planning to use WSL with Ubuntu 20.04, and use install-p4dev-v5.sh like you mentioned here. I hope it works.

But I still couldn't figure out why vagrant up didn't work.

jafingerhut commented 6 months ago

Sorry if I sound like a broken record, but I'd like to steer you towards well-tested paths, and away from ones that I would guess are less likely to work.

I know there are too many words on this page to expect you to want to read them all: https://github.com/jafingerhut/p4-guide/blob/master/bin/README-install-troubleshooting.md but note especially these words there:

Note: These scripts have been reported NOT WORKING on WSL (Windows Subsystem for Linux). I have had success running supported versions of Ubuntu Linux using VirtualBox on these host operating systems:

Ignore those words at your peril.

I would recommend either following the steps on that page that let you download a recently pre-compiled from source VM. If that does not work for some reason, then my second recommendation would be to create a new Ubuntu 20.04 VM inside of VirtualBox on your system, and in that VM, run one of the install-p4dev-v5.sh -v6 or -v7 scripts, at your choice (I test all of them to work in an Ubuntu 20.04 VM every month).

Any other path, and I will not have any time to help you if things go wrong, other than to repeat these recommendations.

Anshul-Johri-1 commented 6 months ago

I'll definitely follow what you recommended sir. I'll close this issue after it's resolved and update about what worked for me (for others to know who might have similar issue). Thank you so much for your time.

Anshul-Johri-1 commented 5 months ago

Here's the summary: I tried vagrant up command multiple times, even after vagrant destroy. But it didn't work in my system. Note: I was in the directory vm-ubuntu-20.04. I also tried config.vm.boot_timeout = 1200.

I always used to get stuck here. ![Screenshot (672)](https://github.com/p4lang/tutorials/assets/156458037/e7a6543d-6b5b-42a2-a46d-75f57f6b2afb)
Eventually it timed out ``` $ vagrant up Bringing machine 'release' up with 'virtualbox' provider... ==> release: Checking if box 'bento/ubuntu-20.04' version '202401.31.0' is up to date... ==> release: Clearing any previously set forwarded ports... ==> release: Clearing any previously set network interfaces... ==> release: Preparing network interfaces based on configuration... release: Adapter 1: nat ==> release: Forwarding ports... release: 22 (guest) => 2222 (host) (adapter 1) ==> release: Running 'pre-boot' VM customizations... ==> release: Booting VM... ==> release: Waiting for machine to boot. This may take a few minutes... release: SSH address: 127.0.0.1:2222 release: SSH username: vagrant release: SSH auth method: private key 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. ```
When restarting the "partial VM" from VirtualBox, I could only get this far. I could login in vagrant, but not in p4. ![Screenshot (674)](https://github.com/p4lang/tutorials/assets/156458037/cffb3764-d25c-4723-bbfb-49caebb171dc) After entering id as "vagrant" and password as "vagrant", I could get no further than this. ![Screenshot (675)](https://github.com/p4lang/tutorials/assets/156458037/13c3ce4d-9fdd-4534-be6e-157c56c413fd)

Now when I tried considering a pre-compiled VM image. These were the options available on README-install-troubleshooting.md. But my system is Windows 11 Home. I was unsure whether Windows 11 Enterprise would work or not.

VM Image Options ![Screenshot 2024-03-10 172121](https://github.com/p4lang/tutorials/assets/156458037/d6aeefe2-4eaa-49de-b77f-8961dcad04f2)

Then eventually I installed Ubuntu 20.04 VM in VirtualBox. Took around 15-20 mins. After installing it, I executed these.

$ sudo apt install git     # For Ubuntu
$ git clone https://github.com/jafingerhut/p4-guide
$ ./p4-guide/bin/install-p4dev-v5.sh |& tee log.txt

# After about 15-20 mins
$ git clone https://github.com/p4lang/tutorials
$ cd tutorials/exercises/basic
$ cp solution/basic.p4 basic.p4
$ make run

# When inside mininet
mininet> h1 ping h2

And this worked fine. Long story short - Ubuntu 20.04 VM in VirtualBox worked fine for Windows 11 Home users.

jafingerhut commented 5 months ago

Glad you got a working setup in the end.

The screen shot you showed of where it got stuck for you trying vagrant up gives me no clues why it is stuck there. That part of the output is all stuff from Linux booting up, and I don't see anything there specifically related to the scripts in this repo. My guess is that you might have similar troubles trying vagrant up with many other Vagrantfile contents than the ones in this repo.

That said, I'm personally happier not trying to debug why vagrant up did not work on your system.

Anshul-Johri-1 commented 5 months ago

I've never had to do vagrant up before. It was my first time. It might be completely possible that I had something in my system interfering with it. Though I can assure you that I exactly followed the instructions mentioned. I tried doing it about 11 times, deleting VM completely, restarting system, retrying it again. It worked only one time at my 3rd / 4th attempt. But when I closed it, it never opened again. But it worked on first try with Ubuntu 20.04 VM in VirtualBox.

I really appreciate you coming forward and helping beginners like me. Thank you so much for your help.