Productivity

MacBook Pro – Windows 7 Boot to VHD

Anyone who knows me personally knows that I run all of my work in a virtual environment. Back in 2009 when Hanselman posted about the Boot-to-VHD option of Windows 7, I had it up and running by the next morning. I’ve not stopped using it since.

My Setup

I have VHD’s for:

  • Different Clients – Therefore I can join their domain and have a computer (VHD) dedicated to their setup. Since each client usually requires a particular set up that normally conflicts (if I were running a single machine)  with another client, booting to a VHD allows me to have various configurations with different tools and sets up.
  • Beta products – I’m in the process of creating a Windows Phone 7 app, yet the tools are in Beta. We all know about Windows Tools and the “beta” work – AKA:Your stuff might come to a crashing halt. Therefore I have a couple VHDs for testing various environments and tools.
  • Android – I have a VHD that I use specifically for Android development.
  • Personal Use – Sometimes I need to develop code in VS2010 or Eclipse or RubyMine and would like it to be separate from the rest of the code I have. This is where I put this stuff.

This process has worked great and I love booting to VHD, I think its one of the best things about Windows 7, hands down.

Can I run it on a Mac?

I’ve never been a Mac person until recently. My wife got a mac about a year ago and I’ve only used it to surf the web and fix some minor issues she had with printing. Other than that, I haven’t really touched it. However I have the need to develop iPhone and iPad apps as I’ve been getting a ton of inquires at my mobile devleopment firm – Agilevent to do so. My Dell D630 was on the way out (video card was pooping out on me) and it was time to buy a new PC before Heartland Developers Conference, which I’ll be presenting at in less than a month.

So, with some advice from Aaron Kardell (thanks Aaron) I picked up a refurb MacBook pro from the Apple Store online.

Booting to Windows and Creating a VHD

I knew that with the MacBook Pro I could run Windows 7 (as it was Intel based). This was possible to do through Bootcamp. This is something thousands of people do every day. Nothing big. However I wanted to install Windows 7, and then create multiple VHD’s for the MacBook pro environment. I followed the instructions in the Bootcamp documentation to set up Windows 7 on a different partition. I have a 500 GB HD, so I split the space equally between OSX and Windows 7. I then installed Windows 7 on the Windows partition.

When you boot a MacBook Pro with Bootcamp, you’ll get two options (if you hold down the options key on the Mac while booting). One is the Mac partition, the other is the Windows partition. I select the Windows partition to boot to Windows. Once I was able to do that, I followed Hanselman’s instructions to create a 80GB expandable vdisk using diskpart after booting to the Windows 7 DVD. This allowed me to create a virtual disk which I was able to install Windows 7 to.

When you select this new partition in the Window setup, it will warn you that you cannot (or likely should not) install windows because of possible driver issues. Blaaaah… nonsense, do it anyway. :)

After I let the install rip for awhile it was done. The system did reboot a couple of times and here’s where the a small problem started. When I added the vdisk and attached it, Windows gave it the boot loader name of “Windows 7″. However my default instance was also named “Windows 7″. Therefore when I booted into Windows 7 I had TWO “Windows 7″ options. I eventually figured out which one was the correct one – but watch out for this because it can be tricky.

Fixing the Same Name Issue

After everything is installed, you’ll want to go back into your default Windows 7 installation and fire up bcdedit from the command line.

Issue the command:


bcdedit /v

This will show you all of the entries in the boot loader for Windows. On one of those you’ll see a path to your .vhd file. That one is your VHD boot. Grab the id (the long guid deal) and copy it to the clipboard. Then type the following command -


bcdedit /set {GuidGoesHere} description "VHD"

Of course, replace the “GuidGoesHere” with the guid you copied from the previous step, also give it a different name other than VHD if you wish.

After that, issue another bcdedit /v command and you’ll see the name has changed. Now, when you reboot into the Windows partition you’ll see the following two options -

  • Windows7
  • VHD

Creating Multiple VHD’s

