kvm初体验之九:vm创建快照

1. 准备一个磁盘格式为qcow2vmraw格式的磁盘无法创建快照)

方法一:从头安装一个磁盘格式为qcow2的vm


[[email protected] vm]# qemu-img create -f qcow2 -o preallocation=metadata /vm/vm2.qcow2 2G

Formatting ‘/vm/vm2.qcow2‘, fmt=qcow2 size=2147483648 encryption=off cluster_size=65536 preallocation=‘metadata‘

[[email protected] vm]# qemu-img info vm2.qcow2

image: vm2.qcow2

file format: qcow2

virtual size: 2.0G (2147483648 bytes)

disk size: 464K

cluster_size: 65536


virt-install --name vm2 --vcpus=1 --ram=1024 --disk
path=/vm/vm2.qcow2,format=qcow2
--cdrom /root/iso/CentOS-6.6-x86_64-minimal.iso --network
bridge:br0

方法二:将现存的磁盘格式为raw的vm转换成qcow2的磁盘格式


[[email protected] vm]# qemu-img info vm1-clone

image: vm1-clone

file format: raw

virtual size: 2.0G (2147483648 bytes)

disk size: 2.0G


[[email protected] vm]# qemu-img convert -f
raw vm1-clone -O qcow2 vm1-clone.qcow2

[[email protected] vm]# qemu-img info vm1-clone.qcow2

image: vm1-clone.qcow2

file format: qcow2

virtual size: 2.0G (2147483648 bytes)

disk size: 813M

cluster_size: 65536

virsh edit vm1-clone


<disk type=‘file‘ device=‘disk‘>

<driver name=‘qemu‘ type=‘raw‘
cache=‘none‘/>

<source file=‘/vm/vm1-clone‘/>

<target dev=‘hda‘ bus=‘ide‘/>

<address type=‘drive‘ controller=‘0‘ bus=‘0‘
target=‘0‘ unit=‘0‘/>

</disk>

修改为


<disk type=‘file‘ device=‘disk‘>

<driver name=‘qemu‘ type=‘qcow2‘
cache=‘none‘/>

<source file=‘/vm/vm1-clone.qcow2‘/>

<target dev=‘hda‘ bus=‘ide‘/>

<address type=‘drive‘ controller=‘0‘ bus=‘0‘
target=‘0‘ unit=‘0‘/>

</disk>

2. 创建快照(virsh
snapshot-create


virsh # snapshot-list vm2

Name Creation Time State

------------------------------------------------------------

virsh # snapshot-create vm2

Domain snapshot 1433458417 created

virsh #

virsh # snapshot-list vm2

Name Creation Time State

------------------------------------------------------------

1433458417 2015-06-05 06:53:37 +0800 shutoff

3. 从快照恢复(virsh
snapshot-revert


virsh # snapshot-list vm2

Name Creation Time State

------------------------------------------------------------

1433458417 2015-06-05 06:53:37 +0800 shutoff

virsh # snapshot-revert vm2 1433458417

4. 删除快照(virsh
snapshot-delete


virsh # snapshot-list vm2

Name Creation Time State

------------------------------------------------------------

1433458417 2015-06-05 06:53:37 +0800 shutoff

virsh #

virsh # snapshot-delete vm2 1433458417

Domain snapshot 1433458417 deleted

virsh # snapshot-list vm2

Name Creation Time State

------------------------------------------------------------

时间: 2024-10-13 21:26:30

kvm初体验之九:vm创建快照的相关文章

kvm初体验之三:vm的安装及管理

Host: CentOS release 6.4 (Final) Guest: CentOS release 6.6 (Final) 全程以root身份操作 1. host上创建桥br0 参考<KVM Virtualization in RHEL 6 Made Easy>2.6 Networking 我的/etc/sysconfig/network-scripts/ifcfg-br0文件内容为: DEVICE=br0 BOOTPROTO=dhcp IPV6INIT=yes IPV6_AUTOC

kvm初体验之五:vm连接网络的两种方式:bridge和nat

1. 在安装vm时指定网络连接方式 1)bridge virt-install --name vm1 --ram=1024 --vcpus=1 --disk path=/vm-images/vm1,size=2 --cdrom /root/iso/CentOS-6.6-x86_64-minimal.iso --network bridge:br0 2)nat virt-install --name vm1 --ram=1024 --vcpus=1 --disk path=/vm-images/v

kvm初体验之八:调整vm的vcpu, memory, disk大小

假设host上创建的vm的名字为vm1. 1. 查看vm1的domain information [[email protected] thm]# virsh dominfo vm1 Id: 10 Name: vm1 UUID: e2597379-5cc5-4ffa-0531-a073a81c5811 OS Type: hvm State: running CPU(s): 1 CPU time: 52.6s Max memory: 1048576 KiB Used memory: 1048576

kvm初体验之七:attach usb storage device to a VM

1. virsh attach-disk vm1 /dev/sdb sdc 将host上的/dev/sdb挂载到vm1的/dev/sdc上 2. virsh detach-disk vm1 sdc 将vm1上的/dev/sdc卸载

二、React初体验之React组件创建

(中间因为应付各种考试,处理其他事情,隔了好时间没更新,现在终于有时间了,续上!) 本文为React初始体验,因此先不考虑文件如何组织,尽量以最简单的方式让大家了解React其中的原理. 在创建组件(component)之前,大家首先需要了解一些基础知识.有ES6.JSX语法等基础知识的同学请跳过下面一段. ES6是JavaScript的最新标准,里面新增了许多语法方式,甚至出现了“类”的继承方式,我个人暂且把他们理解为新增了许多“语法糖”,这些“语法糖”可能带给老手的是方便,而对于我们这些菜鸟

kvm初体验之四:从Host登录Guest的五种方式

1. virt-viewer virt-viewer -c qemu:///system vm1 2. virt-manager (以非root身份运行) virt-manager -c qemu:///system 注: 若以root身份运行virt-manager会出现“Error starting Virtual Machine Manager: Failed to contact configuration server”的错误: 解决方法:以非root身份运行,会有窗口提示你输入roo

Ubuntu下Django初体验(二)——创建工程及应用

一.工程目录详解 创建工程后得到如下目录: 1. manage.py 管理项目.创建数据库.启动服务器等.测试等. 查看子命令: python manage.py 启动服务器: python manage.py runserver 指定启动服务器的地址和端口: python manage.py runserver 0.0.0.0 8080 2. mysite 目录 2.1 settings.py  对于整个网站的配置.配置文件:应用.中间件.数据库.静态目录各类配置... 2.2 urls.py

kvm初体验之六:克隆

目标:克隆vm1到vm1-clone 1. virsh suspend vm1 2. virt-clone --connect qemu:///system --original vm1 --name vm1-clone --file /vm/vm1-clone 或 virt-clone --connect qemu:///system -o vm1 -n vm1-clone -f /vm/vm1-clone 3. virsh start vm1-clone 登录vm1-clone, ifcon

kvm初体验之一:参考文档

KVM Virtualization in RHEL 6 Made Easy KVM Virtualization in RHEL 6 Made Easy – Part 2 RHEL 6 Virtualization Getting Started GuideRHEL 6 Virtualization Host configuration and Guest Installation GuideRHEL 6 Virtualization Administration GuideRHEL 5 Vi