Reducing PV/ Reclaiming free PEs from a PV to be used for another partition/purpose outside of LVM
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 i686creation_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.
Quoted 11 lines · Ajeet Nankani
vgcfgbackup which would give me meta file data as below
extent_size= 65536 # 32 Megabytesdevice = "
/dev/hda6" # Hint only
pe_start= 384
pe_count= 266 # 8.3125 Gigabytes
extent_count= 192 # 6 Gigabytes
"pv0", 0
0-191
Quoted 2 lines
extent_count= 32 # 1024 Megabytes
"pv0", 192
192-223
Quoted 3 lines
Now here if i edit it and in physical volume section where it says that
pe_count= 266, i change it tope_count= 224 which is the last PE used by the Logical Volume.
Yes.
Quoted 2 lines
after saving it if i run vgcfgrestore with this file, will my PV be reduced??
That's what pvresize would do.
Quoted 1 line
after that i can reduce hda6 with parted or similar utility.
and the new size is 384 sectors plus 224 extents of 65536 sectors each.
Alasdair
Signature · 1 line
[email protected]
Re: [linux-lvm] Reducing PV/ Reclaiming free PEs from a PV to be usedfor another partition/purpose outside of LVM
Quoted 24 lines · Alasdair G Kergon
Quoted 11 lines · Ajeet Nankani
vgcfgbackup which would give me meta file data as below
extent_size= 65536 # 32 Megabytesdevice = "
/dev/hda6" # Hint only
pe_start= 384
pe_count= 266 # 8.3125 Gigabytes
extent_count= 192 # 6 Gigabytes
"pv0", 00-191
Quoted 2 lines
extent_count= 32 # 1024 Megabytes
"pv0", 192192-223
Quoted 3 lines
Now here if i edit it and in physical volume section where it says that
pe_count= 266, i change it tope_count= 224 which is the last PE used by the Logical Volume.
Quoted 6 lines
Yes.
Quoted 2 lines
after saving it if i run vgcfgrestore with this file, will my PV be reduced??
That's what pvresize would do.
but pvresize says command not implemented yet.
also what this "pe_start = 384" in meta data means.
Thanks
-ajeet.
Quoted 9 lines
Quoted 2 lines
after that i can reduce hda6 with parted or similar utility.
and the new size is 384 sectors plus 224 extents of 65536 sectors each.
Alasdair
Signature · 1 line
[email protected]