Category Archives: General

Restoring PCs using Windows Home Server

Over the last week I’ve had an unlucky streak with hardware on my home computers. Firstly my sons aging P3 tower had a hard disk failure. It wasn’t catastrophic but it was preventing new data from being written to the drive. So I copied everything off onto the Home Server’s shared folders.

Then I grabbed an old 6.4 Gb drive (yes they used to make them that small) and installed a vanilla copy of Windows XP. It took about 10 hours and 10 reboots to get this all the way up to Windows XP SP2 with IE 7 and all the latest patches. It also meant the drive had about 400 Mb free.

At this point I figure I’ll copy across a couple of files from the Home Server only to find its not responding. Turns out that the CPU (an old P4) has fried itself. Bugger.

So a trip to the local computer shop and I’ve got an el’ cheapo Core2Duo (4500), Asus motherboard (P5B-VM-SE) and 1 Gb of generic RAM. I rip out the old MB and replace with new components hoping and boot the machine. First thing I find is that it doesn’t even recognize the CPU. A quick download and flash of the latest motherboard BIOS fixes that, but the machine still won’t boot into Windows – reboots as soon as it hits the windows loader.

So I spend a few hours re-installing Windows Home Server. This is actually a lot less painful than Windows XP was – it has a neat feature that allows you to re-install the system partition without effecting any of the data backups or shares – very nice. During the installation though I can’t help noticing an odd “pfft” sound that comes from my son’s P3 which is supposed to be turned off. Turns out that the power supply (cranky old 230 W) has chosen this moment to commit suicide.

Next day – off to the shop again to get a new power supply. I opt for the slightly more expensive Thermaltake PSU with a 12cm fan. Theory being larger the fan slower the required rotation and therefore less noise. I was thinking I’d swap with the Home Server since that’s going to be running 24/7. However, surprisingly the new PSU was louder than the existing PSU in the Home Server that had two 8cm fans – weird.

So now my sons P3 machine has a whopping 550W PSU – major overkill – most of the connectors aren’t even compatible with the motherboard.

But now the cool bit.

  • I boot up the P3 connect to the Home Server and do a full system backup. Easy – does this very quickly across my 1Gb network (all my machines have 1Gb LAN) and connect to a 1Gb switch with the exception of the Home Theatre PC which is currently wireless only.
  • Next I power down the P3 – rip out the 6.4 Gb disk with the recently installed Windows XP and replace with a spare 30 Gb disk from my main workstation (I figure it can do with the 4 remaining newer drives).
  • Then I reboot the P3 using the Windows Home Server Restore CD. This takes a while to load – but when its done it then allows me to follow the prompts and restore the previous system image onto the new drive. It doesn’t care that the drive is a different size – as long as its >6 Gb. It even lets me go in and create partitions on the new drive before I do the restore.

Very nice! Well done Windows Home Server team!!

I Command Thee – Exception?

Ok – so I’m reading through WPF Unleashed and I finish reading the chapter on the various deployment types which also covers the inbuilt page navigation framework. Now this is something that I’m very interested in having attempted the feat myself a few times. So I decide its time to stop reading, roll up the sleeves and give it a try.

To start with I try something like this:

The startup XAML defines we’re using a NavigationWindow with the startup page being HomePage.xaml.

<NavigationWindow x:Class="WpfParameterPassing.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300"
    Source="HomePage.xaml">
</NavigationWindow>

The HomePage contains a Button and a TextBox. The idea is that the Button triggers the navigation passing the content of the TextBox to the called page.

<Page x:Class=”WpfParameterPassing.HomePage”
   xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
   xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
   xmlns:local=”clr-namespace:WpfParameterPassing”
   Title=”HomePage”
   x:Name=”_this”>
   <StackPanel>
        <Button Content=”Make Selection” Click =”Button_Click”/>
        <TextBox x:Name=”selectionTextBox”/>
  </StackPanel>
</
Page>

The page to call is defined as a PageFunction which means it allows a value to be returned. The type of this return value is defined by the x:TypeArguments attribute, in this case a string. The called form just has an Ok and Cancel button, together with a TextBox that is populated with the input parameter and which is used to populate the return value.

<PageFunction x:Class="WpfParameterPassing.SelectFunction"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    x:TypeArguments="sys:String"
    Title="SelectFunction"
    RemoveFromJournal="True">
    <StackPanel>
        <WrapPanel>
            <Label Content="Choice to return:"/>
            <TextBox x:Name="choice" HorizontalAlignment="Stretch" Width="150"/>
        </WrapPanel>
        <WrapPanel>
            <Button x:Name="okButton" IsDefault ="True" Content="_OK" 
