On Fri, 2012-02-24 at 12:05 -0800, Jeff Boyce wrote:
Greetings -
I am going through some testing steps to expand a logical volume and the corresponding filesystem on a KVM guest and have run across a deficiency in my knowledge. I spent the afternoon yesterday googling for answers, but had have come up blank still. What I am trying to do is resize the file system to use the additional disk space that I added to the logical volume that the guest uses. Here is what I have done and the details of my system.
Both my host and guest are running Centos 6.2.
My KVM host system has the LVM volume group that is divided into logical
volumes which are then presented to the KVM guests as raw space.
- A guest may use 2 or 3 logical volumes from the host system for its
filesystem (/, /var, /data) and I have logical volumes named within the host system by guest and mount point so that I know what each logical volume is assigned to by it's name.
- I expanded a specific logical volume on the host (/dev/vg/lv_guest1root)
that is used by Guest1, and I can see in vgdisplay and lvdisplay that the logical volume was properly expanded.
- I then issued a resize2fs /dev/vg/lv_guest1root command (on the host)
to resize the filesystem to the expanded logical volume. This resulted in a message that it essentially couldn't find a valid filesystem superblock. Well of course then I realized that there is no filesystem on the logical volume from the perspective of the host. The filesystem wasn't set on the logical volume until the guest installation occurred.
- So then I switched over to the guest system and ran df -h to see the
existing filesystem
[root@guest1 jeffb]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda2 4.5G 2.3G 2.0G 53% / tmpfs 1004M 88K 1004M 1% /dev/shm /dev/vda1 485M 30M 430M 7% /boot /dev/vdb1 2.0G 219M 1.7G 12% /var
- Then I ran resize2fs /dev/vda2 and got the result that the filesystem
is already xx blocks long. Nothing to do!
So here is where I am stuck. Guest1 is my test system so it only has the / and /var logical volumes, whereas the production guest (guest2) that I will be expanding also has /data, which will be the logical volume that I will expand. So two things I did not do where, I did not shut down the guest VM, and I did not unmount the filesystem before asking it to resize. However my research before doing this did not seem to indicate that I had to do either, and the message about nothing to do also seems to indicate that they were not necessary.
So I am missing a hole in my knowledge and additional googling has not helped to fill it. I must be missing something simple. Is this result due to the fact that I am testing on expanding the / filesystem, and it would work properly on a guest system that had /data? Do I need to unmount the filesystem, or shut down the guest VM, or mount the guest from a LiveCD? Or do I need to give it resize2fs /dev/vda rather than specifically /dev/vda2 ? Any clues, or pointers to good documentation is greatly appreciated. Thanks.
The guest put a partition table on the LV. To resize the filesystem, the partition must be resized, as well. There are several ways to do it. I think some people use gparted. To recap the steps, resize the LV, resize the partition, resize the filesystem.
I setup a separate guest with the required tools to resize my guest filesystems and temporarily take down the guest to give the disk space to the utility guest.