2

Ever since I did yum update and tried to create a new (for example) 10GB Disk KVM VPS, the reported disk space inside VM is locked to the initial template size (usually 1GB for linux template).

Normally it should be 10GB (fdisk says so, but df command says otherwise).

[root@localhost ~]# resize2fs /dev/vda1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vda1 to 262160 (4k) blocks.
The filesystem on /dev/vda1 is now 262160 blocks long.

[root@localhost ~]# df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/vda1           1008   760       198  80% /
none                 246     0       246   0% /dev/shm

[root@localhost ~]# fdisk -l

Disk /dev/vda: 10.7 GB, 10737418240 bytes
4 heads, 32 sectors/track, 163840 cylinders
Units = cylinders of 128 * 512 = 65536 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b6106

Device Boot Start End Blocks Id System /dev/vda1 17 16401 1048640 83 Linux All above command is taken inside the VM.

Below is disk part of xml configuration on the host node:

disk type='file' device='disk'>
  <driver name='qemu' type='raw' cache='none' io='native'/>
  <source file='/kvm/v1046-2ogd-j1p2jraixpg1g03y.raw'/>
  <target dev='vda' bus='virtio' />
</disk>

Sparse RAW is used. Not a problem with older VM.

du -hs on host node:

650M    v1046-2ogd-j1p2jraixpg1g03y.raw

ls -lah on host node:

-rw-r--r--   1 qemu qemu  10G Dec 21 21:03 v1046-2ogd-j1p2jraixpg1g03y.raw

It looks like after template installing, the template partition does not resized succesfully. What's the correct command for resizing? Looks like resize2fs didn't extend it fully.

Any help is really appreciated. Thanks for reading.

2
  • You need to resize /dev/vda1 first. Then you can resize the filesystem it contains. Dec 22, 2015 at 4:40
  • Thanks for answer. Turns out resize2fs /dev/vda1 online inside a VM is not supported. Had to load gparted to extend the partition manually. It is solved now. Dec 22, 2015 at 9:12

1 Answer 1

4

What you need to do is to resize the disk using the virt-resize tool.

Install libguestfs-tools and perform the following steps:

1- Create a sparse disk

2- Inspect the template disk filesystem using "virt-filesystems" command in order to select which partition you want to resize

3- Perform the resizing process

Here is an example:

# qemu-img create -f raw /var/lib/libvirt/images/disk10g.img 10G
# virt-filesystems -a /var/lib/libvirt/images/disktemplate.img
# virt-resize --expand /dev/sda1 /var/lib/libvirt/images/disktemplate.img /var/lib/libvirt/images/disk10g.img
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .