How to fix renaming VM user and path?

Discussions related to using VirtualBox on Linux hosts.
Post Reply
MarkFoley
Posts: 150
Joined: 19. Aug 2016, 03:20

How to fix renaming VM user and path?

Post 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.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to fix renaming VM user and path?

Post 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.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
MarkFoley
Posts: 150
Joined: 19. Aug 2016, 03:20

Re: How to fix renaming VM user and path?

Post 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?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to fix renaming VM user and path?

Post by socratis »

MarkFoley wrote:Suggestion?
Yes. Read the message again. I didn't say "Create a VM". I said "Add". Under the "Machine" menu.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
MarkFoley
Posts: 150
Joined: 19. Aug 2016, 03:20

Re: How to fix renaming VM user and path?

Post 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?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to fix renaming VM user and path?

Post 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.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
MarkFoley
Posts: 150
Joined: 19. Aug 2016, 03:20

Re: How to fix renaming VM user and path?

Post 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.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to fix renaming VM user and path?

Post 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.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
MarkFoley
Posts: 150
Joined: 19. Aug 2016, 03:20

Re: How to fix renaming VM user and path?

Post 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.
MarkFoley
Posts: 150
Joined: 19. Aug 2016, 03:20

Re: How to fix renaming VM user and path?

Post 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.
MarkFoley
Posts: 150
Joined: 19. Aug 2016, 03:20

Re: How to fix renaming VM user and path?

Post 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".
Post Reply