archedraft Posted April 8, 2015 Share Posted April 8, 2015 My server has been having issues lately with my pfSense KVM VM not starting when I turn on unRAID. I usually have to hit the power button for unRAID to safely shutdown and then turn in on again for pfSense to finally start (sometimes it takes multiple tries). I cannot diagnosis the issue because without the pfSense VM starting I never get an IP address on my computer and therefore cannot access unRAID... I am guessing that my other VM's are booting up first and causing some sort of inference. (The annoying thing is that if I turn on my old pfSense box to get the internet back and then start unRAID my pfSense VM starts every time, HOW AM I SUPPOSE TO FIX IT IF IT WORKS WHEN IT IS NOT SUPPOSED TO???) I would like to turn off auto start on all my VM's and create a startup script that waits 30 seconds after unRAID starts and then runs "virsh start pfSense" and then waits 30 seconds and then checks to see if it has internet access, if not then try to start pfSense again, and then once it finally gets internet to start the other VM's. I should be able to write the logic behind this script but I am wondering where I need to put the script in order for it to happen at boot? I have the powerdown package installed so would it be best to make a S00 or K00 script? Never made one so just wonder how it works and if this would be the best way? Link to comment
archedraft Posted April 10, 2015 Author Share Posted April 10, 2015 So it sounds like from this post (link below) that the s00.sh scripts will start once unRAID is finished loading which would work. I am working on a script now that will start my pfSense VM then check to see when unRAID has an internet connection. Then it will start loading my other 3 VM's. If unRAID never gets an internet connection, then I am not sure what I will have the script do... maybe shut down the server or try and restart my pfSense VM... I will have to put some more thought into how I want a failed connection to be handled. Any thoughts would be appreciated. http://lime-technology.com/forum/index.php?topic=32225.msg294445#msg294445 Link to comment
kegler Posted April 10, 2015 Share Posted April 10, 2015 So it sounds like from this post (link below) that the s00.sh scripts will start once unRAID is finished loading which would work. See this topic. http://lime-technology.com/forum/index.php?topic=31735.0 Link to comment
dmacias Posted April 10, 2015 Share Posted April 10, 2015 So it sounds like from this post (link below) that the s00.sh scripts will start once unRAID is finished loading which would work. I am working on a script now that will start my pfSense VM then check to see when unRAID has an internet connection. Then it will start loading my other 3 VM's. If unRAID never gets an internet connection, then I am not sure what I will have the script do... maybe shut down the server or try and restart my pfSense VM... I will have to put some more thought into how I want a failed connection to be handled. Any thoughts would be appreciated. http://lime-technology.com/forum/index.php?topic=32225.msg294445#msg294445 So it sounds like from this post (link below) that the s00.sh scripts will start once unRAID is finished loading which would work. I am working on a script now that will start my pfSense VM then check to see when unRAID has an internet connection. Then it will start loading my other 3 VM's. If unRAID never gets an internet connection, then I am not sure what I will have the script do... maybe shut down the server or try and restart my pfSense VM... I will have to put some more thought into how I want a failed connection to be handled. Any thoughts would be appreciated. http://lime-technology.com/forum/index.php?topic=32225.msg294445#msg294445 You could also use the s scripts to have libvirt start later. Maybe have your network bridge script in a s00.sh and libvirt in s01.sh. I just had thought too. Maybe the failed connection is because sometimes unRAID is using eth2 instead of eth1 or vice versa as the main connection. Since your bridging in and out has it hard coded to eth1 or eth2. If you have a failed situation you could try switching the cables and see. Link to comment
archedraft Posted April 10, 2015 Author Share Posted April 10, 2015 You could also use the s scripts to have libvirt start later. Maybe have your network bridge script in a s00.sh and libvirt in s01.sh. I just had thought too. Maybe the failed connection is because sometimes unRAID is using eth2 instead of eth1 or vice versa as the main connection. Since your bridging in and out has it hard coded to eth1 or eth2. If you have a failed situation you could try switching the cables and see. Hmm... I hadn't thought of that. That is fairly likely what is happening (although I wonder why that would only stop my pfsense VM from autostarting when my 3 other VM's start just fine). libvirt is automatically started now correct? How would I change that so that it does not start and I use a s01.sh to start libvirt? Link to comment
CHBMB Posted April 10, 2015 Share Posted April 10, 2015 If you untick enable libvirt does that mean on a reboot it is still unticked and therefore not started? If so use the S0*.sh scripts to start and have a K0*.sh script to turn it off again? Not sure of the viability of this but makes sense the way I'm looking at it. Link to comment
archedraft Posted April 10, 2015 Author Share Posted April 10, 2015 If you untick enable libvirt does that mean on a reboot it is still unticked and therefore not started? If so use the S0*.sh scripts to start and have a K0*.sh script to turn it off again? Not sure of the viability of this but makes sense the way I'm looking at it. I think you're on to something, i bet un-checking the box would do the trick. Although if I do that I would want to understand how to properly handle shutting down the VM's with the K00.sh scripts... It would be pretty nice that if you stop unRAID's array, then kept libvirt turned on and then pfSense would still be running. However what would happen in a powerdown situation? Also, I hate to mess too much with this because JonP has been teasing me with the "more on this later" for VM's... but then again the "later" part usually means more later than sooner Link to comment
CHBMB Posted April 10, 2015 Share Posted April 10, 2015 That's an interesting point. If you manually start libvirt I suspect the Unraid console would "notice" and thereafter stopping the array would stop the VMs, don't know if it's possible to uncouple the process. dmacias would be the man to talk to I guess. Link to comment
dmacias Posted April 10, 2015 Share Posted April 10, 2015 If you untick enable libvirt does that mean on a reboot it is still unticked and therefore not started? If so use the S0*.sh scripts to start and have a K0*.sh script to turn it off again? Not sure of the viability of this but makes sense the way I'm looking at it. I think you're on to something, i bet un-checking the box would do the trick. Although if I do that I would want to understand how to properly handle shutting down the VM's with the K00.sh scripts... It would be pretty nice that if you stop unRAID's array, then kept libvirt turned on and then pfSense would still be running. However what would happen in a powerdown situation? Also, I hate to mess too much with this because JonP has been teasing me with the "more on this later" for VM's... but then again the "later" part usually means more later than sooner If your vm's are on another drive that's not part of the array you should be fine. /etc/rc.d/rc.libvirt start and /etc/rc.d/rc.libvirt stop is all you need. rc.libvirt stop will stop all vm's. My plugin just does it on array start and stop. If you look in /usr/local/emhttp/plugins/dynamix.kvm.manager/event you'll see the start and stop scripts. Link to comment
archedraft Posted April 10, 2015 Author Share Posted April 10, 2015 If your vm's are on another drive that's not part of the array you should be fine. /etc/rc.d/rc.libvirt start and /etc/rc.d/rc.libvirt stop is all you need. rc.libvirt stop will stop all vm's. My plugin just does it on array start and stop. If you look in /usr/local/emhttp/plugins/dynamix.kvm.manager/event you'll see the start and stop scripts. So I would make my S01.sh => /etc/rc.d/rc.libvirt start (libvirt would start when my array is started) and if I did NOT make a K00.sh => /etc/rc.d/rc.libvirt stop then when I stopped the array my VM's would stay turned on correct? How would I safely shutdown the VM's if told unRAID to shutdown without a K00.sh script? Link to comment
CHBMB Posted April 10, 2015 Share Posted April 10, 2015 If your vm's are on another drive that's not part of the array you should be fine. /etc/rc.d/rc.libvirt start and /etc/rc.d/rc.libvirt stop is all you need. rc.libvirt stop will stop all vm's. My plugin just does it on array start and stop. If you look in /usr/local/emhttp/plugins/dynamix.kvm.manager/event you'll see the start and stop scripts. So I would make my S01.sh => /etc/rc.d/rc.libvirt start (libvirt would start when my array is started) and if I did NOT make a K00.sh => /etc/rc.d/rc.libvirt stop then when I stopped the array my VM's would stay turned on correct? How would I safely shutdown the VM's if told unRAID to shutdown without a K00.sh script? Congrats on you 1000th post!!! I think you'd need a K00.sh script, but the K00.sh script only triggers on powerdown events not array stop right? Link to comment
CHBMB Posted April 10, 2015 Share Posted April 10, 2015 I reckon, modify dmacias' plugin to uncouple libvirt starting and stopping with array starting and stopping, then use S0*.sh and K0*.sh to start and stop libvirt with power up and power down. Ignore me K0*.sh is executed on array stopping. Sorry Link to comment
archedraft Posted April 10, 2015 Author Share Posted April 10, 2015 Congrats on you 1000th post!!! Thanks! Feel like a rock star! Link to comment
archedraft Posted April 10, 2015 Author Share Posted April 10, 2015 I reckon, modify dmacias' plugin to uncouple libvirt starting and stopping with array starting and stopping, then use S0*.sh and K0*.sh to start and stop libvirt with power up and power down. Ignore me K0*.sh is executed on array stopping. Sorry Yeah I was thinking that also, I would have to create the K0#.sh because if I didn't and then started the array again the S0#.sh would be triggered and that would confuse unRAID for sure! Link to comment
CHBMB Posted April 10, 2015 Share Posted April 10, 2015 Would having three K0*.sh scripts work? 1. Turn off pfsense 2. Wait for thirty seconds 3. Turn on PFsense My thinking being if it's an array stop then you'll lose connectivity then recover it at point three but if it's a powerdown then by the time the sequence gets to number 3 it's already powered down therefore can't turn it back on? Would need to understand exactly what happens in the whole sequence and I can imagine a whole host of reasons why it wouldn't work. Just brainstorming really... to one of Unraid's ROCK STARS! Link to comment
archedraft Posted April 10, 2015 Author Share Posted April 10, 2015 Just finished my S00.sh script to start pfsense on boot => check for internet => then start my other VM's. Just tested it out and it worked so that's exciting. I will probably just leave libvirt auto started for now and see how S00.sh works for me. Here is my script (feel free to make fun of it or improve it ... I taught myself everything I know about scripts so it's probably over complicated but hey it works...) S00.sh virsh start pfSense-2.2 if virsh list | grep -q "pfSense-2.2"; then logger -tvm-startup[$$] "pfSense-2.2 started" sleep 60 else logger -tvm-startup[$$] "pfSense-2.2 failed to start" sleep 30 virsh start pfSense-2.2 if virsh list | grep -q "pfSense-2.2"; then logger -tvm-startup[$$] "pfSense-2.2 started on attempt #2" sleep 60 else logger -tvm-startup[$$] "pfSense-2.2 failed to start on attempt #2" powerdown -r fi fi ERR=1 # or some non zero error number you want MAX_TRIES=10 COUNT=0 while [ $COUNT -lt $MAX_TRIES ]; do ping -q -c 1 -W 1 8.8.8.8 >/dev/null if [ $? -eq 0 ];then logger -tvm-startup[$$] "Network available" virsh start Windows-8 sleep 30 if virsh list | grep -q "Windows-8"; then logger -tvm-startup[$$] "Windows-8 started" else logger -tvm-startup[$$] "Windows-8 failed to start" fi virsh start Ubuntu-Server-14.04 sleep 30 if virsh list | grep -q "Ubuntu-Server-14.04"; then logger -tvm-startup[$$] "Ubuntu-Server-14.04 started" else logger -tvm-startup[$$] "Ubuntu-Server-14.04 failed to start" fi virsh start OSX-Yosemite-10.10-ATI sleep 5 if virsh list | grep -q "OSX-Yosemite-10.10-ATI"; then logger -tvm-startup[$$] "OSX-Yosemite-10.10-ATI started" else logger -tvm-startup[$$] "OSX-Yosemite-10.10-ATI failed to start" fi exit 0 fi logger -tvm-startup[$$] "Network is not available, waiting.." sleep 5 let COUNT=COUNT+1 done logger -tvm-startup[$$] "Too many non-successful tries" powerdown -r exit $ERR Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.