Sinister Posted March 28, 2020 Share Posted March 28, 2020 I know this is probably really simple but I have a pfsense VM on my unraid server whenever i start my array back up the VM does not start even though the autostart option is ticked is there something i can do to fix this ? Quote Link to comment
JorgeB Posted March 28, 2020 Share Posted March 28, 2020 IIRC autostart currently only works after first array start, like after a reboot. Quote Link to comment
Sinister Posted March 28, 2020 Author Share Posted March 28, 2020 1 hour ago, johnnie.black said: IIRC autostart currently only works after first array start, like after a reboot. Meaning that bringing the array down manually and back up it does not start ? im not sure why i remember it doing things that way. and there is no plugin i can run to do achieve this ? Quote Link to comment
JorgeB Posted March 28, 2020 Share Posted March 28, 2020 25 minutes ago, Sinister said: Meaning that bringing the array down manually and back up it does not start ? Yes, IIRC, not 100% certain. Quote Link to comment
ximian Posted October 23, 2020 Share Posted October 23, 2020 (edited) Hello, do not know if you have fixed your issue. I couldn't find an answer why my vm would not autostart after a windows update. So I created a script that runs every hour. It is kicked off with user scripts. Here is the script: #!/bin/bash if [ ! -f "/tmp/vm.txt" ]; then rm /tmp/vm.txt ; fi virsh list --state-running > /tmp/vm.txt if grep -q "running" /tmp/vm.txt; then exit else virsh start "Windows Server 2016" fi I only have one VM but you can replace grep "running" with VM name instead if you multiple vms Hope this helps Edited October 23, 2020 by ximian Quote Link to comment
Sinister Posted October 23, 2020 Author Share Posted October 23, 2020 6 hours ago, ximian said: Hello, do not know if you have fixed your issue. I couldn't find an answer why my vm would not autostart after a windows update. So I created a script that runs every hour. It is kicked off with user scripts. Here is the script: #!/bin/bash if [ ! -f "/tmp/vm.txt" ]; then rm /tmp/vm.txt ; fi virsh list --state-running > /tmp/vm.txt if grep -q "running" /tmp/vm.txt; then exit else virsh start "Windows Server 2016" fi I only have one VM but you can replace grep "running" with VM name instead if you multiple vms Hope this helps Hi thanks for replying i would like my pfsense vm to autostart when bring up the array. If i were to use this script would it look like this ? #!/bin/bash if [ ! -f "/tmp/vm.txt" ]; then rm /tmp/vm.txt ; fi virsh list --state-running > /tmp/vm.txt if grep -q "running" /tmp/vm.txt; then exit else virsh start "Pfsense" fi Quote Link to comment
JonathanM Posted October 23, 2020 Share Posted October 23, 2020 Be VERY careful when implementing something like this script. I would add a kill feature of some sort, where the script looks for the existence of an arbitrary file on the flash drive before starting the VM, that way you could disable the auto start for troubleshooting. Blindly force starting a VM on a schedule is a bad idea for multiple reasons. Quote Link to comment
ximian Posted November 24, 2020 Share Posted November 24, 2020 On 10/23/2020 at 7:17 AM, Sinister said: Hi thanks for replying i would like my pfsense vm to autostart when bring up the array. If i were to use this script would it look like this ? #!/bin/bash if [ ! -f "/tmp/vm.txt" ]; then rm /tmp/vm.txt ; fi virsh list --state-running > /tmp/vm.txt if grep -q "running" /tmp/vm.txt; then exit else virsh start "Pfsense" fi Sinister , if Pfsense is the only running VM yes then the script will work. If you have multiple VMs running you need to do a virsh list --all into the file and then grep that file for the particular VM that you want to see running. https://stackoverflow.com/questions/37453525/how-can-i-check-specific-server-running-or-notusing-virsh-commands-before-i-s Quote Link to comment
ximian Posted November 24, 2020 Share Posted November 24, 2020 On 10/23/2020 at 10:02 AM, jonathanm said: Be VERY careful when implementing something like this script. I would add a kill feature of some sort, where the script looks for the existence of an arbitrary file on the flash drive before starting the VM, that way you could disable the auto start for troubleshooting. Blindly force starting a VM on a schedule is a bad idea for multiple reasons. Hi jonathanm, just an fyi. Not blindly starting the VM. The virsh list --state-running > /tmp/vm.txt commands checks to see if the VM is running, when it is not running the file is empty if it is is running the running text is found in the file. Quote Link to comment
JonathanM Posted November 24, 2020 Share Posted November 24, 2020 8 hours ago, ximian said: Hi jonathanm, just an fyi. Not blindly starting the VM. The virsh list --state-running > /tmp/vm.txt commands checks to see if the VM is running, when it is not running the file is empty if it is is running the running text is found in the file. Checking to see if the VM is already running before issuing the VM start is NOT what I meant. You need some way of keeping the VM from trying to start automatically, for troubleshooting purposes. Consider the case where starting the VM immediately hangs the host, for whatever reason. You would be stuck in a loop of bouncing the host, and attempting to get access to kill the startup script before it initiates the VM and immediately hangs the host. You need an out of some sort to allow you to stop the auto start process cleanly. That conditional check, where something external is evaluated before starting the VM, is what I was referring to when I said not to blindly start the VM. It could be as simple as a script in the VM itself modifying a file on the host when it shuts down properly to signal it's OK to restart when needed. That way if the VM crashes for whatever reason, it's not blindly restarted. 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.