How to protect Virtualbox VM from coruption due to forced reboots?

Discussion in 'Virtualized Computing' started by Red Squirrel, Mar 30, 2017.

  1. Red Squirrel

    Red Squirrel [H]ardForum Junkie

    Messages:
    9,301
    Joined:
    Nov 29, 2009
    I have a VM at work that runs a department web server. Problem is, they love to randomly force reboot all the machines in the company, including that one. I kinda figured this would be a problem, and well today it really was. Now the VM is corrupt and I will need to rebuild it. It does not get to shut down properly because it's not aware that the host is being forced to reboot.

    Is there anything I can do to prevent this? Is there perhaps a way to run it as a service and have it send an IPMI shut down to the OS when the host is shutting down? Only thing is I don't know if it would really have time to shut down properly as the Windows shutdown is not going to give it a chance. This is some kind of app by the company that gives you 20 minutes to reboot and then just forces the reboot. It does not use a native way such as the shutdown command.

    The only thing I can find is something called VBoxVmService but problem is it's hosted at Sourceforge and I don't really trust that site especially for something I'm going to run on the corporate network. Any other options?

    Failing that I'm thinking of just throwing an extra NIC in the machine and making it act as a router (this is doable in windows right?) and then running the web server off a RPI. At least when the machine reboots the actual web server will be untouched. But I'm hoping to run it on the machine if I can figure out a way so the VM can gracefully shut down when it's force rebooted.

    Open to any suggestions. If it can't be done in Virtual Box open to other VM solutions too. I need to rebuild the VM anyway now that it's corrupted as it won't even start.
     
  2. peanuthead

    peanuthead [H]ardness Supreme

    Messages:
    4,249
    Joined:
    Feb 1, 2006
    "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "VM NAME" GUI/DefaultCloseAction Shutdown

    NOTE: Make sure you shutdown and restart your VM after you type that command as it doesn't take effect immediately.

    You can replace Shutdown with: SaveState, PowerOff, or PowerOffRestoringSnapshot. I have not tested those, but I pulled this from the VirtualBox forum.
     
  3. Red Squirrel

    Red Squirrel [H]ardForum Junkie

    Messages:
    9,301
    Joined:
    Nov 29, 2009
    Just need to run this once and it sets the proper flag? Seems to work, if I hit the X it does initiate a shut down. (I think normally you'd get prompted)

    Here's hoping the OS shutdown does simulate hitting the X on the GUI and not just kills the process completely. But I'll wait and see what happens. They do these reboots completely randomly but next time I happen to catch one I'll sit and wait and see what happens.

    As a side note, any good tricks in Linux to ensure a shutdown happens very fast? Not sure how much time it will truly have to shutdown, even if it does work. The shutdown timer just kind of kills off all the processes once it elapses so there would be little time for the actual shutdown of the VM to take place even if it does work.
     
    Last edited: Mar 31, 2017