> > Why I am afraid of the "semi-official" clone method: 
> > mounting the DASD where I copied the system and wanting to change 
> > configuration files this way may be risky because the home 
> > system and the mounted system both have the very same LogVol-setup.
> > Same setup, meaning also same names/labels.  
> 
> Yet another reason not to have your root file system on a 
> logical volume.

LVM2 is sophisticated enough (at least for SLES10 SP1, which is our
current supported release) that having multiple objects with the same
names will cause it to fail in a predictable and easily recoverable
manner, so long as the UUIDs differ. 

To that end, we employ an init script early in the boot process to
generate new pv and vg UUIDs if it detects that this is a newly-cloned
machine:

---(begin)

#! /bin/bash
#
# - post cloning housework
#
### BEGIN INIT INFO
# Provides:       boot.lvmunclone
# Required-Start: boot.proc boot.udev boot.device-mapper
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:  B
# Default-Stop:
# Description:    Guarantee unique LVM UUIDs on vgroot after cloning
### END INIT INFO

[ "$1" != "start" ] && exit 0

VG=vgroot

# sed, awk, and grep are all in /bin, dynamically linked with libc in
/lib64
# no need for /usr to be mounted, just for the dynamic loader to work

VM00=`awk '/VM00 Name/ { print $NF }' /proc/sysinfo`
TAGS=`vgs --noheadings -o vg_tags ${VG} | sed -e 's/,/ /g'`

case ${TAGS} in
*${VM00}*)
        # VG tagged with VM00 Name, no work needed
        exit 0
        ;;
*)
        echo "Regenerating LVM UUIDs (${VG})."

        for dev in `pvdisplay -c | awk -F':' "/:${VG}:/ { print \\$1 }"`
; do
                pvchange -u ${dev}
        done

        vgchange -u ${VG}

        for tag in ${TAGS} ; do
                vgchange --deltag ${tag} ${VG}
        done

        vgchange --addtag ${VM00} ${VG}
        ;;
esac

---(end)

Note that in our setup the only LVs in vgroot are for /opt and /var. /
is a non-LVM partition, and /usr is not separate (despite the comment in
the script). So far having LVs with duplicate UUIDs has not seemed to
cause any real problem---it's just PVs and VGs that really want to be
changed.

Perhaps something here will be useful to somebody.

ok
r.

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to