Windows Installation from USB Key

I was installing Windows 7 to a fresh hard disk from a bootable USB. When selecting the disk/partition onto which it should be installed I was met with an error about not being able to find a system partition. I followed several guides to no avail but eventually found the following instructions which worked perfectly:

  • Boot Windows installation from USB drive
  • Press Shift+F10
  • In console type diskpart.exe and press enter. In this program execute the following commands:
    • select disk=0
    • create partition primary
    • select partition=1
    • active
    • format fs=ntfs quick
    • assign drive=c
    • exit
  • Navigate to USB flash drive, in my case type: e: (could also be d: e.g. if you don’t have an optical drive)
  • xcopy e: c: /e /h /k
  • cd boot
  • bootsect /nt60 c:

Remove USB drive from computer and restart.
Install Windows as usual.

To remove the unnecessary menu item from the boot screen:

  • Run cmd.exe as Administrator
  • See boot menu list bcdedit
  • Find Windows Setup and copy identifier
  • Run bcdedit /delete {identifier}

Thanks to http://goo.gl/BXw5qR for their great guide!

Using permanent_records Gem with ActiveRecord Session Store

I spent a couple hours pulling out hair when, after switching my Rails app from using the Cookie session store to the ActiveRecord session store, I could no longer log in without an arcane exception RecordNotSaved.

Searches on the web revealed no correlation between using the ActiveRecord session store with the permanent_records gem but stepping through the libraries with pry strongly suggested that calls to loaded? in a couple of Session callbacks should have returned true but didn’t because the record had been deleted thanks to permanent_record.

In the end the following quick monkey patch was all that was needed. Place this in config/initializers/session.rb and enjoy.

https://gist.github.com/slamotte/5589389

Enable Extra Mouse Buttons in Linux Guest VM (VMware)

It’s long bugged me that I was not able to use the extra mouse buttons (e.g. back) in my Linux VMs under VMware Workstation. Apparently it’s bugged a lot of others too because today after finally reaching my breaking point I did a quick search and found that manually adding a single line to your VM’s .vmx file will enable this missing functionality. Here’s the line, simply append it to your vmx file when your VM is powered down and restart:

mouse.vusb.enable = "TRUE"

I wish I’d hit my breaking point long ago and fixed this… Now my Kensington Expert Mouse is a first class Linux citizen in VMware.

Source of solution: http://goo.gl/zCYj6

VMware ESXi Corrupted iSCSI Datastore

Terrible scare yesterday. I rebooted my ESXi server, which hosts several critical systems, and ESXi didn’t recognize the iSCSI datastore. It could see the iSCSI LUN, but attempts to add it as a new datastore warned that all data would be destroyed. Backups were available but I’d rather have (a) found out what the problem was/why it occurred and (b) fixed the problem. So started my 12-hour learning process.

This all came about because I rebooted the host in an attempt to get new vNICs working under a VLAN. Yes, holidays are a great time to play and learn, it would seem. As a consultant, I should spend even more time doing this sort of thing.

So why couldn’t VMware mount the datastore? Did something happen to it? I tried all manner of fixes, including ultimately reconfiguring my host from scratch to wipe out any traces of the old datastore in the hope that some config was corrupted, but no go. The last resort, it would seem, would be to repartition the iSCSI LUN, which to me seemed a last-gasp effort. Since I was at that stage, I followed the following instructions:

esxcfg-scsidevs -c (take note of the disk device)
fdisk -l /dev/disks/t10.F405E46494C4540096D427739387D25525F4A5D245638787

Hmmm, this didn’t show “fb VMFS” like it should, but rather “SFS”. A quick search told me that this indicated a Windows dynamic disk. Uh oh… Rewinding a bit, a couple of weeks ago a Hyper-V Windows Server of mine had lost its iSCSI connection. The disk was there but it couldn’t access it. I saw that it was marked as, you guessed it, Dynamic! Does that mean everything is toast? I can only guess that ESXi saw the disk as VMFS since it was first created, and continued to access it as such even once Windows had marked it as dynamic. Since the Windows server didn’t really use it, odds are that the two didn’t interfere with each other except for the partition table.

Only one way to find out. I continued with the terrifying process of repartitioning the datastore:

