[linux-lvm] Later extents allocated
Zac Slade
krakrjak at volumehost.net
Tue Dec 12 10:18:24 UTC 2006
On Monday 04 December 2006 13:09, Ian Pilcher wrote:
> Trying to reduce the size of a physical volume with pvresize, and being
> told "cannot resize to 1022 extents as later ones are allocated".
>
> Any way to "reorganize" the PV, or am I stuck?
Yes and No. What you want is an lvm repacker. Basically a defragmentation
program for PV Extents. This way you can put all the extents that are not
allocated contiguously into contiguous blocks. Currently no such tool
exists. Right now extents can get fragmented with more growing and shrinking
of logical volumes.
You can accomplish this same task manually with a bit of work. All you need
to do is look at the allocated extents on the pv you wish to make smaller and
allocate them elsewhere.
The tools you'll need are lvdisplay -m and pvmove. Here's an example:
I figured out that I needed to make /dev/sdb only have 45000 PEs allocated.
Through a bit of poking around at my lvdisplay -m output I discovered that I
could accomplish this by moving some extents allocated to main/usr
on /dev/sdb over to /dev/sda3. So all I need to do is put some of /usr
on /dev/sda3 to free up enough extents to shrink /dev/sdb.
lvdisplay -m main/usr
--- Logical volume ---
LV Name /dev/main/usr
VG Name main
LV UUID T6Otoe-ksvl-xalm-qxIM-CzoY-0jsr-ZbdKVb
LV Write Access read/write
LV Status available
# open 2
LV Size 34.00 GB
Current LE 8704
Segments 3
Allocation inherit
Read ahead sectors 0
Block device 253:1
--- Segments ---
Logical extent 0 to 3071:
Type linear
Physical volume /dev/sda3
Physical extents 26170 to 29241
Logical extent 3072 to 3583:
Type linear
Physical volume /dev/sdb
Physical extents 34941 to 35452
Logical extent 3584 to 8703:
Type linear
Physical volume /dev/sdb
Physical extents 43133 to 48252
So I'm going to move LE 3584-8703 off onto /dev/sda3, this will put me under
45000 PEs allocated on /dev/sdb so I turn to pvmove.
pvmove /dev/sdb:43133-48252 /dev/sda3
Once the pvmove completes I can pvresize /dev/sdb down to the proper size.
The thing to keep in mind here is that to get to this point you have to do
some legwork and look at the LV mappings to see where the extents on your PV
are allocated. If you move the extents that are allocated after your target
PV size you will be able to successfully use pvresize.
--
Zac Slade
krakrjak at volumehost.net
ICQ:1415282 YM:krakrjak AIM:ttyp99
More information about the linux-lvm
mailing list