Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Bear with me on this one, since I'm pretty new to LVM.

I have a server with about 5 LVM's on them. They consist of 5PV, using their own VG's and their own corresponding LV's. My issue is, I'm needing to know if it is possible to shrink one of the LV's a bit, and give that extra space to a different LV and expand the other LV. Here's a glimpse of my configuration:

LV That I want to shrink by 30GB
PV /dev/cciss/c0d1p4 VG vg4 lvm2 [76.88 GB / 0 free]

LV That I want to expand by 30GB from the previous LV
PV /dev/cciss/c0d1p2 VG vg2 lvm2 [46.57 GB / 0 free]

/dev/cciss/c0d1p4 is a mount point called /u03 and /dev/cciss/c0d1p2 is a mount point called /backup. They are on two different volume groups. I'll show the output of pvdisplay, vgdisplay, and lvdisplay for these LVMs:

pvdisplay Output

  --- Physical volume ---
  PV Name               /dev/cciss/c0d1p4
  VG Name               vg4
  PV Size               76.89 GB / not usable 3.25 MB
  Allocatable           yes (but full)
  PE Size (KByte)       4096
  Total PE              19682
  Free PE               0
  Allocated PE          19682
  PV UUID               aMo010-TaQn-ehsK-29R9-aFat-HGK4-vwMPMA

  --- Physical volume ---
  PV Name               /dev/cciss/c0d1p2
  VG Name               vg2
  PV Size               46.57 GB / not usable 1008.00 KB
  Allocatable           yes (but full)
  PE Size (KByte)       4096
  Total PE              11922
  Free PE               0
  Allocated PE          11922
  PV UUID               ML2gdx-wkwW-C2tZ-rX5b-hVhQ-xZhq-C1cIFx

vgdisplay Output

  --- Volume group ---
  VG Name               vg4
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               76.88 GB
  PE Size               4.00 MB
  Total PE              19682
  Alloc PE / Size       19682 / 76.88 GB
  Free  PE / Size       0 / 0   
  VG UUID               wbVABu-LR3G-1c5f-qfz8-3eLD-vTEq-1FFrfo

  --- Volume group ---
  VG Name               vg2
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               46.57 GB
  PE Size               4.00 MB
  Total PE              11922
  Alloc PE / Size       11922 / 46.57 GB
  Free  PE / Size       0 / 0   
  VG UUID               aVO4SZ-RVFU-FJfq-QTKi-NBDZ-rWiB-keb41m

lvdisplay Output

  --- Logical volume ---
  LV Name                /dev/vg4/lv_u03
  VG Name                vg4
  LV UUID                edVjf2-wPmY-wRUL-QwIT-PJ1Q-m128-rppA3a
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                76.88 GB
  Current LE             19682
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Logical volume ---
  LV Name                /dev/vg2/lv_backup
  VG Name                vg2
  LV UUID                n2PaAn-S8jl-yQdu-HVyR-pZcI-X9S9-GgeQ4K
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                46.57 GB
  Current LE             11922
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:5

Any help would be appreciated.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

dont take this as gospel,

  1. reduce the filesystem size on the first LV
  2. reduce the lvsize of the first lv
  3. add the freed up physical extents to the other vg(2).
  4. expand the vg(2) to use those physical extents.
  5. expand the lv on vg2
  6. expand the filesystem on the newly expanded lv.

i think thats about the size of it. Feel free to downvote if this is wrong.

share|improve this answer
    
It sounds good to me, but I'm not sure if a PV can belong to two VGs at the same time. –  Cristian Ciupitu Jul 15 '10 at 12:47
    
yes. you may well need a pvmove and pvremove in between steps 2 and 3 before adding them to the other VG. –  Sirex Jul 15 '10 at 12:49
    
Could you provide the commands with the steps to do this, just so that I have something to reference. I'm going to setup a test environment through a VM to test this. –  drewrockshard Jul 15 '10 at 14:29
    
1 and 6 depend on the filesystem in use. but otherwise lvreduce, pvmove, pvremove, vgextend, lvextend, in that order. Setting up test environment is a great idea. –  Sirex Jul 15 '10 at 16:03
    
resize2fs can be used for ext2/ext3/ext4. –  Cristian Ciupitu Jul 16 '10 at 14:20
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.