PDA

View Full Version : [ubuntu] 10.04 LTS server - Help, I installed GRUB by mistake



VFR
November 7th, 2012, 09:14 PM
I have a 10.04 LTS server. I accidentally installed GRUB. It's a long story*.

I ran GRUB, but it didn't work properly, so I Googled for "ubuntu grub problems" and found out that Ubuntu already comes with GRUB 2 by default!

What should I do? Now i have both GRUB and GRUB2. Can I uninstall GRUB? Or will this make my drive unbootable?


*The long story: the server has a RAID 1 mirror, and one of the drives failed. I replaced the bad drive with a new one, and I followed the procedures in this article (http://www.linuxcat.org/showthread.php?tid=39) and got the RAID array rebuilt and synced. Next I ran GRUB to make the new drive bootable, but I got an error saying GRUB doesn't exist, if you want to install it type in "sudo apt-get install grub". So I did that... and it installed GRUB.

darkod
November 7th, 2012, 09:42 PM
Does it boot or not?

grahammechanical
November 7th, 2012, 09:55 PM
I am not familiar with server systems but I understand that when Ubuntu is installed a bootloader (Grub) is always installed, even if there is only one OS on the drive. I assume that this is true with Ubuntu server.

Grub gets installed into the MBR of a drive. Could it be that the drive that failed was the drive that had Ubuntu on it and Grub in its MBR? Could this be the reason that you got the 'Grub does not exist' message? The drive was cloned but Grub was not in the MBR.

If this is the case then you do not in fact have two versions of Grub installed. This link might help you:

https://help.ubuntu.com/community/Grub2

Notice this point:


This guide covers the use of Grub 1.98, the Grub release found in Ubuntu 10.04 LTS (Lucid Lynx). and Grub 1.99, packaged with Ubuntu 12.04 LTS (Precise Pangolin).

We have been calling Grub 1.97, 1.98 and 1.99 Grub 2 but we now have in Ubuntu 12.10 Grub 2.0.

It seems that the Grub that came with Ubuntu 10.04 was Grub 1.98 which is referred to as Grub 2.

It is confusing but you may not have a problem. Does everything work as it should? Remember, If it ain't broke, don't fix it! Good advice.

Regards.

darkod
November 7th, 2012, 10:05 PM
The issue the OP is asking about, if I understand it right, is that he installed/added grub1.
sudo apt-get install grub would install grub1. The grub2 package is grub-pc.

I didn't want to go into too much "what if" in my first post, so I just asked whether it's booting, since removing/purging all grub1/grub2 and installing grub2 again is very easy from inside a working installation.

VFR
November 7th, 2012, 10:32 PM
I haven't tried rebooting since installing Grub1. It's a production machine so I'll wait until the weekend before rebooting.

But basically all I did was sudo apt-get install grub... I didn't do nothing after that. Does merely installing the package write to my MBR or change anything else?

darkod
November 7th, 2012, 10:41 PM
Not sure, but since the machine is still booted, you can simply purge all related to grub, reinstall grub2 and recreate the config files again (if needed). Something like:

sudo apt-get remove --purge grub grub-pc grub-common
sudo apt-get install grub-pc
sudo grub-mkconfig
sudo update-grub
sudo grub-install /dev/sda

That should take care of everything.

VFR
November 8th, 2012, 02:01 AM
You wrote:
sudo grub-install /dev/sda


However in the Ubuntu 10.04 docs (https://help.ubuntu.com/10.04/serverguide/advanced-installation.html), it says:
sudo grub-install /dev/md0


Is it sda, or md0? I'm thinking you're right, installing grub on the DRIVE seems to make more sense than installing grub on the raid array (md0). However it is the official Ubuntu documentation....

Bashing-om
November 8th, 2012, 04:43 AM
I would have to hunt up the info(long time in past I ran raid)//but some levels of raid grub must be installed outside the array, and some raid levels require grub installed on all the disk.

Raid 1 mirror: I honestly do not remember... However, this link seems to answer, read all of it though.
http://askubuntu.com/questions/43036/how-do-i-install-grub-on-a-raid-system-installation

just try'n to help <== BDQ

VFR
November 8th, 2012, 09:16 AM
Ok the abovementioned thread at askubuntu.com says "installing to sda is the correct thing to do", so I went ahead and did this:


$ sudo grub-install /dev/sdb
Installation finished. No error reported.
$ sudo grub-install /dev/sda
Installation finished. No error reported.
Then just to make sure, I tried on md0 and got the following:


$ sudo grub-install /dev/md0
/usr/sbin/grub-setup: warn: Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea..
/usr/sbin/grub-setup: error: embedding is not possible, but this is required when the root device is on a RAID array or LVM volume.
What does this mean?

darkod
November 8th, 2012, 09:26 AM
You wrote:
sudo grub-install /dev/sda


However in the Ubuntu 10.04 docs (https://help.ubuntu.com/10.04/serverguide/advanced-installation.html), it says:
sudo grub-install /dev/md0


Is it sda, or md0? I'm thinking you're right, installing grub on the DRIVE seems to make more sense than installing grub on the raid array (md0). However it is the official Ubuntu documentation....

For software raid (and /dev/mdX) is software raid, you would install it on /dev/sda, /dev/sdb, etc (so that it can boot with any disk failed).

At the moment when I wrote that I forgot you are running raid but for mdadm it's actually /dev/sda also. I don't know if there is some internal script that installs grub to both /dev7sda and /dev/sdb when you write /dev/md0, but the location for the bootloader in software raid is the MBR of the disk, since the array is assmbled by the OS.

For hardware/fakeraid it's the MBR of the array device.

If you watch carefully during installing the server with mdadm, at the end when installing the bootloader you can (shortly) see the message saying "running grub-install /dev/sda /dev/sdb".

That's where grub2 should be.

darkod
November 8th, 2012, 09:28 AM
$ sudo grub-install /dev/md0
/usr/sbin/grub-setup: warn: Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea..
/usr/sbin/grub-setup: error: embedding is not possible, but this is required when the root device is on a RAID array or LVM volume.
What does this mean?

I think the message about not installing on a partition might be because md0 is made of partitions. So, using /dev/md0 as destination is understood as using for example /dev/sda1 and /dev/sdb1. And since grub2 is not recommended to be installed on a partition, hence the message. That's how I understand it.

oldfred
November 8th, 2012, 05:29 PM
If you want to know what is installed where, run the bootinfoscript.

Boot Info Script courtesy of forum members meierfra & Gert Hulselmans
Boot Info Script 0.61 is released April 2, 2012
boot_info_script.sh" file renamed to "bootinfoscript
http://sourceforge.net/projects/bootinfoscript/files/bootinfoscript/0.61/
Page with instructions and link to above new download:
http://bootinfoscript.sourceforge.net/
Paste contents of results.txt in a New Reply, then highlight entire file and click on # in edit panel(code tags) to make it easier to read.
Or You can generate the tags first by pressing the # icon in the New Reply Edit toolbar and then paste the contents between the generated [ code] paste here [ /code] tags.
Install these before running script:
sudo apt-get install gawk
sudo apt-get install xz-utils

Boot script is able to search LVM partitions if the LVM2 package is install, Fedora needs to be mounted to see it with os-prober
# ("apt-get install lvm2" in debian based distros)
# Is able to search Linux Software Raid partitions (MD Raids) if
# the "mdadm" package is installed.
sudo apt-get install lvm2
sudo apt-get install mdadm
sudo apt-get install gawk
sudo apt-get install xz-utils
# unlzma is equivalent to xz --format=lzma --decompress.

VFR
December 20th, 2012, 07:52 PM
Thanks for all your help.

I finally rebooted the server yesterday. It booted into Ubuntu with no problems, GRUB2 worked fine.

Here were the things I ended up doing (culled from darkod's post)

sudo apt-get remove --purge grub grub-pc grub-common (uninstall/purge GRUB)
sudo apt-get install grub-pc (install GRUB2 package)
sudo update-grub (updating to latest version)
sudo grub-install /dev/sda (installing GRUB2 on the MBR... yes sda was correct and not md0)

I didn't need sudo grub-mkconfig... when I installed GRUB it guided me through the configuration, very nice