I have not used the default autostart service for Vbox for a while now, but looking at the unit file there is nothing about Before. Only After entries.
It works as expected and snapshot(s) are created during shutdown, restart and suspend to disk and ram. The only caveat I have is failing to unmount home, which is printed to the screen during shutdown.
But like I’ve said I have not used other autostart service for quite a while now so, I’m not really sure if that is the reason why there is no snapshot created when shutting down.
If you have the time/motivation to investigate just enable persistent logging and then check the previous logs.
journalctl -b 1 --all
Where 1 is the previous log, it can be any number if it exists.
I would not advise creating snapshots, if diskfiles are corrupted a single diskfile is relatively easy for a recovery attempt(Keep in mind, damaged is damaged and unlikely not recoverable). Multiple files for any reason including snapshots makes recovery incredibly difficult and increases chances recovery will be unsuccessful.
Far better is to execute a proper shutdown and later restart. With no snapshot. If you want a better recovery solution, copy the diskfile instead after shutdown or do a conventional backup system.
Then how do you suppose to restore a vm fro a ‘save state’ if there is no snapshot? Also Vbox creates the snapshot automagically when saving state (at least that is the default) , not the user per se, so the user has no control over that…
The VM is an android-x86 8.1-r5 (http://android-x86.org). I want to use android with my PC because it is more comfortable to use a few applications I use frequently.
A good solution to stop cleanly android is to send an acpi event. Just replace “savestate” by “acpishutdown”.
But if you do this then you don’t get a shutdown but a menu where to choose by clicking the command “stop”.
There is no way to execute a local or an android script by using vboxmanage because there are no guest additions for android. Perhaps there is a way by modifying the menu, so the stop is executed by default after 10 s. It is too techie for me. I don’t know how to do this.
The only solution is to use “savestate”.
Now I know using headless feature with vbox auto service is perhaps a big solution for a little problem.
I found a light solution in plasma environment.
A script to shut down vm with savestate, executed when I log out, or I shut down.
A script to launch the snapshot, executed when I log in.
yes I know a snapshot is one file. It is risky. If it is corrupt I lost all. But no data are stored in this vm just a few apps. If there is a problem I just stop the vm with vboxmanage thus nothing is recorded in disk file. And I use the disk file. This disk file is not a recent state, but it is not a problem. In the worst case recreating a vm is a matter of 15-30 mn.
My problem is how to send a command as something as “shutdown -now” to android vm.
I am a very very beginner with qemu.
Does headless vm exist ?
Can I use rdesktop to connect to the vm ?
Can I send a command or script to the vm for executing a “shutdown - now” for example ?
If I keep the snapshot solution : can I send a command to sync time to the android vm ?
Can I share dynamically a webcam and its microphone ? I mean if in the vm no app is using the webcam then the webcam is released and captured by the host.
if yes for the two last question then i am ready to test qemu because there is no solution with Vbox because there is no guest additions for android.
Hi
Normally the usb devices are allocated to the vm for the duration of running… so that would be a no… you could probably unbind, but that would take some experimenting…
For headless, yes, rdesktop, I imaging so. Time, yes, just configure (I use -rtc clock=host,base=utc).
Look at virt-manager and full control from the command line with virsh which can control the virtual machine.
Sigh … the question was how to do it automatically on host shutdown
if i shut down my pc then no snapshot is created
If you had actually read OP question you would have seen that it is perfectly possible to manually save VM state using VB. So how exactly is your “solution” an improvement?
As I described, shutdown and poweroff your virtual machine.
State is then in a completely consistent state for whenever it’s booted up again.
And, of course if your system is powered off, snapshots aren’t going to make a bit of difference since the snapshot should be empty.
Snapshots should be used for checkpointing within your running session,
When things work right, you won’t have problems restoring a snapshot, maybe even 99% of the time.
It’s that tiny percentage of times when you could suffer disk corruption (yes, it does happen. data storage can never be expected to be perfect) in which case you really want to maximize your odds of success.
Powering off a virtual Android device is an interesting thought.
If it was a physical device, you just hit the power button, and it commences an orderly shutdown.
As you probably know, Android is meant for mobile devices where a soft poweroff only shuts down the display and the device continues to run and you have to execute a hard shutdown to really poweroff.
When I wrote Android apps and tested them running in an emulator, I remember there was no thought or concern about an orderly shutdown, you simply powered off without a second thought.
The question is what might happen if you’re running Android as a Server with potentially long running processes which can be considered likely contrary to its design.
Viewing what is posted on the Internet, it seems that an ACPI shutdown should initiate an orderly shutdown and not simply poweroff immediately like what would normally happen with normal x86/x64 OS. This seems likely based on my experience with real, physical Android devices… When I hit the power button to shut completely off, it can take several minutes to poweroff completely.
The question probably can be answered with some simple experimentation.
Besides,
An important issue may be that Android is still a SysVinit system and not systemd, so it’s possible the OS has absolutely no concept of state and running processes during a shutdown.
Although not perfect, systemd solves some problems by its support for hierarchical processes… In SysVinit there is no concept by default, so unless you script code to intelligently check for processes still running, the default is to just kill whatever is happening. This is why, to provide minimal protection the shutdown command used to impose a delay to hopefully allow long running processes to end, but it was completely blind and could just as easily wait far longer than necessary or not long enough.