Hello,
I have a problem. My second computer won't boot - I think the MBR on the disk drive is corrupt.
I don't have a working CDROM drive on that computer. What I have done is to physically move the drive to my first computer. The partitions mount OK, and seem to be good. FC1 is installed on one of them.
My question is, can I re-install grub somehow on the drive, from my working computer (which is running FC2), and then move it back to the other computer, and expect it to work?
On Sun, 2004-11-14 at 19:24 +0000, Colin Paul Adams wrote:
Hello,
I have a problem. My second computer won't boot - I think the MBR on the disk drive is corrupt.
I don't have a working CDROM drive on that computer. What I have done is to physically move the drive to my first computer. The partitions mount OK, and seem to be good. FC1 is installed on one of them.
My question is, can I re-install grub somehow on the drive, from my working computer (which is running FC2), and then move it back to the other computer, and expect it to work? -- Colin Paul Adams Preston Lancashire
Yes you can do that. Just remember that the drive numbers will likely be different when the drive is returned its "home" PC. If you try to edit any entries, they will reference the wrong drive in the current PC.
Note that you can install grub to a floppy disk. Assuming you have a floppy drive on the original PC this could have saved you a bit of hardware tinkering.
Kevin Freeman
"Kevin" == Kevin Freeman kfreem02@comcast.net writes:
Kevin> On Sun, 2004-11-14 at 19:24 +0000, Colin Paul Adams wrote: >> Hello, >> >> I have a problem. My second computer won't boot - I think the >> MBR on the disk drive is corrupt. >> >> I don't have a working CDROM drive on that computer. What I >> have done is to physically move the drive to my first >> computer. The partitions mount OK, and seem to be good. FC1 is >> installed on one of them. >> >> My question is, can I re-install grub somehow on the drive, >> from my working computer (which is running FC2), and then move >> it back to the other computer, and expect it to work? -- Colin >> Paul Adams Preston Lancashire >>
Kevin> Yes you can do that. Just remember that the drive numbers Kevin> will likely be different when the drive is returned its Kevin> "home" PC. If you try to edit any entries, they will Kevin> reference the wrong drive in the current PC.
Kevin> Note that you can install grub to a floppy disk. Assuming Kevin> you have a floppy drive on the original PC this could have Kevin> saved you a bit of hardware tinkering.
This seems like a good idea, so I tried it.
But when I boot with the floppy, I get:
Grub hard disk error.
(Both before I restored the hard disk to the machine, and afterwards).
I've changed the boot sequence to F,A to try to avoid it looking at the hard disk.
Can you tell me what's going on?
On Mon, 2004-11-15 at 20:39 +0000, Colin Paul Adams wrote:
"Kevin" == Kevin Freeman kfreem02@comcast.net writes:
Kevin> Note that you can install grub to a floppy disk. Assuming Kevin> you have a floppy drive on the original PC this could have Kevin> saved you a bit of hardware tinkering.This seems like a good idea, so I tried it.
But when I boot with the floppy, I get:
Grub hard disk error.
(Both before I restored the hard disk to the machine, and afterwards).
I've changed the boot sequence to F,A to try to avoid it looking at the hard disk.
mkfs /dev/fd0 mount /media/floppy/ #or /mnt/floppy if FC2 mkdir -p /media/floppy/boot/grub
cp /boot/grub/stage1 /boot/grub/stage2 /boot/grub/menu.lst /media/floppy/boot/grub/ umount /media/floppy/
/sbin/grub --batch --device-map=/dev/null <<EOT device (fd0) /dev/fd0 root (fd0) setup (fd0) quit EOT
In theory that gives you a grub floppy which includes a working menu. In my testing, it produces a floppy that boots to a grub command prompt. In any case, you can now attempt to boot the sick machine.
Assuming the FC boot partition on /dev/hda1, type root (hd0,0), followed by configfile /grub/grub.conf. This will load the "lost" boot menu. You should be able to check the entries, make any temporary changes, and boot into FC. You can then reinstall grub so that the floppy is no longer necessary - but keep it somewhere safe just in case you need it again.
Kevin Freeman
"Kevin" == Kevin Freeman kfreem02@comcast.net writes:
>> From http://myrddin.org/howto/debian-grub.php : Kevin> mkfs /dev/fd0 mount /media/floppy/ #or /mnt/floppy if FC2 Kevin> mkdir -p /media/floppy/boot/grub
Kevin> cp /boot/grub/stage1 /boot/grub/stage2 /boot/grub/menu.lst Kevin> /media/floppy/boot/grub/ umount /media/floppy/
Kevin> /sbin/grub --batch --device-map=/dev/null <<EOT device Kevin> (fd0) /dev/fd0 root (fd0) setup (fd0) quit EOT
Kevin> In theory that gives you a grub floppy which includes a Kevin> working menu. In my testing, it produces a floppy that Kevin> boots to a grub command prompt. In any case, you can now Kevin> attempt to boot the sick machine.
Thanks a million, Kevin. You're a star!
Kevin> Assuming the FC boot partition on /dev/hda1, type root Kevin> (hd0,0), followed by configfile /grub/grub.conf. This will Kevin> load the "lost" boot menu.
Assumptions not valid. But with some trial and error, I found the following commands sufficient to attempt a boot:
root (hd0,4) configfile /etc/grub.conf
(Disk has FC1 on it, if that is relevanet).
This then attempts to boot a kernel (I'm not presented with a grub menu - I guess there's only one kernel present).
But fails with a message something like:
Disk (hd1,4) not found.
There used to be ANOTHER hard disk in this machine, before that one proved to be unusable, so I'm guessing that this hard disk must have been the primary IDE slave (is that what hd1 is?).
Can I just re-cable the disk as a slave, or better, is there someway of changing the grub.conf on the disk to specify hd0 instead of hd1 (I'm guessing that there is where the problem is)?
On Tue, 2004-11-16 at 07:55 +0000, Colin Paul Adams wrote:
root (hd0,4) configfile /etc/grub.conf
(Disk has FC1 on it, if that is relevanet).
This then attempts to boot a kernel (I'm not presented with a grub menu - I guess there's only one kernel present).
But fails with a message something like:
Disk (hd1,4) not found.
OK, so this time Murphy's Law is working overtime. Boot with the floppy and this time enter: root (hd0,4) cat /etc/grub.conf #if this does not work, cat /boot/grub/menu.lst or /grub/menu.lst
Now you need to duplicate the kernel and initrd lines that were printed by the cat command: kernel /vmlinuz-some-version and some params initrd /initrd-some-version.img
Note: use tab completion to save some typing and prevent mistakes.
After entering the commands above for root, kernel and initrd grub is now ready to resurrect your FC installation. Enter the command boot and press enter.
Once the system boots, edit grub.conf (the HD version) and replace hd1 with hd0. Also, enter a nonzero value for timeout (5 or 10 seconds is fine) so that if you have to use a boot floppy in the future, the menu can be displayed (and then modified) with the configfile option. It would be a good idea to test the grub floppy again with the commands: root (hd0,4) configfile /etc/grub.conf
If this brings up the working grub menu then you know your "emergency recovery" procedures will work in the future.
There used to be ANOTHER hard disk in this machine, before that one proved to be unusable, so I'm guessing that this hard disk must have been the primary IDE slave (is that what hd1 is?).
That is the source of your problem. If you swap, move or replace drives you need to be careful with grub.conf to ensure that you still have a bootable system. Now that you are armed with a grub floppy (and know how to use it) this is less of a concern.
Kevin Freeman
"Kevin" == Kevin Freeman kfreem02@comcast.net writes:
Kevin> On Tue, 2004-11-16 at 07:55 +0000, Colin Paul Adams wrote: >> root (hd0,4) configfile /etc/grub.conf >> >> (Disk has FC1 on it, if that is relevanet). >> >> This then attempts to boot a kernel (I'm not presented with a >> grub menu - I guess there's only one kernel present). >> >> But fails with a message something like: >> >> Disk (hd1,4) not found. >>
Kevin> OK, so this time Murphy's Law is working overtime. Boot
Not yet it isn't! :-)
Kevin> with the floppy and this time enter: root (hd0,4) cat Kevin> /etc/grub.conf
Kevin> Now you need to duplicate the kernel and initrd lines that Kevin> were printed by the cat command: kernel Kevin> /vmlinuz-some-version and some params initrd Kevin> /initrd-some-version.img
Kevin> Note: use tab completion to save some typing and prevent Kevin> mistakes.
Kevin> After entering the commands above for root, kernel and Kevin> initrd grub is now ready to resurrect your FC installation. Kevin> Enter the command boot and press enter.
All done successfully.
Kevin> Once the system boots,
assumptions, assumptions.... NOW Murphy is kicking good and proper. Here are the last few messages from the console:
Mounting root filesystem. EXT3-fs: unable to read superblock mount: error 22 mounting ext3 pivotroot: pivot_root(/sysroot,/sysroot/initrd) failed: 2 umount /initrd/proc failed: 2 Freeing unused kernel memory: 168k freed Kernel panic: No init found. Try passing init= option to kernel.
I tried the above with two different kernels (there's 4 or 5 installed - all FC1). Now, I mentioned before that I was able to mount the root file system on my other computer OK, so I'm rather puzzled by the failure to find the superblock.
Is there anything I can do at this stage?
On Wed, 2004-11-17 at 07:15 +0000, Colin Paul Adams wrote:
assumptions, assumptions.... NOW Murphy is kicking good and proper. Here are the last few messages from the console:
Mounting root filesystem. EXT3-fs: unable to read superblock mount: error 22 mounting ext3 pivotroot: pivot_root(/sysroot,/sysroot/initrd) failed: 2 umount /initrd/proc failed: 2 Freeing unused kernel memory: 168k freed Kernel panic: No init found. Try passing init= option to kernel.
Looking at the bright side, at least the kernel was loaded from the /boot partition. ;)
I can think of 3 likely causes:
1) root parameter on kernel line is pointing to the wrong partition 2) initrd points to a different version than the kernel version 3) your / partition is at least partially corrupt
I tried the above with two different kernels (there's 4 or 5 installed
- all FC1).
Now, I mentioned before that I was able to mount the root file system on my other computer OK, so I'm rather puzzled by the failure to find the superblock.
Is there anything I can do at this stage?
Try modifying the root= parameter of grub's kernel config. If you did a stock FC1 install, try root=LABEL=/. Otherwise, just try root=/dev/hda1 through root=/dev/hda5. One of them has to work! This should not cause any harm to the drive since nothing will be mounted read/write until your / partition is properly specified.
If this still does not work, you might try Toms root/boot: http://www.toms.net/rb/
This floppy contains fdisk, vi, etc. and will allow you to explore the drive to locate the / partition and edit /boot/grub/grub.conf. While there, also verify that /boot/grub/menu.lst links to /boot/grub/grub.conf.
Kevin Freeman
"Kevin" == Kevin Freeman kfreem02@comcast.net writes:
Kevin> On Wed, 2004-11-17 at 07:15 +0000, Colin Paul Adams wrote: >> assumptions, assumptions.... NOW Murphy is kicking good and >> proper. Here are the last few messages from the console: >> >> Mounting root filesystem. EXT3-fs: unable to read superblock >> mount: error 22 mounting ext3 pivotroot: >> pivot_root(/sysroot,/sysroot/initrd) failed: 2 umount >> /initrd/proc failed: 2 Freeing unused kernel memory: 168k freed >> Kernel panic: No init found. Try passing init= option to >> kernel. >>
Kevin> Looking at the bright side, at least the kernel was loaded Kevin> from the /boot partition. ;)
:-) Kevin> I can think of 3 likely causes:
Kevin> 1) root parameter on kernel line is pointing to the wrong partition.
No.
Kevin> 2) initrd points to a different version than the kernel Kevin> version
Kevin> 3) your / partition is at least partially Kevin> corrupt
Well, that seems likely.
Kevin> Try modifying the root= parameter of grub's kernel config. Kevin> If you did a stock FC1 install, try root=LABEL=/. Kevin> Otherwise, just try root=/dev/hda1 through root=/dev/hda5. Kevin> One of them has to work!
Why? If the / partition is partly corrupted, why should it work at all?
Kevin> If this still does not work, you might try Toms root/boot: Kevin> http://www.toms.net/rb/
Kevin> This floppy contains fdisk, vi, etc. and will allow you to Kevin> explore the drive to locate the / partition and edit Kevin> /boot/grub/grub.conf. While there, also verify that Kevin> /boot/grub/menu.lst links to /boot/grub/grub.conf.
I think I#ll try that then. Thanks.
On Wed, 2004-11-17 at 21:36 +0000, Colin Paul Adams wrote:
"Kevin" == Kevin Freeman kfreem02@comcast.net writes:
Kevin> 3) your / partition is at least partially Kevin> corruptWell, that seems likely.
Kevin> Try modifying the root= parameter of grub's kernel config. Kevin> If you did a stock FC1 install, try root=LABEL=/. Kevin> Otherwise, just try root=/dev/hda1 through root=/dev/hda5. Kevin> One of them has to work!Why? If the / partition is partly corrupted, why should it work at all?
Since you were able to mount the partitions when the drive was installed in the other PC, I thought corruption would be unlikely.
From Toms Root Boot diskette you can run e2fsck to determine the state
of the filesystem.
Kevin Freeman
"Kevin" == Kevin Freeman kfreem02@comcast.net writes:
Kevin> Since you were able to mount the partitions when the drive Kevin> was installed in the other PC, I thought corruption would Kevin> be unlikely.
It seems it was just fstab.
I booted with Tomsrtbt, edited grub.conf, and re-booted.
This time, using grub floppy, I got a menu. Booting procedeed further, but was unable to mount / as /etc/fstab had it listed for /dev/hdd5.
I edited that, and re-booted again - this time everything works (booting from a grub floppy).
Booting from the hard disk though still fails with a Hard Disk Error.
So now I think I need to re-install grub on the hard disk. This is /dev/hda, so I suspect that I can get this done by booting the system again via the grub floppy, and then simply typing
grub-install /dev/hda
But as I am in no hurry, I thought I'd check with you first. The root partition is /dev/hda5.
"Kevin" == Kevin Freeman kfreem02@comcast.net writes:
Kevin> Since you were able to mount the partitions when the drive Kevin> was installed in the other PC, I thought corruption would Kevin> be unlikely.
>> From Toms Root Boot diskette you can run e2fsck to determine >> the state Kevin> of the filesystem.
Well, I got everything working, except for one thing - I could not get Grub installed on the MBR of the hard disk.
Still, it's not a problem - I upgraded to FC3, and that has installed Grub on the MBR for me, so now all is fine.
But I would like to know what I was doing wrong, in case I need to do it again. What I did was:
root (hd0,4) setup(hd0)
This seemed to work - installation and verification were all reported as working. But when I cam to boot, I saw no messages from Grub (neither loading stage 2 nor hard disk error nor anything). It just seemed to stop.