* [linux-lvm] Shrinking LVM partition at beginning
@ 2016-04-09 10:12 Nick Urbanik
2016-04-09 17:52 ` Zdenek Kabelac
2016-04-09 23:19 ` Alasdair G Kergon
0 siblings, 2 replies; 4+ messages in thread
From: Nick Urbanik @ 2016-04-09 10:12 UTC (permalink / raw)
To: linux-lvm
Dear Folks,
I want to shrink an LVM partition and expand a preceding, non-LVM
partition. The LVM partition contains three logical volumes. I
shrank the larger, middle home volume at the volume's end successfully
with a command something like this:
sudo lvresize --verbose --resizefs -L -40G /dev/fedora/home
and then used pvmove to move all the pysical extents towards the end
of the disk, using some commands something like this:
sudo pvmove --alloc anywhere /dev/sda6:24387-34626 /dev/sda6:34627-44866
until all the extents are towards the end of the disk, and there are
10240 unused at the beginning of the volume.
So: can anyone suggest how I can shrink the volume group by that 10240
physical extents, so that I can shrink the partition, and expand the
previous partition?
Here are some details:
Fedora 23, i686, MBR partitioning.
[liveuser@samsung ~]$ sudo lvdisplay -m
--- Logical volume ---
LV Path /dev/fedora/root
LV Name root
VG Name fedora
LV UUID C3JJJ0-L7dR-6kLJ-xj4U-zUn2-i9tY-bexbV1
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2013-10-20 18:39:46 -0400
LV Status available
# open 0
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
--- Segments ---
Logical extents 0 to 12799:
Type linear
Physical volume /dev/sda6
Physical extents 10240 to 23039
--- Logical volume ---
LV Path /dev/fedora/home
LV Name home
VG Name fedora
LV UUID lHnoBw-pzJn-jCkZ-JaZ3-evAb-RisG-N22ErF
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2013-10-20 18:39:51 -0400
LV Status available
# open 0
LV Size 85.26 GiB
Current LE 21827
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:4
--- Segments ---
Logical extents 0 to 21826:
Type linear
Physical volume /dev/sda6
Physical extents 23040 to 44866
--- Logical volume ---
LV Path /dev/fedora/swap
LV Name swap
VG Name fedora
LV UUID HL6UPR-Z5AK-Oa6a-X9kZ-1wn0-j3Mn-w3avH9
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2013-10-20 18:39:56 -0400
LV Status available
# open 2
LV Size 2.03 GiB
Current LE 520
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:5
--- Segments ---
Logical extents 0 to 519:
Type linear
Physical volume /dev/sda6
Physical extents 44867 to 45386
[liveuser@samsung ~]$ sudo vgdisplay
--- Volume group ---
VG Name fedora
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 28
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 177.29 GiB
PE Size 4.00 MiB
Total PE 45387
Alloc PE / Size 35147 / 137.29 GiB
Free PE / Size 10240 / 40.00 GiB
VG UUID gAbhli-WPRu-ZOkx-nAbl-lPCD-An7E-uEmhO6
Any suggestions gratefully received.
--
Nick Urbanik http://nicku.org nicku@nicku.org
GPG: 7FFA CDC7 5A77 0558 DC7A 790A 16DF EC5B BB9D 2C24 ID: BB9D2C24
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [linux-lvm] Shrinking LVM partition at beginning
2016-04-09 10:12 [linux-lvm] Shrinking LVM partition at beginning Nick Urbanik
@ 2016-04-09 17:52 ` Zdenek Kabelac
2016-04-09 23:45 ` Alasdair G Kergon
2016-04-09 23:19 ` Alasdair G Kergon
1 sibling, 1 reply; 4+ messages in thread
From: Zdenek Kabelac @ 2016-04-09 17:52 UTC (permalink / raw)
To: LVM general discussion and development
Dne 9.4.2016 v 12:12 Nick Urbanik napsal(a):
> Dear Folks,
>
> I want to shrink an LVM partition and expand a preceding, non-LVM
> partition. The LVM partition contains three logical volumes. I
> shrank the larger, middle home volume at the volume's end successfully
> with a command something like this:
>
> sudo lvresize --verbose --resizefs -L -40G /dev/fedora/home
>
> and then used pvmove to move all the pysical extents towards the end
> of the disk, using some commands something like this:
>
> sudo pvmove --alloc anywhere /dev/sda6:24387-34626 /dev/sda6:34627-44866
>
> until all the extents are towards the end of the disk, and there are
> 10240 unused at the beginning of the volume.
>
> So: can anyone suggest how I can shrink the volume group by that 10240
> physical extents, so that I can shrink the partition, and expand the
> previous partition?
Hi
Unsupported - requires very good understanding about lvm2 metadata format
and very good precision in all calculations if you would do it by hand...
Basically you need to recreate PV header at different position,
and recompute all 'PV' extents in use.
IMHO easiest&safest for a normal user is to just 'copy' disk elsewhere,
reformat with new layout and copy data back (yeah - takes some time,
but with significantly less probability of data loose...)
lvm2 is not meant to be used with other volume manager (like partitions)
so do not expect it will support such sort of operations...
Regards
Zdenek
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [linux-lvm] Shrinking LVM partition at beginning
2016-04-09 10:12 [linux-lvm] Shrinking LVM partition at beginning Nick Urbanik
2016-04-09 17:52 ` Zdenek Kabelac
@ 2016-04-09 23:19 ` Alasdair G Kergon
1 sibling, 0 replies; 4+ messages in thread
From: Alasdair G Kergon @ 2016-04-09 23:19 UTC (permalink / raw)
To: LVM general discussion and development
Outline of the process:
Work out the new layout as best you can.
vgcfgbackup the metadata into a text file.
Update partition table moving the start of the partition, being careful to
respect any alignment restrictions.
Edit the text file based on the new partition start location so that all the
data will be in the same place (so all extent numbers will be smaller by
the same fixed amount, and dev_size and pe_start values will change).
pvcreate with --restorefile and -Zn to format the "new" partition for LVM's
use based on the edited file.
vgcfgrestore from that file.
Alasdair
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [linux-lvm] Shrinking LVM partition at beginning
2016-04-09 17:52 ` Zdenek Kabelac
@ 2016-04-09 23:45 ` Alasdair G Kergon
0 siblings, 0 replies; 4+ messages in thread
From: Alasdair G Kergon @ 2016-04-09 23:45 UTC (permalink / raw)
To: LVM general discussion and development
On Sat, Apr 09, 2016 at 07:52:07PM +0200, Zdenek Kabelac wrote:
> Unsupported
The process could easily be automated, but there just isn't enough
demand to justify spending the time writing and testing code for it.
An expert would also find it pretty easy to test each step as they
proceeded without making any irreversible changes that risked data
loss. E.g. using device-mapper to try out the device in advance
of the partition table change with the PV header sectors mapped
somewhere else and using some of the advanced lvm.conf options
that take metadata from elsewhere.
Alasdair
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-09 23:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-09 10:12 [linux-lvm] Shrinking LVM partition at beginning Nick Urbanik
2016-04-09 17:52 ` Zdenek Kabelac
2016-04-09 23:45 ` Alasdair G Kergon
2016-04-09 23:19 ` Alasdair G Kergon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.