Weblog entry #13 for fsateler

Recovering MBR after a Windows install
Posted by fsateler on Tue 20 Mar 2007 at 21:33
So I finally got around to installing Windows (I haven't had Windows installed in about a year). Since I already had a working Debian install, I just installed Windows on an empty partition. I usually do it the other way around, but of course I wasn't going to reinstall Debian to use my usual approach. After the windows install, I found myself without grub in the MBR. This was totally expected, and one of the reasons I usually install Windows first. Recovering the MBR was far simpler than expected. I just popped in the Debian Etch installer, right after boot got to a terminal (Alt+F2), and did the following
mkdir /mnt/temp
mount /dev/sda1 /mnt/temp
mount --bind /dev /mnt/temp/dev
mount --bind /proc /mnt/temp/proc
mount --bind /sys /mnt/temp/sys
chroot /mnt/temp
grub
When grub loads, I then did the following:
root (hd0,0)
install /boot/grub/stage1 (hd0) /boot/grub/stage2
Then rebooted, and got a grub console instead of my usual grub screen. No problem: just do
configfile (hd0,0)/boot/grub/menu.lst
and the usual interface is up.
After my desktop loaded, I found the grub-install command that would do a better install than me:
grub-install /dev/sda
And then I had a completely normal boot screen. I just had to add the new Windows entry to menu.lst and I was set.
So there goes the ancient fear that installwing Windows after Linux is a pain. There are, of course, cases in which it is a pain (I remember once windows messed with my partition table and linux wouldn't boot), but this time I had absolutely no problems.

--
Felipe Sateler

 

Comments on this Entry

Posted by ajt (204.193.xx.xx) on Wed 21 Mar 2007 at 10:46
[ Send Message | View Weblogs ]
GRUB is very nice to get along with. On the Red Hat training course I took a few years ago they really forced you to inderstand GRUB, and it's really useful stuff to know.

--
"It's Not Magic, It's Work"
Adam

[ Parent | Reply to this comment ]

Posted by cmdrwalrus (66.225.xx.xx) on Thu 22 Mar 2007 at 20:32
[ Send Message ]

It's probably simpler to run "setup" instead of "install" when you invoke grub from the Etch installer. You'd just need two commands:

  root (hd0,0)
  setup (hd0)

That should take care of the menu as well, so you don't have to muck about in the grub console after rebooting--not that it's particularly hard to do that... but this is just a *little* easier. :-)

[ Parent | Reply to this comment ]

Posted by fsateler (200.83.xx.xx) on Thu 22 Mar 2007 at 22:41
[ Send Message | View Weblogs ]
That seems useful. It is a pain to have to type the paths to the stages.
--------
Felipe Sateler

[ Parent | Reply to this comment ]

Posted by Anonymous (88.43.xx.xx) on Mon 26 Mar 2007 at 10:46
It provides tab completion as far as I know... :)

davide

[ Parent | Reply to this comment ]

Posted by fsateler (200.83.xx.xx) on Mon 26 Mar 2007 at 20:57
[ Send Message | View Weblogs ]
It does, but GRUB treats my keyboard as an US layout when it is not... so typing is difficult (I have to find where the keys are). I suppose that is changeable, but since I rarely use the grub console, I don't care much.
--------
Felipe Sateler

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search