How to change location of ~/VirtualBox VMs/... directory

Discussions related to using VirtualBox on Linux hosts.
Post Reply
wbwb
Posts: 18
Joined: 28. Mar 2011, 08:01
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: WinXP

How to change location of ~/VirtualBox VMs/... directory

Post by wbwb »

Hi,
is there any way, for an existing VM (a Win10), which is fully installed (on linux), to rename the default ~/VirtualBox VMs/... directory?

After installation of my 1st machine, I realized that I suddenly had an (i.m.h.o.) annoying ~/VirtualBox VMs/... folder directly visible in my home. It contains a Win10.vbox, a Win10.vbox-prev file, and a Logs directory.

Upon installation I did realize, that for the virtual drive *.vdi (and some other files, eg. VirtualBox.xml, VBoxSVC.log.x) one could chose an individual location, which I set to a hidden directory ~/.VirtualBox/ . I am happy with that.

However, creating the VM (a Win10), I (probably) still hat the default machine folder location under VirtualBox->General->Default Machine Folder.
Now I have a visible ~/VirtualBox VMs/... and an invisible ~/.VirtualBox/ the former one containing the Win10.vbox and Win10.vbox-prev files, the latter one the virtual disk.

I attempted to 'somehow move' the ~/VirtualBox VMs/... directory to the hidden location but I failed. I tried:

(i) changing the directory under VirtualBox->General->Default Machine Folder, however this does not change anything for the existing machine

(ii) moving the previously generated directory ~/VirtualBox VMs/... to a different location and also pointing to this new location with VirtualBox->General->Default Machine Folder.
However this leads to an error on start up of VirtualBox, claiming that the VM is inaccessible, still showing the default name of the machine folder ~/VirtualBox VMs/... as expected location for the VM.

Any help would be most appreciated.

wbwb
erdeslawe
Volunteer
Posts: 241
Joined: 8. Jul 2015, 10:23

Re: How to change location of ~/VirtualBox VMs/... directory

Post by erdeslawe »

Edit VirtualBox Settings > General > Default Machine Folder (That's the VirtualBox Program Settings Menu Option, NOT the Virtual Machine Settings)
wbwb
Posts: 18
Joined: 28. Mar 2011, 08:01
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: WinXP

Re: How to change location of ~/VirtualBox VMs/... directory

Post by wbwb »

I'm sorry, I don't get it. I think I do exactly as you propose:
1) there is no VM running
2) I open Oracle's VM VirtualBox Manager
3) it has a menu entry: File->Preference->General->Default Machine Folder
4) here I've set the Default Machine Folder to a new, hidden location ~/.VirtualBox/
So, I guess, I'm not doing anything to the settings of a particular Virtual Machine at that point.

However this action does not lead to anywhere. In fact, the files Win10.vbox and Win10.vbox-prev, previously generated in the visible directory ~/VirtualBox VMs/..., remain where they are, and moreover upon each start and shutdown of the VM one can see that they get updated, at least regarding their time stamp ... so, somehow the VirtualBox Manager still uses the old Default Machine Folder ... (?)

Once again, the point is, that I want to be able to either automatically have the content of the former ~/VirtualBox VMs/..., moved to the new (hidden) location, or at least reach a state in which I'm allowed to move these files manually - without the VM being 'inaccessible' afterwards.
erdeslawe
Volunteer
Posts: 241
Joined: 8. Jul 2015, 10:23

Re: How to change location of ~/VirtualBox VMs/... directory

Post by erdeslawe »

The Preferences action changes the default Directory/Folder location for the Virtual Machines. You have to move any existing VM Folders and Files to that location yourself, just as you would when organising any other user files.
wbwb
Posts: 18
Joined: 28. Mar 2011, 08:01
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: WinXP

Re: How to change location of ~/VirtualBox VMs/... directory

Post by wbwb »

No. This does not work.
If I do as suggested by you, then, upon the next start of the Oracle VM VirtualBox Manager, the icon of the Win10 VM in the list of available VMs in the left panel takes on a 'slanted question mark' form, and in the panel on the right hand side I get the following error, as already described in my original post:

Runtime error opening '/home/userxyz/VirtualBox VMs/Win10/Win10.vbox' for reading: -102(File not found.).
/home/abuild/rpmbuild/BUILD/VirtualBox-5.1.26/src/VBox/Main/src-server/MachineImpl.cpp[745] (nsresult Machine::i_registeredInit()).
Result Code:
NS_ERROR_FAILURE (0x80004005)
Component:
MachineWrap
Interface:
IMachine {bla...bla}

From the 1st line of this error message you can see, that Oracle's VM VirtualBox Manager does not care about its own setting under File->Preference->General->Default Machine Folder, where I've set the Default Machine Folder to a new, hidden location ~/.VirtualBox/. The VM VirtualBox Manager still wants to open a vbox file from the 'old location' under ~/VirtualBox VMs/...
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to change location of ~/VirtualBox VMs/... directory

Post by Perryg »

You should really read the following.
How to move guests created with => version 4.*

The main issue you have is the guest is already registered and moving it will cause the guest to fail to boot because the control file says it is somewhere that it is not since you moved it.

Be sure when you remove the guest you do not select to delete it or the guest will be gone. I would put everything back the way it was and make sure that you have it working before you continue with the move.

You have already noticed that changing the location in preferences does not change the way an already installed and registered guest works only the new ones.

I really wonder why you feel it necessary to place all of the guests files in a hidden folder and "~/.virtualbox" is really for the base control files and not where the guests VirtualBox VMs was intended to go.
wbwb
Posts: 18
Joined: 28. Mar 2011, 08:01
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: WinXP

Re: How to change location of ~/VirtualBox VMs/... directory

Post by wbwb »

Perryg wrote:You should really read the following.
How to move guests created with => version 4.*
Yep!! That did the job. Sorry for kinda not abiding to the rule of RTFM :oops: Thanks anyway.
(Although I have to admit, that for a newbie, the part of removing an inaccessible VM which one just spent the good of a day on installing, gave me the shivers ;) )
Actually I also found this on the web offsite howto URL removed by mod , which describes two methods, one of which seems identical to the post you are pointing at.
Perryg wrote:I really wonder why you feel it necessary to place all of the guests files in a hidden folder
...that's really just purely out of personal taste: I want my ~/ directory to only show folders I actually want to descend into - not config and admin directories from outer space.
Last edited by mpack on 9. Sep 2017, 10:08, edited 1 time in total.
Reason: Remove link to 5 year old offsite howto.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: How to change location of ~/VirtualBox VMs/... directory

Post by mpack »

Please don't post links to offsite howto blogs. THIS is the definitive site for VirtualBox, not some 4 year old blog. If a method is correct then you'll find a howto right on this site, and we don't need links to incorrect methods.

AFAIK his method one (export/import) has not been the recommended method of cloning a VM for some considerable time.
Post Reply