查看客户机列表 [ops@localhost ~]$ sudo virsh list --all Id Name State ---------------------------------- 39 windows04 running 52 windows05 running 53 fileserver01 running 65 windows03 running 79 windows-desktop running 80 windows02 running - ubuntu shut off - windows01 shut off - windows06 shut off [ops@localhost ~]$ 查看指定vm的块设备列表 [ops@localhost ~]$ sudo virsh domblklist ubuntu Target Source ------------------------------------------------- vda /var/lib/libvirt/images/ubuntu.qcow2 sda - [ops@localhost ~]$ 查看磁盘信息 [ops@localhost ~]$ sudo qemu-img info /var/lib/libvirt/images/ubuntu.qcow2 image: /var/lib/libvirt/images/ubuntu.qcow2 file format: qcow2 virtual size: 100 GiB (107374182400 bytes) disk size: 68.5 GiB cluster_size: 65536 Format specific information: compat: 1.1 compression type: zlib lazy refcounts: true refcount bits: 16 corrupt: false extended l2: false Child node '/file': filename: /var/lib/libvirt/images/ubuntu.qcow2 protocol type: file file length: 100 GiB (107390828544 bytes) disk size: 68.5 GiB Format specific information: extent size hint: 1048576 [ops@localhost ~]$ 块设备容量调整命令参数 [ops@localhost ~]$ sudo virsh blockresize --help NAME blockresize - Resize block device of domain. SYNOPSIS blockresize <domain> <path> <size> DESCRIPTION Resize block device of domain. OPTIONS [--domain] <string> domain name, id or uuid [--path] <string> Fully-qualified path of block device [--size] <number> New size of the block device, as scaled integer (default KiB) [ops@localhost ~]$ 必须在启动状态下执行命令 [ops@localhost ~]$ sudo virsh blockresize ubuntu /var/lib/libvirt/images/ubuntu.qcow2 200G error: Failed to resize block device '/var/lib/libvirt/images/ubuntu.qcow2' error: Requested operation is not valid: domain is not running [ops@localhost ~]$ 启动服务并执行命令 [ops@localhost ~]$ sudo virsh start ubuntu Domain 'ubuntu' started [ops@localhost ~]$ sudo virsh blockresize ubuntu /var/lib/libvirt/images/ubuntu.qcow2 200G Block device '/var/lib/libvirt/images/ubuntu.qcow2' is resized [ops@localhost ~]$ 重新查看磁盘信息 [ops@localhost ~]$ sudo qemu-img info /var/lib/libvirt/images/ubuntu.qcow2 image: /var/lib/libvirt/images/ubuntu.qcow2 file format: qcow2 virtual size: 200 GiB (214748364800 bytes) disk size: 68.5 GiB cluster_size: 65536 cleanly shut down: no Format specific information: compat: 1.1 compression type: zlib lazy refcounts: true refcount bits: 16 corrupt: false extended l2: false Child node '/file': filename: /var/lib/libvirt/images/ubuntu.qcow2 protocol type: file file length: 100 GiB (107390828544 bytes) disk size: 68.5 GiB Format specific information: extent size hint: 1048576 [ops@localhost ~]$
2 月 282023