HorizontalAlignment
="Right" Click
="Button_Click" /> <Button x:Name="cancelButton" IsCancel="True" Content="_Cancel"
HorizontalAlignment
="Right" Click
="cancelButton_Click" /> </WrapPanel> </StackPanel> </PageFunction>

A little bit of code behind for the HomePage is used to trigger the navigation and to subscribe to the Return event so we can update the TextBox with the value returned from the called page.

    public partial class HomePage : Page
    {
public HomePage()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
SelectFunction nextPage = new SelectFunction(selectionTextBox.Text);
nextPage.Return += new ReturnEventHandler<string>(nextPage_Return);
this.NavigationService.Navigate(nextPage);
}
private void nextPage_Return(object sender, ReturnEventArgs<string> e)
{
if (!string.IsNullOrEmpty(e.Result))
selectionTextBox.Text = e.Result;
}
}

Some code behind on the PageFunction derived class is used to wire up the Ok and Cancel buttons. The constructor overload is then used to allow the input parameters to be passed. I like the idea of using constructors to pass the parameters – neat. [Its a shame parameterized constructors can’t be used to initialize objects in XAML – but that’s a whole other story.]

    public partial class SelectFunction : PageFunction<string>
{
public SelectFunction()
{
InitializeComponent();
}
public SelectFunction(string previousSelection) : this()
{
choice.Text = previousSelection;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
OnReturn(new ReturnEventArgs<string>(choice.Text));
}
private void cancelButton_Click(object sender, RoutedEventArgs e)
{
OnReturn(new ReturnEventArgs<string>());
}
}

So – put all this together and it works as expected. Enter a value on the first page (HomePage) – click the button and the value is transferred to the second page (SelectFunction) where it can be modified and returned via the return result.

The next step is to get rid of all that code behind that binds HomePage to SelectFunction. What better way to do this than with a Command? This is where things began to get fuzzy. If I want to create my own command what should it derive from? After a few false starts attempting to derive from RoutedCommand etc. I decide not to derive from anything and just implement ICommand myself.

    public class SelectCommand : ICommand, INotifyPropertyChanged
    {
private string _selection;
public SelectCommand()
{
//Text = "Select Choice";
        }
public Page CallingPage { get; set; }
public string Selection
{
get
{ return _selection; }
set
{
_selection = value;
OnPropertyChanged("Selection");
}
}
private void OnPropertyChanged(string p)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(p));
}

        #region ICommand Members
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
if (CallingPage == null)
CallingPage = (Page) parameter;
if (CallingPage == null)
throw new InvalidOperationException(
"CallingPage cannot be null when invoking the Execute method."); SelectFunction nextPage = new SelectFunction(Selection); nextPage.Return += new ReturnEventHandler<string>(nextPage_Return); CallingPage.NavigationService.Navigate(nextPage); }
#endregion private void nextPage_Return(object sender, ReturnEventArgs<string> e) { if (!string.IsNullOrEmpty(e.Result)) Selection = e.Result; } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion }

Get rid of all the code behind in HomePage and redefine the Button and TextBox to instantiate a new command and a bit of binding to glue it together.

       <Button Content=”Make Selection” CommandParameter=”{Binding ElementName=_this}”>
           <Button.Command>
               <local:SelectCommand x:Name=”selectCommand”/>
           </Button.Command>
       </Button>
       <TextBox x:Name=”selectionTextBox” Text=”{Binding ElementName=selectCommand, Path=Selection}”/>

Now that’s much better. My button is set to execute a command when its activated (Clicked) and the command controls the page navigation and parameter passing for me. We get the result back into the page simply by binding our output field (in this case selectionTextBox) to the Selection property of the command (essentially the output parameter).

But does it work… well no. It generates this little beauty:

WPF Exception

Hmm… so is this a bug – or have I somehow hooked into some interop? If I remove the event handler subscription to the Return event everything works fine – except of course I don’t get my value .

I even tried Dispatching back to the UI thread in case it was a weird threading related issue – no luck. Interestingly when I first attempted to create my command by inheriting from RoutedCommand the button was disabled. This was despite the fact that my CanExecute method is hard-coded to return true. Its at this point I think I need to go back to the books – I’m obviously missing something.

___________________________________

And the answer is given here.

