10 posts in this topic

Posted

Okay, I have to re-install windows for a cousin, however he has 2 different Linux installations and they both are in middle partitions, not the primary ones. For example :

Hard Disk 1 ----> /Sda1 (windows) /Sda2 (linux) /Sda3 (Data)
Hard Disk 2 ----> Sdb1 (data) / Sdb2 (Linux) /Sdb3 (Data)

Now, Grub is installed onto Sda1 according to him and he's not sure where Grub is for the 2nd installation. It's definitely not (?) in the primary Sdb1 partition because it doesn't boot when I detach Sda and boot with just Sdb attached. Actually I get thrown to a 'Grub-rescue' prompt with a couple other messages that I can't recollect atm, I'm not at the machine.

Does this mean Grub is, in fact, also installed on Sdb for the 2nd Linux install he did? If yes, how can I get Grub to 'see' the Linux installation on /Sdb2? He doesn't have any /boot or /swap for either.

And how do I repair Grub on Sda1 after I reinstall Windows for him? I'm kinda lost to be honest, but I'm willing to touch it _only_ if I can fix it for him... because I just don't have the time to give if it ends up borking both Linux installations. He wants both installations, and preferably be able to boot both individually with their own Grub.

I hope I've explained it clear enough, I need help :p

Share this post


Link to post
Share on other sites

Posted

[url="http://sourceforge.net/projects/bootinfoscript/"]http://sourceforge.net/projects/bootinfoscript/[/url]

More info : [url="http://bootinfoscript.sourceforge.net/"]http://bootinfoscript.sourceforge.net/[/url]

Hope this will help you. .
1 person likes this

Share this post


Link to post
Share on other sites

Posted

After you install Windows and remove GRUB from the MBR, use [url="http://www.supergrubdisk.org/category/download/supergrub2diskdownload/super-grub2-disk-beta/"]Super Grub2 Disk[/url] to boot from the Linux installation on the secondary hard drive and reinstall GRUB. The command should look something like the following, assuming the drive is /dev/sdb:

[CODE]
sudo grub-install /dev/sdb
[/CODE]

You should now be able to boot GRUB from that hard drive if it is set as primary in BIOS. Next, use Super Grub2 Disk again to boot from the Linux installation on the hard drive with Windows. You can reinstall GRUB using a similar command to the one you used previously; just reference the other hard drive. The command should look something like the following, assuming the drive is /dev/sda:

[CODE]
sudo grub-install /dev/sda
[/CODE]
1 person likes this

Share this post


Link to post
Share on other sites

Posted

Thanks guys, I'm going to go there later today, I'll try this and see how it goes :D

Share this post


Link to post
Share on other sites

Posted

[quote name='javagreen' timestamp='1349365540' post='595225309']
If yes, how can I get Grub to 'see' the Linux installation on /Sdb2? He doesn't have any /boot or /swap for either.[/quote]

You only need one grub (bootloader) installed in the MBR of the first disk (as setup in bios), the VBR (volume boot record) will take care of the rest. As far as getting grub to see additional distros goes, it should be as simple as:

[code]
grub-mkconfig -o /boot/grub/grub.cfg
[/code]

Assuming you're using Grub2. For Grub 1, you'll have to edit grub.cfg by hand or pehaps use something like os-prober.

[quote name='javagreen' timestamp='1349365540' post='595225309']
And how do I repair Grub on Sda1 after I reinstall Windows for him? I'm kinda lost to be honest, but I'm willing to touch it _only_ if I can fix it for him... because I just don't have the time to give if it ends up borking both Linux installations. He wants both installations, and preferably be able to boot both individually with their own Grub.[/quote]

Load up a live cd / usb pen with the same architecture (32/64 bit) as the installation (important!), then chroot into the installation:

[code]
# change sda1 to your linux partition
mount /dev/sda1 /mnt

# mount temporary file systems in preparation for chroot
mount -t proc proc /mnt/proc
mount -t sysfs sys /mnt/sys
mount -o bind /dev /mnt/dev
mount -t devpts pts /mnt/dev/pts

chroot /mnt /bin/bash

# restore grub
grub-install /dev/sda
[/code]

That's what I do anyway.
2 people like this

Share this post


Link to post
Share on other sites

Posted

^ Thanks for the detailed breakdown bro, I'll be printing this page and taking it across to refer :)

I manage to take good care of my own Linux install, but this Triple installation (Windows, Linux, Linux) with a messy disk structure is kinda throwing me off. I'm going there tonight, will update the thread when I get back.

Cheers!

Share this post


Link to post
Share on other sites

Posted

