Windows 7 System Image Restore – Three Days of Frustration

December 18, 2013 10:00 pm

If you ever need to recover a Windows 7 system image onto a new hard drive, I hope you don’t have to go through the same pain I just did. It took me three days to get my main PC back in working condition…

A few days ago Windows finally alerted me to an impending disk failure (after having silently logged the problem to the event log for over three months – gee, thanks Windows!) It was trying to be helpful by encouraging me to make a system image backup before replacing the drive, which I did. That took a while, of course, with 336 GB to transfer. I used an external USB-to-SATA bridge for this. But it took nowhere near as long as the recovery odyssey I ended up with.

My surprises started when attempting to restore this image on a fresh drive. My system has three hard drives, one for the OS and two for data. I attempted to restore the image using a regular Windows 7 install DVD. I had several lying around, but none of them would work. I ended up burning a new one with Windows 7 Ultimate x64 SP1 and using that.

The first attempt at restoring took over 20 hours. I had connected both the new drive and the old drive (plus my two data drives) to the system via its plentiful SATA connectors, so it was a SATA-to-SATA transfer, which I expected to go really fast. Nope. And, apparently, having all disks connected and active while restoring is bad, since (as I think I’ve now concluded) that messes up the drive letter assignment of the restored image. Somehow the restored image ends up with a non-C:\ drive letter.

Not realizing that this was the problem, I tried using Acronis True Image Home 2012 to create a fresh backup image of the failing drive, and then restored that. Same problem. At least Acronis didn’t take over 20 hours to restore the data…

I ended up with two things that needed to be done: The boot configuration had to be fixed (as I later found out this was because somehow my original drive configuration had been messed up between creating the original Windows System Image Backup and the Acronis Image backup). On top of that, I had to somehow fix up the drive letter mapping so that C: would once again be C: – and not F: The drive letter mapping problem showed itself in that the OS would boot (once the boot config was fixed), but after logging in, it would be stuck at “Preparing Your Desktop”, and sometimes even get to a blank blue screen. From there I could start Task Manager via Ctrl+Alt+Del, and then a command prompt, which showed me that the OS thought it was living on the F: drive.

Here’s the boot configuration fix (applied by booting from a Recovery Disk or Windows install DVD):

bcdedit /export C:\BCD_Backup
c:
cd boot
attrib bcd -s -h -r
ren c:\boot\bcd bcd.old
bootrec /RebuildBcd

The drive letter mapping was harder. I couldn’t do it from the Recovery Disk (which I also created along the way), nor by the Task Manager trick (halfway “booted” into the user account). I finally found the trick: Boot from the old disk, load the SYSTEM registry hive from the new disk, and swap the value \DosDevices\F: in HKLM\SYSTEM\MountedDevices with \DosDevices\C:

So here’s the boot drive letter assignment fix based on the above trick for modifying the registry of a non-booting system:

  1. Note what drive letter the non-working disk has for itself based on the “boot halfway” command-prompt (F:, in this case);
  2. Boot the working disk;
  3. Determine what drive letter the working disk has (C:, in this case);
  4. Start regedit, highlight the [HKLM] branch, select the
    regedit option ‘File->Load Hive’, and load the file
    ‘F:\Windows\system32\config\system’ under a {dummy} name;
  5. Locate the two registry entries:

    [HKLM\{dummy}\MountedDevices  \DosDevices\F:]
    [HKLM\{dummy}\MountedDevices  \DosDevices\C:]

  6. Rename the value \DosDevices\C: to some other name, such as \DosDevices\Z:
  7. Rename the value \DosDevices\F: to \DosDevices\C:
  8. Rename the value \DosDevices\Z: to \DosDevices\F: 
  9. Highlight the {dummy} branch, select the regedit option ‘File->Unload Hive’, and exit regedit.

I don’t think I’ve ever had this much trouble restoring an image. I guess the real lesson is “don’t restore the image with any other drives active on the system, and if possible, use a USB bridge for the disk you’re restoring from”. Microsoft, this should be easier!!!

Migrate Visual SourceSafe to Git – A short how-to

November 30, 2013 1:35 am

My hobby/learning projects have been residing in a single-person SourceSafe database for a long time (yes, I know you’re laughing; I don’t care – for single-person projects it’s just fine and dandy.) It was time to start using something new. I wanted to migrate everything, including history, to git.

The first step was to install the latest version of git (Git-1.8.4-preview20130916) on the system that currently hosts the SourceSafe database. If you’re long-term-memory-capacity limited like me and can’t remember git command-line arguments to save your life, you’ll also install something like TortoiseGit while you’re at it. One important step is to choose to run git from the Windows Command line during setup. (The next step needs git in the PATH.)

