Page 5 of 6

Re: [HOWTO] start and stop VM with your NAS.

Posted: Thu Oct 05, 2017 3:11 pm
by sksbir
docb wrote:It works like a charm. I probably would have worked from the start if I did not try to run it from shell first :?
Is there a possibility to run your script before/after the NAS goes to standby? Right now I have massive problems with my VM after a NAS wake up on lan from standby - I always need to rebot the VM after that. So it would be better just to shut it down / restart when the NAS goes to standy / wakes up.
I think no : If NAS is going to standby, it's because there is no activity, and you request it to have some activity ( freeze or stop VM ) because it have no activity ? 8-)
imho, a NAS who hosts VM should never standby.

Re: [HOWTO] start and stop VM with your NAS.

Posted: Thu Oct 05, 2017 3:28 pm
by docb
Well I often don't really need the nas running when I am on duty. And to save power that would be a nice thing. Bit maybe I just turn it off then, cause your wonderful script works then ;-) By the way, do you know a way to shut it down remotely from another server by script. I just can imagine to open a ssh via the script and pass the credentials which would really not be a safe way

Re: [HOWTO] start and stop VM with your NAS.

Posted: Thu Oct 05, 2017 4:35 pm
by sksbir
docb wrote:Well I often don't really need the nas running when I am on duty. And to save power that would be a nice thing. Bit maybe I just turn it off then, cause your wonderful script works then ;-) By the way, do you know a way to shut it down remotely from another server by script. I just can imagine to open a ssh via the script and pass the credentials which would really not be a safe way
Yes it's a safe way if you don't pass the credential but use key based authentication.
for example : https://www.digitalocean.com/community/ ... nux-server

With this solution, you can remotely invoke a local shell which will freeze or shutdown your WM, take care that they are no more active, and shutdown down the NAS after that.
Maybe remotely brings your NAS to sleep is still working ( take a look at the end of this topic )

Re: [HOWTO] start and stop VM with your NAS.

Posted: Fri Oct 06, 2017 8:41 pm
by docb
Perfect - it works like a charm! Thany you so much for your help!

Re: [HOWTO] start and stop VM with your NAS.

Posted: Tue Jan 23, 2018 4:01 pm
by KPOTOC
Спасибо))) Работает))) Нужно внимательно все сделать по первому посту!

Re: [HOWTO] start and stop VM with your NAS.

Posted: Tue Jan 23, 2018 9:41 pm
by sksbir
in english please.

Re: [HOWTO] start and stop VM with your NAS.

Posted: Thu Mar 04, 2021 9:07 pm
by Tanzpol
Hello!!!

Is this "HowTo" steel good? Now ADM 3.5.4.RE11. And everything was done, like in first post, but VM doesn`t start, is it possible to look for some kind of logs? I don`t know where can I find problems %)

Re: [HOWTO] start and stop VM with your NAS.

Posted: Sun Oct 10, 2021 3:36 am
by wolvverine
Add autostart vm after reboot virtual box
Ticket 40684 22 September 2021 08:22 AM

Please add autostart for VMs after reboot.

in phpvirtualbox:

Code: Select all

/* Enable startup / shutdown configuration.
* This only works in linux and you must add the vboxinit file to
* your startup scripts list.
*/
var $startStopConfig = true;
But add proper vboxinit file to startup scripts.

/volume1/Web/virtualbox/vboxinit - example for init file.

in /usr/local/AppCentral/virtualbox/CONTROL/start-stop.sh
add this:

start()
{
# Get all autostart machines
MACHINES=$($su_command "VBoxManage list vms | awk '{ print \$NF }' | sed -e 's/[{}]//g'")
for UUID in $MACHINES; do
STARTUP=$($su_command "VBoxManage getextradata $UUID 'pvbx/startupMode'" | awk '{ print $NF }')
if [ "${STARTUP}" == "auto" ]; then
VMNAME=$($su_command "VBoxManage showvminfo $UUID | sed -n '0,/^Name:/s/^Name:[ \t]*//p'")
echo "$0: starting machine ${VMNAME} ..."
$su_command "VBoxManage startvm $UUID --type headless" >>/var/log/vb.log
fi
done
}

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

}

Re: [HOWTO] start and stop VM with your NAS.

Posted: Fri Feb 11, 2022 3:20 am
by Mikebos
Can I use this VM auto start/stop script with most current ADM 4.0.3 or file structures changes would not allow for that ?

Thanks !

Re: [HOWTO] start and stop VM with your NAS.

Posted: Wed Feb 16, 2022 5:11 am
by noiden
wolvverine wrote:in /usr/local/AppCentral/virtualbox/CONTROL/start-stop.sh
add this:
I don't get this to work. I have added script in the bottom of the /usr/local/AppCentral/virtualbox/CONTROL/start-stop.sh but no autostart of VM's.

Anyone knows a solutions for this?