To add to what simplezz said, booting from a live disc and using a chroot to recover your GRUB installation would certainly work (and is, in fact, the method that most distribution's installers use to install from disc in the first place), but is merely an alternative to my method of booting into each OS installation. The main advantage of simplezz's solution over mine is that you can update both installations at once (or only do one or the other, as simplezz suggested).

Also, if you are using Debian or a Debian-based distribution (such as Ubuntu or Linux Mint), the distribution provides scripts that probe for existing OS installations and add them to the boot menu. (These scripts are called every time there is a kernel update and will overwrite your [i]grub.cfg[/i], including any custom modifications you have made. If you want to add custom boot entries, place them in [i]/boot/grub/custom.cfg[/i] instead.) Once you are in the chroot or booted into the OS installation, use [CODE]sudo update-grub[/CODE] instead of [CODE]sudo mkconfig -o /boot/grub/grub.cfg[/CODE].

[quote name='simplezz' timestamp='1349440842' post='595227131']
Assuming you're using Grub2. For Grub 1, you'll have to edit grub.cfg by hand or pehaps use something like os-prober.
[/quote]

I believe that GRUB Legacy uses [i]/boot/grub/menu.lst[/i] by default instead of [i]/boot/grub/grub.cfg[/i] like GRUB 2. However, unless your distribution is rather old (like Debian Lenny or CentOS 5), it should have shipped with GRUB 2 instead of GRUB Legacy, so my correction is probably irrelevant.
1 person likes this

Share this post


Link to post
Share on other sites

Posted

[quote name='simplezz' timestamp='1349440842' post='595227131']
You only need one grub (bootloader) installed in the MBR of the first disk (as setup in bios), the VBR (volume boot record) will take care of the rest. As far as getting grub to see additional distros goes, it should be as simple as:

[code]
grub-mkconfig -o /boot/grub/grub.cfg
[/code]

Assuming you're using Grub2. For Grub 1, you'll have to edit grub.cfg by hand or pehaps use something like os-prober.



Load up a live cd / usb pen with the same architecture (32/64 bit) as the installation (important!), then chroot into the installation:

[code]
# change sda1 to your linux partition
mount /dev/sda1 /mnt

# mount temporary file systems in preparation for chroot
mount -t proc proc /mnt/proc
mount -t sysfs sys /mnt/sys
mount -o bind /dev /mnt/dev
mount -t devpts pts /mnt/dev/pts

chroot /mnt /bin/bash

# restore grub
grub-install /dev/sda
[/code]

That's what I do anyway.
[/quote]


[quote name='xorangekiller' timestamp='1349469752' post='595228435']
To add to what simplezz said, booting from a live disc and using a chroot to recover your GRUB installation would certainly work (and is, in fact, the method that most distribution's installers use to install from disc in the first place), but is merely an alternative to my method of booting into each OS installation. The main advantage of simplezz's solution over mine is that you can update both installations at once (or only do one or the other, as simplezz suggested).

Also, if you are using Debian or a Debian-based distribution (such as Ubuntu or Linux Mint), the distribution provides scripts that probe for existing OS installations and add them to the boot menu. (These scripts are called every time there is a kernel update and will overwrite your [i]grub.cfg[/i], including any custom modifications you have made. If you want to add custom boot entries, place them in [i]/boot/grub/custom.cfg[/i] instead.) Once you are in the chroot or booted into the OS installation, use [CODE]sudo update-grub[/CODE] instead of [CODE]sudo mkconfig -o /boot/grub/grub.cfg[/CODE].


I believe that GRUB Legacy uses [i]/boot/grub/menu.lst[/i] by default instead of [i]/boot/grub/grub.cfg[/i] like GRUB 2. However, unless your distribution is rather old (like Debian Lenny or CentOS 5), it should have shipped with GRUB 2 instead of GRUB Legacy, so my correction is probably irrelevant.
[/quote]


I'm back, and it was very .....easy, thanks to both of you's detailed instructions! Way easier than I had thought it would be :p

Before I reinstalled Windows, I decided to try and boot each hard disk on it's own to see how it goes - and surprisingly this time the 2nd hard disk booted his 2nd Linux install without a hitch. Not sure why it hadn't worked the first time I tried it. I proceeded to reinstall Windows onto his 1st hard disk, and followed simplezz's instructions to get Grub back on his HDD 1. Windows wasn't available as an option until I booted into Linux and did 'sudo update-grub' as xorangekiller said.

That was it, both Linux installs are now bootable and both disks can be booted individually.... mission accomplished! :D

Share this post


Link to post
Share on other sites

Posted

Thanks for reporting back. Glad to hear that everything went well. Learning something new is always a good thing (especially if it turns out to be easier than you anticipated).
1 person likes this

Share this post


Link to post
Share on other sites

Posted

[quote name='xorangekiller' timestamp='1349496319' post='595229123']
Thanks for reporting back. Glad to hear that everything went well. Learning something new is always a good thing (especially if it turns out to be easier than you anticipated).
[/quote]

Indeed my friend, and thanks once again to your and simplezz's instructions. They were perfect - that was all I needed to do! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.