linux grub confusion

来源:互联网 发布:urlencode java写法 编辑:程序博客网 时间:2024/06/07 02:10
solution:   http://www.debianhelp.org/node/3463

After installing ubuntu gutsy, I modified the disk partition using fdisk - fix the partition order during the installation, changed the root partition /dev/hda10 to /dev/hda9. then reboot
"
grub error 25
"
I guess the grub can't find the stage2 according to the stage1.5 embedded MBR, or something that leads to menu.list load failure.
Now what I have to do is tore-install the ubuntu gutsy's grub.  "chroot" into the root system will enable gutsy fix itself.
but , bad news, my CD-ROM's broken. I have to boot my notebook from a USB-Disk which recognized by BIOS as "hd0". It matters a lot.  I can't manually boot the gutsy in the grub on this "hd0" disk, in turn, I have to boot another LiveCD using unionfs, and eventually "chroot" into the gutsy.
"grub-install /dev/hda" ?  It doesn't work!  It's reported  that "grub: not found or no block device".

....(hard time)

the problem is, chroot do all the static configuration but the dynamic things, such as mount the peripheral device ,etc. So, Prior to chroot, you need to tell the target system all these runtime information by  "mount".  Here is more details:


from Gerhard Brauer came the solution:

only grub as bootloader on /dev/hda
1. booting the clone in rescue-mode and mount /dev/hda1 /mnt
2. mount -o bind /dev /mnt/dev
3. mount -o bind -t proc /proc /mnt/proc
4. chroot /mnt
5. grub-shell with root (hd0,0) and setup (hd0)

I tried different ways, but only this one worked.

Don't delete stage2

don't run grub-install. It'll produce the error
/dev/sda1 does not have corresponding BIOS drive


add:基本上一个套路就是: 分区表就用fdisk之类工具修改,引导扇区就用grub来操作,dd都最好不要用,格式化使用mkfs。重建分区时直接使用mkfs,不用fdisk来修改。