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. 0. Both my host and guest are running Centos 6.2. 1. 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. 2. 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. 3. 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. 4. 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. 5. So then I switched over to the guest system and ran df -h to see the existing filesystem [root at 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 6. 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. Jeff Boyce Meridian Environmental www.meridianenv.com
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. > > 0. Both my host and guest are running Centos 6.2. > > 1. 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. > > 2. 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. > > 3. 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. > > 4. 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. > > 5. So then I switched over to the guest system and ran df -h to see the > existing filesystem > > [root at 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 > > 6. 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.
Fri, 24-Feb-2012 12:05:55 Jeff Boyce wrote:> 6. Then I ran resize2fs /dev/vda2 and got the result that the filesystem > is already xx blocks long. Nothing to do!Before you can resize filesystem, you have to resize partition. If it is only 2 partitions on /dev/vda, you can use one of two ways: 1. Resize partition from host system (I think it is not the best idea for root partition operations): Run fdisk /dev/vg/lv_guest1root, delete second partition and create new one which starts from the same place but takes all available space, after it you can boot guest (in single mode) and run resize2fs. 2. Boot VM from any 3-party (LiveCD or any) with access to virtual disk, and do the same: in fdisk delete existing partition, create new one and run resize2fs on it. Or just use parted to do it in one command. -- With best regards Sergiy Yegorov RHCSA -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: <http://lists.centos.org/pipermail/centos-virt/attachments/20120224/db22c469/attachment-0004.sig>
On 24.2.2012 21:05, 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. > > 0. Both my host and guest are running Centos 6.2. > > 1. 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. > > 2. 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. > > 3. 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. > > 4. 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. > > 5. So then I switched over to the guest system and ran df -h to see the > existing filesystem > > [root at 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 > > 6. 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?I think you must reboot the guest to see the new bigger disk, then you can repartition, and then after another reboot you can resize your fs. -- Kind Regards, Markus Falb -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 307 bytes Desc: OpenPGP digital signature URL: <http://lists.centos.org/pipermail/centos-virt/attachments/20120227/84b3dc63/attachment-0004.sig>
Responding to the daily digest, see comment at bottom.> Message: 1 > Date: Mon, 27 Feb 2012 14:01:27 +0100 > From: Markus Falb <markus.falb at fasel.at> > Subject: Re: [CentOS-virt] Resize guest filesystem question > To: centos-virt at centos.org > Message-ID: <jifur8$pmi$1 at dough.gmane.org> > Content-Type: text/plain; charset="iso-8859-1" > > On 24.2.2012 21:28, Sergiy Yegorov wrote: >> Fri, 24-Feb-2012 12:05:55 Jeff Boyce wrote: >> >>> 6. Then I ran resize2fs /dev/vda2 and got the result that the >>> filesystem >>> is already xx blocks long. Nothing to do! >> Before you can resize filesystem, you have to resize partition. >> If it is only 2 partitions on /dev/vda, you can use one of two ways: >> 1. Resize partition from host system (I think it is not the best idea for >> root >> partition operations): >> Run fdisk /dev/vg/lv_guest1root, delete second partition and create new >> one >> which starts from the same place but takes all available space, after it >> you >> can boot guest (in single mode) and run resize2fs. >> 2. Boot VM from any 3-party (LiveCD or any) with access to virtual disk, >> and >> do the same: in fdisk delete existing partition, create new one and run >> resize2fs on it. Or just use parted to do it in one command. > > 3. You can repartition from the guest itself > Do as in 2. After saving the new partition table fdisk will probably > request a reboot for using the new table. reboot, then resize the fs. > > -- > Kind Regards, Markus Falb >Thanks to everyone that replied. Ed gave me the right clue that I was missing (and is apparently missing in a lot of the how-to's that I reviewed which only said to expand the LV, then expand the filesystem). I had to expand the partition before expanding the filesystem. So for my solution I rebooted that particular VM using SystemRescue LiveCD, then started GParted and expanded the partition which also expanded the filesystem in a single step. Then rebooted using the VM's image and #df -h now shows the expanded LV and a file system on the full space. Jeff
Apparently Analagous Threads
- Resizing est4 filesystem while mounted
- Can''t see changes in LV Size inside domU (after lvextend on dom0)
- Confusion over steps to add new logical volume to guest VM
- Virt-resize error (ntfs) : Fatal error: exception Guestfs.Error("ntfsresize_opts: /dev/vda2)
- Reg Disk space in guest domain with fedora img