[CentOS] Re: LVM Resizing Problem

Sun May 6 20:47:28 UTC 2007
Scott Lamb <slamb at slamb.org>

On May 6, 2007, at 8:14 AM, Ross S. W. Walker wrote:
>> LVM even warned you --IN CAPS-- "THIS MAY DESTROY YOUR DATA".
>> I guess it was right. I haven't had much luck with reducing a
>> volume below its
>> initial size. I usually make a new LV and rsync or cp -a the
>> data over to it.
>>  I try to leave some free space just for this. Or add a drive
>> temporarily.
>
> Were the LV calculations done in the VG's extent size unit?
>
> Most people forget LVM rounds to the closest whole extent in it's
> calculations which I believe is 4MB by default, so care must be
> taken to make sure any file system fits comfortably in there
> first.

Is there any tool which is aware of both the filesystem and LVM  
layers and can correctly ensure the filesystem fits?

The filesystem on my only large disk array is corrupt, presumably due  
to some problem in one of the Fedora Core 6 update kernels. I  
rebooted into single user mode, fscked (which found a huge number of  
errors) and rebooted and it's still complaining. So it's time to  
start over with a fresh filesystem on a more trustworthy dom0 system  
(CentOS 5). I don't have anything vital stored only there, but there  
are a number of large files I'd like to save if possible. They don't  
fit anywhere else.

Here's my plan:

1. boot a CentOS 5 DVD in rescue mode, fsck the filesystem again
2. shrink the existing filesystem and LV (crossing my fingers)
3. install CentOS 5 to a new LV and filesystem
4. copy whatever's left of these files
5. delete the old LV
6. expand the new filesystem and LV

Never done steps #2 and #6 before, and I want to give it as much  
chance of success as possible with an already-screwed-up filesystem.  
I see the section in the LVM HOWTO [1], but it doesn't mention the  
sort of gotcha you're describing. I'm skeptical of LVM's  
documentation in general. It doesn't even mention RAID (md), instead  
including some incredibly stupid recipes virtually guaranteed to lose  
all your data when one disk out of many fails [2].

[1] - http://www.tldp.org/HOWTO/LVM-HOWTO/reducelv.html
[2] - http://www.tldp.org/HOWTO/LVM-HOWTO/recipeadddisk.html

Cheers,
Scott

-- 
Scott Lamb <http://www.slamb.org/>