Technology Tales

Adventures & experiences in contemporary technology

Restoring the MBR for Windows 7

25th November 2010

During my explorations of dual-booting of Windows 7 and Ubuntu 10.10, I ended up restoring the master boot record (MBR) so that Windows 7 could load again or to find out if it wouldn’t start for me. The first hint that came to me when I went searching was the bootsect command but this only updates the master boot code on the partition so it did nothing for me. What got things going again was the bootrec command.

To use either of these, I needed to boot from a Windows 7 installation DVD. With my Toshiba Equium laptop, I needed to hold down the F12 key until I was presented with a menu that allowed me to choose from what drive I wanted to boot the machine, the DVD drive in this case. Then, the disk started and gave me a screen where I selected my location and moved to the next one where I selected the Repair option. After that, I got a screen where my Windows 7 installation was located. Once that was selected, I moved on to another screen from I started a command line session. Then, I could issue the commands that I needed.

bootsect /nt60 C:

This would repair the boot sector on the C: drive in a way that is compatible with BOOTMGR. This wasn’t enough for me but was something worth trying anyway in case there was some corruption.

bootrec /fixmbr
bootrec /fixboot

The first of these restores the MBR and the second sorts out the boot sector on the system drive (where the Windows directory resides on your system. In the event, I ran both of these and Windows restarted again, proving that it had come through disk partition changes without a glitch, though CHKDISK did run in the process but that’s understandable. There’s another option for those wanting to get back a boot menu and here it is:

bootrec /rebuildbcd

Though I didn’t need to do so, I ran that too but later used EasyBCD to remove the boot menu from the start-up process because it was surplus to my requirements. That’s a graphical tool that has gained something of a reputation since Microsoft dispensed with the boot.ini file that came with Windows XP for later versions of the operating system.

Manually adding an entry for Windows 7 to an Ubuntu GRUB2 menu

21st November 2010

A recent endeavour of mine has been to set up a dual-booting arrangement on my Toshiba Equium laptop with Ubuntu 10.10 and Windows 7 side by side on there. However, unlike the same attempt with my Asus Eee PC where Windows XP coexists with Ubuntu, there was no menu entry on the GRUB (I understand that Ubuntu has had version 2 of this since 9.04 though the internal version is of the form 1.9x; you can issue grub-install -v at the command line to find out what version you have on your system) menu afterwards. Thankfully, I eventually figured out how to do this and the process is shared here in a more coherent order than the one in which I discovered all the steps.

The first step is to edit /etc/grub.d/40_custom (using SUDO) and add the following lines to the bottom of the file:

menuentry 'Windows 7' {
set root='(hd0,msdos2)'
chainloader +1
}

Since the location of the Windows installation can differ widely, I need to explain the “set root” line because (hd0,msdos2) refers to /dev/sda2 on my machine. More generally, hd0 (or /dev/sda elsewhere) refers to the first hard disk installed in any PC with hd1 (or /dev/sdb elsewhere) being the second and so on. While I was expecting to see entries like (hd0,6) in /boot/grub/grub.cfg, what I saw were ones like (hd0,msdos6) instead with the number in the text after the comma being the partition identifier; 1 is the first (sda1), 2 (sda2) is the second and so on. The next line (staring with chainloader) tells GRUB to load the first sector of the Windows drive so that it can boot. After all that decoding, my final remark on what’s above is a simple one: the text “Windows 7” is what will appear in the GRUB menu so you can change this as you see fit.

After saving 40_custom, the next step is to issue the following command to update grub.cfg:

sudo update-grub2

Once that has done its business, then you can look into /boot/grub/grub.cfg to check that the text added into 40_custom has found its way in there. That is important because this is the file read by GRUB2 when it builds the menu that appears at start-up time. A system reboot will prove conclusively that the new entry has been added successfully. Then, there’s the matter of selectively to see if Windows loads properly like it did for me, once I chose the correct disk partition for the menu entry, that is!

Booting from external drives

16th September 2009

Sticking with older hardware may mean that you miss out on the possibilities offered by later kit and being able to boot from external optical and hard disk drives was something of which I learned only recently. Like many things, a compatible motherboard and my enforced summer upgrade means that I have one with the requisite capabilities.

There is usually an external DVD drive attached to my main PC so that allowed the prospect of a test. A bit of poking around in the BIOS settings for the Foxconn motherboard was sufficient to get it looking at the external drive at boot time. Popping in a CrunchBang Linux live DVD was all that was needed to prove that booting from a USB drive was a goer. That CrunchBang is a minimalist variant of Ubuntu helped for acceptable speed at system startup and afterwards.

Having lived off them while in home PC limbo, the temptation to test out the idea of installing an operating system on an external HD and booting from that is definitely there though I think that I’ll be keeping mine as backup drives for now. Still, there’s nothing to stop me installing an operating system onto of them and giving that a whirl sometime. Of course, speed constraints mean that any use of such an arrangement would be occasional but, in the event of an emergency, such a setup could have its uses and tide you over for longer than a Live CD or DVD. Having the chance to poke around with an alternative operating system as it might exist on a real PC has its appeal too and avoids the need for any partitioning and other chores that dual booting would require. After all, there’s only so much testing that can be done in a virtual machine.

A hog removed

11th February 2009

Even though my main home PC runs Ubuntu, I still keep a finger in the Windows world using VirtualBox virtual machines. I have one such VM running XP and this became nigh on unusable due to the amount of background processing going on. Booting into safe mode and using msconfig to clear out extraneous services and programs running from system start time did help but I went one step further. Norton 360 (version 2 as it happened) was installed on their and inspection of Process Explorer revealed its hoggish inclinations and the fact that it locked down all of its processes to defend itself from the attentions of malware was no help either (I am never a fan of anything that takes control away from me). Removal turned out to be a lengthy process with some cancelling of processes to help it along but all was much quieter following a reboot; the fidgeting had stopped. ZoneAlarm Pro (the free version that was gifted to users for one day only towards the end of 2008). Windows continues to complain about the lack of an antivirus application that it recognises so resolving that is next on the to do list.

Repairing Windows XP

21st October 2007

I have been having an accident-prone time of it with Windows XP recently and have had plenty of reason to be thankful for the ability to perform a repair installation. Here are the steps:

  1. Pop the installation disk into your PC’s DVD drive and reboot the PC.
  2. If you have your PC set it up to boot from DVD’s in its BIOS, then you at least will have to option to do this. You may find that this happens by default but I needed to tell it to do the deed.
  3. Select normal installation from the first menu that is presented to you by the installer.
  4. Accept the licence agreement.
  5. Press R at the next menu and that’ll repair the installation.
  6. Follow all of the menus from there on; it’ll be all the usual stuff from here on in and there should be no need to reactivate Windows or reinstall all of your other software afterwards.

There is a repair option on the first screen (step 3 above) but this takes you into the dark recesses of the command line and isn’t what I was needing. I do have to say that they do leave the required option late on in the installation process and that assumes on users having a risk taking streak in them, something that definitely does not apply to everyone. If your boot.ini file is not well, you may find yourself needing to do the full installation and that wipes the slate clean on you, extending the recovery process.

HAL.DLL: a roadblock on the resurrection of a poorly PC

2nd August 2007

My PC is very poorly at the moment and Windows XP re-installation is the prescribed course of action. However, I have getting errors reporting missing or damaged HAL.DLL at the first reboot of the system during installation. I thought that there might be hard disk confusion and so unplugged all but the Windows boot drive. That only gave me an error about hard drives not being set up properly. Thankfully, a quick outing on Google turn up a few ideas. I should really have started with Microsoft since they have an article on the problem. About.com has also got something to offer on the subject and seems to be a good resource on installing XP to boot: I had forgotten how to do a repair installation and couldn’t find the place in the installation menus. In any event, a complete refresh should be a good thing in the long run, even if it is going to be a very disruptive process. I did consider moving to Vista at the point but getting XP back online seems the quickest route to getting things back together again. Strangely, I feel like a fish out of water right now but that’ll soon change…

Update: It was in fact my boot.ini that was causing this and replacement of the existing contents with defaults resolved the problem…

Hard drive partitioning

22nd January 2007

Hard drive partitioningIt has to be said that hard drive partitioning isn’t something that most people do very often, if at all in these days of cheap storage and system virtualisation. I must admit to having several disks in my main machine and can vouch for the virtues of virtualisation: VMware allows me to run multiple operating systems on the same machine, a very useful asset so long as enough memory is available. We can expect to hear more about virtualisation with the likes of Intel and AMD looking at hypervisor solutions for this.

Partitioning does give you what appear to be multiple drives from just the one and that is very useful when you only have a single hard drive in your PC. This was very much the case in my early computing days when catastrophic Windows 9x crashes (some self-inflicted…) often resulted in the pain of a complete re-installation of everything that had been on there. The independence offered by partitions certainly offered me peace of mind back then but 100MB Iomega Zip disks were a very useful defence in depth.

Without partitioning, my curiosity regarding the world of Linux would not have been sated though an approach involving multiple hard drives certainly came into play later on. Having been a Sun Solaris user at university, Linux certainly aroused much interest in me and I have to say that it has come a long, long way since my first ventures into its world.

While the Windows tool FDISK could partition hard drives for you, it wasn’t non-destructive: you had be prepared to restore all of your files from a backup and do a complete software re-installation following its use. It was designed for setting things up at the outset and not changing them later and that thinking seems to have pervaded the design of the Disk Management console found in XP.

For more flexible and non-destructive partitioning, Powerquest’s Partition Magic became the tool of choice, though I did have a dalliance with a package called Partition It before taking the plunge. Partition Magic is now in the Symantec stable and not a lot seems to be heard of it. Version 7, the last from Powerquest before its takeover, has been my staple but 983 errors have been thrown by the application at times and one partitioning operation went awry, forcing me to depend on my backups. Version 8 still throws 983 errors so I started to look beyond Partition Magic altogether. In my search, I happened on version 10 of Acronis Disk Director Suite. It got a strong recommendation from reviewer Davey Winder in PC Pro magazine (backup software True Image 10 from the same company also got a thumbs up from a different PC Pro reviewer) which gave some reassurance and I have to say that I agree. An operation refused by Partition Magic was completed successfully and safely so I know where my vote goes.

  • All the views that you find expressed on here in postings and articles are mine alone and not those of any organisation with which I have any association, through work or otherwise. As regards editorial policy, whatever appears here is entirely of my own choice and not that of any other person or organisation.

  • Please note that everything you find here is copyrighted material. The content may be available to read without charge and without advertising but it is not to be reproduced without attribution. As it happens, a number of the images are sourced from stock libraries like iStockPhoto so they certainly are not for abstraction.

  • With regards to any comments left on the site, I expect them to be civil in tone of voice and reserve the right to reject any that are either inappropriate or irrelevant. Comment review is subject to automated processing as well as manual inspection but whatever is said is the sole responsibility of the individual contributor.