Home Join! Events PING! Committee Directory



Preparing for the recovery of an LVM system

These are procedures to ensure that the system's data and configuration are recoverable in the event of a system failure.

  1. Load any patches for LVM.
  2. Regularly back up your entire system.

    Without a valid backup, you run a real chance of losing some or all of your data. Ensure that you back up ALL of your important data, including the operating system directories such as:

                     /etc  and so on.
    In addition, regularly test that your backups are working by restoring a test file randomly from your backups. It is risky to assume that your backup is working because it is not logging any errors. Many backup utilities have the capability to do some sort of validation of the backup media. For example, fbackup has the -N option that can allow you to check for discrepancies between backup indices and what is actually on the tape. Refer to the fbackup(1M) man page for more information.

    Use COPYUTIL, if possible, too.

  3. Back up the important files separately.

    Take an extra copy of the very important files, preferably to another system as well as to another tape. This will speed up recovery in the event of a system crash. The files that should be backed up are:


    There are many other important files on your system that you may wish to back up separately. The files listed above are required to ensure a smooth system recovery.

  4. Regularly print out the configuration of your system.

    The configuration details stored on the system may not be accessible during a recovery. A printed copy is an invaluable reference. We recommend printing the configuration details once a week and every time a change is made. One thing to note is that some of the commands outlined below create large amounts of output. An alternative to printing them is to output the information to a file and then storing the file off to tape. This allows quick recovery of the information when needed. You could include this configuration file with the backup in step 3.

    The easiest way to save the configuration is to set up a cron job to run regularly, so that even if you don't remember to do it, the system will.

    The output from the following commands is recommended:

         /usr/sbin/ioscan  -fk
         /usr/sbin/vgdisplay  -v
         /usr/sbin/lvlnboot  -v
         /usr/sbin/lvdisplay -v /dev/vgXX/lvYY 
          (for every logical volume)
         /usr/sbin/pvdisplay  -v  /dev/dsk/c#t#d0
          (for every LVM disk)
         lp /etc/fstab

    As an alternative, an intelligent script can be written that will detect any changes in the configuration and only print out those changes. An example script is included at the end of this appendix.

  5. Backup the LVM configuration after every change.

    The vgcfgbackup command copies the LVM headers from the system area of the disk to a disk file, which by default resides in the /etc/lvm.conf directory. Once this information is in a disk file it can be stored to tape during backups of the file system.

    This information in this file allows you to replace the LVM headers on the disk in the event of the disk being replaced, or if your LVM configuration becomes corrupted.

    It is very important that you make these configuration backups whenever you make a change to any part of the LVM configuration.

    This is another task that should be done on a regular basis, whether you have made changes or not. It can be done with a cron job, just prior to the time of a normal backup. The command to use is:

           /etc/vgcfgbackup /dev/vgXX
            (for every volume group)
  6. Update the boot structures after every change to the root volume group.

    This task is only required if you are using LVM on your boot disk. Whenever you make changes to the root volume group, which is usually named /dev/vg00, you MUST update the Boot Disk Reserved Area (BDRA) on the boot disk. To do this issue the following command:

                    /etc/lvlnboot -R

Example script for LVM configuration recording


WORKDIR=/lvmbackup  # directory is regularly backed up,
                    # of course

if [ -f "$LOG" ]
        rm -f "$LOG"

if [ ! -d "$WORKDIR" ]
        echo "missing directory $WORKDIR"
        exit 1


/usr/sbin/vgdisplay -v > vgdisplay.new

LVMVGS=`grep "VG Name" vgdisplay.new | sort -u | cut -c 25-45`
LVMPVOLS=`grep "PV Name" vgdisplay.new | sort -u | cut -c 27-46`
LVMLVOLS=`grep "LV Name" vgdisplay.new | sort -u | cut -c 27-49`

/usr/sbin/pvdisplay -v $LVMPVOLS > pvdisplay.new

/usr/sbin/lvdisplay -v $LVMLVOLS > lvdisplay.new

/usr/sbin/lvlnboot -v > lvlnboot.new 2> /dev/null

/usr/sbin/ioscan -fk > ioscan.new

cp /etc/fstab fstab.new

for CURRENT in *new.

   if diff $CURRENT $ORIG > /dev/null
     # files are the same....do nothing
     rm $CURRENT
     # files differ...make the new file the current file,
     # move old one to file.old.

     echo `date` "The config for $ORIG has changed." >> $LOG
     echo "Copy of the new $ORIG config has been printed" >> $LOG

     lp $CURRENT
     mv $ORIG ${ORIG}old.
     mv $CURRENT $ORIG

if [ -s "$LOG" ]
        mailx -s "LVM configs have changed" $SYSADM < $LOG

exit 0