How to recover a crashed VM

Last week it happened again, one of my virtual machines crashed. And I needed a way to repair the virtual machine or at least retrieve the files located on the virtual hard disk.

Important note: This is (probably) not supported and I can’t guarantee your virtual machine is recovered. Please only use this how-to as your last resort! It might help you 🙂

What happened?: When the virtual machine (VM) crashed it needed a forced shutdown. When restarting the VM it came back with Recovery mode. I wasn’t able to start Windows normally!

Solution: Within VirtualBox (I’m currently using Oracle VM VirtualBox), or any other virtualization software, you are able to mount multiple hard disks. You need to mount the hard disk of the crashed VM to another healthy VM (which works normally). Pay attention to snapshots, mount the latest snapshot! Start the healthy VM.

What happens?: The healthy VM will pick up the crashed hard disk and starts scanning and repairing the hard disk. After repairing Windows will start normally and you are able to browse the hard disk and retrieve your files.

If you are having a lucky day? You could try to shutdown the healthy VM. Unmount the hard disk (which was repaired). And try starting your crashed VM. Now you know whether you are really lucky! It might start!? Good luck!

Adding script like jQuery to your pages

When working with the post of Andrew Connell I faced some challenges with implementing my solution. I wanted to add multiple scripts with dependencies to my pages. When creating one elements.xml containing all three script links the order of the <CustomAction Location=”X” ScriptScr=”Y” /> elements is important.

The following elements.xml is packaged in a feature.

<Elements xmlns=""> <CustomAction Location="ScriptLink" ScriptSrc="~site/_layouts/project_name/js/custom-1.0.0.js?rev=20110413" /> <CustomAction Location="ScriptLink" ScriptSrc="~sitecollection/_layouts/project_name/js/ jquery_query-2_1_7.js?rev=20110413" /> <CustomAction Location="ScriptLink" ScriptSrc="~site/_layouts/project_name/js/jquery-1.5.1.min.js?rev=20110413" /> </Elements>

This results in the following HTML in your pages.

document.write('<script type="text/javascript" src="/_layouts/project_name/js/jquery-1.5.1.min.js?rev=20110413"></' + 'script>'); document.write('<script type="text/javascript" src="/_layouts/project_name/js/jquery_query-2_1_7.js?rev=20110413"></' + 'script>'); document.write('<script type="text/javascript" src="/_layouts/project_name/js/custom-1.0.0.js?rev=20110413"></' + 'script>');

Important to know is the order in the elements.xml is the opposite sequence in the HTML. Meaning the script “jquery_query-2_1_7.js” is depending on “jquery-1.5.1.min.js” and needs to be the last item in the elements.xml.

In the script link I’m using “~site” and “~sitecollection” tokens to change the link according to the site or site collection where the user is located. This is important when creating a generic feature used on multiple sites.

By using the “?rev=20110413” at the end of your link you can force the browser to refresh its local cache. A (script) file is downloaded the first time accessing the page. As long as the link does not change the browser does not download the file. By changing the query string you can force a download of the script when changes are made. The actual value “20110413” is todays date, but can be your own versioning logic.

The example above also has a version number in the file name, this is another way of forcing a download. I simply wanted to illustrate the possibilities, you probably will use either query string or version number.

Lessons learned / best practices:

  • Order in elements.xml for <CustomAction /> elements is of influence of the order of script links in the resulting HTML.
  • Use “~site” and “~sitecollection” tokens to control the script link.
  • Use “?rev=20110413” query string or version number in filename to force a download of the file.

Speaking at DevDays 2011

I will be speaking at the DevDays 2011 in The Hague (NL) on April 28th. It’s a level 300 session about SharePoint Features en Solution Upgrading. More information on

Session abstract: SharePoint Features en Solution Upgrading

The devdays_speakersession is held in Dutch:

Het feature en solution framework dat gebruikt wordt voor deployment van custom SharePoint solutions is geïntroduceerd als onderdeel van SharePoint 2007. In SharePoint 2010 is dit onderdeel verder uitgebreid met feature versioning en upgradability. Dit is van invloed op de application lifecycle management strategie.
Deze presentatie gaat in op het feature en solution framework, wanneer pas je feature upgrade toe en hoe ga je om met het upgraden van bestaande geactiveerde en niet-geactiveerde features. Tijdens de sessie worden meerdere demo’s gebouwd op basis van verschillende scenario’s.