kvm to vmware和系统启动失败报错
一. 纯手动迁移
1. 将本地qcow2镜像转换成vmdk格式
1.1 拷贝kvm的qcow2镜像
cp lyj/lyj-ambari1.qcow2 ~
1.2 格式转换成vmware可识别的vmdk格式
qemu-img convert -f qcow2 ~/lyj-ambari1.qcow2 -O vmdk ~/lyj-ambari1.vmdk
1.3 远程传输到vmware机器上
[root@localhost:/vmfs/volumes/5f17aa04-b31b57a5-227b-0cc47adb9204/ambari_7.97convert_test] scp root@192.168.7.97:~/lyj-ambari1.vmdk .
MD5值校验
md5sum lyj-ambari1.vmdk
4f9211ccf92109ccdba75f03300cfdea lyj-ambari1.vmdk
vmdk适应当前esxi系统
[root@localhost:/vmfs/volumes/5f17aa04-b31b57a5-227b-0cc47adb9204/ambari_7.97convert_test] vmkfstools -i lyj-ambari1.vmdk -d thin lyj-ambari1-71.vmdk
1.4 从vmware上启动虚拟机
结果:edd=off。。。。
分析:为方便console连接,kvm模板设置了ttyS=0
解决:开机ctrl+x进去,linux行把grub的ttyS0改为tty0后,正常启动;启动后,改grub配置文件中对应的ttyS0
结果:经测试,虚拟机已成功启动,但是启动后依然问题,进入了dracut#模式,报错显示未找到各分区{root,swap};
原因分析:查阅资料发现,这是因为操作时系统正在运行。。。
其他:而且如果镜像文件太大,cp慢,格式转更慢,scp也相当慢。150G的qcow2转100G的vmdk需要数小时,然后scp又是数小时,然后vmdk格式适应vmware又是数小时,加起来导入一个大容量虚拟机,花了整整一天时间。
报错
也找不到sda盘
尝试1:
未发现逻辑卷,尝试失败
在shell命令行中执行如下命令,可以找到相关的lvm虚拟卷。然后临时进入系统
dracut:/# lvm vgscan
dracut:/# lvm vgchange -ay
dracut:/# exit
进入系统之后,重新生成相关的内核启动文件
[root@localhost ~]# dracut -f
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
————————————————————————————————————————————
尝试2:
无法进入救援模式,只能进入紧急模式,没有boot目录,也未发现逻辑卷,尝试失败
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-*
2) 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
3) Rebuild the kernel image for that specific kernel
dracut -f
4) Select the new kernel image
ls -ltrh /boot/initramfs-*
5) 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
6) Go to the Grub config
vim /boot/grub2/grub
7) Delete the old menuentry and make sure that the new menuentry is top of all
8) Generate a GRUB configuration file
grub-mkconfig
9) Reboot
10) Done.
______________________________________________________________________________________________
尝试3:通过救援光盘进入救援模式
尝试成功
3.1. 救援模式激活逻辑卷
3.1.1 激活逻辑卷
vgscan #查看系统中的卷组
lvscan #查看系统中的逻辑卷
vgchange -ay #激活逻辑卷
此时会显示active字样已经被激活的逻辑卷列表
此时再运行:
lvscan
可以看到lv已激活
查看root所在的卷组【lsblk、lvscan、 ls等】:
比如/dev/centos/root
3.1.2 修复根分区文件系统
然后运行:
fsck /dev/centos/root #修复根分区逻辑卷
如果提示是xfs文件系统,需要用xfs_repair修复,则运行:
xfs_repair /dev/centos/root
然后会跑一堆日志,最后提示: release dirty buffer! done!
然后reboot重启系统,仍然通过救援模式引导系统:
这个时候再次尝试查找centos时,就能找到了,并提示自动挂载到/mnt/sysimage下。
3.3 从救援模式切换到系统环境,重新生成引导
chroot /mnt/sysimage
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sda
备注: /dev/sda指的是需要安装grub引导程序的硬盘(也就是开机引导的那块硬盘),这个可以通过lsblk或者fdisk -l来查看,根据实际情况自行选择
所有命令完成以后,重启机器,本以为能搞定,结果依然失败!
3.4 重新生成initramfs镜像文件
此时再次经行 尝试2 的操作
先进入救援模式,然后切换到系统环境
chroot /mnt/sysimage
重新生成initramfs镜像文件,内核版本在/lib/modules下可见
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot -f
此时lvm找到了
系统启动后,在以上界面自动重启一次,然后启动成功
注:迁移后网卡名发生改变
————————————————
二. 使用vmware-conventer工具
图形化操作,自行百度吧
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?