如何把物理机的linux迁移到vmware中
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
如何把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)
/developerworks/cn/linux/l-clonezilla/index.html
2、恢复物理机镜像到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中以后,由于物理机的硬件条件跟虚拟机不同,所以并不能立刻开始使用,甚至启动都启动不起来,所以需要修复一下,修复的方法,有几种,引用一下,可以每种都试下,那种方便使用哪种。
方法一:
引用自:/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之后,虚机不再报错了,系统正常了!
只需要修改自己的网络地址,所有服务已正常。
方法二:引用自/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 action 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.
1. I f your physical source machine has a vCenter Converter 4.0 supported version of Red Hat installed and you still have access to it:
1. U pgrade to vCenter Converter 4.0 if you have not done so already.
2. R un Converter and perform another physical to virtual conversion. This virtual machine should boot.
2. I f you are unable to use Converter to create a new Red Hat virtual machine that boots, you will need to modify the guest operating system.
Notes:
o Before beginning, VMware recommends that you take a snapshot of your virtual machine. VMware also recommends that you back up any files that you edit in the following steps. Once the operating system is working the snapshot and back up files can be deleted.
o In these steps, you will be making sure that the operating system has the appropriate type of virtual hard disk controller. This can be either LSI Logic or BusLogic. Choose the controller that is most suited to your version of Red Hat and make sure that it is this controller that is being presented to the virtual machine.
3. B oot the virtual machine from the first Red Hat installation disk.
4. A t the first prompt, type linux rescue and press Enter.
5. C hange root to the mounted installation. Type chroot /mnt/sysimage and press Enter.
6. I f the physical computer was IDE based, replace any instance of the text /dev/hda with /dev/sda in the files /etc/fstab,
/boot/grub/device.map, and /boot/grub/grub.conf.
7. E nsure that grub is installed properly. Type grub-install and press Enter.
8. I f the file /etc/modules.conf exists, edit it and remove any existing entries.
9. E dit the file /etc/modprobe.conf.
1. L ook for alias ethx module entries, where x is replaced by a number and module is replaced by text. Change each module entry to pcnet3
2.
2. I f you will be using BusLogic:
Look for alias scsi_hostadapterx module entries, where x is replaced by a number and module is replaced by text. Change each module entry to BusLogic.
3. I f you will be using LSI Logic:
Look for alias scsi_hostadapterx module entries, where x is replaced by a number and module is replaced by text. Change each module entry to mptscsih.
Additionally, look for an alias scsi_hostadapter module entry, where module is replaced by text and there is no number after hostadapter. If it exists, replace module with mptbase. If it does not exist, add alias scsi_hostadapter mptbase directly above the line that now reads alias scsi_hostadapter1 mptscsih.
10. Determine the full path to the ramdisk image to be rebuilt. The file will is located in /boot. List the contents of the directory by typing
ls /boot and pressing Enter. There will be a file with a name similar to initrd-2.6.9-42.EL.img. In this example, the full path to the ramdisk image is /boot/initrd-2.6.9-42.EL.img. Make a note of this.
Note: If there is more than one initrd- file in /boot, type cat /etc/grub.conf and press Enter to determine which file is being used.
11. Determine the kernel version to use for rebuilding the ramdisk image. Type ls /lib/modules and press Enter. In this example, you will see the directory 2.6.9-42.EL. Make a note of this.
Note: If there is more than one directory shown, type cat /etc/grub.conf and press Enter to determine which kernel version is being used.
12. Rebuild the ramdisk. Type the command mkinitrd -v -f /boot/initrd-2.6.9-42.EL.img 2.6.9-42.EL and press Enter, where /boot/initrd-2.6.9-42.EL.img is replaced with the information noted in
h. and 2.6.9-42.EL is replaced by the information noted in step i.
3. I f you are unable to use a supported version of Red Hat, or the procedure in 2. did not work:
0. M odify the physical machine to have support for either BusLogic or LSI Logic.
1. C onvert the physical machine again.
方法三:引用自/blog/cns!E99E74DBE0A928BC!595.entry Successful Physical to Virtual P2V conversion of Linux boxes with
VMware Converter
• For those you who are looking for the comprehensive details steps of how to P2V a linux box with VMware Converter.
Pre-requisites: Have the Linux installation Boot CD1 handy. You should purchase VMware Converter Enterprise license.
1. Download VMware Converter Enterprise latest version and burn it to the CD. I used version 3.0.2 update 1.
2. Boot up with the above VMware Converter CD on the physical Linux box.
3. Let the WinPE load up and watch for the Network adaptor settings screen. Make necessary changes such as IP addressing.
4. Finally you should see the VMware Converter screen where you can import the machine.
5. Click on Import machine button and follow the steps.
6. Important Make sure you select all disks and no resizing during the import process.
7. If all the information is entered correctly, it should start importing to ESX/VC.
8. It will create a VM on the selected ESX server.
9. In my case it failed at 97% where the error occurs at customization
steps (which I did not configure for) but after successful copy of the
local disks.
10. Go to the ESX server where the imported VM resides. Edit the settings.
11. In the VM’s settings, check any irregular settings which might
appears. In my case, I had to change the OS type of VM from other 32bit
to REHL 4.
12. When the VM is powered up for the first time as soon as P2V has
finished, kernel panic will occur and it is just as expected.
Steps to fix the kernel panic on the Linux VM
13. Boot up with the bootable Linux installation CD 1. If it doesn’t
boot from the CD, you may have to change the VM’s setting to go to the
BIOS setting on the next boot so that you can change the boot sequence.
14. At the boot: prompt type Linux rescue and hit enter.
15. It will search for the Linux partition. In my case, it could not
find the hard disks. So, I had to go back to VM’s setting to change the
BusLogic SCSI controller to LsiLogic.
16. After changing to LsiLogic controller, Linux installation image was able to find the Linux partitions on the VM.
17. The system will give you opportunity to mount the root file system.
At the linux prompt, type: chroot /mnt/sysimage and hit enter.
18. It will get you back to the prompt. Now at the prompt type: kudzu and hit enter.
19. It will ask you to remove old hardware and detect and install new hardware. Follow the instructions.
20. After exiting from Kudzu, at the prompt type: ls /lib/modules and
take note of the version/image. For instance, your active linux version
is 2.6.9-5.ELsmp. Take note of it.
21. After that you will need to make new RAM disk as follows.
22. Type /sbin/mkinitrd -v -f /boot/initrd-2.6.9-5.ELsmp.img 2.6.9-5.ELsmp
23. Reboot.
24. After the reboot, it should successfully boot up without any kernel panic.
25. If you still see the kernel panic, then go back to step 20 and find the correct module and repeat the steps 22 & 23.
26. After you have booted the system successfully, determine if it is working as expected.
27. Install VMware Tools.
The steps from 13 to 24 should take about 20-30 minutes. This procedure
should be the same for most Linux distributions. Hope it will help
on
your P2V of Linux boxes.
方法四:这是我迁移的一台机器,在这个环境下,我什么都没有做,自动就好了。
物理机的操作系统是 redhat 5.2,这个跟centos 5.2应该都是一样的先把物理机克隆出来,然后vmware中建立磁盘的时候,选择的是ide类型的,然后直接恢复到虚拟机中,恢复完了重启虚拟机,就可以了,没有报错。