VM autostart

Just about everything is virtual these days. Topics relating to virutalization go here.
Sobreiro
Posts: 12
youtube meble na wymiar Warszawa
Joined: Wed Apr 22, 2020 2:10 am

VM autostart

Post by Sobreiro »

Hi!

I've got a AS5304T and i need to autostart all VM at booting the NAS.


Thanks!
flavict
Posts: 13
Joined: Sun Jul 26, 2015 10:32 pm

Re: VM autostart

Post by flavict »

I have used this ... it is in French. It is working on my AS5104T

https://www.forum-nas.fr/threads/resolu ... ost-110973
thebadboyltz
Posts: 30
Joined: Thu Jan 18, 2024 6:53 pm

Re: VM autostart

Post by thebadboyltz »

Hello, I also followed this method and it works perfectly, now I am looking for a solution so that the VM can shut down properly when the NAS turns off.

I tested this command but it doesn't work.

Do you have an idea ?

THANKS

Code: Select all

#!/bin/sh

/opt/VirtualBox/VBoxManage start-stopvm homeassistant --type vrdp &

or this but doesn't work

Code: Select all

#!/bin/sh

/opt/VirtualBox/VBoxManage startstopvm homeassistant --type vrdp &
User avatar
Nazar78
Posts: 2228
Joined: Wed Jul 17, 2019 10:21 pm
Location: Singapore
Contact:

Re: VM autostart

Post by Nazar78 »

Code: Select all

#!/bin/sh

/opt/VirtualBox/VBoxManage controlvm homeassistant acpipowerbutton --type vrdp
Don't run the command in background "&", let it complete first before continuing else it might get killed when the host reached the final stage of reboot/shutdown.
AS5304T - 16GB DDR4 - ADM-OS modded on 2GB RAM
Internal:
- 4x10TB Toshiba RAID10 Ext4-Journal=Off
External 5 Bay USB3:
- 4x2TB Seagate modded RAID0 Btrfs-Compression
- 480GB Intel SSD for modded dm-cache (initramfs auto update patch) and Apps

When posting, consider checking the box "Notify me when a reply is posted" to get faster response
thebadboyltz
Posts: 30
Joined: Thu Jan 18, 2024 6:53 pm

Re: VM autostart

Post by thebadboyltz »

thank you for your answer but I am a beginner and I need more detail (sorry)

currently I created a file so that my VM starts automatically

here is the file that I copied to /usr/local/etc/init.d

Code: Select all

#!/bin/sh

/opt/VirtualBox/VBoxManage startvm homeassistant --type vrdp &

so the file that you offer me should I install it or?

THANKS
User avatar
Nazar78
Posts: 2228
Joined: Wed Jul 17, 2019 10:21 pm
Location: Singapore
Contact:

Re: VM autostart

Post by Nazar78 »

Replace your entire file content with below:

Code: Select all

#!/bin/sh

case "$1" in
  start)
    /opt/VirtualBox/VBoxManage startvm homeassistant --type vrdp &
    ;;
  stop)
    /opt/VirtualBox/VBoxManage controlvm homeassistant acpipowerbutton --type vrdp
    ;;
  *)
    echo "Usage: $0 <start|stop>"
    exit 1
    ;;
esac

exit $?
AS5304T - 16GB DDR4 - ADM-OS modded on 2GB RAM
Internal:
- 4x10TB Toshiba RAID10 Ext4-Journal=Off
External 5 Bay USB3:
- 4x2TB Seagate modded RAID0 Btrfs-Compression
- 480GB Intel SSD for modded dm-cache (initramfs auto update patch) and Apps

When posting, consider checking the box "Notify me when a reply is posted" to get faster response
thebadboyltz
Posts: 30
Joined: Thu Jan 18, 2024 6:53 pm

Re: VM autostart

Post by thebadboyltz »

thank you, I will test tomorrow and let you know. thank you
thebadboyltz
Posts: 30
Joined: Thu Jan 18, 2024 6:53 pm

Re: VM autostart

Post by thebadboyltz »

unfortunately it doesn't work,

As soon as I copied the file, virtualbox became unavailable, I restarted the NAS and the VM no longer started.

What is the danger if a VM shuts down instantly?
User avatar
Nazar78
Posts: 2228
Joined: Wed Jul 17, 2019 10:21 pm
Location: Singapore
Contact:

Re: VM autostart

Post by Nazar78 »

You can test it from the SSH console, to start it just run:

Code: Select all

/usr/local/etc/init.d/YOUR-SCRIPT-NAME start
To stop:

Code: Select all

/usr/local/etc/init.d/YOUR-SCRIPT-NAME stop
Note for this to work automatically, you'll need two files with the same content but different prefix name (S & K). And it needs to run after VB has loaded or unloaded at level 81. E.g. for startup is S81virtualbox-helper, for shutdown K81virtualbox-helper. Usually we create this only one file place it elsewhere then symlink to S-LEVEL-YOUR-SCRIPT-NAME to the init.d directory.
What is the danger if a VM shuts down instantly?
Same as you pull out a plug of a running PC, the disk can get corrupted. In this case the VM. But I strongly think VB could handle this without issue as I've done power off many times.
AS5304T - 16GB DDR4 - ADM-OS modded on 2GB RAM
Internal:
- 4x10TB Toshiba RAID10 Ext4-Journal=Off
External 5 Bay USB3:
- 4x2TB Seagate modded RAID0 Btrfs-Compression
- 480GB Intel SSD for modded dm-cache (initramfs auto update patch) and Apps

When posting, consider checking the box "Notify me when a reply is posted" to get faster response
thebadboyltz
Posts: 30
Joined: Thu Jan 18, 2024 6:53 pm

Re: VM autostart

Post by thebadboyltz »

sorry to be a drag, for you it makes sense, for me it's Chinese :-)

to test in the console I try with this
/usr/local/etc/init.d/S99autobootVM.sh stop


What could cause the file you suggested to me to not work?

As I write I'm laughing because I'm so bad
Post Reply

Return to “Virtualization”