fdisk /dev/disks/t10.F405E46494C4540096D427739387D25525F4A5D245638787
d (deletes the partition: gulp!)
n (create new partition)
p (make primary)
enter (accept default)
enter (accept default again)
t (change partition type)
fb (VMFS)
X (expert mode)
b (change beginning of partition)
1 (first partition)
128 (select secdtor)
W (write changes and exit: double gulp!)
vmkfstools -V (discover the VMFS)

At this point, in vShpere I did a Rescan on the Storage Adapters, and after clicking on Storage, to my amazement, my iSCSI datastore was there! I added my VMs to the inventory and started them up, and all was fine. Very cool.

To finish things off, I disconnected the LUN from that rogue Windows server and removed the LUN from OpenFiler so this can’t happen again. While it’s fine for different ESXi hsots to share a LUN, it’s clearly a bad idea for Windows and ESXi to try and play together…

VMware Workstation 7.1 and Ubuntu 10.10

Ever since my work computer’s hard disk crashed and I reinstalled VMware Workstation 7.1.2 on Ubuntu 10.10, I get an annoying dialog every time I start Workstation telling me that certain modules need to be compiled. The last, VMCI Sockets, always fails with a compiler error. Apparently the kernel in 10.10 breaks the compile. Here’s how to fix it:

wget http://www.debuntu.org/sites/www.debuntu.org/files/vmware-7.1-ubuntu10.10-patch-v2.tar_.gz
tar -xzvf vmware-7.1-ubuntu10.10-patch-v2.tar_.gz
cd vmware-7.1-ubuntu10.10-patch 
sudo sh ./apply_patch.sh

Sweet! Thanks to this site for the instructions.

Microsoft Development Tax

Preamble

I used to be a Microsoft-only developer until I started working with my latest client. I used to buy my annual $3000 MSDN subscription so I could stay on top of their technology. And to a diminished extent, I still have to keep on top of this because I have several clients that are Microsoft shops. But at my current client, they use almost all open-source tools and technologies. This I initially found quite disturbing. Where would support come from? How can we run our business using these amateurish products that anyone can contribute to. Where’s the QA?!

It didn’t take long for my fears to subside. What I had initially thought to be concerns turned out to be benefits. I won’t get into the whole open/closed source debate here as it’s been done to death, but it became apparent that quality of these products, especially the more mature ones, is in fact probably better than that of the corresponding Microsoft offerings. Now, everyone makes mistakes and bugs get into products all the time. In the open source world, when a bug does get introduced, many many eyes quickly see it, and enthusiasts (as opposed to paid staff) race to fix the problem. As a result, quality really becomes almost a given because poorly-written applications are largely destined to never make it out of the gate due to a lack of adoption. Don’t get me wrong: there is plenty of junk out there. But by and large, software like Ubuntu, Ruby on Rails, and Eclipse just to name a few are very robust and proven technologies. One needs to be diligent in selecting the tools that will run their business just as much in the open source world as in the closed source world.

When asked to build a solution for one of my clients, I would normally create a .NET web app  in Visual Studio that would eventually run on Windows Server. Visual Studio is not cheap. Windows Server and its various client access licenses is not cheap. Now I write Ruby on Rails apps that run on Ubuntu Server. These are proven technologies, and Rails is one of the nicest environments to work with, which makes my work more fun and more productive. A great benefit is that all of this is free. So tell me how I am supposed to tell my clients that they should pay for Microsoft infrastructure when I can give them the same thing built faster that uses free software? I can’t.

You Expect Us to PAY for This?

But to me, there is a more fundamental problem with Microsoft. And this one is really starting to bother me.

A constant theme in the open source world is that there are minimal financial barriers to adoption of these technologies. You want to run Ubuntu or some other flavour of Linux? Download the installer disc and install it. No CALs or other license fees to worry about. You want to learn Ruby on Rails? Go to the Rails site, install the executables, and away you go. There are some free IDEs if that’s what floats your boat, but by and large people use simple text editors. And there are lots and lots of tutorials, examples, blogs, screencasts, etc. All free. Not so with Microsoft.

