[svlug] As requested, "lilo.raid" script for software RAID-1 ...

Bryan -TheBS- Smith thebs at theseus.com
Tue May 30 12:09:27 PDT 2000


As requested, "lilo.raid" script for software RAID-1 ...

Purpose/Use:
  To make setting up a mirror /boot partition and lilo.conf
    *** TOTALLY TRANSPARENT ***
  I.e., Setup /boot and /etc/lilo.conf as usual, but run
    this script (lilo.raid) *IN PLACE OF* /sbin/lilo.

Conditions:
  1.  You have either the RAID modules loaded in a root ramdisk
        (see man mkinitrd) *OR* compiled into the kernel
  2.  There is a /boot partition on each disk, at the same
        partition (e.g., /dev/hda2 and /dev/hdc2)
  3.  You have a working /etc/lilo.conf for the first disk        
        (and it writes to the beginning of the disk/MBR itself)

What it does:
  1.  Mounts both /boot filesystems (see "CONSTANTS" below)
        (NOTE:  "noauto" for /boot fses are REQUIRED!)
  2.  Creates a 2nd lilo.conf for the second disk
        (you can name it -- see "CONSTANTS" below)
      With the following 2 modifications:
        A.  Remapps BIOS disk 0x80 to 2nd disk
          (so LILO can boot without 1st -- required at top)
        B.  Sed replaces three "CONSTANTS" as defined below
  3.  Installs the respective LILO to the MBR of each disk


--- BEGIN SCRIPT ---

#!/bin/sh
#
#	/root/bin/lilo.raid
#	$Id: lilo.raid,v 1.2 2000/03/19 06:40:57 root Exp root $
#

#############################################################################
#	CONSTANTS (change for your configuration)
#############################################################################

#	Hard Drive Devices (all parts except /boot can be in md devices)
#============================================================================
_HD0=/dev/hda
_HD1=/dev/hdc                   # Good idea to keep on separate IDE channel
                                # (if disks are IDE, can use with SCSI too ;-)

#	Partition Mounts (must exist in /etc/fstab and set to noauto)
#============================================================================
_MOUNT0=/boot
_MOUNT1=/boot.1                 # Note:  Files will be copied and mirrored
                                #        from /boot each time this is run

#	LILO Configuration Files
#============================================================================
_LILO0=/etc/lilo.conf
_LILO1=/etc/lilo.1.conf		# Note:  This WILL be created for you

#############################################################################
#	SCRIPT
#############################################################################

#	Mount Partitions
#============================================================================
/bin/mount ${_MOUNT0}
/bin/mount ${_MOUNT1}

#	Mirror Partition
#============================================================================
/bin/rm -r ${_MOUNT1}/*
cd ${_MOUNT0}
/usr/bin/find . -depth -mount -print | /bin/cpio -pmdv ${_MOUNT1}
cd /

#	Mirror lilo.conf
#============================================================================
/bin/rm ${_LILO1}
#	Prefix Device/BIOS Remapping for Drive 1 when Drive 0 is down
#----------------------------------------------------------------------------
echo " " > ${_LILO1}
echo "disk=${_HD1}" >> ${_LILO1}
echo "    bios=0x80" >> ${_LILO1}
echo " " >> ${_LILO1}
#	Substitute devices
#----------------------------------------------------------------------------
sed -e 's|'${_HD0}'|'${_HD1}'|' -e 's|'${_MOUNT0}'|'${_MOUNT1}'|' \
	${_LILO0} >> ${_LILO1}

#	Install Both LILOs
#============================================================================
/sbin/lilo -C ${_LILO0}
/sbin/lilo -C ${_LILO1}

#	Unmount Partitions
#============================================================================
/bin/umount ${_MOUNT0}
/bin/umount ${_MOUNT1}

--- END SCRIPT ---

-- 
 Bryan "TheBS" Smith -- Engineer, IT Professional and Hacker
      E-mail:  mailto:thebs at theseus.com,b.j.smith at ieee.org
  Disclaimer:  http://www.SmithConcepts.com/legal.html
*************************************************************
  TheBS ... Serving E-mail filters to /dev/null since 1989






More information about the svlug mailing list