redhat 9 删除/boot后的系统修复(转)

redhat 9 删除/boot后的系统修复(转)[@more@]朋友的客户有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> kernel /boot/vmlinuz-2.4.20-8 ro root=LABEL=/
grub> initrd /boot/initrd-2.4.20-8.img
只是想测试下文件位置是否正确。我笨哦~~
dd if=/dev/cciss/c0d0p1 of=/tmp/mbrbackup count=1
hexdump mbrbackup 察看mbr信息

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10617542/viewspace-963410/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10617542/viewspace-963410/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值