Now it’s technically true that you can write .NET apps with Notepad or one of the free versions of Visual Studio. But no serious developer is going to that, especially in a corporate setting. Microsoft keeps most of the really useful features out of these free versions so you are really forced to pay to write code for their platforms. It’s no secret that more people are shunning Microsoft solutions as time goes on, so you’d think Microsoft would want to reverse this trend by making their platform more attractive to developers. Instead, Microsoft seems intent on taxing developers, the very grassroots community that they built their business on, by charging them for things like Visual Studio, MSDN, TechNet, and development copies of Windows and Windows Server. This seems self-defeating in an age where there are so many free alternatives.

Instead, Microsoft should drive development by making things like VS2010 available freely. This would really help turn things around for them. It is hard for a lot of SMBs to justify spending thousands on a copy of VS2010 PLUS Windows servers, CALs, etc when they can spend nothing on Linux server apps built on free Java/Eclipse or Ruby on Rails. Once today’s open-source enthusiasts, which is predominantly a younger demographic, gets promoted within enterprises to the point that they make infrastructure decisions, Windows will be in serious trouble.

Microsoft TechDays (BlechDays?) 2010

What  brought me to write this is the upcoming Microsoft TechDays 2010. While it’s true that there is value in the sessions presented at this event, a big attraction is the “free” stuff you walk away from the event with. Last year, the only significant take-away was a one-year subscription to TechNet Plus. This product (which arguably should be made freely available to developers, see above) has a sticker price greater than that of TechDays itself, and was a major consideration in my deciding to attend. No doubt a lot of others felt the same way.

It was recently announced (note the distinct lack of comments) that a TechNet subscription would NOT be included for 2010 attendees. This was enough to make me instantly decide not to attend. Fast forward a couple of weeks however and I get an email link to a post saying that TechNet WOULD be included in 2010 because of the efforts of the event coordinators who convinced MS Canada to supply attendees with subscriptions. Here is an excerpt:

I am happy to announce that the hard work has paid off and we have been able to work with Microsoft corporate and each TechDays 2010 attendee will get a TechNet subscription!

This benefit is added to the over 50 Sessions of technical content, networking opportunities, great offers from our Partners, like Telerik, Pluralsight, Xceed, and access to 50 virtual labs to get hands-on without requiring you to provide the necessary hardware and software to support adoption. 

Now, to be clear, I did announce just a couple of weeks ago that we would notbe providing TechDays 2010 attendees with TechNet subscriptions, but understanding that now, more than ever, you need all the tools in your arsenal to help you deploy Windows 7 and Office 2010, implement Windows Server 2008 R2, Hyper-V, SharePoint 2010, and other technologies, we were able to work with our colleagues at Microsoft Corporate to make a one-time exception.

Fantastic! But several inconsistencies and flaws in their reasoning were apparent.

First, the email stated how significant it was that they managed to secure subscriptions for attendees. I agree. But they went on to seemingly minimize the significance of this by stating that it will NOT be included in 2011 or later, and that it’s really no big deal because it’s the sessions that provide value blah blah bullshit. So which is it? Are you just trumpeting yourselves for getting us TechNet subscriptions, or telling us that they aren’t really all that important because you aren’t going to try and get them in 2011, or they are important but you aren’t going to bother trying again? A lesson in expectation management seems in order. But I really started to boil when I read some of the comments to that post which were somewhat smugly answered, seemingly in an attempt to minimize the value of TechNet compared to the sessions. While I can’t disagree with that statement to some extent, it seems they fail to acknowledge that there are a lot of people that go to this event primarily for TechNet and the value that IT brings. Worse, in typical Microsoft style, they try to tell people how to think rather than listen to their concerns. After all, they are Microsoft, so they must know best. To wit:

The sessoins [sic] are the main “gift” you get and I think people must see the value of that.

Thanks for that blinding insight, clearly we aren’t capable of thinking for ourselves. But what really got to me was that they censored my comments to that post. I twice asked why Microsoft doesn’t make development tools more freely available, once rather pointedly, a second time in a much less aggressive fashion, but both comments were never listed. I guess they don’t want others thinking that people might not agree with their authoritative views. Well f*ck you Microsoft Canada, I will not pay even the early bird fee of $350 for the privilege of attending your TechDays now or in the future. And while I will provide Microsoft solutions to my clients if they so desire, that will not be my first recommendation.

Ubuntu 10.04 Is Here

Not sure why I am so excited about this. Geek obviously, but still. Normally I am fairly reserved when a new version of something comes out, but this one feels different.

