免费注册 查看新帖 |

Chinaunix

广告
  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1379 | 回复: 0
打印 上一主题 下一主题

redhat 9 删除/boot后的系统修复 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-11-02 13:01 |只看该作者 |倒序浏览
    朋友的客户有redhat9系统无法再启动,只能进到grub,他到现场后让我帮忙看一下。说 grub后root (hd0,0) ,Error 21: Selected disk does not exist 当时估计就是grub坏了而已。
    他启动盘引导进入resuce 模式,设置好网络。我putty登录后看,吓了一跳。整个boot目录是空的。
删掉了,因为以前没有遇到过。凭直觉应该能修复系统。因为我远程,操作起来更不敢随便启动。
    好久没有用rh9,不甚上手。比对了我们公司的as4,boot目录 (后来发现文件变化很大)
-rw-r--r--  1 root root   49930 10月  6 19:37 config-2.6.9-42.0.3.ELsmp
drwxr-xr-x  2 root root    1024 10月 25 13:36 grub
-rw-r--r--  1 root root  542049 10月 25 13:36 initrd-2.6.9-42.0.3.ELsmp.img
-rw-r--r--  1 root root   23108 2005-08-04  message
-rw-r--r--  1 root root   21282 2005-08-04  message.ja
-rw-r--r--  1 root root  766287 10月  6 19:37 System.map-2.6.9-42.0.3.ELsmp
-rw-r--r--  1 root root 1444549 10月  6 19:37 vmlinuz-2.6.9-42.0.3.ELsmp
另有grub文件夹下的文件应该不难恢复,/usr/share/grub/i386-redhat/下有相似文件
整理了一下思路,一步一步来
1.察看了下分区信息,
[root@localhost root]# cat /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
none                    /dev/pts                devpts  gid=5,mode=620  0 0
LABEL=/home             /home                   ext3    defaults        1 2
none                    /proc                   proc    defaults        0 0
none                    /dev/shm                tmpfs   defaults        0 0
LABEL=/tmp              /tmp                    ext3    defaults        1 2
LABEL=/usr              /usr                    ext3    defaults        1 2
LABEL=/var              /var                    ext3    defaults        1 2
/dev/cciss/c0d0p6       swap                    swap    defaults        0 0
/dev/cdrom              /mnt/cdrom              udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0
[root@localhost root]# mount
/dev/cciss/c0d0p1 on / type ext3 (rw,defaults)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw,defaults)
/dev/cciss/c0d0p2 on /home type ext3 (rw,defaults)
none on /proc type proc (rw,defaults)
/dev/cciss/c0d0p7 on /tmp type ext3 (rw,defaults)
/dev/cciss/c0d0p3 on /usr type ext3 (rw,defaults)
/dev/cciss/c0d0p5 on /var type ext3 (rw,defaults)
/dev/cdrom on /mnt/cdrom type iso9660 (ro)
应该是hp机器作raid后的硬盘设备。作grub后需要考虑这个问题
在grub中加入boot=/dev/cciss/c0d0
2.cp 光盘上的 vmlinuz 到boot,再
  mkinitrd /boot/initrd-2.4.20-8.img 2.4.20-8
3.重新安装grub 。当时想着就剩下grub的问题了。
[root@localhost root]# cat /boot/grub/device.map
(fd0)   /dev/fd0
(hd0)   /dev/cciss/c0d0
4.install grub.
grub> root (hd0,0)   
root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)      
setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  16 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
Done.
grub> quit
grub> kernel /vmlinuz-2.4.20-8 ro root=LABEL=/
Error 15: File not found
grub> device (hd0) /dev/cciss/c0d0
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> kernel /vmlinuz-2.4.20-8 ro root=LABEL=/
Error 15: File not found        
在这里停了很久(不明白kernel位置从哪里开始计算的,还以为是device没有被grub正确识别成hd0的缘故)
grub> kernel /boot/vmlinuz-2.4.20-8 ro root=LABEL=/
   [Linux-bzImage, setup=0x1400, size=0xcf88d]
grub> initrd /boot/initrd-2.4.20-8.img
   [Linux-initrd @ 0x3a7000, 0x48e10 bytes]
让朋友重起后依旧提示无法识别设备
确认module中有cciss
[root@localhost root]# more /etc/modules.conf
alias eth0 e100
alias scsi_hostadapter aic7xxx
alias scsi_hostadapter1 cciss
alias usb-controller usb-ohci
alias usb-controller usb-ohci
第一天卡在这里了,就让服务先跑着,真是个搞笑的方法......
5.想了n久,一直在grub上,并搜google,毕竟这个提示不得不让我疑惑阿
Probing devices to guess BIOS drives. This may take a long time.
/dev/cciss/c0d0 does not have any corresponding BIOS drive.
今天想碰碰运气
估计就是那个system.map的问题了,这是和内核有关的文件,如果重编内核应该可以。rh9,看来直接卸载以下就能ok了
[root@localhost root]# rpm -qa | grep kernel
kernel-smp-2.4.20-8
kernel-pcmcia-cs-3.1.31-13
kernel-2.4.20-8
kernel-BOOT-2.4.20-8
全部重装下,rh也就方便在这里了~~~:)
结果是猜对了,必须的文件都有了,看来比rhel4还多了个kernel.h,就等重起了
lrwxrwxrwx   1 root     root           19 Nov  2 12:08 System.map -> System.map                                              -2.4.20-8
-rw-r--r--   1 root     root       520129 Mar 14  2003 System.map-2.4.20-8
-rw-r--r--   1 root     root       330649 Mar 14  2003 System.map-2.4.20-8BOOT
-rw-r--r--   1 root     root       546061 Mar 14  2003 System.map-2.4.20-8smp
-rw-r--r--   1 root     root        44309 Mar 14  2003 config-2.4.20-8
......
最终 grub.conf内容
default=1
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.20-8BOOT)
        boot=/dev/cciss/c0d0
        root (hd0,0)
        kernel /boot/vmlinuz-2.4.20-8BOOT ro root=LABEL=/
        initrd /boot/initrd-2.4.20-8BOOT.img
title Red Hat Linux (2.4.20-8)
        boot=/dev/cciss/c0d0
        root (hd0,0)
        kernel /boot/vmlinuz-2.4.20-8 ro root=LABEL=/
        initrd /boot/initrd-2.4.20-8.img
......
一些命令解释
device (hd0) /dev/cciss/c0d0  会替代默认的或者原先设置的设备映射值
boot=/dev/cciss/c0d0    加在 grub中,使能找到硬盘
maps the /dev/cciss/c0d0 disk to (hd0) and it overrides what you already specified with the device.map or another device command.
grub>find kernel /boot/vmlinuz-2.4.20-8 ro root=LABEL=/
grub>find initrd /boot/initrd-2.4.20-8.img
  只是想测试下文件位置是否正确。
dd if=/dev/cciss/c0d0p1 of=/tmp/mbrbackup count=1
hexdump mbrbackup      察看mbr信息
edit @ 2006.11.2 by luweinet   luweinet@hotmail.com
其他更多的知识点请参考
http://www.gnu.org/software/grub/manual/grub.html


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/6408/showart_194032.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP