我已经安装了 kvm,为虚拟主机创建了一个新的映像:
sudo qemu-img create -f qcow2 /var/lib/libvirt/images/lubuntu.img 30G
为其创建了一个.xml配置文件:
<domain type='kvm'>
<name>lubuntu</name>
<uuid>f5b8c05b-9c7a-3211-49b9-2bd635f7e2aa</uuid>
<memory>10485760</memory>
<currentMemory>10485760</currentMemory>
<vcpu>1</vcpu>
<os>
<type>hvm</type>
<boot dev='cdrom'/>
</os>
<features>
<acpi/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="raw"/>
<source file="/var/lib/libvirt/images/lubuntu.img"/>
<target dev="vda" bus="virtio"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"/>
</disk>
<disk type="file" device="cdrom">
<driver name="qemu" type="raw"/>
<source file="/var/lib/libvirt/images/lubuntu-17.04-desktop-i386.iso"/>
<target dev="hdc" bus="ide"/>
<readonly/>
<address type="drive" controller="0" bus="1" target="0" unit="0"/>
</disk>
<interface type='bridge'>
<source bridge='virbr0'/>
<mac address="00:00:A3:B0:56:10"/>
</interface>
<controller type="ide" index="0">
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
</controller>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport="yes" listen='0.0.0.0'/>
<console type='pty'>
<target port='0'/>
</console>
</devices>
</domain>
开始于:
virsh create lubuntu.xml
我使用 vnc 查看器连接到它并看到安装窗口后,但当我单击“安装”时,我看到警告,说我没有足够的磁盘空间
This pc has only 262.7 kB free.
我的 lubuntu.img 文件正好是这个大小,我无法修复。当我这样做时:
valera@ubuntu-server:/var/lib/libvirt/images$ sudo qemu-img resize lubuntu.img +5G
Image resized.
它仍然有 200+ kB 大小...
答案1
您type="raw"
在 qcow2 图像 lubuntu.img 的 xml 中使用了它。将其更改为type="qcow2"
可解决问题。