I use 8.04 at work at my primary OS with a dash of VMware Workstation thrown in for Windows/Outlook and other testing. At home my machines are primarily Windows 7 thanks to my MAPS and TechNet subscription. I really love using 8.04 at work but it has some issues. Sound seems to be a big problem; often times it will just stop working for no reason until I reboot, which I don’t like to do very often. This is generally fine because I don’t do much that requires sound, but it makes it pretty frustrating when there’s an important screencast to be viewed.

More of a problem is when it slows to a crawl. It’s pretty frustrating when I am trying to get something done quickly and it becomes unresponsive for 30 seconds or longer. I would think any modern OS should be able to multitask pretty well, so I don’t know what’s going on there. This doesn’t happen a lot but when it does, it makes me wonder if I should switch back to Windows.

I am very much hoping that 10.04 fixes both issues.

In the past, I used to occasionally install Linux just for something to do, but then once it was installed, I’d be all “ok, now what?”, then destroy the installation and put Windows back on it. You could hardly blame me: all my clients were Windows-based, so there was little point in me putting much effort into Linux. Times have changed: now I wish all my clients used Linux.

As a test, I installed it under VMware Workstation. It installed fine, but after initially booting, I was unable to enter a password: the keyboard didn’t work. Not the coolest start! I clicked the little man-in-wheel icon at the bottom and selected the option to display the on-screen keyboard. After rebooting, the keyboard showed up and I logged in. Then I opened a terminal and entered:

sudo dpkg-reconfigure console-setup

After rebooting, I turned off the on-screen keyboard. Now everything is working well. Apparently this is caused by a conflict introduced by the VMware tools during automated setup, and by not doing an automated setup this shouldn’t happen.

Better SSH Remote Access

If you’re very familiar with using the ~/.ssh/authorized_keys file to allow secure, password-less SSH access to your servers, then you probably don’t need to read this post.

I have only been using this file for a short while, instead opting for the tedious (?) option of entering a password each time I connect to a host. This is mostly because I thought the process of appending your public key to the authorized_keys file was too clumsy.

Today I realized that there’s an easier way. Assuming you already have your RSA key created in ~/.ssh/id_rsa.pub (create it via ssh-keygen if not), simply issue the following command to add it to a server’s authorized_keys file:

ssh-copy-id -i ~/.ssh/id_dsa.pub user@server

When prompted, enter the password for “user” as if you were logging on to that box normally, and then test it with

ssh user@server

You should no longer be prompted for a password.

How to Quickly Configure an Unbuntu/Rails Development Virtual Machine

I’m starting a new Rails project, and as usual I want a new dedicated virtual machine to keep it isolated from my other development environments. Since it will be based on Ruby on Rails, Ubuntu is my choice for operating systems. Though it’s not terribly onerous, I didn’t feel much like installing from scratch, so I found a great resource here: http://hex.io/1lda

After starting the VM and installing VMware Tools as per the site’s instructions (http://hex.io/1ldb) and excellent script (I recommend upgrading the kernel before this to avoid having to run “sudo vmware-config-tools.pl –d” again, like I had to) I used the Synaptic Package Manager to install Ruby, Rails, MySQL Server & client + tools, Git, the full version of vim, and several other packages.

Since my project will use SQL Server as the back-end database, I needed to install a suitable database adapter. Instructions for one such adapter are at http://hex.io/1ld5. As documented, specific versions of support gems are required.

The number one annoyance for me to running Ubuntu in a VM is that horrific speaker beep when doing filename completion or trying to scroll past the end of file in vim.

After some research, I found two complementary solutions. First, edit /etc/modprobe.d/blacklist.conf and add the following lines:

# turn off the PC speaker
blacklist pcspkr

This kills the beep once and for all. However it would be nice to get a visual beep, so add the following to ~/.inputrc:

set bell-style visible

There were also keyboard issues as the VM image is set to an international keyboard by default. I changed the keyboard to a Generic 104-key model and set the layout to English Canadian. No more irritating accent characters.

Here’s a nice article on configuring remote access in Ubuntu: http://hex.io/1ld8. This way the VM can be running on a host in the server room and I can connect to it using my main workstation. I particularly like the bit about allowing multiple users to access different virtual screens.

At the end of the day, I have a pretty current VM image that’s ready for Rails development action.