Can't re-install GRUB

Kernels, Network, and Services configuration
Post Reply
Message
Author
SLind
Posts: 2
Joined: 2009-06-12 07:47

Can't re-install GRUB

#1 Post by SLind »

Hello,

yesterday i tried to modify my partitions on debian etch. I installed a second hd, booted with an usb-stick grml and copied everything to the second hd with "cp -a". After that I deleted all partitions and created new ones. I also created an ext3-filesystem with grml (mkfs.ext3 /dev/sda1,6). Next I copied my data back to the system partition and tried to boot, but grub says "error 2" or "error 18" while loading stage 1.5.

So I tried to re-install grub. I booted with the grml-stick again and chrooted to my new root partition with:

Code: Select all

mount /dev/sda1 /mnt/sda1
mount --bind /dev /mnt/sda1/dev
mount --bind /proc /mnt/sda1/proc
mount --bind /sys /mnt/sda1/sys
chroot /dev/sda1/ /bin/bash
After that i tried an install with

Code: Select all

root@grml:/$ /usr/sbin/grub-install /dev/sda
Searching for GRUB installation directory ... found: /boot/grub
The file /boot/grub/stage1 not read correctly.
I don't know why grub says that, because

Code: Select all

root@grml:/$ stat /boot/grub/stage1
  File: `/boot/grub/stage1'
  Size: 512             Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d      Inode: 2007048     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2009-06-12 12:28:47.000000000 +0200
Modify: 2009-06-12 12:28:47.000000000 +0200
Change: 2009-06-12 12:28:47.000000000 +0200
Doing a manual install didn't work either:

Code: Select all

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 2: Bad file or directory type

grub> cat (hd0,0)/
Error 2: Bad file or directory type

grub> find /boot/grub/stage1
 (hd3,0)

grub found the file only on my grml usb-stick:

Code: Select all

root@grml:/$ cat /boot/grub/device.map
(fd0)   /dev/fd0
(hd0)   /dev/sda
(hd1)   /dev/sdb
(hd2)   /dev/sdc
(hd3)   /dev/sdd
I'm at a loss what to do. If it helps, here are some interesting outputs:

Code: Select all

root@grml:/$ fdisk -l

Disk /dev/sda: 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/sda1   *           1        6079    48829536   83  Linux
/dev/sda2            6080       19457   107458785    5  Extended
/dev/sda5            6080        6203      995998+  82  Linux swap / Solaris
/dev/sda6            6204       19457   106462723+  83  Linux

Disk /dev/sdb: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      182401  1465136001   83  Linux

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       60801   488384001   83  Linux

Disk /dev/sdd: 1024 MB, 1024966656 bytes
32 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 1984 * 512 = 1015808 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *           1        1009     1000897   83  Linux

Code: Select all

root@grml:/$ cat /boot/grub/menu.lst
title           Debian GNU/Linux, kernel 2.6.18-5-686
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.18-5-686 root=/dev/sda1 ro
initrd          /boot/initrd.img-2.6.18-5-686
savedefault

title           Debian GNU/Linux, kernel 2.6.18-5-686 (recovery mode)
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.18-5-686 root=/dev/sda1 ro single
initrd          /boot/initrd.img-2.6.18-5-686
savedefault

title           Debian GNU/Linux, kernel 2.6.8-3-386
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.8-3-386 root=/dev/sda1 ro
initrd          /boot/initrd.img-2.6.8-3-386
savedefault

title           Debian GNU/Linux, kernel 2.6.8-3-386 (recovery mode)
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.8-3-386 root=/dev/sda1 ro single
initrd          /boot/initrd.img-2.6.8-3-386
savedefault


User avatar
julian67
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Can't re-install GRUB

#2 Post by julian67 »

Use a recent Debian install CD, a Lenny one is good (maybe Etch is but I don't remember). Use the Rescue option from the boot menu. It will go start the installer and go through one or two stages (non-destructive) and then offer you some rescue options, one of which is to re-install grub. This often succeeds where attempting the same thing from a running OS or a chroot fails.

And never use cp -a as a backup or restore mechanism on anything that matters.
Wisdom from my inbox: "do not mock at your pottenocy"

SLind
Posts: 2
Joined: 2009-06-12 07:47

Re: Can't re-install GRUB

#3 Post by SLind »

In this case the live-cd also could not re-install grub :-(
And never use cp -a as a backup or restore mechanism on anything that matters.
....and instead of cp -a i should have used...?

User avatar
julian67
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Can't re-install GRUB

#4 Post by julian67 »

SLind wrote:In this case the live-cd also could not re-install grub :-(
And never use cp -a as a backup or restore mechanism on anything that matters.
....and instead of cp -a i should have used...?
rsync for backing up/synchronising data. If you read man cp and man rsync you'll see cp is more limited and there are more circumstances when it can fail.

dd is useful for backing up the mbr, because if you can restore the original mbr and partition table after a failure like this then at least you're back where you started fairly quickly.
Wisdom from my inbox: "do not mock at your pottenocy"

jalu
Posts: 1397
Joined: 2008-11-19 23:26

Re: Can't re-install GRUB

#5 Post by jalu »

SLind:
In this case the live-cd
if it isn`t just a typo, julian67 is meaning the debian install-cd.

User avatar
julian67
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Can't re-install GRUB

#6 Post by julian67 »

Yes, the install CD, not the live CD.
Wisdom from my inbox: "do not mock at your pottenocy"

Post Reply