-
Question: LVM2 VG resizing and movement of PE within VG
Hi all,
I have some problem with using my harddisk space after giving it all
to LVM.
My situation on /dev/sda (the only disk in my laptop):
/dev/sda1 some partition (about 25 % of all space)
/dev/sda2 LVM (about 75 % of all space)
I created a VG00 on /dev/sda2 and 3 LVs (LV01-LV03) which ate about
80% of the VG space.
Later I removed LV01, so the first 600 PE in this VG are free now.
My problem:
I want some of the diskspace back from LVM, let's say I want a /dev/
sda3-VFAT-partition I can use through windows (please no suggestions
for workarounds, I want to learn about LVM :-)
My trials:
1. try:
pvresize --setphysicalvolumesize XXG -t /dev/sda2
--> "cannot resize to YY extends as later ones are allocated."
This in fact is true as a "lvdisplay -m" tells me that LV03 is using
PE after #YY.
2. try:
OK, maybe we need to move these PE after #YY to somewhere before
it... I've removed LV01, so there's enough of free space...
pvmove -n /dev/VG00/LV03 /dev/sda2:OO-ZZ /dev/sda2:AA-BB
-->"No extends available for allocation"
My questions:
1. How can I move the allocated PE to some unallocated PE within the
same VG (and same physical device) ?
2. If I would be able to move the allocated PE to free PE before PE
YY, would I be able to resize the VG (and then be able to resize the
partition it resides on) ?
Or is the answer, that I will never be able to claim the "unused"
space back (well, I know it is not unused, the VG uses it) from the
VG, without prior moving of the PE to another physical device ?
Thank you for your help !
-
Re: Question: LVM2 VG resizing and movement of PE within VG
hasenhei staggered into the Black Sun and said:
> /dev/sda1 about 25% of all space
> /dev/sda2 LVM, about 75 % of all space
>
> I created a VG on /dev/sda2 and 3 LVs (LV01-LV03) which ate about 80%
> of the VG space. Later I removed LV01, so the first 600 PE in this
> VG are free now. I want some of the diskspace back from LVM
Like the LVM-HOWTO says, it's *a lot* easier to expand partitions,
filesystems, LVs, VGs, and PVs than it is to shrink them.
> pvresize --setphysicalvolumesize XXG -t /dev/sda2
> --> "cannot resize to YY extends as later ones are allocated."
Yep. The man pages for the LVM2 tools sort of mention that this is a
problem that they might fix in a future release.
> OK, maybe we need to move these PE after #YY to somewhere before it...
> I've removed LV01, so there's enough free space...
>
> pvmove -n /dev/VG00/LV03 /dev/sda2:OO-ZZ /dev/sda2:AA-BB
> -->"No extents available for allocation"
pvmove moves the PEs in a PV to other PVs, not the same PV. AFAICT,
there is no currently-existing tool in LVM2 that does what you want.
Maybe somebody should write one. Even if you had to have the PVs and
LVs umounted/inactive during the move, a tool like that might be useful
for certain situations.
I suppose you could get a large-enough USB2 disk, boot from a LiveCD
that has the LVM2 tools, and pvmove all your junk onto the USB2 disk.
Then kill the partition and re-fdisk the disk, pvcreate the newer,
smaller partition, vgcreate it, and pvmove all your junk back. It'd
take some time and be annoying, but it'd work.
> How can I move the allocated PE to some unallocated PE within the
> same VG (and same physical device)?
See previous paragraphs.
> Or I will [not] be able to claim the "unused" space back (well, I know
> it is not unused, the VG uses it) without moving the PE to another
> physical device ?
AFAICT, yes. HTH anyway,
--
A project for developing fully automatically driven cars
(not just those misnamed auto-pilots) has been improved by your
explosive flatulence. --MegaHAL, trained on ASR
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see