Hi,
I'm scripting an unattended install of Debian Linux with VirtualBox 7.0.2 - the script does the following:
1. Create VM and storage
2. Do unattended install
3. Start VM
4. Run some commands inside the VM
5. Shut down VM: "VBoxManage.exe controlvm ... acpipowerbutton"
6. Take a snapshot: "VBoxManage.exe snapshot ... take 00fresh"
7. Clone VM from that snapshot: "VBoxManage.exe clonevm ... --basefolder ... --name ... --register --snapshot 00fresh"
Now, when I try to start it, the cloned VM will not boot the first time, but go from "Saved" into "Powered Off" state (quick, in about 4 seconds).
When I try to start the cloned VM again, it will boot normally.
Any ideas where that comes from and how to avoid it?
Cheers,
JT
Linux guest VM cloned from snapshot does not start the first time
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Linux guest VM cloned from snapshot does not start the first time
What purpose does taking the snapshot serve? The VM is already shut down so I don't know why you wouldn't just clone the base disk, plus the snapshot is just taken and so will be empty.
-
- Volunteer
- Posts: 5677
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: Linux guest VM cloned from snapshot does not start the first time
I'm wondering why any of the VMs is in the Saved state at all, because I'd expect both VMs to be in the Powered Off state after steps 5, 6 and 7. How does the guest OS react on the ACPI shutdown signal?
Re: Linux guest VM cloned from snapshot does not start the first time
Thanks for answering.
Does that not make sense or is there a better way to do it?
However I think I understand the problem now:
When introducing a delay between steps 5 and 6, the cloned VM will show up with state "Powered Off" (and boot up on the first attempt).
Without the delay, the snapshot gets taken while the base VM is still in the process of shutting down!
Thus, my related follow-up question would be: How to best wait for the shutdown to be completed?
So far the only way I see is to check the VM state with "VBoxManage.exe showvminfo --machinereadable ..." in a loop until I see the "VMState" field is set to "poweroff"...
Cheers,
JT
My rationale is that maybe later I'd like to continue working on that base VM, but still retain the ability to go back to the "pristine" state from before.mpack wrote:What purpose does taking the snapshot serve? The VM is already shut down so I don't know why you wouldn't just clone the base disk, plus the snapshot is just taken and so will be empty.
Does that not make sense or is there a better way to do it?
I'd thought so as well. The guest OS shuts down fine as far as I can see.fth0 wrote:I'm wondering why any of the VMs is in the Saved state at all, because I'd expect both VMs to be in the Powered Off state after steps 5, 6 and 7. How does the guest OS react on the ACPI shutdown signal?
However I think I understand the problem now:
When introducing a delay between steps 5 and 6, the cloned VM will show up with state "Powered Off" (and boot up on the first attempt).
Without the delay, the snapshot gets taken while the base VM is still in the process of shutting down!
Thus, my related follow-up question would be: How to best wait for the shutdown to be completed?
So far the only way I see is to check the VM state with "VBoxManage.exe showvminfo --machinereadable ..." in a loop until I see the "VMState" field is set to "poweroff"...
Cheers,
JT
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Linux guest VM cloned from snapshot does not start the first time
If your purpose is simply to make a backup that you can return to, then I'd make a proper backup - not a clone. Simply copy the VM folder to a backup drive - there's no need to mess with snapshots.
-
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: Linux guest VM cloned from snapshot does not start the first time
This is it.jtconsol wrote:the only way I see is to check the VM state with "VBoxManage.exe showvminfo --machinereadable ..." in a loop until I see the "VMState" field is set to "poweroff"...