[CentOS] OT: Fortunate clueless dd chum - lvm recovery

Sat Aug 15 01:22:14 UTC 2009
Robert Nichols <rnicholsNOSPAM at comcast.net>

Ross Walker wrote:
> On Aug 14, 2009, at 12:48 PM, Robert Nichols  
> <rnicholsNOSPAM at comcast.net> wrote:
> 
>> Ross Walker wrote:
>>> On Fri, Aug 14, 2009 at 5:00 AM, Chan Chung Hang
>>> Christopher<christopher.chan at bradbury.edu.hk> wrote:
>>>
>>> Question now is, was the first sector of partition 1 damaged (was it
>>> 63 or 64 sectors dd'd)?
>>>
>>> If so it will require a more tricky procedure to fix.
>> No, the ext2 file system does not use the first 1K block of the partition.
>> That space is left free for a boot loader.  The first super block of the
>> file system is the 2nd 1K block of the partition, and even if that gets
>> overwritten it is easily recovered from one of the backup super blocks.
> 
> I did not know that, good information.
> 
> So stage2 is written in first 1k of the partition?

No, nowhere near enough room.  Just stage 1 goes into the first sector.
The second sector is unused.  Stage 1 then loads the fs-specific stage 1.5
from absolute sector numbers on the disk.  Stage 1.5 then loads stage 2
from the file system.  (Yes, if the *_stage1_5 files get moved on the
disk, you have to re-run the GRUB installer.)

The only time more than the 446-byte stage 1 gets installed is when
installing GRUB in the MBR or in the boot sector of a logical drive in
the extended partition.  There, there can be a full track available,
which is enough room for the appropriate stage 1.5, but not for the
100+ KB of stage 2.

> Ah but I believe the OP has the partition setup as a LVM PV. Question  
> is does LVM leave the first 1k free for a stage2 boot loader?
> 
> And if the LVM metadata is corrupt is there a second copy at the end  
> of the PV?

No idea.  I don't use LVM.  Having a known recovery path if things get
munged is more important to me than the features of LVM.

-- 
Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.