Page 1 of 1

How to disable automatic "Save State"

Posted: 23. Jun 2013, 01:46
by meowsqueak
I am using VirtualBox with a Bootcamped Win7 guest on my Macbook Pro, however I don't think this is a Mac-specific issue so I'm posting here.

I have the Win7 guest OS on a bootable (Bootcamp) partition, so I can boot it natively if necessary. I can also mount this partition and boot it via VirtualBox. It works really well. However there's one problem - if I "save state" and then boot into native Windows, then boot back into OS X and restore the "saved state", it completely corrupts my Win7 partition. This makes sense because it is trying to restore a memory image that no longer corresponds to the disk state. Chaos should and does ensue. So I avoid doing this by never selecting "Save State" myself.

However if my MBP ever shuts down automatically due to low battery, it seems to automatically invoke this "Save State" option rather than shutting down the VM. This is highly dangerous, because if I don't realise this and boot up Windows before running VirtualBox again, then *boom* - no more Win7.

So I'd like a way to prevent VirtualBox from selecting the "Save State" option when the OS automatically tells it to shut down. I'd prefer an ACPI Shutdown but a 'power cable yank' will do just as well. Any ideas please?

Re: How to disable automatic "Save State"

Posted: 23. Jun 2013, 02:13
by mpack
The solution seems simple - stop using saved states, shut the VM down properly. There are lots of scenarios in which the use of that feature is inappropriate, e.g. when moving an image between different hardware platforms (which is effectively what you did). The raw disk feature is expert level: use at your own risk, and there's no support. If you choose to use it then you are expected to understand the risks and limitations.

Re: How to disable automatic "Save State"

Posted: 23. Jun 2013, 02:26
by meowsqueak
Hi, I'm sorry, and I mean no disrespect, but I don't believe you interpreted my post correctly. I am not using the "save state" option myself. I stated that I know the risks, and even expect the corruption, and that I don't use the option myself. The keyword here is automatically.

It is used automatically by VirtualBox and the OS when the OS shuts down. This is the scenario I wish to prevent. I would prefer that VirtualBox simply shut the VM down properly rather than using the "Save State" option when the OS tells it to terminate quickly. How do I configure VirtualBox to do this?

Here's a use-case - we had an extended power cut, and my laptop, which was left running due to unrelated tasks, ran out of battery power and shut down, unattended. When I booted it back up the next day, I noticed that VirtualBox had "saved state", and I was concerned because I knew I had only been one Windows boot away from disaster. I didn't tell it to save state, the system did it itself, and I want to prevent that. I'd quite like to simply disable the save state feature entirely.

Re: How to disable automatic "Save State"

Posted: 23. Jun 2013, 13:12
by mpack
Hmm. I see. I admit I ignored the "automatic" part of your question because I couldn't think of a situation where VBox saves state automatically, but I guess your use case is such a situation. And in fact I'm pretty sure the cause is because of a long line of complaints from laptop users that VBox used to corrupt their disks or control xml files when they close the lid on their laptops.

At first glance I can see nothing in the manual about overriding this behaviour, so the only workaround would seem to be to make sure to discard any saved state before running the VM. You could do this manually, or you might also put the "VBoxManage discardstate" command into a startup script for your host.

Re: How to disable automatic "Save State"

Posted: 23. Jun 2013, 16:07
by loukingjr
I'd prefer an ACPI Shutdown but a 'power cable yank' will do just as well.
I just thought I would mention the only time I've had guest corruption to the point it would no longer boot is when I lost power while the guest was running. This was on a desktop but I think "a power cable yank" might not work so well.

Re: How to disable automatic "Save State"

Posted: 24. Jun 2013, 00:18
by meowsqueak
loukingjr wrote:
I'd prefer an ACPI Shutdown but a 'power cable yank' will do just as well.
I just thought I would mention the only time I've had guest corruption to the point it would no longer boot is when I lost power while the guest was running. This was on a desktop but I think "a power cable yank" might not work so well.
Fair comment. Ideally I'd prefer that VB just shut the VM down (and the absence of such a control seems like a major oversight), but in the absence of this, I think I'd rather take my chances with a 'power cable yank' which *might* corrupt the guest, than accidentally booting a saved state after the volume has changed, which *will* corrupt it.

Re: How to disable automatic "Save State"

Posted: 24. Jun 2013, 01:07
by loukingjr
I think mpack's idea of just deleting the .sav file would be your best bet. I'm guessing this isn't an occurrence that would happen very often.

Re: How to disable automatic "Save State"

Posted: 24. Jun 2013, 01:15
by meowsqueak
loukingjr wrote:I think mpack's idea of just deleting the .sav file would be your best bet. I'm guessing this isn't an occurrence that would happen very often.
Yes, that's the approach I'm going to use. Looks like it's a common problem with laptops but this will at least help me avoid the drop-dead scenario. Thanks everyone.