TOPIC: EASYBCD
Restoring the MBR for Windows 7
25th November 2010During 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. Though this wasn't enough for me, it 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 their 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 2010A 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!