# qemu-img info vm5.qcow2
image: vm5.qcow2
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 1.6G
cluster_size: 65536
Format specific information:compat: 1.1lazy refcounts: true# qemu-img resize /data/kvm/vm5.qcow2 +10G //鏡像空間加10G
Image resized.# qemu-img info vm5.qcow2
image: vm5.qcow2
file format: qcow2
virtual size: 30G (32212254720 bytes)
disk size: 1.6G
cluster_size: 65536
Format specific information:compat: 1.1lazy refcounts: true
重啟虛擬機,查看磁盤空間已經調整,掛載空間還需要調整
# virsh shutdown vm5# virsh start vm5# virsh console vm5# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root19G 697M 17G 4% /
tmpfs 246M 0 246M 0% /dev/shm
/dev/vda1 477M 34M 418M 8% /boot# fdisk -l
Disk /dev/vda: 32.2 GB, 32212254720 bytes
16 heads, 63 sectors/track, 62415 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00070304Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
/dev/vda2 1018 41611 20458496 8e Linux LVMDisk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18798870528 bytes
255 heads, 63 sectors/track, 2285 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000Disk /dev/mapper/VolGroup-lv_swap: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
新增的空間進行分區
# fdisk /dev/vda WARNING: DOS-compatible mode is deprecated. It's strongly recommended toswitch off the mode (command 'c') and change display units tosectors (command 'u').Command (m for help): pDisk /dev/vda: 32.2 GB, 32212254720 bytes
16 heads, 63 sectors/track, 62415 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00070304Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 41611 20458496 8e Linux LVM
Partition 2 does not end on cylinder boundary.Command (m for help): n //新增分區
Command actione extendedp primary partition (1-4)
p //主分區
Partition number (1-4): 3
First cylinder (1-62415, default 1): 41611
Last cylinder, +cylinders or +size{K,M,G}(41611-62415, default 62415):
Using default value 62415Command (m for help): pDisk /dev/vda: 32.2 GB, 32212254720 bytes
16 heads, 63 sectors/track, 62415 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00070304Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 41611 20458496 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 41611 62415 10485640 83 LinuxCommand (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.