Once your VHD is set up, you’ll want to boot back into your default Windows 7 install and then copy the .vhd file somewhere safe. This will be your boilerplate Windows 7 install. At  a later time if you’d like to have ANOTHER VHD to boot from (maybe to test beta software, you go to a new client, etc), you can copy this same VHD into a new folder on the default Windows 7 install, perform the bcdedit commands to add the VHD to your boot loader (as listed in great detail in Hanselmans post) and now you’d have three options to boot from:

  • Windows7
  • VHD
  • <YourNewEntryHere>

Booting to the VHD

To recap, I have a MacBook pro, which I’ve used Bootcamp to install Windows 7. Once that was installed I created a VHD (after choosing Windows 7 from the initial boot loading screen). I have created, perhaps, many VHD’s to boot to, and used the bcdedit tool to add them to my Windows boot loader options.

To boot the any of the VHD’s I perform the following steps -

  1. Power on the Macbook Pro while holding down the option key
  2. Select the Windows Partition to boot into.
  3. Once Windows start to boot I will receive an option of what Windows installation I want to boot into (the default “Windows7″ or any of the VHD’s)
  4. I select the VHD, and Windows starts, running with full hardware support*

Its that simple. I can now copy over a new VHD, install some software and test it out.

* Drivers & Full Hardware Support - Because the MacBook Pro hardware is different than a regular PC, you’ll need to put the OSX install CD into the drive and install the Bootcamp tools for Windows. This will install ALL of the hardware drivers you need. You will then be able to use the “command” key on the MacBook Pro keyboard AS the “Windows Key” as you would on a normal Windows keyboard. I advise that you install the Bootcamp tools and then create a copy of the VHD as your baseline/boilerplate VHD. This will allow you to quickly copy over the VHD and get up and running smoothly.

Visualizing the VHD Install

To help you understand what just happend, I’ve created the diagram in Figure 1-1 below. Click it for a larger view.

MacBook Pro, Windows 7 and VHD

Figure 1-1: Visualizing the VHD install. OSX and Windows are boot options. If booted to Windows 7, the other options then become available during the boot process of Windows

Medium Trust is a PITA

There. I said it. Medium Trust is PITA. I wont be surprised if someone replies with  one of the following:

“Well, not really, you only have to do x, y and z and your code is compatible with medium trust environments”

or

“It’s there (Medium Trust) because code needs boundaries within controlled scenarios such as hosting environments.. “

Blah. Blah. Blah. You’re both right. However, it’s still a PITA. Why? In the past 4 months I’ve spent countless hours figuring out why my app is broken in a medium trust environment. I use certain tools to make my life easier (such as Castle Active Record, Windsor, ASP.NET MVC, Spark, etc) yet a lot of them assume full trust. They do have options to get them running under partial/medium trust but in my experience the debugging of these tools in said environments sucks.

Needless to say, I just got done debugging for 2.5 hours why my Spark MVC site would not precompile my views. The error was “No Input could be found". WTH!?! Finally, after walking through my app line by line I found the following in a Spark view:

 

${Html.ActionLink("Track Admin", "index", new { controller = "track" })} ${Html.ActionLink("Speaker Admin", "index" , new {controller="speaker"})}

 

The problem is that I had deleted those controllers and moved that part of the app. Once I removed the code, it recompiled fine. Completely frustrating and the root cause of this is Medium trust. I just spent 2.5 hours working on a debugging issue for Medium trust when I could be creating my app for a mobile start up company that I’m heading up.

Long story short : I’m not a fan of Medium Trust. I don’t know many people who are.

How Can we Get Around It?

I’m not sure we can in the .NET space. Other dynamic languages don’t seem to have these issues, but they do run into odd edge cases at runtime which can be even more of a pain to handle. So at this point, the only answer I have is to recommend any open source or commercial vendor to test their product on a lock down medium trust environment and provide very clear and concise instructions for how to get their product to run under medium trust.

I’ve Moved to WordPress

I’ve moved my blog engine once again. I started with DasBlog, then went to BlogEngine.NET and now I’m finally on WordPress.

Why WordPress? You’re a .NET guy …

Plain and simple. What I had, didn’t work and I need my blog to work, and work quickly. I don’t have time to write plug-ins, hacks to fix something I didn’t write simply so I can communicate with everyone via my blog. I need a solution that allows me to fire up my blog or Live Writer and create an entry very quickly.  I need a solution that allows me to add the new whiz-bang widget created by Developer X. I don’t want to be a blog widget developer,  I am an entrepreneur. My time is better spent figuring out business problems with code.

Secondly – My Host, RackSpace Cloud didn’t work well with Blog Engine .NET. I spent 3 hours trying to figure it out with their support team and they said the problem was my fault, I said it was their fault and we went back and forth. When it comes down to it, the problem was that when I created a new post, a new xml file was created in APP_Data and it was not being propagated across the cloud. Some users would see my post, others would not. A royal PITA.

Long story short. Yes. It’s WordPress. Yes. Its PHP. Yeah, I’m running this on Apache. Yes, I write .NET software for a living. But as I said in my last post, go with what solves the problem. Use what gets the job done. WordPress does that for me right now. Who knows, that could change in the upcoming years.

Suspending Resharper 5

For those of you who don’t know, ReSharper is no longer a Visual Studio add-in. Previously if you needed to disable ReSharper for whatever reason you could do so in the Add-In Manager in Visual Studio. You no longer can. Disabling ReSharper is now termed “Suspending” it. You can suspend ReSharper from the Tools > Options > Resharper options window. Press Suspend. ReSharper will now be suspended.

I know, why would I disable ReSharper? Well, at my current client I’m working on a VB.NET ASP.NET Web Forms application which talks to Microsoft CRM through the CRM WebService and LinqToCrm. The web service proxy that gets generated is over 94,000 lines long. Thats 94,000 lines of VB.NET. When ReSharper starts to analyze that file (as well as the other VB.NET files in the app) all hell breaks loose. The IDE locks up and I can’t do a single thing. Therefore I had to suspend ReSharper while working in this project.

Here’s the crux … the only VB.NET project is the Website, all other libraries are C# (thankfully) and I want to use ReSharper. Going through the tools menu each time I need to Suspend/Resume Resharper is a royal PITA. Thankfully ReSharper gave us a key command: Resharper_ToggleSuspend to assist in toggling the suspension of ReSharper. This is not mapped to any key combo by default. What I have done is mapped it to CTRL + ALT + F6. Now when I need to turn ReSharper On/Off when I enter/leave the VB.NET project I hit the key combo and I’m back in action (or out of action in regards to turning it off). Super easy. Booyakasha.

Frugally Increasing Employee Moral

Lately I’ve witnessed some amazing failures in regards to employers increasing employee moral during a time of need for an organization – they just don’t they actually do the reverse. This usually has a very negative effect on organizational efficiency and employee morale in general. For example – The organization is not doing so well, so they decide to cut costs. The economy is in the toilet, just today the employment rate hit 10.2 percent and nearly everyone who has a job is seeing a lot of “fringe benefits” being cut from the list at work. I have a problem with this, let me explain why.

 

Some Background …

I used to work at an entertainment company for awhile and we received a few fringe benefits that I thought were good – at the time (since I’ve learned better): 

  • Free Coffee (not good stuff, but average brew)
  • Free Creamer – Now this was not like gold plated creamer, but we had 2 different flavors to choose from, but its nice if you don’t like that “lets grow some hair on your back” kind of black coffee.
  • Free hot chocolate
  • Free tea
  • Free aspirin/ibuprofen/basic medical supplies

This is no Google or Microsoft, but at that point in time in my life, I thought it was cool. I was single, didn’t have much at the time and this was the first job I’d really had that offered employees much of anything – so I was stoked/excited for this “free stuff”. That was until the company stopped buying it because of “cost savings” reasons.

… AND THAT’S A LOAD OF BULL.

