Resizing partitions with & w/o lvm

Discussion in 'Installation/Configuration' started by anw, Jan 17, 2009.

  1. anw

    anw New Member

    Normally, I would just try stuff to see what worked, but in this case there's real data that I don't want to lose, so thought I'd ask for advice here first.

    I have three partitions on this disk, laid out thusly:

    |--root--|--swap--|-------------- hda3 (lvm) --------------|

    hda3 is the only one using lvm. What I want to do is shrink hda3 from the front, to give a couple of more (contiguous) gigabytes to swap. There's plenty of room. Here's the output of lvdisplay:
    and here's the output of pvdisplay:
    So, there's plenty of room; but what I don't understand is there doesn't seem to be any way to tell lvresize or pvresize how to move the lv's or pv's around. In other words, I want to tell pvresize (and probably fdisk, too, right?) to scoot everything over to the right by a couple of gig, then tell fdisk to increase the swap partition by said amount.

    I've found several examples on the net, but none demonstrate how to exercise this fine a control over the starting and ending locations, and, as I say, I'd be much more open to just experimenting if these weren't currently in use with (a lot) of real, live data.

    TIA!
     
  2. grandpagenocide

    grandpagenocide New Member

    While online enlarging is no problem, you have to umount for shrinking!
    Code:

    # umount /dev/vg_blah/lv_blah

    Perform a check of the filesystem...
    Code:

    # e2fsck -f /dev/vg_blah/lv_blah

    Resize the filesystem first.
    Code:

    # resize2fs /dev/vg_blah/lv_blah 9G

    Then reduce the size of the logical volume.
    Code:

    # lvreduce -L -1G /dev/vg_blah/lv_blah

    After that you can shrink down the volume group if desired.
    Code:

    # vgreduce vg_blah /dev/sdxy

    Warning: It is crucial that you use the exact amount of space. If you reduce volume more than the filesytem you truncate the logical volume and you risk data loss!

    !!! I WOULD NEVER SHRINK A FILESYSTEM WITHOUT A BACKUP !!!

    copied from linuxquestions.org, worked for me, boot off linux rescuse disk or live distro, i do advise play around on a spare box if u got one, i completly screwed up like 10 times before i found this tut and got it right
     
  3. anw

    anw New Member

    Thanks for the help!

    Don't I have to reduce the VG size if I'm going to reduce the partition? I have three lv's in this VG, but an extra 177 gig or so of space in the volume group, which is the full size of the partition. So, do I need to shrink any of the LVs? And, when I do shrink the VG, how do I tell it to shrink it from the front, and not from the back (i. e., add space between swap and hda3 so I can contiguously expand swap)?
     
  4. falko

    falko Super Moderator Howtoforge Staff

  5. anw

    anw New Member

    Hey, Falko!

    Thanks. I had actually read that article, but there were still a couple of questions I had. Right now, as you can see in a minute by what I'm fixing to post, this may have been OBE- I think I'm just going to get a new drive if it's pretty easy.

    If not, I'll return to this and figure out exactly what question I had on that article.

    Thanks for the help! New question coming...
     

Share This Page