Page 1 of 1

VBoxManage VittualBox in not accessible

Posted: 26. Aug 2020, 21:57
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!

Re: VBoxManage VittualBox in not accessible

Posted: 27. Aug 2020, 19:35
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?

Re: VBoxManage VittualBox in not accessible

Posted: 27. Aug 2020, 23:02
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.

Re: VBoxManage VittualBox in not accessible

Posted: 27. Aug 2020, 23:16
by fth0
Is USER == bvserv? ;)

Re: VBoxManage VittualBox in not accessible

Posted: 27. Aug 2020, 23:22
by BlasterToad
Yes looks like I missed it in a couple locations

Re: VBoxManage VittualBox in not accessible

Posted: 28. Aug 2020, 19:04
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.