标签:des style io os 使用 ar for 文件 div
Ubuntu14.04上的 qemu比RHEL6.4上的版本要新,导致在Ubuntu14.04创建的Guest(RHEL6.4)虚拟机复制到RHEL6.4HOST主机上不能运行。为解决这个问题,可以按下面的步骤:
1)在Ubuntu14.04上把qcow2格式的vm转成raw格式的。
2)在RHEL6.4上define raw格式的vm。
既然RHEL6.4支持raw格式的vm,那么可以在Ubuntu上直接创建 raw格式的虚拟机,然后复制到RHEL6.4。但是raw格式的vm占有空间太多,复制起来颇费时间。
查看虚拟机镜像格式命令:
$ qume-img info vm.img
file format: raw
virtual size: 80G
disk size: 80G # 这个在开始创建的时候非常小。稀疏文件。
因此可以采用下面的办法:
1)在Ubuntu14.04上用virt-manager安装kvm类型的虚拟机vm.img。默认就是raw格式。可以用80G。
2)拷贝这个vm.img和vm.xml到RHEL6.4上。注意目录位置一定是(可以用链接):
/etc/libvirt/qemu/vm.xml
/var/lib/libvirt/images/vm.img
3)修改vm.xml。此处需要注意,RHEL6.4使用的vm.xml和Ubuntu14.04上的略有不同。下面列出RHEL6.4上个的vm.xml(不同之处):
<domain type=‘kvm‘>
<name>vm</name>
<uuid>...</uuid>
<memory unit=‘KiB‘>4194304</memory>
<currentMemory unit=‘KiB‘>4194304</currentMemory>
<vcpu placement=‘static‘>4</vcpu>
<os>
<type arch=‘x86_64‘ machine=‘rhel6.4.0‘>hvm</type>
<boot dev=‘hd‘/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset=‘utc‘/>
<!--
<clock offset=‘localtime‘/>
-->
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<!-- diff below -->
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type=‘file‘ device=‘disk‘>
<driver name=‘qemu‘ type=‘raw‘/>
<source file=‘/var/lib/libvirt/images/vm.img‘/>
<target dev=‘vda‘ bus=‘virtio‘/>
</disk>
<disk type=‘block‘ device=‘cdrom‘>
<driver name=‘qemu‘ type=‘raw‘/>
<target dev=‘hdc‘ bus=‘ide‘/>
<readonly/>
<address .../>
</disk>
...
<serial type=‘pty‘>
<target port=‘0‘/>
</serial>
<console type=‘pty‘>
<target type=‘serial‘ port=‘0‘/>
</console>
...
</devices>
</domain><emulator>/usr/libexec/qemu-kvm</emulator>
$ virsh define vm.xml
5)启动和关闭:
$ virsh start vm
$ virsh shutdown vm
下面说明如何virsh console登录虚拟机。首先需要在vm的/etc/init/下创建ttyS0.conf文件,内容如下:
# /etc/init/ttyS0.conf: # ttyS0 - agetty stop on runlevel [016] start on runlevel [345] instance ttyS0 respawn pre-start exec /sbin/securetty ttyS0 exec /sbin/agetty /dev/ttyS0 115200 vt100-nav
$ yum install libguestfs-tools
$ virsh shutdown vm # 必须首先关闭虚拟机 $ virt-copy-in -d vm ttyS0.conf /etc/init $ virt-ls -d vm /etc/init $ virt-cat -d vm /etc/init/ttyS0.conf
$ virsh start vm $ virsh console vm
菜鸟玩云计算之十六:Ubuntu14.04上创建的虚拟机迁移到RHEL6.4
标签:des style io os 使用 ar for 文件 div
原文地址:http://blog.csdn.net/ubuntu64fan/article/details/39397525