[CentOS] Freeing pv space for snapshots

Sat Jan 6 17:47:05 UTC 2007
Paul <unix at bikesn4x4s.com>

On Sat, January 6, 2007 3:20 am, Johnny Hughes wrote:
> On Fri, 2007-01-05 at 19:04 -0500, Paul wrote:
>> On Thu, January 4, 2007 11:40 pm, Alvin Chang wrote:
>> > On 05/01/07, Aleksandar Milivojevic <alex at 8-p.ca> wrote:
>> >> I've used it, and it works correctly (and it is available in CentOS
>> >> 4.4).  It shrinks file system as it should.  The only things Paul
>> should
>> >> be careful is to first shrink file system, than logical volume and to
>> >> correctly calculate file system size and by how many extents he can
>> >> shrink logical volume.  If he shrinks logical volume too much, he
>> might
>> >> end up loosing data.  Running fsck in non-destructive mode (fsck -N)
>> >> and/or attempting to mount file system read-only after he shrinks
>> >> logical volume might be a good idea to test all is OK.
>> > A little technique you can use is:
>> > 1. shrink the file system to the size slightly less than what you
>> really
>> > want
>> > 2. reduce LV to the size that is what you really want
>> > 3. expand the file system to the size of the LV (usually the resize
>> > program can be told to expand the file system to maximum available
>> > space automatically on the LV.)
>>
>> You guys are great!  Thanks.  It was a breeze!  I really have fun
>> learning
>> more and more.  I feel like an LVM expert now.  Here's the steps I took:
>>
>> First my lv was like 38G, and I wanted to make it about 32G in the end.
>> I
>> know that should be way more than enough.  I also did a dd to an image
>> file on a secondary drive for a precaution (always have a failsafe
>> recovery!)
>>
>> 1.  booted up on CentOS 4.4 Live CD.  -When I booted up on it, I told it
>> to boot nonet to not bring up the interfaces, but it did anyhow.  I did
>> a
>> "ifconfig eht0 down" to do a shut on it.  Anyhow, out of all the
>> LiveCD's
>> I have tried, I do like the Centos the best!
>>
>> 2.  e2fsck -fv /dev/VolGroup00/LogVol00
>>
>> 3.  resize2fs -p /dev/VolGroup00/LogVol00 30G
>>
>> 4.  lvresize -L 32G /dev/VolGroup00/LogVol00
>>
>> 5.  resize2fs -p /dev/VolGroup00/LogVol00 (size defaults to lv size)
>>
>> Now I have my free PV space!
>>
>> # pvdisplay
>>   --- Physical volume ---
>>   PV Name               /dev/hda2
>>   VG Name               VolGroup00
>>   PV Size               38.22 GB / not usable 0
>>   Allocatable           yes
>>   PE Size (KByte)       32768
>>   Total PE              1223
>>   Free PE               143
>>   Allocated PE          1080
>>   PV UUID               cQCke5-zi9o-xhOW-HlR5-M46g-VbHC-99Csch
>>
>> Now I am on to learning how to do a full backup with snapshots!
>>
>
> Good job ... first thing to understand (at least as I understand it :P)
> is that you will only be able to create a snapshot that is 6GB or
> smaller.
>
> So, as long as the used space on the LVs you take snapshots of are < 6GB
> will be OK, otherwise you will have problems.
>
> My understanding is that you need free space that is going to be at
> least as large as the "used space" on the "LARGEST" LV that you are
> going to create a snapshot for.  (At least that is how I currently setup
> my VGs and LVs where snapshots are involved).

Well, I know I have way more than enough space, but it was my
understanding that you can have way less space than is actually used,
cause the space just tracks changes.  I used to use "fssnap" in Solaris
allot and that doesn't take any space at all, cause it's just some kind of
tracking info, I think that is at least what I can compare it to in my
mind.  So, even though I am using 6gigs worth, I can do a snapshot with
like probably 500megs easy.  I think anyhow.