-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generation 2 Hyper-V VM boots too fast for boot_command to trigger #7278
Comments
Log output: When Packer gets to the "Typing the boot command...." part the VM is already way past the "Press any key to boot from cd or dvd" prompt. I have tried to start up in headless mode but the VM still starts too fast. I'm not really sure if there is any solution to this other than building an ISO which doesn't prompt me to press a key to start the installation. I have had plenty of success with building generation 1 VMs on the same Windows 10 machine, but I don't see the prompt here though. Below is the template I'm using. |
{ |
@marcinbojko I know you've done a lot with generation 2 windows VMs -- do you have any insights for a workaround here? I don't think there's really anything Packer can do here because Gen 2 vms just blast through the boot sequence so fast. |
@SwampDragons - what's funny - having a lots of different Hyper-V stacks (different baremetal and versions), different DVD/isos to test I can say one thing: it's unpredictable ;)
|
@SwampDragons I'd suggest maybe using a feature called 'start delay', as it's better for packer to wait a sec or ten, then just let VM Gen2 to fly. The name of a feature is here:
|
Startup_delay is a great hint! I'll add it to the hyper-v docs. |
Hey guys, I really appreciate your suggestions on the issue here. Unfortunately the AutomaticStartDelay setting won't help much here as it doesn't slow down the boot process when the VM gets the initial start trigger. What AutomaticStartDelay really does is preventing a boot storm when a hyper-v host, or an entire hyper-v cluster, running many VMs, are rebooted. Example: I'll take a look at the boot_command tweak suggested here. My current boot_command string is currently: It doesn't seem to have any effect in the VM though as I don't see the VM rebooting multiple times. It could actually work though I guess. I'll grab some screenshots in order to get you a better understanding of what happens at my end. |
Hmm I tried the following settings, but the VM doesn't seem to get any input from packer at all: |
@KimRechnagel - my initial understanding of your problem was that packer was too slow to start interfering with VM's boot menu - in this case AutomaticStartDelay is a key to it. |
@SwampDragons - it's not so great, as it has to be set by packer during the VM creation ;) I'd suggest to add this option to packer commands (of course in the code also) to be able to slow down a little for super fast VMs. |
@marcinbojko Yes, packer is too slow to start interfering with the boot menu, or the VM is too fast for vmconnect.exe, which I can see in the code that packer is using, to connect to the VM. I'm not trying to be rude, but AutomaticStartDelay has nothing to do with this issue as this setting works exactly as I described above. I tested it locally on my machine by setting AutomaticStartDelay to 10 seconds and then starting the VM. It doesn't delay anything after the start request has been sent to the VM, it just tells the host to wait X seconds to send the start request to the VM when the host eg. has been rebooted. I'll test with another ISO and will also collect data about my system, versions etc. as per your suggestion. Thanks for your feedback. |
@KimRechnagel - no worries, startdelay would be recommended in our first understanding of your problem - which we already ruled out. |
Hmm maybe the "solution" could be as simple as getting packer to connect to the VM before sending the Start-VM cmdlet. I just "tested" it manually and what happens is that I connect to the VM and see the black console. When I hit the start button it still takes vmconnect about 3-4 seconds to actually display the boot screen. I see the "Press any key to boot from CD or DVD..." for about 1 second before it times out and tries to PXE boot instead. I guess the issue might just be that vmconnect.exe is too slow to connect. Well, I'll look into that as well. |
@KimRechnagel - what would happen if you'll switch to exhanced session (in vmconnect) for this particular packer VM? |
@marcinbojko Enhanced session was already enabled. I disabled it but unfortunately it didn't change anything. I did test something else, but it raises a lot of other challenges with DHCP/PXE etc. but if I change the boot order to be: Then the VM waits for PXE to time out and vmconnect has plenty of time to connect to the VM. The problem with this is that then I only have a small window to send the boot commands during the end of the PXE timeout and when the "Press any key to boot...." times out. Furthermore if I had a DHCP/BOOTP on my network, that would complicate the boot process even more. A question regarding boot_commands on hyper-v; The documentation states that I can add "On" to e.g. I tried with I never saw the "Press any key to boot..." when creating Gen1 VMs, so I don't actually know if boot_command works on my setup. Still waiting for the eval ISO to download. |
How far into the installation is this? Did it just start? |
That's interesting - my packer just goes through 3rd batch of WU. |
It seems like your Hyper-V host is physical, or at least running on Server 2016? I'm testing with my llaptop with the latest version of windows 10. It might make a difference when building Gen 2 machines. |
True. I am not a windows guy, however I'll try with w10. |
Ok the evaluation ISO finished downloading. I didn't change anything but the ISO, I used your templates... and it works. It's very odd... it seems like the eval ISO waits just about 1-2 seconds longer at the "Press any key to boot" prompt, which means that packer has time to connect and send the boot_command. |
Yup, that's what I noticed in thread you were mentioning. Switching to different ISO (Partner channel) broke my deployment flow. BLAME Microsoft? |
It does not work with the template I modified myself. I tested two times now and the boot_command does not seem to be sent. I'll tweak the settings one line at a time until I figure out what triggers this. |
Wow this is weird. I managed to "break" your template as well by changing: To: Changed it back, and it worked again |
Well, now your template fails again. It consistently failed three times in a row. This is odd. There is a very very fine balance between when it works and not. |
@SwampDragons sorry for answering to closed issue - I'd like to try aproach with -AutomaticStartDelay passed to New-VM or Set-Vm. So the sequence would be: run vmconnect and WAIT for VM to start. |
Ah, sorry; didn't realize you were thinking of adding this option. The powershell scripts that comprize the hyperv driver are here, and the new-vm code specifically is here The new-vm code uses golang templating to produce a minimal powershell script and allow us to work around passing a ton of parameters into our Powershell call. |
@marcinbojko I tested your template on a standalone physical Dell Poweredge 815 Hyper-V 2012 R2 host with local harddrives. The funny thing is that I see the same behavior as you. The VM starts, I see the "Press any key" prompt for maybe 3-4 seconds (Packer seems to be connected here), then the VM goes into PXE boot, times out after 60 seconds goes back to "Press any key" and THEN starts the installation. |
2012/2016, windows 10 up to 1803. W10 1809/2019=packer unusable. |
@marcinbojko Just an update. I have built a nested hyper-v host on a hyper-v 2016 cluster. I have used my original 1809 ISO from the VLSC site as well as the evaluation ISO and so far I have not had any issues with packer connecting too slow. It seems like vmconnect.exe connects way faster in my current setup, so missing the boot_command is not an issue. |
Interesting. DNS issues? |
I don't think so, as it wouldn't make sense if vmconnect relies on DNS to lookup local VMs. |
I suppose your nested HV is a standalone, out of AD host? |
Yes, it's a standalone hyper-v host. Its only purpose is building packer templates which I'm going to use on an Ansible server elsewhere in our infrastructure. The packer hyper-v host is a member of an AD and use the AD DNS servers. The Hyper-V host is also a DHCP server exclusively for the packer templates. |
I wish I had this bug. It takes 48 hours for all of my Hyper-V images to build. Sometimes longer if any of the builds get stuck at the "Waiting of ssh access stage." In regards to a solution, I had a couple of ideas you could try (I obviously don't have the hardware to do so myself)... namely, try adding PXE (aka the Network Boot option) to your boot order. That might buy the seconds you need. You can modify this chunk of A more reliable kludge might be booting the machine without an ISO (or using a non-bootable dummy ISO if it's needed to ensure a DVD drive is provisioned)... and then waiting for the new guest to reach the UEFI error screen (shown below). From there you can mount the actual installation ISO, and with a sufficient delay, have If the latter idea works, (aka if you test it by mounting/swapping the ISO manually), then we know a potential fix, and the focus could shift to making |
I've been encountering this same issue and wanted to detail something that appears to be working for me. First off my environment:
Issue: note: This screen is actually frozen. It took me a while to realize this but if you've made it this far, packer can NO longer send boot commands. I kept trying to send ctrl+alt+del/ctrl+shift+alt+del to try and reboot the machine and nothing was happening. SolutionThe solution for me which feels very much like a hack was to wait until the frozen boot screen times out. ( about 60s ). After that, this error screen will launch: The good new is, once you get to the error screen, packer can start sending boot commands again so from here you just need to tab down and press enter to restart. Here's the code: "boot_wait": "70s",
"boot_command": [
"<tab><wait><enter><wait>",
"a<wait>a<wait>a<wait>a<wait>a<wait>a<wait>"
], |
why not create an image with the efisys_noprompt.bin file and skip this 'press any key' entirely. Works for all hypervisors. Don't forget to get a new hash (Get-FileHash) |
We've got a PR containing a potential fix for this, if anyone is up for testing it out: https://circleci.com/gh/hashicorp/packer/9097#artifacts/containers/0 |
@SwampDragons - this worked for me. |
@SwampDragons Thank you, this works for us also! |
Next week, probably Tuesday. :) |
@SwampDragons, thank you for your hard work! Packer 1.4.4 released and can be found https://packer.io/downloads.html page. |
Ah, I will fix that link. However, 1.4.4 had a critical HyperV bug that we didn't catch until just after releasing -- you should probably use the nightly build that is already linked there. |
Oh, I think i was my doing. I was fixing this broken intendation and it slipped somehow. |
@marcinbojko It's my fault for not catching it in tests; it's already fixed on the master branch, so no worries. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
I'm trying to build a generation 2 Windows Server 2016 VM on Windows 10 with the hyper-v role installed. I have the exact same issue as janegilring in the quote below. More info in a minute, just need to get out of this "Reference new issue" popup which just closed on me.
"I was just setting up the same Packer build configuration in a different environment (lab - slower hardware).
The issue in that environment seems to be the opposite: While Packer is in the "Starting the virtual machine..." state, the VM has already started and the "Press any key to start installation" screen is gone when Packer gets to the waiting state. Even when setting the boot wait to 0 seconds, Packer is too slow to type the boot commands.
However, I suppose that`s another issue so I'll create one after some more testing.
Originally posted by @janegilring in #6208 (comment)"
The text was updated successfully, but these errors were encountered: