VBoxManage VittualBox in not accessible

Discussions related to using VirtualBox on Linux hosts.
Post Reply
BlasterToad
Posts: 4
Joined: 26. Aug 2020, 21:50

VBoxManage VittualBox in not accessible

Post by BlasterToad »

I am hoping someone can help. I am running a cron job script as root to backup our VMs. I am getting an error from VboxManage though and can't find my way around it. We are running Ubuntu 18.04.5 LTS and official VirtualBox not the Ubuntu package.

Edit: Looking back at my logs, the script was working up until mid March. The script has not been altered.

Here is my script, User name is obfuscated:

Code: Select all

#!/bin/bash
######################
#
# Shut down and back up select VMs
#
#####################

#make new date formatted directory
sudo mkdir /mnt/md1/VirtualMachines/bak/$(date +%Y_%m_%d) |& tee -a /mnt/md1/Scripts/log_vboxBak_$(date +%Y_%m_%d).txt;
sudo chown bvserv /mnt/md1/VirtualMachines/bak/$(date +%Y_%m_%d) |& tee -a /mnt/md1/Scripts/log_vboxBak_$(date +%Y_%m_%d).txt;

#Read array of virtual machines from file
readarray -t VM < /mnt/md1/VirtualMachines/auto-start_list.txt

#loop through array of VMs
for i in "${VM[@]}"
do
# Shut down virtual machine
sudo -u bvserv VBoxManage controlvm "$i" poweroff |& tee -a /mnt/md1/Scripts/log_vboxBak_$(date +%Y_%m_%d).txt;
# Export virtual machine to dated file
sudo -u USER VBoxManage export "$i" -o /mnt/md1/VirtualMachines/bak/$(date +%Y_%m_%d)/"$i".ova |& tee -a /mnt/md1/Scripts/log_vboxB$
# Restart virtual machine
sudo -u USER VBoxManage startvm "$i" --type headless |& tee -a /mnt/md1/Scripts/log_vboxBak_$(date +%Y_%m_%d).txt
#echo "$i"
done
Here is my generated output log with error:

Code: Select all

VBoxManage: error: Failed to initialize COM because the global settings directory '/root/.config/VirtualBox' is not accessible!
VBoxManage: error: Failed to initialize COM because the global settings directory '/root/.config/VirtualBox' is not accessible!
VBoxManage: error: Failed to initialize COM because the global settings directory '/root/.config/VirtualBox' is not accessible!
VBoxManage: error: Failed to initialize COM because the global settings directory '/root/.config/VirtualBox' is not accessible!
VBoxManage: error: Failed to initialize COM because the global settings directory '/root/.config/VirtualBox' is not accessible!
VBoxManage: error: Failed to initialize COM because the global settings directory '/root/.config/VirtualBox' is not accessible!
VBoxManage: error: Failed to initialize COM because the global settings directory '/root/.config/VirtualBox' is not accessible!
VBoxManage: error: Failed to initialize COM because the global settings directory '/root/.config/VirtualBox' is not accessible!
VBoxManage: error: Failed to initialize COM because the global settings directory '/root/.config/VirtualBox' is not accessible!
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: VBoxManage VittualBox in not accessible

Post by scottgus1 »

This does not appear to be a Virtualbox problem. It appears that ... wait for it ... the global settings directory '/root/.config/VirtualBox' is not accessible. :lol:

Keep in mind that Virtualbox is a user-space program and relies on files stored in the logged-on user's home path '/{username}/.config/VirtualBox'. See https://www.virtualbox.org/manual/ch10. ... configdata

If this folder does not exist or has altered-from-normal permissions, vboxmanage cannot read it to find the guest data it needs. Also, if the guests are registered in '/{you}/.config/VirtualBox' but the script runs under root so vboxmanage looks in '/root/.config/VirtualBox', then things will go south.

Have you checked that this folder hasn't had its permissions modified?
BlasterToad
Posts: 4
Joined: 26. Aug 2020, 21:50

Re: VBoxManage VittualBox in not accessible

Post by BlasterToad »

scottgus1 wrote:This does not appear to be a Virtualbox problem. It appears that ... wait for it ... the global settings directory '/root/.config/VirtualBox' is not accessible. :lol:

Keep in mind that Virtualbox is a user-space program and relies on files stored in the logged-on user's home path '/{username}/.config/VirtualBox'. See https://www.virtualbox.org/manual/ch10. ... configdata

If this folder does not exist or has altered-from-normal permissions, vboxmanage cannot read it to find the guest data it needs. Also, if the guests are registered in '/{you}/.config/VirtualBox' but the script runs under root so vboxmanage looks in '/root/.config/VirtualBox', then things will go south.

Have you checked that this folder hasn't had its permissions modified?
The script is running vboxmanage in user space

Code: Select all

sudo -u user
, and .config folder and all sub-folders and files are owned by the user with read / write permissions applied. I have just double checked this before posting.
fth0
Volunteer
Posts: 5690
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: VBoxManage VittualBox in not accessible

Post by fth0 »

Is USER == bvserv? ;)
BlasterToad
Posts: 4
Joined: 26. Aug 2020, 21:50

Re: VBoxManage VittualBox in not accessible

Post by BlasterToad »

Yes looks like I missed it in a couple locations
BlasterToad
Posts: 4
Joined: 26. Aug 2020, 21:50

Re: VBoxManage VittualBox in not accessible

Post by BlasterToad »

It turns out, although all GUI tools display permissions as being owned and full access by user, using ls -la shows that at some point the config file ownership was set as root. Will test after hours tonight to see if that fixes things.
Post Reply