Re: [linux-lvm] Shrinking LVM partition at beginning

2016-04-09 Thread Alasdair G Kergon
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

___
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/


Re: [linux-lvm] Shrinking LVM partition at beginning

2016-04-09 Thread Alasdair G Kergon
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

___
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/


[linux-lvm] Shrinking LVM partition at beginning

2016-04-09 Thread Nick Urbanik

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 Nameroot
 VG Namefedora
 LV UUIDC3JJJ0-L7dR-6kLJ-xj4U-zUn2-i9tY-bexbV1
 LV Write Accessread/write
 LV Creation host, time localhost.localdomain, 2013-10-20 18:39:46 -0400
 LV Status  available
 # open 0
 LV Size50.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 Namehome
 VG Namefedora
 LV UUIDlHnoBw-pzJn-jCkZ-JaZ3-evAb-RisG-N22ErF
 LV Write Accessread/write
 LV Creation host, time localhost.localdomain, 2013-10-20 18:39:51 -0400
 LV Status  available
 # open 0
 LV Size85.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 Nameswap
 VG Namefedora
 LV UUIDHL6UPR-Z5AK-Oa6a-X9kZ-1wn0-j3Mn-w3avH9
 LV Write Accessread/write
 LV Creation host, time localhost.localdomain, 2013-10-20 18:39:56 -0400
 LV Status  available
 # open 2
 LV Size2.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 
 Formatlvm2

 Metadata Areas1
 Metadata Sequence No  28
 VG Access read/write
 VG Status resizable
 MAX LV0
 Cur LV3
 Open LV   1
 Max PV0
 Cur PV1
 Act PV1
 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   ni...@nicku.org
GPG: 7FFA CDC7 5A77 0558 DC7A 790A 16DF EC5B BB9D 2C24 ID: BB9D2C24

___
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/