Instantly I went from a somewhat happy employee to a jaded, “I hate you Mr. CTO because you took away one of the few things that helped me love my job. Free creamer and hot chocolate.” Seriously, I no longer “loved my job” – it pissed me off that much. Yes, this is an extreme example, but its a real life experience that actually happened to me early in my career. I wasn’t the only one that felt like this either – this pissed everyone off. Nearly 90% of the company drank coffee and used that same type of creamer. Employees complained about this for months. Everyone was jaded in one form or another. Everyone knew this was BULL.

To prove my point that it was a load of malarkey I calculated the cost of the creamer at a wholesale rate for a given month. I found that we spent something like $80 on hot drink supplies per month. $80 dollars in supplies made a lot of people happy. More than happy, it was something people liked a lot. It increased morale. We had about 100 employees, so per person, we’re talking PENNIES ON THE DOLLAR.

 

The Point

The point of this is … happy people produce more. Unhappy people don’t. How many times have you seen an unhappy person at work cranking out code quickly or busting out reports at breakneck speed? Umm…rarely ever, if at all. However, if that same employee is happy, they’re output is exponentially higher – I’ve witnessed this myself, heck, I’ve even been both of those people. I’m not going to go cite any articles saying x and y and z with some fancy charts proving this, go look it up on Google if you really need to prove it, trust me, the proof is in the pudding.

My last full time employer, Magenic, is a great example of a company with nice fringe benefits. While these fringe benefits were not expensive they were seen as golden nuggets by all employees. We were given free soda (tons of various flavors), free premium brewed coffee, creamer, hot chocolate, water, and snacks if there were any around at the time (snacks were a here and there kind of thing if we had an event, etc). This had a profound effect on people. Giving nerds like us free soda while coding was awesome! At all times you knew you could go grab a soda if you wanted. There was literally an endless supply. Morale was high because of this. Don’t get me wrong, we still had up’s and down’s, but this very cheap offering helped morale more than most know. The key thing is… Magenic was not immune to the economic downturn of the last year. But regardless how bad things got, people still needed to work, and nerds needed soda. These fringe benefits were never taken away because of a “cost reduction strategy”. Taking away these fringe benefits would cost the company more money than it would ever save. Morale is expensive to lose, and can be cheap to gain.

But how cheap, is cheap?

 

How To Improve Morale Frugally

There are a ton of ways to do improve moral frugally. Here are a couple:

  • Free Soda  – If it cannot be free, buy your own machine and charge 10 cents or 25 cents a can. Keep it dirt cheap if you ABSOLUTELY have to charge. IMO – you don’t need to charge, tightwad.
  • Free Weekly Lunch (or better yet, free lunch) -  While not as cheap as soda, its an excellent team builder as well as morale builder. However this is usually only possible at smaller companies.
  • Free Premium Coffee/Creamer/Hot Chocolate/Tea – This is another no brainer. Get a couple industrial brewers and keep that stuff on TAP. Seriously. At MarketWatch.com Lou and I were constantly making trips to get coffee up to as late as 4pm. Caffeine == awake nerds. Side note: If you charge your employees for coffee, sit down, slap your self in the face and stop. That’s all. It’s coffee. Its pennies on the dollar for your return.
  • Dont Sweat The Small Stuff – 2 Monitors, the fastest machine you can buy. All of these things have cost benefits not to mention employee morale.

This list could go on forever… but I feel there are more idea’s (and much better ones than the ones above) brewing in this thread than I can post in this blog. I suggest you check out the thread and get some ideas.

Employee’s are not cheap. Intellectual knowledge is even more expensive. Treating your employees to these cheap fringe benefits is like a very cheap insurance policy on your employee’s staying with your company.

Think about it …

Would you be more likely to think twice about leaving a company that gave you tons of great fringe benefits (soda, coffee, snacks, a lunch, powerful equipment) than if you were treated like a 10-Key Data Entry 15 year old?  My experience says that you’d realize that “If I leave this company, I’m not going to get x, y or z. I’ve never had x, y or z at any other company. I really like x y and z. Maybe leaving is not an option.”

Think about it. Happy employees = More Output = Happy Company