[virt-tools-list] How to resize a partition in a KVM image? (after the image is resized by "qemu-img resize")

Peng Yu pengyu.ut at gmail.com
Sat May 3 05:10:15 UTC 2014


Hi,

A KVM guest had the following root partition.

Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/mintaka--vg-root  3.7G  3.3G  134M  97% /

After the guest was shutdown, I run "qemu-img resize" to resize the
image. And I got the following.

$ qemu-img info saiph.qcow2
image: saiph.qcow2
file format: qcow2
virtual size: 50G (53687091200 bytes)
disk size: 3.8G
cluster_size: 65536


Then I restarted the vm. When I tried fdisk, I got the following,
which is different from https://gist.github.com/larsks/3933980 (as I
don't see the three partitions vda[1-3]).

~$ sudo fdisk  /dev/mapper/mintaka--vg-root
[sudo] password for pengy:
Device contains neither a valid DOS partition table, nor Sun, SGI or
OSF disklabel
Building a new DOS disklabel with disk identifier 0x158bca61.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/mapper/mintaka--vg-root: 4005 MB, 4005560320 bytes
255 heads, 63 sectors/track, 486 cylinders, total 7823360 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x158bca61

                       Device Boot      Start         End      Blocks
 Id  System

When I try resize2fs, it does not increase the root size.

:~$ sudo resize2fs /dev/mapper/mintaka--vg-root
resize2fs 1.42.8 (20-Jun-2013)
The filesystem is already 977920 blocks long.  Nothing to do!

Does anybody know how can I increase the root partition size so that
it uses the whole qcow2 image? Thanks.


-- 
Regards,
Peng




More information about the virt-tools-list mailing list