To work around the limitation I need to make the callback for the return an instance method of the calling form. Hmm… easy enough passing as a callback delegate in C# but how to declare that in XAML? Not too sure about the merits of this limitation – means putting code in the HomePage code behind again.

        public void Returned(object sender, ReturnEventArgs<string> e)
{
if (!string.IsNullOrEmpty(e.Result))
selectionTextBox.Text = e.Result;
}

Oh – and a bit of reading into RoutedUICommand makes things clearer as to why inheriting from it got me nowhere Maybe it can help me with the problem above though?

Windows Home Server RTM

Just setup my Windows Home Server machine to the RTM version (from RC). Performed a manual backup using a single drive (320Gb) which does an amazing job of backing up my main workstation and the home theatre PC [this isn’t a full backup given the workstation alone has over a terabyte of disk – but its most of the important stuff]. However, I then included the second drive into the storage “array” and the backups started failing again. This was the same problem I had with the RC – basically the server machine just reboots halfway through a backup. It seems like a hardware issue given how sudden the reboot is (there is nothing untoward reported in any of the event logs) – but as to which device is failing…

The most obvious candidate would be the second hard drive – a 400Gb Seagate drive. Thing is I’ve run all of Seagate’s own diagnostics over this drive (SeaTools) and it comes up fine every time. Maybe its the SATA controller – but that’s an on-board device which also is operating the primary drive. Maybe its the Intel gigabit on-board LAN controller – but why does it only fail when the second drive is operational. The Seagate drive is marginally faster than the Western Digital – but both drives are less than 6 months old. The S.M.A.R.T. diagnostics for both drives also look pretty normal – with both showing near-perfect health.

Another annoying problem is that I can’t seem to install the Windows Home Server Connector software on my sons PC. It was all working fine under the RC but for some reason refuses to un-install correctly and hence can’t install the update. Frustrating – I was about to resort to some sysinternals tools to track exactly where it was getting stuck – but figured its probably time to just rebuild the machine anyway given its a very old box whose OS has probably hasn’t been re-installed for 6 years or so. Was thinking of upgrading it from XP SP2 to Vista but my 4 ½ year old son has some nostalgic feelings towards XP and isn’t ready for the leap (stumble?) to Vista.

As for the Windows Home Server box itself… dunno – I checked out some motherboard and PSU pricing tonight. Its currently running a crusty old P4 2.8GHz and given its going to be running 24 hours a day I figured I might opt for a more energy efficient choice with a silent PSU to boot. The home theatre PC is silent from any distance greater than 30cm and uses a CoreDuo mobile chip. Seems like a Home Server box should probably be running the same sort of hardware… which leads me to wonder why I need both a Home Server and Home Theatre PC – both of which run 24/7. Oh well – I think its a common sentiment that hopefully the Home Server team will address in the next version.

______________

Slowly but steadily working my way through the WPF book. There are some huge similarities between a lot of what’s in WPF and that I’ve been working on (in my day job) over the last 3 years. This isn’t surprising given that we based a lot of our work on some early XAML samples from Microsoft (and others). I’m already imagining how it would be possible to build an infrastructure framework over the top of WPF to more easily create business applications. So should I dig into Acropolis or just go ahead and build my own?

Little to Report

I haven’t made any progress for the last week on my WPF attempt at PhotoPlay for a bunch of reasons relating to work and home commitments. I’m pretty disappointed about this – I had hoped to have got further. The good news is that I received an e-mail on Monday from www.fishpond.com.au indicating that my book has been shipped and I should expect it by the end of the week.

I must admit I almost resorted to Amazon when purchasing this book – but then at the last minute I figured there must be a local alternative with quicker shipping. The local alternative was fractionally cheaper although I believe they still import the book from their overseas distributors, so I doubt the delivery would have been much different. I’m glad I bothered to look around though because I’m an anti-fan of Amazon – I know the rest of the world disagrees but I just find the entire Amazon web experience to be dismal. Their search never seems to work – even when you know they have the book, and their ordering/check-out process is frustrating.

Hmm… Ok – I had a bad day at work today – vent over…

Who needs a blog?

Well interestingly enough it seems that these days not having a blog can have a negative impact on your chances of getting a job… “So what sort of things do you put on your blog?”, “What’s that – you don’t have one!”.

Writing this introductory blog entry brings back memories of posting up my first “home page” back in the early web days when such things were mandatory for all geeks. If I remember correctly I think I got about three updates to my first (and only) web site. Just past the “Under construction” and just prior to ever having any meaningful content. Let’s see how the blog goes