Vboxautostart error user is not allowed to autostart vms

So The Official Way™ doesn't work.
  • Reply with quote

[SOLVED] Reliable way to start VirtualBox as a guest on macOS High Sierra

So The Official Way™ doesn’t work.

Code: Select all   Expand viewCollapse view
2.21.3. Mac OS X: Starting the Autostart Service With launchd
On Mac OS X, launchd is used to start the Oracle VM VirtualBox autostart service. An example configuration file can be found in /Applications/VirtualBox.app/Contents/MacOS/org.virtualbox.vboxautostart.plist. To enable the service copy the file to /Library/LaunchDaemons and change the Disabled key from true to false. Furthermore replace the second parameter to an existing configuration file which has the same format as on Linux, see Section 2.21.1, “Linux: Starting the Autostart Service With init”.

To manually start the service use the following command:

Copy# launchctl load /Library/LaunchDaemons/org.virtualbox.vboxautostart.plist
For additional information on how launchd services can be configured see:

http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/BPSystemStartup.html.

I have read countless incorrect ways to do this. This is just one more that doesn’t, despite its official provenance.

The plist file is a wrapper around

Code: Select all   Expand viewCollapse view
/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh /etc/vbox/autostart.cfg

and this gives me

Code: Select all   Expand viewCollapse view
VBoxAutostart: error: User is not allowed to autostart VMs
VBoxAutostart: error: User is not allowed to autostart VMs
VBoxAutostart: error: User is not allowed to autostart VMs
00:00:00.000405 main     VirtualBox Autostart 6.1.28 r147628 darwin.amd64 (Oct 18 2021 19:59:14) release log
00:00:00.000408 main     Log opened 2021-11-17T01:47:51.817796000Z
00:00:00.000409 main     Build Type: release
00:00:00.000430 main     OS Product: Darwin
00:00:00.000441 main     OS Release: 17.7.0
00:00:00.000452 main     OS Version: Darwin Kernel Version 17.7.0: Fri Oct 30 13:34:27 PDT 2020; root:xnu-4570.71.82.8~1/RELEASE_X86_64
00:00:00.000609 main     DMI Product Name: iMac12,1
00:00:00.000680 main     DMI Product Version: 1.0
00:00:00.000684 main     Firmware type: failed - VERR_NOT_SUPPORTED
00:00:00.000720 main     Host RAM: 12288MB (12.0GB) total, 10469MB (10.2GB) available
00:00:00.000723 main     Executable: /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart
00:00:00.000723 main     Process ID: 3596
00:00:00.000724 main     Package type: DARWIN_64BITS_GENERIC

That permissions problem looks serious. But is it?

Code: Select all   Expand viewCollapse view
bash-3.2# cat /etc/vbox/autostart.cfg
default_policy = deny
paul = {
    allow = true
    startup_delay = 10
}

Sure looks like it should work.

If I change that deny to allow…

Code: Select all   Expand viewCollapse view
VBoxAutostart: error: could not get base directory: VERR_PATH_NOT_FOUND

No idea what base directory it’s looking for or how to set it.

I just had to reinstall VirtualBox twice and now have the latest version with the extension pack installed.

The only reliable way to start it is still

Code: Select all   Expand viewCollapse view
   /usr/local/bin/VBoxManage startvm ed8b8574-9a71-4b27-b0a9-c6ac81721fe2

which isn’t useful if I can’t get to the console of the host system.

Code: Select all   Expand viewCollapse view
/usr/local/bin/VBoxHeadless

fails with missing kernel module errors, necessitating another reinstall of VirtualBox. Again, not something one can do without physical access to the host machine.

Tried rolling my own plist file and getting rid of all the other junk:

Code: Select all   Expand viewCollapse view
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version='1.0'>
<dict>
<key>Label</key>
<string>org.virtualbox.autostart</string>
<key>ProgramArguments</key>
<array>
   <string>/usr/local/bin/VBoxManage</string>
   <string>startvm</string>
   <string>ed8b8574-9a71-4b27-b0a9-c6ac81721fe2</string>
</array>
<key>Disabled</key><false/>
<key>KeepAlive</key><true/>
</dict>
</plist>

No better but no worse. Has anyone ever gotten this to work?

Last edited by paulbeard on 31. Dec 2021, 03:35, edited 1 time in total.

paulbeard
 
Posts: 15
Joined: 13. Jun 2013, 18:51

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby granada29 » 17. Nov 2021, 05:43

The problem you are seeing with the kernel modules not being loaded is a known bug in VirtualBox 6.1.28 and earlier when running macOS Monterey.

You will see this discussed in

viewtopic.php?f=39&t=104272&start=15

where the interim solution is to install a test build of 6.1.29

VirtualBox versions earlier than 6.1.28 will case a kernel panic on macOS Monterey, so best to use at least 6.1.28
There is no need to re-install VirtualBox after a boot — You can manually load (or use a shell script) the required modules. This is also discussed in the linked topic.

granada29
Volunteer
 
Posts: 519
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby paulbeard » 17. Nov 2021, 06:13

The problem I am seeing isn’t about kexts not loading. I am not running Monterey on this system. It used to start reliably from the command line in earlier versions so perhaps dropping back to an earlier release will fix that problem. But my main issue is autostarting at boot time. Other services can do, both system-provided and third-party services. I’d like to keep the focus there. If I need to drop back to an earlier 6.1.x release, I’d be interested in knowing which one.

paulbeard
 
Posts: 15
Joined: 13. Jun 2013, 18:51

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby granada29 » 17. Nov 2021, 07:26

Just to be clear. Are you trying to run your VM at system boot (i.e. no users logged in) or are you trying to have it start after login?

If the answer is system boot, then the GUI is not available and you need to be doing a headless start.

If it’s after the user has logged in then startvm is fine, but you should probably be starting from a login script, rather than the system boot script.

granada29
Volunteer
 
Posts: 519
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby paulbeard » 18. Nov 2021, 05:34

I need it to start at system boot. If the host reboots for any reason, I want virtualbox to start the VM as it reboots. Running the command from cron via @reboot has never worked so launchd seems to be only thing. If only I could get it to work…seems simple enough from looking at other working plist examples but something ain’t right..

paulbeard
 
Posts: 15
Joined: 13. Jun 2013, 18:51

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby granada29 » 18. Nov 2021, 06:22

Then you definitely need to do a headless start.
See user manual 7.1.2 for 2 ways of doing this.

1. VBoxManage startvm <VM-name> —type headless
2. VBoxHeadless —startvm <uuid>|<vmname>

Your script also needs to start the VM with the correct user — its a really bad idea to have VirtualBox running as the root user. Also a good idea to use full path names — you can’t assume that the ususal default PATH has been set.

granada29
Volunteer
 
Posts: 519
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby paulbeard » 18. Nov 2021, 06:32

I couldn’t get VBoxHeadless to run but perhaps that’s resolved now. This shouldn’t be this hard to do, and it would be favorite if the Official™ docs could be relied on. Traveling soon which makes this a task I need to address.

The username should be picked up when the script loads, based on the directory/path is loads from. I guess I’ll find out if that assumption pans out.

paulbeard
 
Posts: 15
Joined: 13. Jun 2013, 18:51

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby paulbeard » 22. Dec 2021, 23:42

Just had occasion to test this and it still doesn’t work. The plist file I set up was gone when the host system restarted. Not great. Commandline uses of VBoxManage and VBoxHeadless failed. In the UI admin tool, there were kext errors so I installed the latest version. This is not Monterey or Big Sur…it’s High Sierra as it says at the top. Maybe I need to drop way back to a 5.x version of Vbox.

Still in the hunt for a reliable way to start VirtualBox as a guest on macOS High Sierra with no intervention or user action. Don’t even care if it runs as root.

paulbeard
 
Posts: 15
Joined: 13. Jun 2013, 18:51

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby granada29 » 23. Dec 2021, 07:11

I wrote a program a couple of years ago that helps with configuring start at boot. It is signed and notarised.

https://whatroute.net/software/vboxstar … -1.0.0.zip

I have never released it and there is no documentation, but you should be able to figure it out when you run it. It will install a launch daemon plist, a shell script and also the /etc/vbox file. If there is any interest, then I’ll put together a brief HOWTO.

I just tried it out with a Windows 10 VM on macOS Sierra with VirtualBox-6.1.30 and it worked fine.

Before configuring the boot software I verified that the VM would load and run OK from the VirtualBox Manager.

My VM is configured on an external USB drive, so I configured it with a 30 sec start delay.

If you don’t like it after trying it, there is an uninstall button that will remove the configuration.

granada29
Volunteer
 
Posts: 519
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby paulbeard » 23. Dec 2021, 07:25

I’ll take a look, thanks.

Took a minute of head scratching…it doesn’t like a VM to be running which makes sense, I guess. But it started it just fine after I installed the autostartup bits. Nice work picking up the existing VMs…

Seems like a lot of work to make an app to do this, especially as Oracle doesn’t seem bothered to do it.

Thanks for taking the time,

paulbeard
 
Posts: 15
Joined: 13. Jun 2013, 18:51

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby granada29 » 23. Dec 2021, 09:13

paulbeard wrote:Seems like a lot of work to make an app to do this, especially as Oracle doesn’t seem bothered to do it.

It is all in the VirtualBox documentation but many people have a fear of using the Terminal and not many have tried to get it working on macOS. Oracle have far more pressing issues than this rarely used feature so I understand why it’s not in their gui.

I think the delay to allow USB disks to become visible was the key to finally getting it to work, but I also took care to make sure the VM would start as the specified user and not as root.

Anyway — I’m glad you got your boot startup working. Feel free to suggest improvements. I know documentation is always a good idea, and is also rarely consulted. The UI should be self explanatory.

granada29
Volunteer
 
Posts: 519
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby paulbeard » 23. Dec 2021, 09:53

I live in the Terminal but launchctl just isn’t clear. I haven’t tested this with a reboot of the host yet…/fingers crossed

A lot of attempts to make this work, seems I’m not the only one chasing it. New OS releases and changes to launchctl don’t help, I suspect.

paulbeard
 
Posts: 15
Joined: 13. Jun 2013, 18:51

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby paulbeard » 31. Dec 2021, 02:09

Well, I just had occasion to test this (power flickered enough to knock the host over) and it works like a charm. I wish the tool you made was standard issue for the virtual box installer…I see so many web pages on this, none of which work as well as yours. Thanks for making it and sharing it.

paulbeard
 
Posts: 15
Joined: 13. Jun 2013, 18:51

  • Reply with quote

Re: Reliable way to start VirtualBox as a guest on macOS High Sierra

Postby granada29 » 31. Dec 2021, 03:02

I am pleased to hear that it worked for you. Please edit the title of the topic and mark it as solved. That will help anyone else searching for how to do this.

Last edited by granada29 on 31. Dec 2021, 04:34, edited 1 time in total.

granada29
Volunteer
 
Posts: 519
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows



Return to VirtualBox on Mac OS X Hosts

Who is online

Users browsing this forum: No registered users and 13 guests

Если вы запускаете виртуальные машины VirtualBox на сервере, то скорее всего, захотите, чтобы они оставались запущенными даже после неожиданной перезагрузки сервера.

В этой небольшой статье мы рассмотрим как настроить автозапуск виртуальной машины VirtualBox с помощью системы инициализации systemd, которая сейчас используется повсеместно.

Давайте создадим файл юнита, который будет управлять автозагрузкой. Для этого выполните такую команду:

sudo systemctl edit vbox@.service --full --force

В открывшемся редакторе вставьте такой текст:

Description=Virtual Box Guest %I
After=network.target vboxdrv.service
Before=runlevel2.target shutdown.target
[Service]
User=root
Group=root
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/usr/bin/VBoxManage startvm %i --type headless
ExecStop=/usr/bin/VBoxManage controlvm %i acpipowerbutton
[Install]
WantedBy=multi-user.target

С помощью этого юнита мы и будем делать автозапуск virtualbox linux. В этом примере я запускаю виртуальную машину от имени пользователя root, но вам нужно запускать её от того пользователя, к которому добавлены виртуальные машины и от имени которого VirtualBox обычно работает.

Сохраните изменения в файле и выполните следующую команду, чтобы система инициализации перечитала конфигурационные файлы с диска:

systemctl daemon-reload

В нашем юнит файле мы предусмотрели возможность использования параметра, в котором передается имя или UUID идентификатор виртуальной машины. Если в имени машины есть пробел, то лучше использовать UUID, а иначе можно и имя.

Смотрим список виртуальных машин:

VBoxManage list vms

Теперь давайте запустим машину Ubutnu1804 с UUID ed0ce7dd-0ddb-46bf-913c-876671c4d1f1 с помощью systemd:

sudo systemctl start vbox@ed0ce7dd-0ddb-46bf-913c-876671c4d1f1

Если во время запуска произошла ошибка, вы можете посмотреть её выполнив:

journalctl -xe

В данном случае машина уже была запущена. Я остановил её и запустил ещё раз с уже помощью systemd. Смотрим статус виртуальной машины:

sudo systemctl status vbox@ed0ce7dd-0ddb-46bf-913c-876671c4d1f1

Если всё хорошо, то всё, что нам осталось, это добавить этот сервис в автозагрузку:

sudo systemctl enable vbox@ed0ce7dd-0ddb-46bf-913c-876671c4d1f1

Выводы

В этой статье мы разобрались как делается автозагрузка виртуальной машины virtualbox. Как видите, всё очень просто и удобно. Теперь ваши виртуальные машины будут всегда запущены.

Creative Commons License

Статья распространяется под лицензией Creative Commons ShareAlike 4.0 при копировании материала ссылка на источник обязательна .

Об авторе

Основатель и администратор сайта losst.ru, увлекаюсь открытым программным обеспечением и операционной системой Linux. В качестве основной ОС сейчас использую Ubuntu. Кроме Linux, интересуюсь всем, что связано с информационными технологиями и современной наукой.

On a Linux system with VirtualBox installed, you can start VMs automatically during system boot. In this guide, we are going to learn how to autostart VirtualBox VMs on system boot on Linux. This demo uses Ubuntu 16.04 as the Linux machine that hosts multiple VirtualBox 6.0 virtual machines.

VirtualBox comes with a service called vboxautostart-service that makes it easy to automatically start virtual machines during system reboot.

Configure VirtualBox Autostart Service

In order to configure a VirtualBox VM to start on system boot on Linux, you need to activate the autostart service. The autostart service can be activated by setting two variables in /etc/default/virtualbox;

  • VBOXAUTOSTART_DB – which defines the absolute path to the autostart database directory, usually the /etc/vbox.
  • VBOXAUTOSTART_CONFIG – defines the path to the virtual machine autostart configuration.

These variables can be defined as;

VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/autostartvm.cfg

To place these variables in the /etc/default/virtualbox, run the command below;

echo -e "VBOXAUTOSTART_DB=/etc/vboxnVBOXAUTOSTART_CONFIG=/etc/vbox/autostartvm.cfg" | sudo tee /etc/default/virtualbox

Define the virtual machine autostart configuration settings. The autostart configuration file contains options that controls how the virtual machine is auto started.

vim /etc/vbox/autostartvm.cfg
default_policy = deny

amos = {
    allow = true
    startup_delay = 10
}
  • default_policy – defines whether to allow or deny the virtual machine autostart by default. In our example above, we denied any one from auto-starting the VM and explicitly allow one user, amos.
  • username (amos) – with the default deny policy, you can define the specific users that are allowed to autostart the virtual machine (allow = trues). You can also define how long to delay the VM startup. 10 seconds is used in this demo.

Set Ownership of Database directory

The database directory, /etc/vbox, should be writable by the user to be used to start VMs automatically. To make it easy, you can simply add your user to vboxusers group and set the group ownership of the database directory to vboxusers group. After that, set the write permissions for the group. In this case, amos user is to be used to automatically start the virtual machine.

sudo usermod -aG vboxusers amos
sudo chgrp vboxusers /etc/vbox

Assign the group write permissions on the autostart database directory.

sudo chmod g+w /etc/vbox

To shield the directory from being modified or deleted by other users except the owner or the root user, set sticky bit.

sudo chmod +t /etc/vbox

Enable Virtual Machine Autostart

As a user, you can enable autostart for individual machines. This requires that you define the path to the database directory first.

VBoxManage setproperty autostartdbpath /etc/vbox/

Once that is done, you can now setup the virtual machine to automatically start on system boot.

vboxmanage modifyvm fedora30 --autostart-enabled on

Where fedora30 is the UUID or the name of your virtual machine.

Restart  vboxautostart-service

The configuration is now done. To effect the settings, you need to restart the  vboxautostart-service.

sudo systemctl restart vboxautostart-service

Testing the Virtual Machine autostart

To test that your virtual machine can actually autostart on system boot, reboot you system and check. When system boots, your VM should now be running.

If you which to disable the virtual machine autostart;

vboxmanage modifyvm fedora30 --autostart-enabled off

That is all on how to autostart VirtualBox VMs on system boot on Linux. Feel free to drop any comment. Enjoy.

Related Tutorials;

Resize Root Partition of VirtualBox VM Snapshot

Install VirtualBox Guest Additions on Debian 10 Buster

Install Debian 10 Buster on VirtualBox

Install and Configure Endian Firewall on VirtualBox

How to Upgrade VirtualBox 5.2 to VirtualBox 6.0 on Ubuntu 16.04

Virtualbox to create a Computer inside another Computer

Autostart Virtualbox VMs

So… certainly things evolve quickly and others lack behind. We’ve got systemd since 15.10 or so and it was the prominent change in 16.04. We actually made the switch for Snap! Websites and that help tremendously as it is very reliable since then (older versions were really bad in comparison.)

At first, I found a Stackoverflow answer describing the old way and it did not work which is why I decided to switch to systemd. I found this page about it and it’s already pretty good! Just a couple of things I had to tweak on my system to make it all work properly.

Deleting the Old Way

Just to make sure it works properly, delete the files from the old environment if you created them. If you did edits to some of them, you probably want to undo those edits.

This is to make sure that the old way doesn’t suddenly kick in and mess up your systemd setup.

$ rm -rf /etc/vbox

On my end, I edited the /etc/default/virtualbox file to add these two variables:

VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg

So I went ahead and deleted those two lines.

However, I also changed the following and that I kept:

#SHUTDOWN=poweroff
SHUTDOWN=acpibutton

I prefer to have a good APCI shutdown and a plain power off. If it takes too long to shutdown, we’ll anyway get a power off (a.k.a. a kill).

If you did anything else to try to make the old way work, please make sure to revert that too. You’re on your own on that side of things…

Create Service File

Now you are ready to create a service file.

In mine, I have pretty much the same thing as the one from the page I referenced above, except for the vboxdrv.service. I’m not too sure where that came from, but under Ubuntu 18.04, there is no such thing. Though I remove that one reference.

The script includes two names you need to change:

vm1 — enter the name of your Virtualbox machine (this one appears three times)
alexis — unless you are also an alexis and your account is name like that, change that name

Then save the file under /etc/systemd/system/.

For example, if you use gvim to edit your files:

$ sudo gvim /etc/systemd/system/vm1.service

Then copy/paste the following and do the edits as expected:

[Unit]
Description=vm1
After=network.target virtualbox.service vboxdrv.service
Before=runlevel2.target shutdown.target
 
[Service]
User=alexis
Group=vboxusers
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
 
ExecStart=/usr/bin/VBoxManage startvm vm1 --type headless
ExecStop=/usr/bin/VBoxManage controlvm vm1 acpipowerbutton
 
[Install]
WantedBy=multi-user.target

Note: the vboxdrv.service comes from a comment (see below) and should help even further (i.e. I have had problems with my services starting once in a while, most of the time, I still had to restart them by hand—I’ll have to confirm once I reboot that it works every time).

Once the file is ready, you need to tell systemd to reload everything including that new file. It may do so automatically, but just in case here is the command you need:

sudo systemctl daemon-reload

Now you are ready to use this service.

Note: To see a list of services you have running on your system, the cleanest way is to use the following command:

sudo systemctl

It automatically sends its output to less so you don’t have to pipe manually. At the bottom of the list comes a brief explaination of what the columns stand for. Especially, if a column says «failed», then the service doesn’t work as expected.

Enable/Start/Stop Service

Now that we created a service file, we want to enable and start it. This supposes that your VM is ready to be started as if you were rebooting your machine.

Note that in the script above, there is nothing to say that one service should be started before and/or after another. It’s doable but you should ask yourself whether it makes sense that the computers should be started in a very specific order. i.e. if something fails on computer B when A isn’t running, it should keep trying until it works…

