Page 1 of 1

Trying to make VM start at start of OS.

PostPosted: Tue Jun 14, 2016 2:23 am
by Jarod24
I'm trying to make the VM start up automatically at launch of the ASUSTOR server.
I'm using a AS6204T running ADM version 2.6.1.R5H1

I'm brand new to Linux, but I gathered that I would need to create a script under /usr/local/etc/init.d/ that does this
(ref: viewtopic.php?f=49&t=1681)

Using ln I setup this symblink file:
Code: Select all
lrwxr-xr-x    1 root     root            52 Jun 13 17:58 S99MyServer.sh -> /volume1/Software/_VirtualBox/S99MyServer.sh*



On my old windows server I used this:
Code: Select all
@REM Restore to current snapshot, ignoring any changes
"%VBOX_MSI_INSTALL_PATH%\VBoxManage.exe" snapshot "MyServer" restorecurrent
@REM Start the VirtualBox in headless mode
"%VBOX_MSI_INSTALL_PATH%VBoxHeadless.exe" --startvm "Myserver"



I've tried these lines in the script but that didn't work; also I assume that using sudo with 'root' is pointless and/or bad. Would you want/need to run Virtualbox under root or some other user?
Any help getting this thing work is greatly appreciated.

Code: Select all
#!/bin/sh -e

# Startup Virtualbox on system startup.
# Windows code
# @REM Restore current snapshot
# "%VBOX_MSI_INSTALL_PATH%\VBoxManage.exe" snapshot "MyServer" restorecurrent
# @REM Start the VirtualBox in headless mode
# "%VBOX_MSI_INSTALL_PATH%VBoxHeadless.exe" --startvm "MyServer"

VMUSER="root"
VMNAME="MyServer"

echo "===Reset changes back to snapshot==="
sudo -H -u $VMUSER VBoxManage snapshot "$VMNAME" restorecurrent
sleep 10

echo "===Starting VirtualBox VM==="
sudo -H -u $VMUSER VBoxHeadless startvm "$VMNAME"
# sudo -H -u $VMUSER VBoxManage startvm "$VMNAME" --type headless

Re: Trying to make VM start at start of OS.

PostPosted: Fri Jul 15, 2016 8:55 pm
by jkorzeniowski
I also need this.
I edited /usr/local/etc/init.d/S81virtualbox :
start_daemon () {

[ -e "$rcP" ] || ln -s $PKG_PATH/CONTROL/start-stop.sh $rcP
$PKG_PATH/vb_json.sh true
sed -i 's/\"show\":\".*\"/\"show\":\"true\"/g' $PKG_PATH/asportal/virtualbox.json

if [ -e "$ASPORTAL_PATH" ] && [ "Yes" == "$ASPORTAL_STAT" ]; then
$ASPORTAL_PATH/CONTROL/start-stop.sh reload &
fi

load_ko vboxdrv.ko
load_ko vboxpci.ko
load_ko vboxnetflt.ko
load_ko vboxnetadp.ko

# For USB Devices.
[ -e "/dev/vboxusb" ] || mkdir -p -m 0750 /dev/vboxusb 2>/dev/null
# Copy binary to opt
[ -e "/opt/VirtualBox" ] || mkdir -p -m 0750 /opt/VirtualBox 2>/dev/null
[ -e "/opt/VirtualBox" ] && ln -sf $PKG_PATH/bin/* /opt/VirtualBox/ 2>/dev/null
[ -e "/opt/VirtualBox" ] && cp -af $PKG_PATH/bin/VBox* /opt/VirtualBox/ 2>/dev/null
[ -e "/opt/VirtualBox" ] && cp -af $PKG_PATH/bin/VMM* /opt/VirtualBox/ 2>/dev/null
[ -e "/opt/VirtualBox" ] && rm -rf /opt/VirtualBox/components /opt/VirtualBox/ExtensionPacks 2>/dev/null
[ -e "/opt/VirtualBox" ] && cp -af $PKG_PATH/bin/components /opt/VirtualBox/ 2>/dev/null
[ -e "/opt/VirtualBox" ] && cp -af $PKG_PATH/bin/ExtensionPacks /opt/VirtualBox/ 2>/dev/null
# phpvirtualbox
[ -e "/usr/local/www/virtualbox" ] || cp -af $PKG_PATH/phpvirtualbox /usr/local/www/virtualbox 2>/dev/null
/opt/VirtualBox/VBoxSVC & 2>/dev/null
/opt/VirtualBox/VBoxManage setproperty websrvauthlibrary null 2>/dev/null
/opt/VirtualBox/VBoxManage startvm "Server"
/opt/VirtualBox/vboxwebsrv -b 2>/dev/null
# GuestAddition iso
[ -e "/usr/share/virtualbox" ] || mkdir -p -m 0750 /usr/share/virtualbox 2>/dev/null
[ -e "/usr/share/virtualbox" ] && ln -sf /usr/local/AppCentral/virtualbox/bin/additions/VBoxGuestAdditions.iso /usr/share/virtualbox/ 2>/dev/null

}


But it won't work and I get Aborted status on VM :/

Could somebody from Asustor write how to autostart vms and stop cleanly when shutdown?

Re: Trying to make VM start at start of OS.

PostPosted: Tue Apr 03, 2018 3:46 am
by jamesmct
Has anyone made headway on this yet. I've been doing tons of research and haven't been able to figure this out yet myself.

Thanks!

Re: Trying to make VM start at start of OS.

PostPosted: Wed Apr 04, 2018 6:18 pm
by sksbir
Hi

I posted this a long time ago : viewtopic.php?f=46&t=8147

I'm not using VM anymore at the moment.