KVM虚拟机磁盘空间扩容

版权声明: https://blog.csdn.net/zhuangzi123456/article/details/81453620

一,环境说明:

add_disk.img磁盘映像文件原本是2G大小。

二,在宿主机上操作对虚拟机磁盘空间扩容

# virsh blockresize --domain template --path /iptv/src/add_disk.img --size 4G

Block device '/iptv/src/add_disk.img' is resized

# qemu-img info ./add_disk.img

image: ./add_disk.img

file format: qcow2

virtual size: 4.0G (4294967296 bytes)-----------注意,已经增大了,原来是2G的;

disk size: 200K

扫描二维码关注公众号,回复: 3986048 查看本文章

cluster_size: 65536

Format specific information:

compat: 1.1

lazy refcounts: false

参数说明:

--path:必须跟的是img文件的绝对路径。

在虚拟机中查看,确实已经增大了:

# fdisk -l

磁盘 /dev/vdb:4294 MB, 4294967296 字节,8388608 个扇区

Units = 扇区 of 1 * 512 = 512 bytes

扇区大小(逻辑/物理):512 字节 / 512 字节

I/O 大小(最小/最佳):512 字节 / 512 字节

附录:virsh blockresize子命令使用方法介绍

# virsh help blockresize

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)

# man virsh

blockresize domain path size

Resize a block device of domain while the domain is running.

path specifies the absolute path of the block device;(path指定虚拟机的块设备文件的绝对路径,也就是说,比如你的虚拟机的磁盘映像文件为/tm/test.img,则这里path的值就是/tmp/test.img) it corresponds to a unique target name (<target dev='name'/>) or source file (<source file='name'/>) for one of the disk devices attached to domain (see also domblklist for listing these names).(这个path指定的块设备对要与附属于域的所有磁盘设备中的一个独一无二的target名称(在xml文件中,由<target dev='name'/>)或源文件(在xml文件中,由<source file='name'/>指定的)指定的块设备一致);

size is a scaled integer (see NOTES above) which defaults to KiB (blocks of 1024 bytes) if there is no suffix.(默认是KB,如果不指定size的单位,则使用KB,但也可以使用M,G,T等单位) You must use a suffix of "B" to get bytes (note that for historical reasons, this differs from vol-resize which defaults to bytes without a suffix).

猜你喜欢

转载自blog.csdn.net/zhuangzi123456/article/details/81453620