虚拟机镜像文件格式-raw
来源:互联网 发布:centos界面美化 编辑:程序博客网 时间:2024/05/19 11:37
目前公司以raw作为虚拟机模板的储存方式,在部署虚拟机的时候,采用的是LV作为储存设备。这样的好处是可以用于局域网内的服务器共享,也方便在不同服务器上进行传输,单个服务器可以利用lv的快照特性来备份。
关于LVM的介绍,可以参考鸟哥的书关于逻辑卷管理的章节,非常的详细,讲的很清楚 http://vbird.dic.ksu.edu.tw/linux_basic/0420quota_3.php
创建及扩展raw文件
创建4G空的文件
dd if=/dev/zero of=4G.img bs=1024k count=4096
追加到原有的镜像之后
cat vm1.img 4G.img > vm1_new.img
[root@localhost ~]# fdisk -lu conpaas.img
last_lba(): I don't know how to handle files with mode 81a4
You must set cylinders.
You can do this from the extra functions menu.
Disk conpaas.img: 0 MB, 0 bytes
4 heads, 32 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
conpaas.img1 * 2048 4192256 2095104+ 83 Linux
Partition 1 has different physical/logical endings:
phys=(1023, 3, 32) logical=(32752, 0, 1)
查看到sectors单位和分区Start的位置,得到偏移量进行挂载
[root@localhost ~]# mount -o loop,offset=$[2048*512] conpaas.img /mnt
raw文件与lv转换
方式比较简单,直接dd就行了
dd if=/dev/vg/vm1 of=vm1.img bs=10m
dd if=vm1.img of=/dev/vg/vm1 bs=10m(必须先创建vm1逻辑卷,并且要比vm1.img文件大)
下面是virsh命令创建虚拟机用到的配置文件,‘disk’平常用的多的几种方式,以iso文件作为cdrom,raw和lv作为磁盘.
<domain type='xen'>
<name>conpaasimg2g</name>
<uuid>cab3ba1a-f7e9-4c02-8ba3-ca82abaa6312</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<vcpu>1</vcpu>
<os>
<type>hvm</type>
<loader>/usr/lib/xen/boot/hvmloader</loader>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/debian.iso'/>
<target dev='hdc' bus='ide'/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/debian.img'/>
<target dev='hda' bus='ide'/>
</disk>
<!--disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/vg/lvol30'/>
<target dev='hdb' bus='ide'/>
</disk-->
<interface type='bridge'>
<mac address='0e:27:1e:50:e4:ea'/>
<source bridge='brvlan121'/>
<script path='vif-bridge'/>
<target dev='vif-1.0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='6009' passwd='123456'/>
</devices>
</domain>
qcow2
下面有一篇关于qcow2简介的文章,收藏一下,先感谢这位作者
Qcow2文件格式简述
http://bbs.linuxtone.org/forum.php?mod=viewthread&tid=24268&fromuid=41256
另外最近研究的xtreemfs中有一个场景,
利用qcow2的快照特性以及xtreemfs的replication来快速部署大量虚拟机,再对xtreemfs熟悉一段时间后再总结。
关于LVM的介绍,可以参考鸟哥的书关于逻辑卷管理的章节,非常的详细,讲的很清楚 http://vbird.dic.ksu.edu.tw/linux_basic/0420quota_3.php
创建及扩展raw文件
创建4G空的文件
dd if=/dev/zero of=4G.img bs=1024k count=4096
追加到原有的镜像之后
cat vm1.img 4G.img > vm1_new.img
挂在raw文件
在进行虚拟机故障排除的时候非常有用,下面是挂在方法:
[root@localhost ~]# fdisk -lu conpaas.img
last_lba(): I don't know how to handle files with mode 81a4
You must set cylinders.
You can do this from the extra functions menu.
Disk conpaas.img: 0 MB, 0 bytes
4 heads, 32 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
conpaas.img1 * 2048 4192256 2095104+ 83 Linux
Partition 1 has different physical/logical endings:
phys=(1023, 3, 32) logical=(32752, 0, 1)
查看到sectors单位和分区Start的位置,得到偏移量进行挂载
[root@localhost ~]# mount -o loop,offset=$[2048*512] conpaas.img /mnt
raw文件与lv转换
方式比较简单,直接dd就行了
dd if=/dev/vg/vm1 of=vm1.img bs=10m
dd if=vm1.img of=/dev/vg/vm1 bs=10m(必须先创建vm1逻辑卷,并且要比vm1.img文件大)
下面是virsh命令创建虚拟机用到的配置文件,‘disk’平常用的多的几种方式,以iso文件作为cdrom,raw和lv作为磁盘.
<domain type='xen'>
<name>conpaasimg2g</name>
<uuid>cab3ba1a-f7e9-4c02-8ba3-ca82abaa6312</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<vcpu>1</vcpu>
<os>
<type>hvm</type>
<loader>/usr/lib/xen/boot/hvmloader</loader>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/debian.iso'/>
<target dev='hdc' bus='ide'/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/debian.img'/>
<target dev='hda' bus='ide'/>
</disk>
<!--disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/vg/lvol30'/>
<target dev='hdb' bus='ide'/>
</disk-->
<interface type='bridge'>
<mac address='0e:27:1e:50:e4:ea'/>
<source bridge='brvlan121'/>
<script path='vif-bridge'/>
<target dev='vif-1.0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='6009' passwd='123456'/>
</devices>
</domain>
qcow2
下面有一篇关于qcow2简介的文章,收藏一下,先感谢这位作者
Qcow2文件格式简述
http://bbs.linuxtone.org/forum.php?mod=viewthread&tid=24268&fromuid=41256
另外最近研究的xtreemfs中有一个场景,
利用qcow2的快照特性以及xtreemfs的replication来快速部署大量虚拟机,再对xtreemfs熟悉一段时间后再总结。
0 0
- 虚拟机镜像文件格式-raw
- 修改虚拟机镜像大小(qcow2/raw resize)
- 虚拟机镜像文件格式转换:VirtualBox to VMWare
- qcow2、raw、vmdk等镜像格式
- qcow2、raw、vmdk等镜像格式
- qcow2、raw、vmdk等镜像格式
- qcow2、raw、vmdk等镜像格式
- qcow2、raw、vmdk等镜像格式
- qcow2、raw、vmdk等镜像格式
- 虚拟机镜像格式
- 虚拟机镜像文件
- ubuntu虚拟机镜像
- Hadoop虚拟机镜像
- BIN与NB0镜像文件格式
- android userimage镜像文件格式定义分析
- 上传虚拟机镜像-运行虚拟机实例
- 转:qcow2、raw、vmdk等镜像格式
- 转:qcow2、raw、vmdk等镜像格式
- OLTP和OLAP
- MMSeg中文分词算法
- 我喜欢四十五度地靠着你
- iOS 109个Demo范例
- 韩媒传朝鲜二号人物崔龙海被捕 韩官方称未证实
- 虚拟机镜像文件格式-raw
- 微信公众平台开发调试
- SHXMLParser的使用报错-解析
- 感悟
- 二级
- Android系统亮屏、锁屏、屏幕解锁事件(解决部分手机亮屏后未解锁即进入resume状态)
- 单片机编程语言与开发环境
- html与xml解析库htmlcxx使用过程中的若干问题及解决方案
- 笔记本硬盘坏了怎么办?笔记本硬盘修复方法