First, you can test that systemd recognize your file with:

$ systemctl status vm1

The status command is also useful to check whether a service is running or not.

Now you can start the VM.

$ sudo systemctl start vm1

It should return on the very next line unless something goes wrong.

If you have the Virtualbox UI open, you should see that it gets started there. The icon changes with what appears on the screen as normal. However, because we use the headless feature, you don’t see the actual GUI part. You can show that window at any time while the machine is running by selecting the « Show» menu (it’s found in the Machine menu or when you right-click on the VM).

Finally, to make the VM run automatically on a reboot, you need to enable it. This is done using the enable command like so:

$ sudo systemctl enable vm1

You can verify the current status at any time. Note that the enable state shows on its own. There are two entries in the output. Both should be enabled. Here is an example of the output. I highlighted the enabled you are looking for in red:

$ systemctl status vm1
 virtualbox_finball2.service - finball2
   Loaded: loaded (/etc/systemd/system/vm1.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sat 2019-11-23 20:13:36 PST; 34s ago
    Tasks: 0 (limit: 9830)
   CGroup: /system.slice/vm1.service

Nov 23 20:13:35 monster systemd[1]: Starting vm1...
Nov 23 20:13:36 monster VBoxManage[12050]: Waiting for VM "vm1" to power on...
Nov 23 20:13:36 monster VBoxManage[12050]: VM "vm1" has been successfully started.
Nov 23 20:13:36 monster systemd[1]: Started vm1.

The last few lines are logs (called journals in systemd) showing what happened. It should say that it started your Virtualbox system.

You can later disable the service like so:

$ sudo systemctl disable vm1

which will prevent it from auto-restarting on a reboot. Note that you can still start a VM marked as being disabled.

Renaming a VM

I use rather long names for my VM that include:

  1. The name of what I’m using the VM for
  2. The OS name (Ubuntu, Fedora, FreeBSD, SunOS, MacOS, etc.)
  3. The hostname of the computer running the VM (because when you run VMs on 3 or 4 different computers, it’s not easy to know what’s what otherwise)
  4. The processor (i86x or amd64)
  5. The sub-name of the computer (i.e. I create clusters that get one VM name + one sub-name such as front end, database, backend…)

I think such long names are great in the Virtualbox interface, but to type in your service file, it may cause problems (between dashes, spaces, parenthesis… and just the fact that such long names are hard to replicate without a few mistakes into them…)

So on my end, I had to rename the VMs. The cool thing, though, is that we now have grouping capabilities. So I can still keep my crazy naming convention for the group, and name each computer in the group something really simple (i.e. <cluster_name>_<sub-name> — for example wordpress_frontend and wordpress_database).

Where is My VM’s Window?

The script is going to start the VM headless. This is actually important if you were to run the VM on a server without X-Windows. (Yes! It’s doable, I’m just not too sure how you do the installation all by hand. It must be somewhat painful!)

Your VMs are going to start alongside the X-Windows environment and because of that, the X-Windows system may not be ready to open a window in the first place. So instead we start VMs headless.

When you are in the Virtualbox GUI, you see the VMs that are running. They have a green arrow. Right-click on those and select « Show» to open the window. Now you have full access to the VM’s console. To hide the window again, you can of course minimize. However, if you want to actually close the X-Windows but leave the VM running, use the «Detach GUI» option found under the «Machine» menu.

In older versions (before 5.x), detaching the GUI was done in various ways:

  1. Machine » Detach GUI
  2. View » Close VM
  3. Close VM (as a button)

Various Errors

The virtual machine has terminated unexpectedly during startup with exit code 0 (0x0).

Looking into that one, I could not really see why one of my virtual machine wouldn’t start, especially with an exit code of 0… First I checked that the machine still existed as expected (right location, etc.) It was there.

So next I searched the Internet and found a page which I won’t even link here, it was totally useless except for one small detail: one of the message was one person asking the other what they saw in their log file. Yes. Why wouldn’t I look at that for once.

Here are the last few messages:

00:00:01.005004 GIM: KVM: Resetting MSRs
00:00:01.186998 VMSetError: /build/virtualbox-p8NxA3/virtualbox-5.2.34-dfsg/src/VBox/VMM/VMMR3/VM.cpp(326) int VMR3Create(uint32_t, PCVMM2USERMETHODS, PFNVMATERROR, void*, PFNCFGMCONSTRUCTOR, void*, VM**, UVM**); rc=VERR_VMM_R0_VERSION_MISMATCH
00:00:01.187018 VMSetError: The VMMR0.r0 module version does not match VBoxVMM.dll/so/dylib. If you just upgraded VirtualBox, please terminate all VMs and make sure that neither VBoxNetDHCP nor VBoxNetNAT is running. Then try again. If this error persists, try re-installing VirtualBox.
00:00:01.188756 ERROR [COM]: aRC=NS_ERROR_FAILURE (0x80004005) aIID={872da645-4a9b-1727-bee2-5585105b9eed} aComponent={ConsoleWrap} aText={The VMMR0.r0 module version does not match VBoxVMM.dll/so/dylib. If you just upgraded VirtualBox, please terminate all VMs and make sure that neither VBoxNetDHCP nor VBoxNetNAT is running. Then try again. If this error persists, try re-installing VirtualBox. (VERR_VMM_R0_VERSION_MISMATCH)}, preserve=false aResultDetail=0
00:00:01.189069 Console: Machine state changed to 'PoweredOff'
00:00:01.194933 Power up failed (vrc=VERR_VMM_R0_VERSION_MISMATCH, rc=NS_ERROR_FAILURE (0X80004005))
00:00:01.695786 GUI: UIMachineViewNormal::resendSizeHint: Restoring guest size-hint for screen 0 to 800x600
00:00:01.695873 ERROR [COM]: aRC=E_ACCESSDENIED (0x80070005) aIID={76eed314-3c72-4bbb-95cf-5eb4947a4041} aComponent={DisplayWrap} aText={The console is not powered up}, preserve=false aResultDetail=0
00:00:01.695961 GUI: Aborting startup due to power up progress issue detected...

And interestingly enough, they give you the exact answer of what to do next (3rd line in the logs above):

  • Sstop all your VMs;
  • Quit VirtualBox;
  • Make sure all the VM services are down (reboot if you want to make 100% sure); and
  • Restart VirtualBox.

Now it should work and it did for me.

The Old Way

At first, I tried the old way, mainly because there are a large number of posts in link with that one. But I just could not find the Virtualbox autostart script anywhere. I tried that once and nothing happened so I would imagine that it’s missing (was removed) in new versions (Ubuntu 18.04 at least).

These are a few points I wanted to make regarding that method.

I go the following error when trying to install a Virtualbox in auto-start mode and trying to fix the problem took me a little while…

VBoxManage: error: Adding machine 'my-virtual-box' to the autostart database failed with VERR_ACCESS_DENIED
VBoxManage: error: Details: code NS_ERROR_UNEXPECTED (0x8000ffff), component SessionMachine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "COMSETTER(AutostartEnabled)(ValueUnion.f)" at line 3035 of file VBoxManageModifyVM.cpp

The fact is that once you added yourselves to the vboxusers group, you need to log out and back in properly or even just forget about that group for a moment and use your primary group instead.

In other words, the docs I’ve found such as this one:

https://askubuntu.com/questions/404665/how-to-start-virtual-box-machines-automatically-when-booting

tell you to use vboxusers but you could also do that:

chgrp <my-primary-group> /etc/vbox

(Note: in most cases, your primary group name is your username)

and the chmod is not even necessary. Of course, that one won’t help much if you want many users to be able to use the autostart feature. The idea is just to have a way to do your setup before you log out and/or test with a full restart of your computer (in my case, I have a monster with 512Gb of RAM, two processors with a total of 64 threads, it takes forever to reboot so I prefer to avoid it if I can.)

I’ll try again and see whether it works if I restart the computer and I have the correct group in there…

However, I just rebooted and it did not work, there is still something fishy about it under 18.04, I just can’t see the vbox service. I can see the Virtualbox kernel module, just no the service. I probably need to install something else…

Понравилась статья? Поделить с друзьями:
  • Vbox код ошибки e fail 0x80004005
  • Vbox e xml error
  • Vbox e iprt error 0x80bb0005 linux
  • Vbox e file error 0x80bb0004 mac
  • Vbox e file error 0x80bb0004 export