Re-Install grub after a windows install

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help

Re-Install grub after a windows install

Postby xlancealotx on Sat Jan 09, 2010 1:19 pm

Been a while, but my windows partition got hosed. I would like to re-install the basic OS which will naturally kill grub. So my question which I think is pretty easy, can I simply re-install windows, get that working. Then just boot off my mint live CD, issue something like a grub-install which will then re-write making the world a happy place again?

Tnx
xlancealotx
Level 1
Level 1
 
Posts: 2
Joined: Sat Jan 09, 2010 12:11 pm

Linux Mint is funded by ads and donations.
 

Re: Re-Install grub after a windows install

Postby Lantesh on Sun Jan 10, 2010 1:07 am

This will work for Grub2 on Helena

* Boot your Helena live CD
* Open a terminal - Applications, Accessories, Terminal.
* Determine your normal system partition - `sudo fdisk -l` (That is a lowercase L)
* If you aren't sure, run `df -Th`. Look for the correct disk size and ext3 or ext4 format.
* Mount your normal system partition:

sudo mount /dev/sdXY /mnt

- Example: sudo mount /dev/sda1 /mnt
- Note: substitue the correct partition: sda1, sdb5, etc.
- Note: GRUB 2 counts the first drive (X) as "0", but the first partition (Y) as "1"

* Only if you have a separate boot partition:

sudo mount /dev/sdXY /mnt/boot

- with sdXY being your /boot partition designation.

* Reinstall GRUB 2:

sudo grub-install --root-directory=/mnt /dev/sdX

- Example: sudo grub-install --root-directory=/mnt /dev/sda
- Note: Substitute the correct device - sda, sdb, etc. Do ''not'' specify a partition number.

* Unmount the partition:

sudo umount /mnt

* Reboot.
Lantesh
Level 6
Level 6
 
Posts: 1219
Joined: Sat Apr 12, 2008 1:02 pm

Re: Re-Install grub after a windows install

Postby breaker on Sun Jan 10, 2010 2:46 am

You can also back up your mbr (and thus grub), reinstall windoze, then restore your mbr.
rtfm - read the fine manual...
Boot info script: http://ubuntuforums.org/showthread.php?t=1291280
grub2 https://help.ubuntu.com/community/Grub2
PC-BIOS based booting, mbr, boot records; http://thestarman.pcministry.com/
breaker
Level 5
Level 5
 
Posts: 613
Joined: Sun Mar 16, 2008 5:28 am

Re: Re-Install grub after a windows install

Postby sv1xv on Mon Jan 11, 2010 5:01 pm

breaker wrote:You can also back up your mbr (and thus grub), reinstall windoze, then restore your mbr.
How do you backup MBR? Do you use "dd" or some other utility?
Hardware: ASUS Eee PC 4G Surf
Software: Mint Linux 8 (Helena)
User avatar
sv1xv
Level 1
Level 1
 
Posts: 5
Joined: Thu Dec 31, 2009 12:04 am

Re: Re-Install grub after a windows install

Postby breaker on Tue Jan 12, 2010 6:46 am

I have used both dd and the Windows program HDHacker. The second option is slightly easier because after your install, you will be booting to Windows anyway, just keep the HDHacker installer and the mbr file on a handy pen drive. I like to back up the boot sector too in case something goes really wrong. If your Windows is too hosed to use before your install, just use dd before and HDHacker after, but you could use dd from a Live CD or Live usb of course.

HDHacker: http://dimio.altervista.org/eng/
dd examples: http://www.debianhelp.co.uk/ddcommand.htm

For dd /dev/sdx is for mbr of drive x and /dev/sdx1 is for first boot sector of drive x... don't forget the count=1 bs=512... don't get if= and of= mixed up!
rtfm - read the fine manual...
Boot info script: http://ubuntuforums.org/showthread.php?t=1291280
grub2 https://help.ubuntu.com/community/Grub2
PC-BIOS based booting, mbr, boot records; http://thestarman.pcministry.com/
breaker
Level 5
Level 5
 
Posts: 613
Joined: Sun Mar 16, 2008 5:28 am

Re: Re-Install grub after a windows install

Postby viking777 on Tue Jan 12, 2010 7:32 am

I read about a different method the other day I have never tried it (because you need to have Windows on your mbr for it to work and I don't have). If it works then I believe it is a far better way to dual boot than I have ever heard of before - if it works.

This is what you do.
Install Windows first

Then install Linux which will recognise the windows install and add it to the grub start up list. Where the process differs is that you DO NOT install grub to the MBR, you install it only to the partition you are installing Linux on. This is easy to achieve, you just click the 'Advanced' button when you get to the summary screen of the installer (step 8 I think it is). In here you will see a drop down box with a choice of places to install grub the default is the hard disk mbr but you change that to the correct partition instead then install normally.

When the install is finished - but before rebooting, you open gparted from the live cd and have a look at where the boot flag is (it will probably be on your windows partition still). If that is the case move it to the Linux partition. (simply right click your linux partition select manage flags and tick boot) If the installer has moved it to the Linux partition then you need do nothing.

When you boot you should be presented with a grub menu with a choice of linux and windows.

So far there is not much difference from a normal install. The difference comes though if you want to remove linux at any stage. With a normal install (grub on the mbr) removing linux will result in a failed boot and you will have to repair your mbr from a windows disk. With this method, all you have to do is to move the boot flag back onto your windows partition with gparted before you delete your linux partition and windows will boot again on its own - no effort and much more user friendly.

Should you decide to install a third distro you repeat the procedure above but this time move the boot flag to the new install (which will already include the other two distros in its boot menu).

I stress I have never tried this, but it came from a very authoritative source and would not have been published if it didn't work.

So now you have three choices of what to do!

EDIT. I just tried this out in Virtualbox - it works, so I can really recommend it.
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).
Image
User avatar
viking777
Level 14
Level 14
 
Posts: 5153
Joined: Mon Dec 01, 2008 11:21 am

Re: Re-Install grub after a windows install

Postby allis0 on Sat Jun 26, 2010 9:57 am

I'd just like to say a big thank you to Lantesh. Your tip (the first reply) worked brilliantly for me. :D
allis0
Level 1
Level 1
 
Posts: 1
Joined: Sat Jun 26, 2010 9:51 am

Re: Re-Install grub after a windows install

Postby Lantesh on Sat Jun 26, 2010 12:16 pm

allis0 wrote:I'd just like to say a big thank you to Lantesh. Your tip (the first reply) worked brilliantly for me. :D


You're welcome. 8)
Lantesh
Level 6
Level 6
 
Posts: 1219
Joined: Sat Apr 12, 2008 1:02 pm

Linux Mint is funded by ads and donations.
 

Return to Installation & Boot

Who is online

Users browsing this forum: No registered users and 21 guests