kvm 下运行的 WINWS7磁盘空间不足 增加磁盘 实战(这个有问题,还未解决)

 

创建一个新硬盘:

[root@NB vhost]# qemu-img create -f qcow2 add_win_desk.img 5G
Formatting 'add_win_desk.img', fmt=qcow2 size=5368709120 encryption=off cluster_size=65536
[root@NB vhost]# ll -h add_win_desk.img 
-rw-r--r-- 1 root root 193K Dec 12 10:59 add_win_desk.img
[root@NB vhost]# qemu-img info add_win_desk.img 
image: add_win_desk.img
file format: qcow2
virtual size: 5.0G (5368709120 bytes)
disk size: 196K
cluster_size: 65536

查看现在正在运行的虚机:

[root@NB vhost]# virsh list
 Id    Name                           State
----------------------------------------------------
 1     win64                          running
 2     c01                            running

先关掉要加硬盘的虚机win64,然后编辑该虚机的配置文件:

[root@NB vhost]# virsh destroy win64
Domain win64 destroyed

[root@NB vhost]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 2     c01                            running
 -     1xp                            shut off
 -     app01                          shut off
 -     app02                          shut off
 -     ha01                           shut off
 -     ha02                           shut off
 -     win64                          shut off
[root@NB vhost]# virsh edit win64
..
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/data/vhost/add_win_desk.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

...下面的报错是因为<address type='drive' controller='0' bus='0' target='0' unit='0'/>
应该是:<address type='drive' controller='0' bus='0' target='0' unit='1'/>

注意,我们在些使用的硬盘接口为ide接口,硬盘名称为hdb,所以添加完毕后系统是可以直接识别的。

[root@NB vhost]# virsh start win64
error: Failed to start domain win64
error: internal error Process exited while reading console log output: qemu-kvm: -drive file=/data/vhost/add_win_desk.img,if=none,id=drive-ide0-0-0,format=qcow2,cache=none: Duplicate ID 'drive-ide0-0-0' for drive
启动失败!!!!

重新加载配置文件:

[root@NB qemu]# cd /etc/libvirt/qemu/
[root@NB qemu]# ls
1xp.xml    app02.xml  ha01.xml  networks
app01.xml  c01.xml    ha02.xml  win64.xml
[root@NB qemu]# virsh define win64.xml
Domain win64 defined from win64.xml

看计算机管理:

可见磁盘未分配,右击分配磁盘定义盘符:

成功!!!!

posted @ 2016-12-12 13:50  bass  阅读(547)  评论(0编辑  收藏  举报