Re: [bitfolk] Downsizing LVM PVs

Top Page

Reply to this message
Author: Jan Henkins
Date:  
To: users
Subject: Re: [bitfolk] Downsizing LVM PVs
Hello Andy,

On 04/02/13 13:13, Andy Smith wrote:
> Hi Paul,
>
> On Mon, Feb 04, 2013 at 12:30:53PM +0000, Paul Stimpson wrote:
>> I think I need to either:
>>      1) Find someone who is a Clonezilla god who can tell me how to
>> make Clonezilla shrink the PV using some of the advanced options.
> I don't know anything about CloneZilla I'm afraid, but…

>
>>      2) Restore the image to one of our new test boxes, shrink the PV
>> to under 250GB and then make a new Clonezilla image from that.


You missed out a "HAVE BACKUPS" just about here.

> …shrinking a PV is easy.


But seriously, it's easy to forget just how powerful LVM is. Thank you
very much for this tutorial.

>
> - Boot a live distribution or rescue environment
>
> - Shrink the filesystem on the LV and the LV along with it:
>
>    # lvresize --resizefs -L250G /dev/yourvg/yourlv

>
>    If you haven't got a recent enough LVM for it to support
>    --resizefs, you'll have to do it as a resize2fs first (or
>    equivalent for your FS), followed by an lvresize.

>
> - Shrink the PV to match, assuming your PV is /dev/sda1:
>
>    # pvresize /dev/sda1 --setphysicalvolumesize 250G

>
> - HAVE BACKUPS
>
>    Finally you'll need to shrink the partition /dev/sda1 which will
>    involve deleting the partition and recreating it again smaller.

>
>    HAVE BACKUPS

>
>    This is the scariest part. You could use something like:

>
>    HAVE BACKUPS

>
>    # pvs --units s

>
>    To see the size of the (now shrunk) PV in sectors, so you can work
>    out how big to make the partition.

>
>    One trick I sometimes use to make it a little less terrifying is
>    to shrink the PV (and everything inside it) a bit smaller than I
>    need, shrink the partition, and then grow everything back to the
>    maximum it can be as that requires no guesswork over exact sector
>    numbers.

>
>    All of the resize commands without an explicit target size will
>    grow to maximum of their container.

>
> So there you go, simple.
>
> Cheers,
> Andy
>


--

Regards,
Jan Henkins