LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grub error on reinstall debian etch (https://www.linuxquestions.org/questions/linux-newbie-8/grub-error-on-reinstall-debian-etch-527090/)

bjhinkle 02-09-2007 01:52 PM

Grub error on reinstall debian etch
 
Have been trying to setup a router using debian etch. I have found, being new to linux, it's easier for me to reinstall/start over when I screw something up or don't like the way something is installed. I have probably reinstalled about 5-10 times so far. On each reinstall I repartition and reformat the drive and fix what I did not like about the last installation. During the last install I repartitioned and reformatted then continued with the install. When I got to the grub install portion I got the following error:

The grub package failed to inatll to /target/. Installing GRUB as a boot loader is a required step.

GRUB installation failed. Continue anyway?

I choose yes then get the message stating this is a new installation and do I want to install GRUB. I choose yes.

Then the screen turns red and I get this error.

Unable to install GRUB in (hd0) Executing 'grub-install (hd0) failed. This is a fatal error.

I thought the hard disk may be corrupt so I installed a new one and get the same error. Thought my install cd may be corrupt so created another and get the same error. I then downloaded debian sarge and tried to install and it works! I would be satisfied with installing sarge but my network cards don't seem to work under sarge. So, if anyone can help me figure out why grub won't install under etch, I would be thankful.

One last thing I did search the forums and came across this thread http://www.linuxquestions.org/questi...d.php?t=459705.

I tried checking out the bios and don't have any options for boot sector protecion. The solution the author had was booting to win98 disk and fdisk. But I don't have a windows partition on this computer.

saikee 02-09-2007 03:00 PM

I don't think it has anything to do with Grub or etch but more to do with the installer.

I would in such a case restore Grub or even write the menu.lst myself if the installer doesn't manage it.

Have a look at the Task B4 and B5 on the last link of my signature on how to restore Grub.

For Grub to work all you need are 3 files of stage1, stage2 and menu.lst in /boot/grub subdirectory. The stage1.5 if available will be used but Grub can survive without it. If menu.lst isn't there Grub simple defaults to a Grub prompt. Even without menu.lst a user can still boot a Debian manually using the "tab" key to let Grub match the kernel and initrd files names.

Also check out this thread and the advice gave by Pixellany.

bjhinkle 02-12-2007 04:03 AM

Ok what am I doing wrong here. Getting frustrated may be easier to install sarge and just get the network adapters to work under sarge. I have followed every instruction I came across including yours saikee. I did a fresh install of etch set my partitions to approx 30gig each home, var, root, etc. Setup a 1.6gig swap. Thinking maybe has something to do with large partition size, but no still getting error when I get to the grub install. Tried lilo and get same error that it cannot install. So, I continued the install without bootloader. After reboot get grub error 15. Downloaded debian live cd and boot to it. Tried running "sudo grub" but was not found. So sudo apt-get install grub while booted to live cd. Ran sudo grub > then find /boot/grub/stage 1 and get error 15. Quit grub and run sudo fdisk -l and get:

Disk /dev/hda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 4255 34178256 83 Linux
/dev/hda2 4256 19457 122110065 5 Extended
/dev/hda5 4256 8510 34178256 83 Linux
/dev/hda6 8511 12157 29294496 83 Linux
/dev/hda7 12158 16412 34178256 83 Linux
/dev/hda8 16413 19257 22852431 83 Linux
/dev/hda9 19258 19457 1606468+ 82 Linux swap / Solaris

Then run grub again

grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... no

Error 15: File not found

Then try mounting hda /mnt/root, proc /mnt/root/proc, and bind /dev /mnt/root/dev and chroot to /mnt/root/bin/bash.

Try to run grub from here and file not found. Try apt-get install grub and apt-get not found. Try install-grub and file not found.


What is the deal am I missing something or going out of my mind. Have not had any problems installing debian etch multiple times. Nothing has changed on this computer except new hard disk since I was having the same problem with the old disk. Thanks.

saikee 02-12-2007 07:34 AM

Grub has already told you that stage1 (also stage2) has not been found in the 1st partition of 1st disk and that is (hd0,0) to Grub or hda1 in Linux. Grub always counts from 0.

If you found /boot/grub/stage1 it is the version in the Live CD as it is that version that you are booting to and not inside hda1!

You can get away the problem pretty qickly by boot up Debian Live CD, mount hda1, copy all the files from Debian's /boot/grub directory into hda1, invoke a Grub shell, tell Grub the root partition you are insterested is in (hd0,0) and ask it to set itself up in the MBR or (hd0) as follow

Code:

sudo mkdir /mnt/hda1
sudo mount /dev/hda1 /mnt/hda1
sudo mkdir /mnt/hda1/boot/grub
sudo cp -R /boot/grub/* /mnt/boot/grub
sudo grub
root (hd0,0)
setup (hd0)
quit

On a reboot you should boot to a Grub prompt and that is where you can start the real computing by booting Debian "manually".

In Manual booting with a Grub prompt there are only 4 commands

(1) "root (hd0,0)" will tell Grub you are insterested in hda1
(2) "kernel /boot/(name of kernel) root=/dev/hdax ro" telling what kernel to be used and supply the "/" partition name for hdax
(3) "initrd /boot/(name of initrd)" telling what ramdisk file to be used.
(4) "boot" statement as the green light for Grub to go ahead

You obviously have no idea of where to get (name of kernel) and (name of initrd) right? You can use the Live CD to mount hda1 and write it down. Or more cleverly using the "tab" key because Grub (just like Bash) responds to the tab key by try to match the filing name. The Debian kenerl and initrd always start with "vmlinux" and "initrd" respectively.

Here is the relevant section of my Debian Sarge Grub
Code:

title                Debian GNU/Linux, kernel 2.4.27-2-386
root                (hd0,22)
kernel                /boot/vmlinuz-2.4.27-2-386 root=/dev/hda23 ro
initrd                /boot/initrd.img-2.4.27-2-386
boot

if you type at Grub prompt
Code:

kernel                /boot/vmlinuz-
and then press the "tab" key you will find Grub responds by
Code:

kernel                /boot/vmlinuz-2.4.27-2-386
so use it to the good effect.

All the commands that boot a Linux are those you need to put ine /boot/grub/menu.lst, except you need an extra "title" statement to identify the system.

bjhinkle 02-12-2007 05:49 PM

Maybe I don't have the right live cd but when I try the instructions you gave me I don't have /boot/grub when booted into the live cd.

Opened terminal then:

casper@live:~$ cd /
casper@live:/$ sudo mkdir /mnt/hda1
casper@live:/$ sudo mount /dev/hda1 /mnt/hda1
casper@live:/$ sudo mkdir /mnt/hda1/boot/grub
casper@live:/$ sudo cp -R /boot/grub/* /mnt/boot/grub
cp: cannot stat '/boot/gru/*': No such file or directory
casper@live:/$ cd boot
casper@live:/boot$ ls
config-2.6.18-4-486
initrd.img-2.6.18-4-486.bak
vmlinuz-2.6.18-4-486
initrd.img-2.6.18-4-486
System.map-2.6.18-4-486

bjhinkle 02-13-2007 04:31 PM

Any help ?????????

saikee 02-13-2007 06:35 PM

From the howto of 145 systems in my signature
Quote:

(B) The next task is to get hold of 3 files Grub needs for installation. They are called stage1, stage1.5 and stage2, which are held together in a directory, and are available in any Linux Live CD that supports Grub. So just boot up a Live CD and ask Linux to report to you their position by command
Code:

find / -name stage1
you will find these files are typically held in the following directories

Red Hat, Fedora C2 to C6
/usr/share/grub/x86_64-redhat/stage1
/usr/share/grub/i386-redhat/stage1

Mandriva
/lib/grub/i386-mandriva/stage1

Mandrake
/usr/local/lib/grub/i386-pc/stage1
/usr/lib/grub/i386-pc/stage1


Suse
/usr/lib/grub/i386-suse/stage1

Gentoo, Knoppix, Mepis, Xubuntu, Ubuntu, Kubuntu, Debian
/lib/grub/i386-pc/stage1


Frugalware, Kanotix
/usr/lib/grub/i386-pc/stage1
If your Debian boot disk, which I never use, doesn't have Grub's stage files just get them from any of the above Live CDs. Any consistent set of stage files can boot up your PC. I tried Grub from version 0.91 to 0.97 myself.

bjhinkle 02-14-2007 08:37 AM

That did it. The live cd I downloaded from http://live.debian.net/ did not have grub. At least I could not find it. I started, once again, by booting to debian etch installation cd. Repartition and reformatted the drives. Got to the grub installation and got error then just skipped and continued without boot loader. Popped in knoppix cd and booted. Mounted hda1, created grub folder and copied stage files, installed grub to mbr, then rebooted. Grub came up, typed boot parameters and booted. Created menu.lst file with boot parameters and rebooted. Thanks for your help.

saikee 02-14-2007 09:32 AM

Nice to see a happy ending.

You obviously picked a bit experience about Linux booting too.

soccercisco 02-17-2007 12:35 AM

Just wanted to add my two cents...

I have a netinstall CD of Debian Etch and for some reason grub works fine on some Computers (my 2 desktops) but not on others (my Dell Laptop). That is, when I install Debian Etch with the "same" CD on different computers I get different results, namely, grub or no grub. Although, thanks to this AWESOME explanation, what I thought it was a "lost battle" (installing Etch on my Laptop) has come to a happy ending.

Thanks for the clear explanations, I just wanted to add that (as in my case) the installation of grub might not even be related to the means of installation (in my case the netinstall CD), but perhaps something more sinister... Although, I can prove by experience that following the steps above (and extrapolating the information to one's own configuration) you will get a working boot, just like the default one.

Cheers,

lyckantropen 02-28-2007 04:05 AM

although the initial problem may be solved by using a livecd to fix grub, this is a serious issue for mass deployment of linux installations using systemimager for example. i've been trying to replace images of sarge running lilo with new etch images using systemimager and grub has been failing to install on fresh copies.

Tests i ran so far:

with a sarge system, and trying to load an image on a clean HD:

- using different versions of syslinux (stable and etch/testing) ...works fine.
- using different versions of systemimager (stable and etch/testing) ...works fine.
- basic image with sarge + grub ...works fine.
- using the basic image, changing the sources.list to point to etch and not stable, preforming a dist-upgrade and upgrading to kernel 2.6.18-3-i686: grub_install fails.

On loading the image, grub_install sends a warning on the different paths (/sbin/ and /usr/sbin) and then the process shuts down, leaving the image with no bootloader.

At first i thought this would have to do with systemimager's compatibility with etch, but from what i'm reading in forums the problem is a lot more widespread.

For now our temporary solution is to load all computers with sarge + grub and then reload the etch images, as the previous install of grub holds out fine.

saikee 03-01-2007 06:35 AM

From my experience with Grub the script "grub-install" is executed inside a Linux kernel and will suffer whatever problem you have with the kernel.

A more reboust implementation of Grub is to do it "outside" the Linux kernel from a Grub prompt.

You can get a Grub prompt when booting up a Grub screen in Debian and pressing immediately the "c" key.

If you have the /boot/grub directory in the 2nd partition of the 1st disk, which is known to Grub as (hd0,1) and want to place Grub in the MBR then these lines will guarantee success
Code:

root (hd0,1)
setup (hd0)

If you restore a system image it is generally necessary to restore its boot loader because the hard disk addresses may not match the original. To make sure the hard disk addresses (so the the boot loader can find the kernel position) matched you will need to clone the whole disk or put the partition back at the exact spot where it was cloned out.


All times are GMT -5. The time now is 03:09 PM.