[linux-lvm] Reducing PV/ Reclaiming free PEs from a PV to be used for another partition/purpose outside of LVM

Ajeet Nankani fromkth+lvm at fastmail.fm
Sun Feb 6 20:15:48 UTC 2005


I have hda6 as the only PV in a Volume Group which contains 2 Logical
Volumes.
I have around 42 contiguous free PEs at the end of PV.
I want to reduce this PV by 42 or less PEs so that i can reduce hda6 and
create one more partion hda7(Fat32) for some other work.

There is not any straight command to do it atleat untill now, because i
tried to use pvresize and it said that command not implemented yet.

I thought of one way, but i am not sure it would work or not, so i need
you people comments on it.

First i will create a meta data backup of the Volume Group with the
command

vgcfgbackup which would give me meta file data as below 

================================================
description = "Created *after* executing 'pvmove -v -i 60 --alloc
anywhere /dev/hda6:233-264 /dev/hda6:192-223'"

creation_host = "XXXXX"        # Linux XXXXX 2.6.9-1.667 #1 Tue Nov 2
14:41:25 EST 2004 i686
creation_time = 1107716048      # Sun Feb  6 19:54:08 2005

VolGroup00 {
        id = "cdEPbO-5o71-hUIa-szPC-FAra-E79P-cdbuTS"
        seqno = 17
        status = ["RESIZEABLE", "READ", "WRITE"]
        extent_size = 65536             # 32 Megabytes
        max_lv = 0
        max_pv = 0

        physical_volumes {

                pv0 {
                        id = "BQSuB1-GYJf-bfdM-wnZd-JJgi-fZAM-jm4th6"
                        device = "/dev/hda6"    # Hint only

                        status = ["ALLOCATABLE"]
                        pe_start = 384
                        pe_count = 266  # 8.3125 Gigabytes
                }
        }

        logical_volumes {

                LogVol00 {
                        id = "6WyF9L-t4dJ-8HrR-NdTo-CoZh-NKvl-z6fidr"
                        status = ["READ", "WRITE", "VISIBLE"]
                        segment_count = 1

                        segment1 {
                                start_extent = 0
                                extent_count = 192      # 6 Gigabytes

                                type = "striped"
                                stripe_count = 1        # linear

                                stripes = [
                                        "pv0", 0
                                ]
                        }
                }

                LogVol01 {
                        id = "N3auhB-e9br-76Cw-Eqvw-c31w-mq3Y-T5QBp8"
                        status = ["READ", "WRITE", "VISIBLE"]
                        segment_count = 1

                        segment1 {
                                start_extent = 0
                                extent_count = 32       # 1024 Megabytes

                                type = "striped"
                                stripe_count = 1        # linear

                                stripes = [
                                        "pv0", 192
                                ]
                        }
                }
        }
}
=====================================================================

Now here if i edit it and in physical volume section where it says that
pe_count = 266, i change it to pe_count = 224 which is the last PE used
by the Logical Volume.

after saving it if i run vgcfgrestore with this file, will my PV be
reduced?? after that i can reduce hda6 with parted or similar utility.

Any comments??

Thanks.

-ajeet.




More information about the linux-lvm mailing list