openmediavault-virtualbox: graceful (ACPI) shutdown or suspend virtual machines on reboot or shutdown OpenMediaVault

    • Offizieller Beitrag

    Virtualbox's init script saves the state of each vm on shutdown. I suppose you could change this to acpi shutdown.


    /etc/init.d/vboxinit

    Code
    stop()
    {
            # vms are saved, instead of stopped.
            MACHINES=$($su_command "VBoxManage list runningvms | awk '{ print \$NF }' | sed -e 's/[{}]//g'")
            for UUID in $MACHINES; do
                    VMNAME=$($su_command "VBoxManage showvminfo $UUID | sed -n '0,/^Name:/s/^Name:[ \t]*//p'")
                    echo "$0: saving machine ${VMNAME} state ..."
                    $su_command "VBoxManage controlvm $UUID savestate" >>/var/log/vb.log
            done
    }

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Hello,


    I also want shut down my VM when the server shuts down. Unfortunately there's no vboxinit under /etc/init.d
    There's a script called "virtualbox".
    How can I shut down of my VM before the server shuts down (via script)?
    Unfortunately under root there is no VM visually. You have to change to user "vbox". See here

    OMV-Server-HW: MoBo Fujitsu D3417-B2 (Intel-LAN), Intel Xeon E3-1245 v6 Kaby Lake (4x3.70GHz), 16GB-Ram ECC UDIMM, 1x512GB SSD Samsung 850 Pro (sda2 - 30GB system, 4GB swap, sda5/rest - for work), 1x 10TB WD Red Pro, 1x 3TB WD Red (both basic setup) - Digibit R1 Sat-IP-Server with SatIP-Axe-Firmware


    OMV-Server-SW: Debian Buster with Proxmox kernel (always up-to-date), OMV v5 (always latest), omv-extras-plugin (always latests), AutoShutdown-Plugin, Docker with PlexMediaServer, TVHeadend, any many more


    BackupServer: Synology DS1010+ with 4GB Ram, 9TB@SHR (different hdd's), DSM 5.2-5967-2

  • For version OMV 2.1/2.2.14:
    1)
    check file /etc/defaults/virtualbox :
    -----text in file: -----------------------------
    # Defaults for VirtualBox.
    # Sourced by vboxweb-service on startup
    VBOXWEB_USER=vbox
    VBOXWEB_HOST=127.0.0.1
    ----------------------------------------------------
    2)
    in file etc/init.d/vboxinit check 2 fragments,
    edit (# Required-Stop: $all)
    ,all system services will continue work some time after shutdown/reboot, until vboxinit script run)
    add delay 60 seconds ($su_command "sleep 60s")
    and change command from savestate to acpipowerbutton in script,


    --fragment1: -----------------------------------
    ### BEGIN INIT INFO
    # Provides: vboxinit
    # Required-Start: vboxdrv $local_fs
    # Required-Stop: $all
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Description: Controls VirtualBox sessions
    ### END INIT INFO
    ---fragment2:-------------------------------------
    stop()
    {
    # vms are saved, instead of stopped.
    MACHINES=$($su_command "VBoxManage list runningvms | awk '{ print \$NF }' | sed -e 's/[{}]//g'")
    for UUID in $MACHINES; do
    VMNAME=$($su_command "VBoxManage showvminfo $UUID | sed -n '0,/^Name:/s/^Name:[ \t]*//p'")
    echo "$0: stopping machine ${VMNAME} ..."
    $su_command "VBoxManage controlvm $UUID acpipowerbutton" >>/var/log/vb.log
    $su_command "sleep 60s"
    done
    }
    ----------------------------------------------------


    3)


    check "run premission" for etc/init.d/vboxinit
    4)
    run command from shell:
    sudo update-rc.d vboxinit defaults


    5) reboot system , start VM , check host reboot\shutdown,
    shutdown test for Windows Guest VM:
    put test.cmd in "computer" shutdown scenaries in gpedit.msc:
    ------------
    ping 127.0.0.1 -n 10
    ping 127.0.0.1 -n 3 > c:\log.txt
    ---------
    (for result need minimum 13 seconds)


    check c:\log.txt file and creation data of file.


    check "windows Reliability Monitor" 10-15 min after host reboot , non graceful windows shutdown-s show warnings in "Reliability Monitor graph".


    -----------------------------------------------------
    -----------------------------------
    for version OMV-4 no solution
    (in default settings "savestate" mode, work only for quick and small VM-s, delay in scripts not work)

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!