Page 1 of 1

Tip for Windows (host) Virtualbox users - use symlink!

Posted: 12. Dec 2014, 22:48
by jazcyk
This would actually apply to any platform - but *nix users will not be surprised. They know about it. But it is my experience that Windows users often don't. And it can with advantage be used with Virtualbox on a Windows host. If some people think that this is trivial, then just please ignore :-)

Since Vista Windows has had support for symlinks - refer
http://technet.microsoft.com/en-us/libr ... 53194.aspx (also applies to Wndows desktop editions from Vista).
http://en.wikipedia.org/wiki/NTFS_symbolic_link

Virtualbox has 2 settings for 1) default machine folder (a global setting) 2) and snapshot folder (a setting for each VM). But even if you use them there will still be Virtualbox files in {systemdrive}:\Users\{user}\VirtualBox VMs. However you can move everyting using a symlink. After creating the first VM you simply need to
1) copy "VirtualBox VMs" folder to where you want (here it will be "F:\VirtualBox VMs"). Next delete/rename the original - if not, you cannot create the symlink in next step
2) execute from cmd.exe (commandline) as administrator 'mklink /d {systemdrive]:\Users\{user}\VirtualBox VMs" "F:\VirtualBox VMs"'. The doublequotes around file paths are essential as file paths has space characters. The symlink is created and used by Virtualbox (or rather Windows) from now on. But all physical files are on F: now.
.. and you will not even need to use the 2 setitngs in Virtualbox at all.


I started doing so yesterday, as I was hit by the latest bad Windows Update (http://www.infoworld.com/article/285873 ... 04394.html) after what Windows could not print the login screen on my system. I routinedly restore a backup image of the Windows system partition in such cases. But all updates and changes to the VMs since the time of backup were lost of course. Also snapshots from after the time of backup were not used even though all .vdi's and snapshot folder were on F: (due to settings in Virtualbox used) . But the use of the snapshots had a dependency on now overwritten files in user profile.

But next time it will not be the case. I can now backup the Windows host and the drive with the VM's completely independently - even if snapshots exist (and I won't need to merge them into the .vdi to ensure that they are used). If I restore Windows from a backup the VMs are not set_back_in_time to the time of backup.


Good if this is useful for someone. Also good if someone can laugh at it :-)

Re: Tip for Windows (host) Virtualbox users - use symlink!

Posted: 12. Dec 2014, 22:59
by jazcyk
I forgot to mention C:\Users\{user}\.VirtualBox -folder. I have moved this to F: with a symlink as well. But not sure if it is necessary, actually.

Re: Tip for Windows (host) Virtualbox users - use symlink!

Posted: 13. Dec 2014, 00:10
by loukingjr
I must be having a bad day. How is this better than changing the default machine folder location for the VMs?

Re: Tip for Windows (host) Virtualbox users - use symlink!

Posted: 13. Dec 2014, 00:27
by jazcyk
I wrote that clearly, I think. Even if you change the default machine folder location for the VMs and also change paths to snapshots there well still be files in your Windows 'user profile' telling Virtualox what snapshots to use. What I am doing is moving those files as well. And if you restore the host from a backup, recent snapshots created after the backup cannot be used. Virtualbox is simply not aware of their existence. When you create a snapshot the .vdi (or whatever virtual disk format you use) "freezes" (is not written to anymore) and everything that happens to the VM is written to a snapshot file instead.

If you don't have snapshots it does not matter of course. Everything is then inside the .vdi (or whatever).


Also the .VirtualBox -folder will be an old version after restore if you keep it in your user profle. But I don't know if it contains anything important except for logs.

Re: Tip for Windows (host) Virtualbox users - use symlink!

Posted: 13. Dec 2014, 00:38
by loukingjr
the snapshots folder follows the machine's folders.

Re: Tip for Windows (host) Virtualbox users - use symlink!

Posted: 13. Dec 2014, 12:00
by jazcyk
"the snapshots folder follows the machine's folders.". No, they don't. Not on Windows hosts, at least.

Re: Tip for Windows (host) Virtualbox users - use symlink!

Posted: 13. Dec 2014, 12:12
by jazcyk
Maybe I did not express myself clearly.

You can register an existing valid virtual disk from anywhere on the filesystem no matter the setting. And the setting does not move the files describing the snapshsot hierachy and the ".VirtualBox" folder. By symlinking you can move all data and logs related to Virtualbox.

Re: Tip for Windows (host) Virtualbox users - use symlink!

Posted: 13. Dec 2014, 14:53
by loukingjr
jazcyk wrote:"the snapshots folder follows the machine's folders.". No, they don't. Not on Windows hosts, at least.
I didn't mean they physically "move". The default machine folder location only affects where newly created guests are located. Preexisting guests, if any, remain where they were. So if you change the default machine location, each new guest will be created in the new location including the logs, snapshot folder if you create any, the .vdi file etc.
jazcyk wrote:Maybe I did not express myself clearly.

You can register an existing valid virtual disk from anywhere on the filesystem no matter the setting. And the setting does not move the files describing the snapshsot hierachy and the ".VirtualBox" folder. By symlinking you can move all data and logs related to Virtualbox.
Yes, you can register a .vdi file from anywhere. But it's much easier to move it into the guest folder you want to use it with.
A symlink doesn't "move" anything. It just points to a file object.