Preserving VirtualBox VM’s and Configurations on a Multi-disk Host

Important background information:

My desktop computer has been running Windows 10 since I bought it about five years ago. It was clear to me that I needed to reinstall the OS but that always involves lots of backups and configuration changes. I’d rather not go through this but sometimes you need to.

My system has two drives: a 225G SSD for the OS install and a 2T hard drive for data. When I originally set VirtualBox up, I configured it to store my VM’s and the ISO farm on the 2T HD. This, it turns out, made my OS refresh easy. I currently have 19 VM’s for my various playgrounds, which would have been a real mess to deal with.

How to:

Before reinstalling the OS, you should update VirtualBox (and the Guest Additions if you also install them) to the latest edition. Make sure everything is working OK by spinning up at least one VM. Once you shut all the VM’s down, you need to locate and copy the VirtualBox configuration directory to a safe backup location. This is a hidden folder typically in your user profile named “.VirtualBox”. This folder holds both your VirtualBox configuration settings and the latest VirtualBox Extensions installer file, both of which you will need later.

Once you shut all the VM’s down, you should consider if you want to back everything up. What I did was to shutdown my computer and disconnect my HD.

WARNING: This may cause issues later. In my case after I installed the new OS and reconnected my HD, my HD assumed a different drive letter. You need to reassign drive letters immediately if this happens. I used Windows “Disk Management” tool to do this.

Once you have installed and updated the new OS, and also have your drive letter changes corrected (see warning above), do the following:

1). Install the latest VirtualBox, it should match the version you updated to prior to the OS reinstall.

2) Start VirtualBox. You will not see any VM’s listed because you have not copied the config file yet. But you should do this before copying the old config file over to the new install.

3) Stop VirtualBox.

4) Copy both the “VirtualBox.xml” and VirtualBox Extension Pack file to the new .”VirtualBox” configuration folder under your user profile, replacing the new config file with your old one.

5) Start VirtualBox and reinstall the VirtualBox Guest Additions.

6) Start up some VM’s. Hopefully everything works. If needed, you could make changes to the VirtualBox.xml file, but you shouldn’t have to.

PortQryV2.exe

PortQryV2.exe is a standalone binary from Microsoft. It appears that the last release was around the Server2003/XP days but it can still be downloaded and is still useful. Once downloaded, the installer file creates a directory and drops the PortQry.exe file in it. This is nice to have when a server is behind firewalls and troubleshooting is required.

A simple example that checks if port 445 is available using both TCP and UDP (445 is TCP – this is just an example to show use):

portqry.exe  -n myserver.mydomain.com -e 445 -p 

As always, get help:

portqry.exe /?

Get Windows Server Uptime (also Windows 10)

I have needed to retrieve the uptime from several Windows servers in the last few months. There is a number of ways to do this but I can’t seem to remember how to do this when I need to. Obviously a native “uptime” command would be too easy. So here is one way (use these commands in the cmd.exe terminal):

net statistics server

Look for the “Statistics since” line.

Or use this command:

systeminfo | find "Time"

On windows 10:

net statistics workstation

Note that these commands don’t return the actual uptime, but rather the last boot time. If you really want the math done for you so that you get the actual uptime in a human format, and you have a GUI front end, then do the following:

Start the Task manager.
Click the "Performance" tab.