Windows 7 seems to fix itself!

Microsoft gets some stick for Windows supposedly being less than stable (which, as I’ve written here many times before, is not my experience); however my netbook has had more than its fair share of BSODs this evening… something to do with a file called tdx.sys (the TDI Translation Driver). I should point out that this machine is running a beta operating system (i.e. one where problems should be expected) but the good news is that Windows 7 detected the problem and the Action Center referred me to Microsoft knowledge base article 967891, from where I was able to apply for, download and install the associated hotfix.

Action Center KB referral

Only time will tell if the hotfix solved the problem but the point is that Windows self-diagnosed the issue and I was able to follow the necessary steps to fix it. Some people may argue that if the system can diagnose the issue then it should be able to self-heal and they may have a point but I’d like to know which updates are being applied (and why), so this system works for me.

On a related note, Daniel Terhell at Resplendence Software has written a great utility called WhoCrashed. If you’re trying to diagnose the cause of system crashes, this might just help out (it makes use of Microsoft’s Debugging Tools for Windows) – and it’s free for personal use. If it can’t find any crash dumps on your system (but you can see them in the %windir%\minidump folder) then make sure you are running the program as Administrator (and that’s no excuse for running with Admin privileges all the time).

WhoCrashed

If you want to see just how stable your system is and you’re looking for the Reliability Monitor, under Windows 7 (at least in the beta – build 7000) it is available in the Action Center.

Installing WordPress on a Mac: the aftermath (phpMyAdmin, databases, themes, plugins and fixing the tags)

Last week I wrote about installing WordPress on a Mac but I wanted to follow that up with a post on what happened next.

Installing phpMyAdmin

