如何把linux物理机迁移到vmware中
gzjoker
要把物理机的linux迁移到vmware中,vmware 自己提供了vmware converter,这个看了评测,好像不能迁移到vmware workstation中,所以没有去尝试。google之后,发现了一些方法,实际测试成功,整理一下。
1、备份物理机
如果是windows的系统,这个好办了,常用的ghost之类的都可以用,而linux系统,ghost不可用。有一个开源的工具Clonezilla可以用。
到这里下载一个live cd:/clonezilla-live.php,刻盘,使用光盘启动机器,完成备份。如果想要完成迁移,大部分都需要把物理机的所有硬盘都迁移到vmware中,这时候需要在物理机上面外接一个硬盘来放备份的镜像,Clonezilla也支持把镜像放到ftp,nfs server,samba等网络服务器上面,但是那样速度可能太慢,如果速度快,可以插入一个USB的移动硬盘,Clonezilla会自动识别USB设备的。
关于Clonezilla的使用方法,可以看下面的这些连接,图文并茂的:
(1)
/fine-print-live-doc.php?path=./clonezilla-live /doc/01_Save_disk_image/00-boot-clonezilla-live-cd.doc#00-boot-clone zilla-live-cd.doc
(2)
www.ibm/developerworks/cn/linux/l-clonezilla/index.html
2、恢复物理机镜像到vmware中
vmware虚拟机怎么使用新建一个vmware的虚拟机,新建的磁盘最好跟物理机的磁盘大小相等或者
大于物理机的磁盘大小,最终硬盘的磁盘大小会与物理机的数据大小有关系。
新建磁盘如果是scsi的,最好选择buslogic的scsi卡,否则后面修复的时候,会不到磁盘,不能选择buslogic的,就选择ide的磁盘,但是这样修复完了以后,则需要去修改/etc/fstab文件了,因为物理机是scsi磁盘,看到的是/dev/sda1这样的格式,ide的磁盘就是/dev/hda1这样的格式。
使用Clonezilla的live cd启动虚拟机,按照上面两个连接的方法,把物理机的镜像恢复到虚拟机中。developerworks上面的那篇文章,在恢复的步骤,说要先给目标磁盘分区,格式化之类的,我没有做,直接启动live cd然后恢复即可,会自动对目标磁盘分区。
3、修复vmware镜像中的linux
物理机的镜像恢复到vmware中以后,由于物理机的硬件条件跟虚拟机不同,所以并不能立刻开始使用,甚至启动都启动不起来,所以需要修复一下,修复的方法,有几种,引用一下,可以每种都试下,那种方便使用哪种。
方法一:
引用自:zhangjiansheng.wordpress/2010/02/14/%E4%BD%BF%E7%94%A8clo nezilla%E8%BF%9B%E8%A1%8Clinux%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%89%A9%E 7%90%86%E6%9C%BA%E5%88%B0%E8%99%9A%E6%8B%9F%E6%9C%BA%E7%9A%84p2v%E8% BF%81%E7%A7%BB/
操作步骤:(测试成功)
1,使用clonezilla live进行备份。
可备份到移动硬盘上,或者网络上。
不管使用哪种方式,都建议将备份好的image放到网络上,便于后续的恢
复工作。
记录一下,当前1.2.3版本的clonezilla还不认识R710的网卡,所以引导过程需要超时4次,每次1分钟,因为机器有4块网卡,耗时。当了后边vmware 环境中,它就认识那个网卡了,启动非常快速。
2,在虚拟机中创建一个新的虚拟机。
注意硬盘不能小于物理机的硬盘。
3,启动虚拟机,并以clonezilla live光盘引导。
进入shell模式,使用fdisk对本地的硬盘进行分区,只需要创建一个分区,保存分区表。
重启虚拟机。
sudo su –
fdisk -l
fdisk /dev/sda;(创建分区)
reboot
4,再次以clonezilla live光盘引导,启动虚拟机,进行linux系统的恢复。
进行恢复。使用网络资源进行恢复,本地机器设置静态ip即可,我使用的ssh方式挂载镜像数据,非常方便。
5,恢复系统以后,调整一些参数。
如果不执行此步骤,直接启动虚机硬盘引导,会遇到panic之类的严重错误,其实就是不到合适的引导盘。
用linux的安装光盘(随便哪个版本都可以,只要是Linux即可,版本与主机系统相同是最好)引导虚拟机启动,进入linux rescue模式。
然后执行mkinitrd命令,重建initrd即可。
如果有多余的文件系统,可以修改/etc/fstab文件进行注释,如果原来物理机里有多块本地硬盘,或者加载有iscsi/san等网络磁盘,都需要修改这个文件。
6,重启就好了。
poertoff虚机,修改虚机设置,将光驱挂载去掉,虚拟机可以不要光盘引导了,可以自行引导了。
power on之后,虚机不再报错了,系统正常了!
只需要修改自己的网络地址,所有服务已正常。
方法二:引用自kb.vmware/selfservice/microsites/search.do?language=en_US &cmd=displayKC&externalId=1002402
Virtual machine does not boot after being converted from a physical Red Hat machine
Details
• A converted physical machine running Red Hat does not boot as expected
• Virtual machine fails to boot after conversion
• The boot process halts with an error
• Possible errors include:
o No volume groups found
o Kernel panic – not syncing: Attempted to kill init!
o VFS: Cannot open root device "LABEL=/" or 00:00
o Please append a correct = "root=" boot option
o Kernel panic: VFS: Unable to mount root fs on 00:00
Solution
The issue occurs because the operating system’s ramdisk image does not include the drivers or modules for the virtual SCSI adapter configured for the virtual machine. These modules are not in the ramdisk image because the image was originally created on a system that did not use this hardware. You must replace the existing ramdisk image with one that includes the proper drivers.
Converter 3.0.x did not support hot cloning of Linux operating systems or the configuration of resulting virtual machines for new virtual hardware. It only supported cold cloning without configuration. vCenter Converter 4.0 does support hot cloning and the configuration of some Linux operating systems, including Red Hat. Refer to the manual for a list of supported versions.
Please validate that each troubleshooting step below is true for your environment. Each step will provide instructions or a link to a document, in order to eliminate possible causes and take corrective a
ction as necessary. The steps are ordered in the most appropriate sequence to isolate the issue and identify the proper resolution. Please do not skip a step.
Note: If you perform a corrective action in any of the following steps, attempt booting the virtual machine again.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论