[linux-lvm] Shrinking LVM partition at beginning

Nick Urbanik nicku at nicku.org
Sat Apr 9 10:12:46 UTC 2016


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 at 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 at 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 at nicku.org
GPG: 7FFA CDC7 5A77 0558 DC7A 790A 16DF EC5B BB9D 2C24 ID: BB9D2C24




More information about the linux-lvm mailing list