Centos7 虚拟机环境下断电后进入dracut模式

Vmware虚拟机环境下的Centos7,系统掉电后,无法重启,直接进入的dracut。因匆忙之中,没有来得及抓图。但记得系统提示:
Warning: /dev/centos/root does not exist
Warning: /dev/centos/swap does not exist
Warning: /dev/mapper/centos-root does not exist
然后就是提示输入journalctl查看日志。日志中主要内容也是提示以上三问题。
尝试安装盘启动恢复,提示无法找到任何linux分区。
按照https://blog.csdn.net/weixin_43905458/article/details/104059550的方法修复,在/dev目录中,找不到centos。
无奈用英文搜索,终于找到一篇文章:https://unix.stackexchange.com/questions/425045/warning-dev-centos-root-swap-centos-root-does-not-exist-after-configuring-dr
按照他的做法:

$ lvm vgscan
$ lvm vgchange -ay 
$ exit

系统引导成功!但文章说,重启后依然会失败。本人菜鸟,不明缘由。
幸好后面提供了解决方法,但我想先凑活着用,就没有敢尝试。希望高手验证。
恐网站无法访问,把解决办法转贴,共大家参考。
The reason why you’re seeing this is due of initramfs kernel image being build for the specific system it’s running on, so migrating to a new hardware will cause it to fail to boot.
Rebuilding initramfs in emergency mode(or go to the Rescue Mode ):
Then

  1. List the initramfs images you have:
 ls -ltrh /boot/initramfs-*
  1. Locate the kernel version you’re using and create a backup of it:
  cp -iv /boot/initramfs-3.10.0-1062.el7.x86_64.img /boot/initramfs-3.10.0-1062.el7.x86_64.img.back
  1. Rebuild the kernel image for that specific kernel
  dracut -f
  1. Select the new kernel image
  ls -ltrh /boot/initramfs-*
  1. Specify the new kernel version (For Example):
  dracut -f  /boot/initramfs-3.10.0-1062.el7.x86_64.img 3.10.0-1062.el7.x86_64
  1. Go to the Grub config
  vim /boot/grub2/grub
  1. Delete the old menuentry and make sure that the new menuentry is top of all
  2. Generate a GRUB configuration file
grub-mkconfig
  1. Reboot
  2. Done.

你可能感兴趣的:(linux)