-   Linux - General (
-   -   vgreduce LMV (

klompie 06-16-2011 09:53 AM

vgreduce LMV
I have installed Fedora 15 on my laptop a couple of days ago, but now i want to install windows next to it.
T do this i have to resize the lvm partition.

Using a live disk, I used this post as guide:

But at the final step (vgreduce) i get this message:
Physical volume "/dev/sda2" still in use

What now? Can someone help me reducing the size of my lvm partition?

Some info:

[root@Rene-Fedora rene]# vgs
  VG            #PV #LV #SN Attr  VSize  VFree 
  vg_renefedora  1  3  0 wz--n- 465,25g 334,38g
[root@Rene-Fedora rene]# lvs
  LV      VG            Attr  LSize  Origin Snap%  Move Log Copy%  Convert
  lv_home vg_renefedora -wi-ao 75,00g                                     
  lv_root vg_renefedora -wi-ao 50,00g                                     
  lv_swap vg_renefedora -wi-ao  5,88g                                     
[root@Rene-Fedora rene]# pvs
  PV        VG            Fmt  Attr PSize  PFree 
  /dev/sda2  vg_renefedora lvm2 a-  465,25g 334,38g
[root@Rene-Fedora rene]#


[root@localhost liveuser]# swapoff -a
[root@localhost liveuser]# vgreduce vg_renefedora -a
  Physical volume "/dev/sda2" still in use

MensaWater 06-16-2011 12:52 PM

vgreduce does NOT resize a PV it - removes it. Since sda2 is the only PV in your VG you can not reduce it. At this point you can "vgremove" to remove the entire volume group if that is your intent.

If your intent is to resize the VG rather than remove it you can use the pvresize command which will allow you to shrink the size of the PV on sda2 then you can use fdisk or parted to resize the partition on /dev/sda.

If you type "man pvresize" it gives you some good information.

klompie 06-16-2011 03:21 PM

When using pvresize i get this message:

[root@Rene-Fedora rene]# pvresize --setphysicalvolumesize 131G /dev/sda2
  /dev/sda2: cannot resize to 4191 extents as later ones are allocated.
  0 physical volume(s) resized / 1 physical volume(s) not resized

klompie 06-17-2011 12:54 AM

So i found out that lv_home and lv_swap are at the beginning of the pv and lv_root at the end. SO how do i move the lv_root on the pv so i get the free space at the and?

MensaWater 06-17-2011 08:59 AM

Haven't done this. From research it appears moving extents with the same PV can be done on the same disk using "pvmove --alloc" with additional flags. (Do a web search for that in quotes as shown and you'll get lots of hits.) I can't give any guidance as I haven't done that but it appears others have. I've seen it suggested that "pvmove --alloc anywhere" would do it but the "anywhere" makes me think you couldn't be sure where the extents would end up.

You could for this purpose get rid of the swap completely then add it back after the resize is all done by using swapoff to remove your swap usage on the system. (man swapoff). You'd then do an lvremove to remove the swap LV. That will free up the space at the front of the PV which might make your pvmove --alloc move other extents to the front.

As noted I haven't done the above - try it at your own risk. You should definitely have a full backup before attempting this.

klompie 06-17-2011 09:07 AM

I found this when searching for it:

Looks promising. Will try this when i get home.

All times are GMT -5. The time now is 05:49 PM.