It is currently Sun Aug 18, 2019 10:30 am
All times are UTC + 8 hours

Trying to make VM start at start of OS.

VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL) version 2.

Trying to make VM start at start of OS.

Postby Jarod24 » Tue Jun 14, 2016 2:23 am

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
Jarod24
 
Posts: 4
Joined: Mon Jun 13, 2016 8:49 pm

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

Postby jkorzeniowski » Fri Jul 15, 2016 8:55 pm

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?
jkorzeniowski
 
Posts: 1
Joined: Fri Jul 15, 2016 7:49 pm

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

Postby jamesmct » Tue Apr 03, 2018 3:46 am

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!
jamesmct
 
Posts: 2
Joined: Tue Apr 03, 2018 3:44 am

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

Postby sksbir » Wed Apr 04, 2018 6:18 pm

Hi

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

I'm not using VM anymore at the moment.
sksbir
 
Posts: 322
Joined: Tue Aug 25, 2015 9:23 pm

Return to VirtualBox

  • You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot post attachments in this forum
  • Who is online

    Users browsing this forum: No registered users and 1 guest