Page 1 of 1

How to fix renaming VM user and path?

Posted: 23. Aug 2016, 06:27
by MarkFoley
I've renamed the Ubuntu user originally used to set up the Window 7 VM. Before, the path to the VM file was /home/administrator/VirtualBox\ VMs/labratw. Now the path is /home/hprsadmin/VirtualBox\ VMs/labratw. The Unix username is likewise changed, but UID:GID are still the same as they were. When I fire up VirtualBox I now get the error: "Failed to open a session for the virtual machine labratw." If I symlink /home/hprsadmin to /home/administrator I can open the VM.

But ... is there a way to change the path to /home/hprsadmin/... somewhere? I'll likely change the user again when I get this workstation connected to the domain.

Re: How to fix renaming VM user and path?

Posted: 23. Aug 2016, 10:09
by socratis
The VMs are stored by default to the user's home folder. The VMs are store and registered in the VirtualBox.xml file by using the absolute path. If you change your home directory, then it breaks. If the files have moved to the new location, edit VirtualBox.xml, and fix the paths, but be careful.

Another option (safer) is to Remove the VMs from VirtualBox Manager. Do not delete the files. Then re-add the VMs.

Re: How to fix renaming VM user and path?

Posted: 23. Aug 2016, 18:20
by MarkFoley
I tried the "safe" way, but ran into a problem. As soon as I entered the Name of the VM I got the message, "Cannot create the machine folder labratw in the parent folder /home/hprsadmin/VirtualBox VMs. This folder already exists and possibly belongs to another machine."

Suggestion?

Re: How to fix renaming VM user and path?

Posted: 23. Aug 2016, 19:51
by socratis
MarkFoley wrote:Suggestion?
Yes. Read the message again. I didn't say "Create a VM". I said "Add". Under the "Machine" menu.

Re: How to fix renaming VM user and path?

Posted: 23. Aug 2016, 20:31
by MarkFoley
I removed the VMs -- did not delete the files. On my VirtualBox Manager window I have no VMs listed and 'New', 'Settings', 'Discard' and 'Start' menu options with only 'New' enabled. 'New' takes me right the the "Name and operating system" dialog which is where I got my "Cannot create ..." error. Where is the 'Machine' menu?

Re: How to fix renaming VM user and path?

Posted: 23. Aug 2016, 20:36
by socratis
MarkFoley wrote:Where is the 'Machine' menu?
In the menu bar? Search for how to enable the menus under Ubuntu, if they are disabled.

Re: How to fix renaming VM user and path?

Posted: 23. Aug 2016, 21:09
by MarkFoley
The menu bar seems to be something you get when actually running a VM, but I've found nothing for the Oracle VM VirtualBox Manager. Can you post an image of showing your 'Machine' menu? Meanwhile, I'll try the not-so-safe method you suggested.

Re: How to fix renaming VM user and path?

Posted: 23. Aug 2016, 21:11
by socratis
Find your Ubuntu menus. You need them. I don't know why Ubuntu is so stupid in that regard, but find them. There are ways. You didn't search enough.

I have a Mac, my menu won't help you.

Re: How to fix renaming VM user and path?

Posted: 23. Aug 2016, 21:24
by MarkFoley
Sorry, I don't know what you mean by "Ubuntu Menus". What are these? Something on the Oracle VM VirtualBox Manager window? Something on the desktop? The only virtualbox related "menu" have have for Ubuntu is an icon for "Oracle VM VirtualBox". Clicking on that brings up the "Oracle VM VirtualBox Manager" window. There is nothing on that window other than the menu icons I described earlier.

At the moment I'm stuck. My VM is gone, although the vdi file is still there.

Re: How to fix renaming VM user and path?

Posted: 23. Aug 2016, 21:40
by MarkFoley
OK, I did it the hard way. I Moved the vdi file to /tmp and created the new VM, specifying "Use an existing virtual hard disk file" and pointing that the to vdi I copied to /tmp/labratw. That booted.

I then closed VirtualBox and moved the vdi back from /tmp to /home/hprsadmin/VirtualBox VMs/labratw. I edited the following files:

/home/hprsadmin/.config/VirtualBox/VirtualBox.xml
/home/hprsadmin/VirtualBox\ VMs/labratw/labratw.vbox
/home/hprsadmin/VirtualBox\ VMs/labratw/labratw.vbox-prev

and replaced all instances of /tmp/labratw with /home/hprsadmin/VirtualBox\ VMs/labratw/. Note that it was not sufficient to simply edit VirtualBox.xml (tried that right at the beginning of all this).

So, perhaps brute force, but the VM is up and running. If you (or anyone out there) knows how to get that Machine menu and how to Add versus create a New machine, please post. I'll have to do this again when I add the domain user.

btw - When I now run my Virtual Machine, yes, I can see the menu in the 'Running' windows, including the 'Machine' menu item. However, that menu has 'Settings', take Snapshot, Session Information, Pause, Reset and ACPI Shutdown. I don't see and 'Add' option.

So - there must be another, official way of renaming, adding, cloning or whatever. Please post if you know.

Re: How to fix renaming VM user and path?

Posted: 24. Aug 2016, 17:41
by MarkFoley
As a final post on this topic, I did need to ultimately move my VM to another user: mark; this time, an AD domain user. The tricky bit here is that the user's Home directory is located on the Domain Controller as a redirected folder. Therefore, I don't want the .vdi file located there otherwise I'd be accessing the VM image across the network. So, I created a new folder and moved files as follows:

Code: Select all

$ mkdir -p /home/VirtualMachines/mark
$ mv /home/hprsadmin/VirtualBox\ VMs/labratw /home/VirtualMachines/mark
$ chown -R mark.domain\ users /home/VirtualMachines/mark

$ mv /home/hprsadmin/.config/VirtualBox /home/HPRS/mark/.config
$ chown -R mark.domain\ users /home/HPRS/mark/.config/VirtualBox
I then edited /home/HPRS/mark/.config/VirtualBox/VirtualBox.xml and /home/VirtualMachines/mark/labratw/labratw.vbox* and changed all references to the old user hprsadmin to the correct paths for user mark.

I fired up the VM for the new domain user mark, and it worked!

Now, if someone can tell me how to do this using VBoxManage, I'd greatly appreciate it as I Socratis is correct in saying this method is not particularly "safe".