The second step was to install vss2git (http://code.google.com/p/vss2git/). After some trial-and-error with converting my entire database (a mistake, by the way, see step three) and getting error messages about the log file, I changed the permissions of the install folder to allow “read/write” for every user.

The third step was to convert each main project in SourceSafe (well, via a copy of the SourceSafe folder, actually, just to be paranoid) to a git repository by making sure to use $/Path.to.project in the vss2git tool’s Project field.

image

The fourth step was to convert each of these newly created full repositories to “bare” repositories for sharing across my local network. The command line for that is

git clone –bare –no-hardlinks Path.to.project Path.to.project.git

And that’s pretty much it. A fifth, optional step is to remove the original repository folders that served as the source for the bare repositories (so they don’t clutter up the Windows file share).

I am now the proud “owner” of 13 brand-new, independent little git repositories!

[Update 2013-12-01]

Well, I wasn’t too happy with the above solution. It creates too many nested folders (partly because of how Visual Studio creates stuff in VSS in the first place.) Once I clone the resulting repo, I get something like:

CloneRoot/Uncorked.root/Uncorked.root

That’s not what I want. I need it to be CloneRoot/Uncorked.root at most.

This answer on a StackOverflow question provided a good path to take. Based on that answer, I cobbled together a .cmd file to process all my repositories:

@echo off
for /d %%d in (*) do (
  if not exist %%d\config (
    echo %%d
    cd %%d
    attrib -h .git
    move .git %%d/
    cd %%d/
    attrib +h .git
    git init
    git add .
    git commit -am "moved git root"
    cd ..
    git clone --bare --no-hardlinks %%d %%d.git
    move %%d.git ..
    cd ..
    rem pause
  )
)

The impending XP-ocalypse – Take Action!

November 17, 2013 3:19 pm

The November 2013 issue of CVu (link available to accu.org members only, sorry) has an article from Silas Brown (The Windows XP Threat: A Call to Action), calling people to do something about the problem we all will face when Microsoft stops issuing security updates for Windows XP after April 8, 2014.

The article has a little code snippet that will insert a time-left countdown and message on a website, asking people to replace the operating system on their PC with something other than Windows XP (since XP systems are quite old by now, Linux is suggested as the best alternative). I wanted to take action as well, so I looked around for a plugin to WordPress that I could use. I didn’t find one that was custom-written for precisely this purpose, but what came close was the Linux Promotional Plugin, which is aimed at anyone running Windows or Mac, and encourages them to switch to Linux.

I took some time to understand how the plugin code works (at a shallow level of understanding; just enough to be able to make changes), and found that it was pretty easy to make the changes I needed for my purpose. I even found a small bug while I was at it and sent a note about it to the original plugin author.

The plugin is now live on my blog and has the modifications I made. If you’re interested in using it, you can download the modified plugin, and re-use what you want. It might be useful to use a diff tool to see what changes I made. That might help you adapt the plugin to your own needs more quickly.

I used Internet Explorer’s “F12” Developer Tools to test my changes (modifying the user agent string). Here’s what people on Windows XP will now see when they visit this blog:

image

Silas points people to a Microsoft blog post for motivation, and quotes a particularly relevant passage, so I’ll repeat that here as well:

When Microsoft releases a security update…criminals will…identify the specific section of code that contains the vulnerability…develop code that will allow them to exploit it on systems that do not have the security update installed on them.  They also try to identify whether the vulnerability exists in other products…if a vulnerability is addressed in one version of Windows, researchers investigate whether other versions of Windows have the same vulnerability…the Microsoft Security Response Center…[releases] security updates for all affected products simultaneously…But after April 8, 2014, organizations that continue to run Windows XP won’t have this advantage over attackers any longer.  The very first month that Microsoft releases security updates for supported versions of Windows, attackers will reverse engineer those updates, find the vulnerabilities and test Windows XP to see if it shares those vulnerabilities.  If it does, attackers will attempt to develop exploit code that can take advantage of those vulnerabilities on Windows XP.  Since a security update will never become available for Windows XP to address these vulnerabilities, Windows XP will essentially have a “zero day” vulnerability forever.

Do not be the person who ignores this problem! Take action, whether that be replacing XP with Linux, finding someone to help you with that, or just taking the computer off the Internet!

Slack is to your organization as sleep is to your body

October 17, 2013 12:48 am

This is just to collect a few thoughts I had on June 28, 2013 to make them easier to find and refer to. This tweet started it: https://twitter.com/GeekTieGuy/statuses/350639064703176705

Here is what the next few tweets summarized:

Slack is to your organization as sleep is to your body: time to regenerate and be inspired by dreams and wake with new energy.

What happens when we deprive the body of sleep? We become manic, disoriented. We diminish our capability to be creative, we go insane.

What happens when we deprive the organization of slack? It becomes reactive, haphazard, brittle, overloaded, unable to think.

I recently led a session at Agile Open California with this same title. It was interesting to a few people, and I was sure I’d blogged my expanding tweets, but I apparently hadn’t. Fixed that now…

Mastodon