How to shrink SQL server 2008 R2 database in a dev environment

I am writing this tips as a note to myself.

As a SharePoint developer I run my SharePoint 2010 development inside a VM. As times goes by I found myself short of hard disk spaces. Following these steps helped to alleviate the problem:

  1. Open up your SQL database where SharePoint is installed
  2. Find the database where its log file is taking up lots of space, in most situations it would be Sharepoint_Config.
  3. Right click the database -> Properties -> options and now change recovery mode from full to simple
  4. Right click database again -> Tasks -> shrink -> database then click Ok. This will shrink the SharePoint_Config_log.ldf file
  5. Finally change the recovery mode to full by following a similar step as #3

Please do not use this technique in prod environment as you normally would require to have a normal database backup process.