码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-06-03 23:21:45      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

假设host上创建的vm的名字为vm1

1. 查看vm1domain information

[root@tanghuimin 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 KiB

Persistent: yes

Autostart: disable

Managed save: no

Security model: selinux

Security DOI: 0

Security label: system_u:system_r:svirt_t:s0:c790,c799 (enforcing)


2. 修改vm1vcpu, memory

1)实时修改vcpumemory

virsh setvcpus vm1 xxx #数值不能超过vm1.xml中配置的vcpu

virsh setmaxmem vm1 xxx #vm1处于shut off状态时才能设置成功

virsh setmem vm1 xxx #数值不能超过maxmem


2)配置文件修改vcpu, memory

修改vm1的配置文件

virsh edit vm1

<memory>对应dominfo中的Max memory

<currentMemory>对应dominfo中的Used memory

<vcpu>对应dominfo中的CPU(s)

<memory unit=‘KiB‘>1048576</memory>

<currentMemory unit=‘KiB‘>1048576</currentMemory>

<vcpu placement=‘static‘>1</vcpu>

vm1先关机再启动即可生效

virsh destroy vm1

virsh start vm1


3. vm1扩展一个10Gdisk

生成一个大小为10G的磁盘文件/vm/vm1-add

dd if=/dev/zero of=/vm/vm1-add bs=1M count=10240

修改vm1的配置文件

virsh edit vm1

vm1现有的磁盘文件为/vm/vm1

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

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

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

<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=‘raw‘ cache=‘none‘/>

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

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

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

</disk>

vm1先关机再启动即可生效

virsh destroy vm1

virsh start vm1

查看vm1的磁盘信息

root@localhost ~]# fdisk -l| grep Disk

Disk /dev/sda: 2147 MB, 2147483648 bytes

Disk identifier: 0x000e3e47

Disk /dev/sdb: 10.7 GB, 10737418240 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_root: 1405 MB, 1405091840 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_swap: 213 MB, 213909504 bytes

Disk identifier: 0x00000000


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

标签:

原文地址:http://www.cnblogs.com/tanghuimin0713/p/4550407.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!