linux内核丢失怎么修复,linux内核修复

1、准备一个linux盘

2、进入linux rescue

3、重建initrd

在紧急修复模式下输入

chroot /mnt/sysimage

mkinitrd -f /boot/initrd-uname.img

uname //uname依照自己的情况输入,这里我加入-f是强制,懒得mv了

reboot

以下是原文:

How to recover Linux from booting failed because of LVM change?

I have a CentOS Linux test server, now because of some change and

upgrading, the hard disks changed from /dev/hda to /dev/sda, and

because of it, the server could not boot up.

I only have 2 partitions, /dev/sda1 is /boot, which is ext2 I

think, then /dev/sda2 is a lvm partition, it has 2 logical volumes,

one is LogVol00 mapped as /, another is LogVol01 as swap.

So I boot up with a rescue cd, which could rescan the pv and lv

by:

pvscan

vgchange -ay

Now I could mount the lvs, but if I reboot to CentOS again, it

still fail.

Which file should I change on my hard disk so that it could update

itself to know now /dev/hda is /dev/sda?

Thanks,

Steve

Clarification added December 21, 2009:

ok, to make it more clear:

I've changed /etc/fstab and /boot/grub/menu.1st

They all pointing to /dev/VolGroup00/LogVol00, which is ok.

The problem is VGs are not updated/refreshed to see the PVs which

are changed.

I want to sync the VG settings or recreate the VG so it sees the

correct PVs which are on /dev/sda now. How to manually change some

files to make it work? as my centos could not boot up any more.

Clarification added December 22, 2009:

Hi all,

As Bil suggested, I tried chroot, here is the steps:

# modprobe dm-mod

# pvscan

# vgchange -ay

# mount /dev/sda1 /boot

# mount /dev/VolGroup00/LogVol00 /mnt/sda2

# mount -t proc none /mnt/sda2/proc

# mount -t sysfs none /mnt/sda2/sys

# mount -o bind /dev /mnt/sda2/dev

# chroot /mnt/sda2

# pvscan

# vgchange -ay

# exit

# umount /mnt/sda2/{proc,sys,dev}

# umount /mnt/sda2

# reboot

a4c26d1e5885305701be709a3d33442f.png

Every steps are successfully done, all seems

good, but guess what? the problem is still the same after

reboot.

Here is the error message:

...

kernel /vmlinuz-xxx ro root=/dev/VolGroup00/LogVol00 rhgb

quiet

...

initrd /initrd-xxx.img

...

Momory for crash kernel (0x0 to 0x0) notwithin permissible

range

...

Red Hat nash version 5.1.19.6 starting

Reading all physical volumes. This may take a while...

Volume group "VolGroup00" not found

Unable to access resume device (/dev/VolGroup00/LogVol01) # this is

the swap

mount: could not find filesystem '/dev/root'

setuproot: moving /dev failed: no such file or directory

setuproot: error mounting /proc: no such file or directory

setuproot: error mounting /sys: no such file or directory

switchroot: mount failed: no such file or directory

kernel panic - not syncing: attempted to kill init!

Oh man, is there anything did I missed?

Clarification added December 22, 2009:

OK, Great, I've fixed it by rebuild initrd, thanks to all you

experts, :D fstab, grub are all ok, the problem is with initrd. Here is what I

did: # modprobe dm-mod # pvscan # vgchange -ay # mount /dev/VolGroup00/LogVol00 /mnt/sda2 # mount -t proc none /mnt/sda2/proc # mount -t sysfs none /mnt/sda2/sys # mount -o bind /dev /mnt/sda2/dev # chroot /mnt/sda2 # mount /dev/sda1 /boot # pvscan # vgchange -ay #cd /boot #mv initrd-2.6.18-164.6.1.el5.img initrd.bak

#mkinitrd /boot/initrd-2.6.18-164.6.1.el5.img

2.6.18-164.6.1.el5

#grub-install --recheck /dev/sda # exit # umount /mnt/sda2/{proc,sys,dev} # umount /mnt/sda2/boot # umount /mnt/sda2 # reboot Just for your reference, here are the booting error

message: ... kernel /vmlinuz-xxx ro root=/dev/VolGroup00/LogVol00 rhgb

quiet ... initrd /initrd-xxx.img ... Momory for crash kernel (0x0 to 0x0) notwithin permissible

range ... Red Hat nash version 5.1.19.6 starting Reading all physical volumes. This may take a

while... Volume group "VolGroup00" not found Unable to access resume device (/dev/VolGroup00/LogVol01) # this is

the swap mount: could not find filesystem

'/dev/root' setuproot: moving /dev failed: no such file or

directory setuproot: error mounting /proc: no such file or

directory setuproot: error mounting /sys: no such file or

directory switchroot: mount failed: no such file or

directory kernel panic - not syncing: attempted to kill

init! Thanks again, Linux gurus!~~~ Steve

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值