º»¹®¿¡¼´Â 25G ±âº»À̹ÌÁö¸¦ 20G·Î ÁÙÀÌ´Â ÀÛ¾÷
ÀÛ¾÷½Ã¿¡´Â VMÀ» ²ô°í ÀÛ¾÷
:: ÇöÀç µð½ºÅ© Å©±â È®ÀÎ
# qemu-img info disk
image: disk
file format: qcow2
virtual size: 25G (26843545600 bytes)
disk size: 394M
cluster_size: 65536
backing file: /var/lib/nova/instances/_base/9e2657ababfb190119ce1132e48f4e4ba17db05d
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
:: ÆÐÅ°Áö ¼³Ä¡
# apt install libguestfs-tools
¡Ø If you're running this on a dedicated Glance server without libvirt, change the setting to bypass libvirt back-end:
$ export LIBGUESTFS_BACKEND=direct
:: À̹ÌÁö³» ÆÄƼ¼Ç »çÀÌÁî È®ÀÎ
# virt-filesystems --long --parts --blkdevs -h -a disk
Name Type MBR Size Parent
/dev/sda1 partition 83 25G /dev/sda
/dev/sda device - 25G -
¿©±â¼´Â ÁÖÆÄƼ¼Ç(/dev/sda1)ÀÌ 1.2G »ç¿ëÁß
# virt-df disk
Filesystem 1K-blocks Used Available Use%
disk:/dev/sda1 19248060 1245636 17986040 7%
:: gueshfish¸¦ ÀÌ¿ëÇؼ ¸ÞŸµ¥ÀÌŸ °ª º¯°æ
# guestfish -a disk.img
><fs> run
><fs> list-filesystems
...
><fs> e2fsck-f /dev/sda1
><fs> resize2fs-size /dev/sda1 19G
><fs> exit
¡Ø ½ÇÁ¦·Î ÁÙÀÌ·Á´Â µð½ºÅ© Å©±âº¸´Ù´Â Àû°ÔÇؼ üũ
:: ÁÙÀÌ·Á´Â µð½ºÅ© À̹ÌÁö »ý¼º
# qemu-img create -f qcow2 -o preallocation=metadata newdisk.qcow2 20G
:: ÆÄƼ¼Ç Á¤º¸(µ¥ÀÌŸ) º¹»ç
# virt-resize --shrink / dev / sda1 ./disk ./newdisk.qcow2
:: È®ÀÎ
# qemu-img info newdisk.qcow2
image: disk
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 1.5G
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
# virt-filesystems --long --parts --blkdevs -h -a disk
Name Type MBR Size Parent
/dev/sda1 partition 83 20G /dev/sda
/dev/sda device - 20G -
# virt-df disk
Filesystem 1K-blocks Used Available Use%
disk:/dev/sda1 20263528 1245896 19001248 7%
Âü°í URL