Installing WordPress is all very well, but it’s good to be able to manipulate the database. The command line mysql tools would have worked but a graphical interface (even an ugly one with bizarre icons) is often easier, so I installed phpMyAdmin as described by Nino Müller:

  • Download the latest version of phpMyAdmin (I used v3.1.2).
  • Extract the files to ~/Sites/phpmyadmin.
  • Copy config.sample.inc.php to config.inc.php and edit the Blowfish secret (the line which reads $cfg['blowfish_secret'] = ''; .
  • Navigate to http://localhost/~username/phpmyadmin and login.

Unfortunately, after attempting to logon, I was presented with an error message:

#2002 – The server is not responding (or the local MySQL server’s socket is not correctly configured)

Following The Vince Wadhwani’s advice at his Hackido site I typed mysqlconfig --socket to verify the socket is in use for MySQL (e.g. /tmp/mysql.sock) but I couldn’t find a config.default.php file (or the equivalent entry in my config.inc.php file) to adjust the socket. A post at Friends of ED suggested creating a symbolic link for the socket and it seemed to work for me:

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Following this I could log into phpMyAdmin (although I still have a warning message that phpMyAdmin cannot load the mcrypt extension – this doesn’t seem to be causing any problems though).

Importing a WordPress database

Using phpMyAdmin on my web host’s server, I exported the database from the live copy of markwilson.it and attempted to import it on the Mac. Unfortunately this didn’t work as my database was too large for PHP to upload – as confirmed by creating a file named ~/Sites/phpinfo.php containing <?php phpinfo(); ?>, then viewing it in a browser (http://localhost/~username/phpinfo.php) and looking for the upload_max_filesize variable.

Rather than messing around with my PHP configuration, I googled for the necessary commands and typed:

/user/local/mysql/bin/mysql -u root -p
drop database wordpressdatabasename;
source ./Downloads/wordpressdatabasename.sql
quit

At this point, the local copy of WordPress was running on the live database, but the links were all to the live site, so I used phpMyAdmin to edit the site URL in the wp_options table, changing it from https://www.markwilson.co.uk/blog to http://localhost/~username/blog.

Because the live copy of the site is on an old version of WordPress, browsing to http://localhost/~username/blog/wp-admin prompted me to upgrade the database, after which I could log in and edit the site settings (e.g. the blog address).

WordPress database upgrade

WordPress 2.7 Dashboard

Restoring the theme and plugins

At this point, although WordPress was running on a local copy of my live database, the normal theme was missing and the plugins were disabled (as they were not present). I copied them from the live server and, after selecting the theme and enabling the plugins saw something approaching normality, although there were a few plugins that required updating and I still couldn’t get rid of a particularly annoying database error:

WordPress database error: [Table ‘wordpressdatabasename.wp_categories’ doesn’t exist]
SELECT cat_name FROM wp_categories ORDER BY cat_name ASC

By disabling plugins one by one (I could also have grepped /~Sites/blog/wp-admin/wp-content/plugins for wp_categories), I found that the issue was in the Bad Behavior plugin that I use to ban IP addresses known to send spam.

Moving from categories to tags

When I first moved this site to WordPress, I used Dean Robinson’s Ultimate Category Cloud plugin to provide a tag cloud (at that time WordPress did not support tags). Over time, that because unmanageable and, although I still need to define a decent taxonomy for the site, the categories still have some value if they are converted to tags.

Over some tapas and drinks in the pub, my friend Alex Coles at ascomi and I had a look at the database structure and Alex came up with a quick SQL query to run against my WordPress database:

UPDATE wp_term_taxonomy SET taxonomy='post_tag' WHERE taxonomy='category'

That converted all of my categories to tags, but there were some I manually edited to return to categories (General – which was once called Uncategorised – and Site Notices) but for some reason, all the posts were recorded in a category of Uncatagorized. Some late night PHP coding (reminiscent of many nights at Uni’ – as Steve will no doubt remember – although in those days it was Modula-2, C, C++ and COBOL) resulted in a script to run through the database, identify all posts with a category of 17 (which in my database is the default category of “General”), put the post numbers into an array and then explicitly set the category as required, taking a note of the ones which have been changed so that they can be ignored from that point on:

<html>
<head>
</head>

<body>
<?php

// Connect to the WordPress database
$db_hostname = "localhost:/tmp/mysql.sock";
$db_username = "wordpressuser";
$db_password = "wordpresspassword";
$db_connect = mysql_connect($db_hostname, $db_username, $db_password) or die("Unable to connect to server.");
$db = mysql_select_db("wordpressdatabasename",$db_connect);

// Retrieve all objects including a category with the value of 17 (my default category)
$hascat = mysql_query("SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id = '17' ORDER BY object_id");
echo '<p>'.mysql_num_rows($hascat).' rows found with category</p>';

$correct_ids = array();

// Build a PHP array (not a MySQL array) containing the relevant object IDs for later comparison
while ($row = mysql_fetch_array($hascat))
{
$correct_ids[] = $row[0];
}
echo '<p>Array built. Length is '.count($correct_ids).'. First ID is '.$correct_ids[0].'.</p>';

// Retrieve every object
$result = mysql_query("SELECT * FROM wp_term_relationships ORDER BY object_id");
echo '<p>'.mysql_num_rows($result).' rows found total</p>';

// The magic bit!
// If the object is not in our previous array (i.e. the category is not 17)
// then add it to category 17 and put it in the array so it won't get added repeatedly
while ($row = mysql_fetch_array($result))
{
if (!in_array($row['object_id'],$correct_ids))
{
// Add to category 17
mysql_query("INSERT INTO wp_term_relationships (object_id,term_taxonomy_id,term_order) VALUES ('".$row['object_id']."','17','0')");
echo '<p>Alter database entry for object '.$row['object_id'].'.</p>';
// Add to the array so it is not flagged again
$correct_ids[]=$row['object_id'];
}
else echo '<p style="color:white; background-color:black">'.$row['object_id'].' ignored.</p>';
}

?>
</body>
</html>

Remaining issues

Permalinks don’t seem to work – it seems that Mac OS X does not support using .htaccess files by default and, whilst it’s possible to modify for the root folder it doesn’t seem to work for individual user sites. I’ll do some more digging and see if I can find a fix for that one.

WordPress also features the ability to automatically update plugins (and itself), but my installation is falling back to FTP access when I try to update it and making it work appears to be non-trivial. Again, I’ll take another look when I have more time.

More ineptitude from HM Revenue and Customs

18 months ago, I had a rant about the ineptitude of HM Revenue and Customs in losing the personal details of over 25 million people in the UK. Well, if you don’t want to read another rant, stop now because I’ve just got home and found another shining example of their bureaucratic f***-ups.

In common with several million people, I filed an on-line tax return recently. I used the self assessment website from HM Revenue and Customs, entered the relevant numbers, and let it work out how much tax I owed. And the good news was that it calculated that I was owed several hundred pounds. Bonus! I like that sort of tax return but sadly my joy was not to last long. A few days after I received my refund and the 31 January tax return payment deadline had passed, I received a letter explaining that there was a mistake on my return and that I now owed the Revenue some money as a result of having been over-refunded. I thought it was too good to be true but I’d just put in the numbers that the system asked for – how was I to know that the line on my PAYE coding notice that said tax underpaid from a previous year was being reclaimed in my tax code was a complete fallacy? Hey – I only read it from an official Government document… (you may detect a sense of sarcasm… it may be the lowest form of wit but it’s also entirely deliberate).

So I phoned HM Revenue and Customs to check that I wouldn’t be fined for late payment as it was their mistake, to which the response was “How do I know it is a Revenue and Customs mistake?” and my answer was “Because your website calculated my tax bill!” but knowing that resistance is futile, that the tax man is always the first debt that should be paid (and that a smaller refund was better than nothing) I repaid the balance of my account in order to avoid interest and a fine.

Today, I received a final demand from HM Revenue and Customs. To their credit (excuse the pun!), it was issued on the day I made payment but it was issued on 16 February – just a five days (three working days) after they wrote to tell me that I had been overpaid. What’s worse though is that the final demand was for payment by 28 February and was sent by Royal Mail second class post and not delivered until today – 3 March – a whole 16 days (12 working days) later and after the payment deadline! According to Google Maps the postie could have walked the 217 miles from the HMRC offices in Sunderland to my house in a little under 3 days… so what took the Royal Mail so long to deliver it with the aid of some trucks and vans (no wonder they are losing so much business custom)?

I suspect that the final demand, although dated 16 February was not posted until much later, by which time my account had been settled. Which begs the question, why can’t HMRC (or anyone else sending out bills) wait a few days to receive payment before issuing final notices?

Right, time to pack up my soapbox. I found that cathartic and if you’re still reading I hope you did too.

Installing Windows SharePoint Services on Windows 7 (or Vista)

Windows SharePoint Services (WSS) is not supported on a client operating system, but that’s not to say it shouldn’t run – right? After all, Windows client releases include a web server and can run a database service – that should pretty much cover the basics (back in the days of Windows NT it was generally reckoned that the differences between the Workstation and Server releases were just a few registry entries – but even if that was true then, there are a few more differences today)! In response to this, the guys at Bamboo Nation came up with an installer for SharePoint on Vista and, even though it’s been around for a while (thanks to Garry Martin for alerting me to this), last week I finally got around to trying it out on Windows 7.

It seems to work well but, having never installed SQL Server 2008 Express Edition (WSS needs access to a SQL database) I needed to combine two very good resources (the Jonas Nilsson’s installation guide for Windows SharePoint Services 3.0 SP1 on Windows Vista and Symantec’s article on installing and configuring SQL Server 2008 Express) – the result is my installation notes (repeated in full here in case either of those articles ever disappears but for screen shots, refer to the originals – or to Jim Parshall’s video tutorial):

  1. Gather together all the resources that will be required. Assuming that Windows is already running, the remaining components are:
  2. Install and configure SQL Server 2008 Express Edition:
    • SQL Express may be downloaded with or without tools – I went for the “without” option but the tools may be useful for troubleshooting purposes. If you’re installing on an older platform, there are some pre-requisites (.NET Framework 3.5 SP1, Windows Installer 4.5 and Windows PowerShell 1.0) but my Windows 7 client already had these (or later versions).
    • Run the SQL Server Express installer and follow the wizard. It’s fairly straightforward but there are a couple of things to watch out for:
      • For the instance configuration, specify MSSQLSERVER as both the named instance and the instance ID.
      • For the server configuration, use NT AUTHORITY\SYSTEM (no password) as the SQL Server database engine account name and set the SQL Server Browser startup type to Automatic.
      • For database engine configuration, either Windows or mixed mode authentication may be used (I stuck with the defaults) but the installer will not continue until users or groups are specified for unrestricted access to the SQL server. SQL DBAs and security guys will probably have lots of best practice advice here for use with production servers but I took the view that it’s probably nothing too much to worry about on a developer workstation and simply gave the necessary rights to the account I was running as.
  3. Install and configure Internet Information Services in Control Panel, Programs and Features by clicking the option to turn Windows features on or off and enabling:
    • Internet Information Services
      • Web Management Services
        • IIS 6 Management Compatibility
          • IIS 6 Management Console
          • IIS 6 Scripting Tools
          • IIS 6 WMI Campatability
          • IIS 6 Metabase and IIS 6 configuration capability
        • IIS Management Console
      • World Wide Web Services
        • Application Development Features
          • .NET Extensibility
          • ASP.NET
          • ISAPI Extensions
          • ISAPI Filters
        • Common HTTP Features
          • Default Document
          • Directory Browsing
          • HTTP Errors
          • HTTP Redirection
          • Static Content
        • Health and Diagnostics
          • HTTP Logging
          • Request Monitor
        • Performance Features
          • HTTP Compression Dynamic
          • Static Content Compression
        • Security
          • Basic Authentication
          • Request Filtering
          • Windows Authentication
  4. Install the WSS on Vista setup helper application by running wssvista.msi.
  5. Install WSS by:
    • Locating the WSS on Vista helper application files in %programfiles%\WSSonVista\Setup and running setuplauncher.exe.
    • Pointing the setuphelper to the WSS installer (sharepoint.exe)
    • Following the WSS installation wizard, selecting an advanced installation for a web front-end server, creating a new server farm, and supplying the details for the local SQL database (including the account details).
  6. At the end of the WSS installation, take a note of the port number used, and then navigate to http://localhost:portnumber/. If all goes well, then you should see the SharePoint Central Administration site in your browser:
    Windows SharePoint Services running on Windows 7

Finally, a couple of additional notes:

  • I ran all of this as a standard user, answering just a few UAC prompts at the appropriate points to elevate my privileges).
  • These instructions will allow access to SharePoint site from the local machine; however it will be necessary to create some firewall exceptions if remote client access is required.

Useful Links: February 2009

A list of items I’ve come across recently that I found potentially useful, interesting, or just plain funny:

Understanding how histograms are used in digital photography

The backlog of photography-related posts for this blog is now almost as long as the virtual pile of half-written IT-related ones but I’ve been meaning to write something about histograms in relation to digital photography ever since Andy Gailer‘s presentation on working with raw digital camera images at my local camera club last year.

For the first few years that I owned a digital camera, I ignored the histogram – quite simply because I didn’t understand it. Since Andy explained it to me, I find it an incredibly useful tool for helping me ensure that I’ve captured the maximum amount of data in my images.

The histogram, quite simply, shows 256 levels of light (tones) that are present in an image. The peaks indicate a large volume of pixels in a particular tone and the troughs appear where there are fewer pixels. On the left side of the histogram are the dark areas and on the right side are the lighter areas.

Image showing a Royal Mail postbox in the snow (underexposed)Take, for example, the accompanying picture of a post box outside a gift shop. As can be seen, I took this after a snow fall and I didn’t compensate for the light reflected by the snow. Even though the camera’s automatic white balance would have attempted to make some corrections, the snow shows as grey and the histogram tells me that most of the pixels occur in the darker areas to the left of the graph.

A histogram from an underexposed imageMy camera will show me a histogram but if I view this in Adobe Photoshop, I can see a little more detail. As well as some statistical data about the mean levels and the standard deviation, I can hover my mouse pointer over the graph and see how many pixels appear for a given level. In this case I can see that at level 247, there are only 24 pixels (out of more than six million in the entire image) – effectively there is very little happening in the highlights.

Adjusting levels using the histogramBy adjusting the levels, I can alter the highlights (white slider), midtones (grey slider) or shadows (black slider) and improve the overall exposure of the image. Effectively, I set the black and white points and adjust the contrast.

The ideal histogram is evenly distributed with no breaks and a gradual tail off for shadows and highlights. If I hold the Alt key (Option key on a Mac) as I preview the adjustments, I can see the pixels which are being clipped from the image and I should stop just before this become noticeable (Adobe Camera Raw will show clipping as blue or red pixels when this option is enabled). A few points to note are:

  • Over-exposed images will have clipped highlights and under-exposed images will exhibit clipping in the shadow detail.
  • The vertical scale is of no real consequence (it’s just an indication of the number of pixels at any given light level).
  • Clipping is effectively throwing away part of the detail in the image and should be avoided where possible although it can be used to effect (e.g. as a deliberately high- or low-key image).
  • By adjusting the midtones, the overall brightness of the image may be altered without clipping.
  • Low contrast images will have a very narrow histogram, whilst high contrast images will cover more of the graph.
  • Techniques such as high dynamic range (HDR) photography (and tone mapping) can be used to increase the light levels captured in the image – effectively increasing the exposure latitude.
  • For finer control, individual histograms may be viewed for red, green and blue colour channels or the luminosity.

Image showing a Royal Mail postbox in the snow (levels adjusted)In this example, I have adjusted the highlight details by moving the white slider from 255 to 203 (and Photoshop has automatically adjusted the midtone levels for me). Histogram on an adjusted imageThe end result is a picture which appears to be better exposed although looking at the histogram tells me that there is some detail missing from the shot now (effectively 42 levels have been cut out and the remaining 204 levels of light have been redistributed across the scale – hence the gaps in the graph). These gaps/spikes are an indication of a phenomenon known as image posterisation (or banding) which is not very evident in this image but can generally be spotted in areas of shadow, or the sky, caused by a reduction in the bit depth of the image.

There are those who will say that image adjustment using levels is a very crude tool; however it’s useful to demonstrate how to read histograms. Hopefully this post has thrown some light onto what is one of the more technical aspects of digital photography but is also a very useful tool.

A good news story… courtesy of LogMeIn

A few days ago, one of my colleagues was telling me about how his father’s stolen laptop has been recovered. I’m leaving out the names (for privacy reasons) but it’s a good news story for the end of the week.

In common with many IT workers, my colleague provides technical support for family members and, to make this easier, he had installed LogMeIn. There are any remote control products available (I just use standard RDP/VNC connections) but the advantages of some of the specialist products include NAT traversal (and other firewall-friendly functionality) and, it seems, alerting when a PC is available (or not).

After his father’s PC was stolen, my colleague started to build a new one for him, so, imagine his surprise when the original machine appeared online! Using the remote control software, he was able to identify the user as they browsed a social networking site and then provide the police with fairly conclusive evidence as to who was using the machine.

In the words of my anonymous friend:

“Go technology…”

Thanks to his use of the LogMeIn software and the user browsing a social networking site (in the process revealing their identity) the computer was recovered and three people spent some time in the custody of the local police force (although I understand the actual recipient of the computer was later released with a caution).

Maybe I’ve finally found a use for social networking websites!

Free Microsoft Virtualization eBook from Microsoft Press

Every now and again, Microsoft Press makes free e-books available. I just missed out on the PDF version of the Windows Vista Resource Kit as part of the Microsoft Press 25th anniversary (the offer was only valid for a few days and it expired yesterday… that’s what happens when I don’t keep on top of my e-mail newsletters) but Mitch Tulloch’s book on Understanding Microsoft Virtualization Solutions is also available for free download (I don’t know how long for though… based on previous experience, that link won’t be valid for long).

This book covers Windows Server 2008 Hyper-V, System Center Virtual Machine Manager 2008, Microsoft Application Virtualization 4.5 (App-V), Microsoft Enterprise Desktop Virtualization (MED-V), and Microsoft Virtual Desktop Infrastructure. If you’re looking to learn about any of these technologies, it would be a good place to start.

Hyper-V Q&A

Windows Server 2008 Hyper-VMicrosoft’s hypervisor-based virtualisation platform (Hyper-V) has been around for a few months now and, even though there is a whole host of information out there on the web, it’s still a source of confusion for many.

This post is a list of questions and answers for those trying to get started with the Microsoft hypervisor. It is based, in part, on information provided during the Hyper-V technology adoption programme and has been used with the kind permission of Microsoft Windows Virtualization product team, supplemented with additional information where appropriate.

Installation

Q. What are my options for installing Hyper-V?
A. Hyper-V is available as a role for x64 Editions of Windows Server 2008 Standard, Enterprise or Datacentre editions (i.e. not for 32-bit x86 or Itanium architectures, nor for web edition). The Hyper-V role is supported on either a server core or a full installation; however server core is recommended, due to its increased security. In addition, there is a standalone version of Hyper-V – Microsoft Hyper-V Server 2008 – designed for organisations who would like the benefits of Hyper-V but who do not run Windows (a comparison of features in the various Hyper-V products is available).

Q. I installed Hyper-V from the Windows Server 2008 media but it seems to be a pre-release version. Is that right?
A. Windows Server 2008 shipped with a beta version of Hyper-V. It is necessary to install an update to bring the Hyper-V components up to their RTM level, as well as to update the integration components in the virtual machines. John Howard has blogged extensively on obtaining Hyper-V, changes at RTM, upgrade considerations and more.

Q. How can I tell which version of Hyper-V I have installed?
A. Sander Berkouwer has provided some excellent advice for determining the installed version of Hyper-V on his blog (I also linked to some useful resources for those looking to upgrade a pre-release copy of Hyper-V).

Q. I’m not entirely comfortable with server core – how can I install the Hyper-V role?
A. John Howard has created step by step guidance on installing Hyper-V on Server Core. The basic steps are:

  1. After installation, logon to Windows and set a password.
  2. Configure the computername, firewall exceptions, remote desktop connection and then restart using the following commands (for more information on administering server core, see a few commands to get started with Server Core and there are also some alternative utilities available – including the HVconfig utility from Hyper-V Server):
    netdom renamecomputer %computername% /NewName:newcomputername
    netsh advfirewall firewall set rule group="Remote Administration" new enable=yes
    cscript \windows\system32\scregedit.wsf /ar 0
    cscript \windows\system32\scregedit.wsf /cs 0
    shutdown /t 0 /r
  3. Update Hyper-V to the RTM version (see Microsoft knowledge base article 950050)
  4. Enable the Hyper-V role using ocsetup Microsoft-Hyper-V
  5. Restart the computer using shutdown /t 0 /r

Q. Hyper-V relies on hardware assisted virtualisation. How can I tell if my hardware supports this?
A. Michael Pietroforte has written about the free tools that AMD and Intel provide to indicate whether a processor has the necessary virtualisation functionality and John Howard has also written about enabling hardware assisted virtualization in the BIOS. If your machine does not have the option (and some do not!), try a BIOS update.

Performance

Q. How does Hyper-V’s disk input/output (IO) compare with a non-virtualised solution?
A. In order to ensure that IO will never be reported complete until it has been written to the physical disk, Hyper-V does not employ any additional disk caching other than that provided by the guest operating system. In certain circumstances, a Hyper-V VM can appear to provide faster disk access than a physical computer because Hyper-V batches up multiple requests and coalesces interrupts for greater efficiency and performance. In Microsft’s internal testing they also found that:

  • Pass-through disks can sustain physical device throughput.
  • Fixed VHDs can also sustain physical device throughput at the cost of slightly higher CPU usage.
  • Dynamically expanding and differencing VHDs do not usually hit physical throughput numbers due to the overhead of expansion and greater likelihood of disk fragmentation.

Q. How can I measure performance in Hyper-V?
A. The MSDN website features a section on measuring performance on Hyper-V (specifically relating to running BizTalk Server in a VM but equally applicable to many other workloads).

Q. Sometimes, my virtual machines are paused automatically – why does this happen?
A. Rather than let a virtual machine run out of disk space, Hyper-V will pause the VM if the server is running critically low on space. In addition, an event (ID 16050) is written to the Hyper-V VMMS log.

Synthetic device driver model

Q. I’m confused about the various versions of the integration components (ICs) for virtual machines. Why does each release of Hyper-V have it’s own ICs?
A. Integration Components (ICs) are version specific – i.e. the versions used within the child partitions must match the version of Hyper-V that is running in the parent partition (Windows Server 2008 RTM was shipped with the Hyper-V Beta ICs). The Hyper-V RTM upgrade package (see Microsoft knowledge base article 950050) includes the updates for both the parent and child partitions. In addition, there are Hyper-V ICs for Linux and Professional, Enterprise and Ultimate versions of the Windows 7 and Windows Server 2008 R2 betas already come with Hyper-V integration components installed.

Q. Is there a method to incorporate the Hyper-V synthetic devices with Windows Preinstallation Environment (WinPE) for servicing?
A. Performing maintenance on a Hyper-V host from within WinPE represents a challenge for systems administrators in that, without the integration components, virtual hard disks (.VHDs) must be connected to the IDE controller (limiting the number of VHD’s that can be used at any given point in time) and legacy network adapters might be required in order to provide network access. Mike Sterling has a great blog post on using the Hyper-V integration components with WinPE (using the Windows Automated Installation Kit to create a custom WinPE image including the appropriate files extracted from the Hyper-V integration services setup disk). Attaching the resulting .ISO image to a VM and powering it on should provide full access to all synthetic devices.

Management

Q. What tools does Microsoft provide to manage Hyper-V?
A. Out of the box, Microsoft provides a Microsoft Management Console (MMC) snap-in (Hyper-V Manager). This snap-in is also available for x86 (32-bit) versions of Windows Server 2008, as well as for Windows Vista SP1 (x86 or x64 – see also Microsoft knowledge base article 952627). If you have the management tools installed on a Windows Vista machine then you might also find Tore Lervik’s Hyper-V Monitor Gadget for the Windows Sidebar useful.

Whilst Hyper-V Manager is adequate for managing a single host (locally or remotely), remote management with System Center Virtual Machine Manager (SCVMM) 2008 provides a centralised management console, designed to manage thousands of VMs across hundreds of physical servers running Virtual Server 2005, Hyper-V or even VMware ESX via VMware Virtual Center.

Hyper-V can also be managed using Windows Management Instrumentation (WMI), for example in a Windows PowerShell script and there is an open source PowerShell Management Library for Hyper-V available on CodePlex.

Q. My version of Windows Server 2008 does not seem to have the Hyper-V Management tools available.
A. Windows Server 2008 SKUs without Hyper-V or for other architectures (i.e. 32-bit x86 and Itanium) do not include the Hyper-V management tools.

Q. What else can SCVMM offer that the standard management tools do not?
A. Information on SCVMM may be found on the Microsoft website but the main features include:

  • Physical to virtual (P2V) and limited virtual to virtual (V2V) conversion (V2V is from VMware to Hyper-V – for Virtual Server to Hyper-V there is a free tool available (Matthijs ten Seldam’s VMC to Hyper-V Import Tool) and, for conversions from other products or back to physical hardware, various third party tools are available).
  • Orchestration of migration activities (i.e. quick migration for Hyper-V, VMotion for ESX).
  • Intelligent placement of virtual machines.
  • Management of virtual machine templates, virtual hard disks, CD/DVD (.ISO) images, etc.
  • Full integration with Windows PowerShell (with supported PowerShell cmdlets) as well as other System Center products such as System Center Operations Manager and PRO packs.
  • Virtual machine self-service for users to provision their own VMs, based on a quota system.

Q. I have a fully-patched Hyper-V host and SCVMM 2008 installation but SCVMM says my host needs attention. Have I missed something?
A. VirtualBoy Matt McSpirit blogged about a couple of updates required for Hyper-V and BITS when using SCVMM 2008. After installing these and rebooting, everything should be fine.

Q. How can I patch the virtual machines that are held offline (templates, etc.)?
A. Offline VMs may be patched using the Microsoft Offline Virtual Machine Servicing Tool.

Q. I’m trying to configure remote management for Hyper-V and it seems very difficult.
A. It can be! Luckily, John Howard had a few days vacation to use up and the result was a tool called hvremote. You can read more and download the tool on MSDN – but don’t use it if you’re using SCVMM to manage your Hyper-V hosts.

Q. I’m using the Hyper-V Virtual Machine Connection to access the console of one of my Hyper-V virtual machines but every time I press Ctrl+Alt+left to release the mouse (I do not have integration components installed) my screen turns 90°. Have i been infected with a virus?
A. Probably not! Some Intel chipsets use that key combination to rotate the display. Either turn off that functionality in the display driver settings or press Alt+Tab to break out of the VM and change the hotkey in the Hyper-V settings.

Environmental benefits

Q. Virtualisation is often cited as an enabler for green IT – how can that be? Surely I’m just moving the same heat and power requirements into one place?
A. An underutilised server still uses a significant proportion of its maximum power and consolidation of many low-utilisation servers onto a shared infrastructure will normally result in power supplies running more efficiently and a net reduction in power consumption.

By consolidating many servers onto onto a smaller number of servers using virtualisation then many servers may be retired. These older servers are likely to be less efficient than a modern server and will all require cooling, resulting in further power cooling savings.

Whilst disposal of old servers is not very “green”, some servers may be redeployed in scenarios where a physical infrastructure is still required.

Q. Does Hyper-V work in conjunction with the Processor Power Management (PPM) power savings in Windows Server 2008?
A. When the Hyper-V server role is enabled system sleep states (standby and hibernate) are disabled. The major savings in power and cooling requirements are gained by switching servers off and, by viewing overall demand for the entire virtualised infrastructure rather than working at an individual sever level, it is possible to use management technologies to bring servers on and offline in order to meet demand.

Virtual machine settings

Q. With Microsoft Virtual Server, it’s really difficult to access the virtual machine BIOS. Is there still a virtual machine BIOS?
A. Hyper-V VMs do still have a virtual machine BIOS; however, all of the BIOS features (e.g. numlock setting, boot device order, etc.) may be set in the virtual machine configuration or using a script. As a conseqence of this, Microsoft has removed the ability to access the BIOS at boot time.

Q. Hyper-V can import and export its own XML-based VM configurations but not the legacy .VMC format. Is there a way to migrate my Virtual Server and VirtualPC settings to Hyper-V without recreating the configuration manually (I’m not using SCVMM)?
A. As mentioned when discussing V2V migrations above, Matthijs ten Seldam (The author of VMRCplus) was written a VMC to Hyper-V import tool (remove the VM Additions before importing to save effort later).

Storage

Q. Can a virtual machine boot from SAN (FC or iSCSI), NAS, USB disk or Firewire disks (the boot order in the BIOS settings only shows floppy, CD, IDE and network)?
A. Virtual hard disks (VHDs) can be used to boot or run a VM from:

  • Local storage (IDE or SCSI).
  • USB storage (USB key or disk).
  • Firewire storage.
  • SAN Storage Area Network (iSCSI or fibre channel).
  • NAS Network Attached Storage (file share, NAS device).

It’s also possible to assign a non-removable volume (direct attached storage or a SAN LUN) to an IDE channel in the VM settings and to boot from that device.

Q. Is it possible for Hyper-V virtual machines to access USB devices?
A. Not directly and, although many people would like to see this functionality, Microsoft is adamant that this is a client-side virtualisation feature and have no plans to include USB support in the product at this time. There is a workaround, using the Remote Desktop Connection client though (and this approach can also be used for audio).

Q. How can I move VM images to another physical disk?
A. With Hyper-V, the simplest approach I’ve found for moving virtual machines is to export the VM and import it to a new location. Alternatively, you could move the VHD and create a new virtual machine configuration.

Networking

Q. I’m confused by the various network interfaces on my Hyper-V host – what’s going on?
A. It’s not as confusing as it first looks! The parent partition is also virtualised and all communications run via a virtual switch (vswitch). In effect the physical network adapters (pNICs) are unbound from all clients, services and protocols, except the Microsoft Virtual Network Switch Protocol. The virtual network adapters (vNICs) in the parent and child partitions connect to the vswitch. Further vswitches may be created for internal communications, or bound to additional pNICs; however only one vswitch can be bound to a particular pNIC at any one time. Virtual machines can have multiple vNICs connected to multiple vswitches. Ben Armstrong has a good explanation of Hyper-V networking (with pictures) on his blog and I described more in an earlier post on Hyper-V and networking.

Q. Can I use Hyper-V over a wireless connection?
A. Not directly, but there is a workaround, as described in my blog post on Hyper-V and networking.

Q. Is NIC teaming supported?
A. Not by Microsoft, but certain OEMs provide support, and Patrick Lownds has blogged about new Broadcom support for NIC teaming that seems to work with Hyper-V.

Legacy operating system support

Q. The virtual machine settings include a processor option which limits processor functionality to run an older operating system such as Windows NT on the virtual machine. What does this feature actually do?
A. This feature is designed to allow backwards compatibility for older operating systems such as Windows NT 4.0 (which performs a CPUID check and, if CPUID returns more than three leaves, it will fail). By selecting the processor functionality check box Hyper-V will limit CPUID to only return three leaves and therefore allow Windows NT 4.0 to successfully install. It is possible that other legacy operating systems could have a similar issue.

Q. Does this mean that Windows NT 4.0 is supported on Hyper-V?
A. Absolutely not. Windows NT 4.0 is outside its mainstream and extended support lifecycle and is not supported on Hyper-V and no integration components will be released for Windows NT 4.0.

Q. But one of the stated advantages for virtualisation is running legacy operating systems where hardware support is becoming problematic. Does this mean I can’t virtualise my remaining Windows NT computers?
A. The difference here is between “possible” and “supported”. Many legacy (and current) operating systems will run on Hyper-V (with emulated drivers) but are not supported. Windows NT is no longer supported, whether it is running on physical or virtual hardware. Microsoft do highlight that Windows NT 4.0 has been tested and qualified on Virtual Server 2005 and that Virtual Server may be managed (along with Hyper-V and VMware ESX) using System Center Virtual Machine Manager 2008.

Copying files between virtual machines

Q. I want to copy files between Hyper-V virtual machines. Is there a way to do this?
A. Microsoft make a distinction between client-side and server-side virtualisation usage scenarios and note that virtualisation servers are typically managed by a group of administrators who want to deploy a secure, locked down server by default (and do not want additional attack vectors created through virtualisation). This is the reason that Hyper-V does not include shared folder or drag and drop functionality (nor are there any plans to do so at a later date). The options for transferring data from one virtual machine to another are:

  • Setup a virtual network just as you would for physical systems.
  • Use a virtual CD/DVD creation tool and insert a virtual CD/DVD; this can be done while the virtual machine is running.

Microsoft’s stated position is that, in the case of client-side virtualisation, a single user is running a virtualisation product (e.g. Virtual PC) locally ands expects the capability to move files from one virtual machine to another. For this reason, Virtual PC includes shared folder support (but are not set by default).

Q. How does this work if I move a Virtual PC VM with shared folders to a Virtual Server or Hyper-V system?
A. In this case the shared folders guest components won’t load because the required server-side components are not available in Virtual Server or Hyper-V.

Bulk file renames in Windows Explorer

Working in Windows Explorer today, I noticed something that I found pretty useful. At first I wasn’t sure if it was a new feature in Windows 7 (I’ve since tested and found XP will do something similar, so I guess Vista will too) but I was bulk renaming files and found that Explorer would allow me to rename several files to the same filename root, but suffixed with an identifier to ensure that each file name was unique.

For example, imagine you work for an organisation that produces a lot of customer design documents but which is really keen on re-use. Some customisation is inevitable but you might start out with a template document, or you might work from a documentation set produced for a similar customer environment.

In this example, I have three documents in my set:

Customer X – Infrastructure Design (AD)
Customer X – Infrastructure Design (Exchange)
Customer X – Infrastructure Design (SharePoint)

If I copy and paste these, I now have 6 documents:

Customer X – Infrastructure Design (AD) – Copy
Customer X – Infrastructure Design (AD)
Customer X – Infrastructure Design (Exchange) – Copy
Customer X – Infrastructure Design (Exchange)
Customer X – Infrastructure Design (SharePoint) – Copy
Customer X – Infrastructure Design (SharePoint)

Keeping the copies highlighted, if I right click and select Rename, I can rename them all to a common root of Customer Y - Infrastructure Design. The resulting directory structure is:

Customer X – Infrastructure Design (AD)
Customer X – Infrastructure Design (Exchange)
Customer X – Infrastructure Design (SharePoint)
Customer Y – Infrastructure Design (3)
Customer Y – Infrastructure Design (2)
Customer Y – Infrastructure Design

At this point, it’s now very simple (faster than renaming each file individually and typing the whole filename would have been) to amend the end of each filename to get what I really wanted:

Customer X – Infrastructure Design (AD)
Customer X – Infrastructure Design (Exchange)
Customer X – Infrastructure Design (SharePoint)
Customer Y – Infrastructure Design (AD)
Customer Y – Infrastructure Design (Exchange)
Customer Y – Infrastructure Design (SharePoint)

Some people may be unimpressed. Others may say “script it”. And more people might say use the document templating features in Microsoft Office! Whatever your view, for me, this was a real timesaver.