#!/bin/sh
#
# Sample /linuxrc script to be used on an init-ramdisk. See the INSTALL.initrd
# instructions for creating an init-ramdisk image to use with this script.

# Mount devfs
# You should only uncomment this line if you are running devfs but do not
# have the kernel automatically mount it on /dev. See the end of this script
# for unmounting.
# mount -t devfs none /dev

# Run the devfs deamon, if devfs is present.
if [ -a /dev/.devfsd ]; then
	if [ -x /sbin/devfsd ]; then
		/sbin/devfsd /dev
	fi
fi

# Mount /proc. This is required for EVMS, so it can find Device-Mapper.
mount -t proc none /proc

# Load modules
# If you installed kernel modules to the init-ramdisk, they should be loaded
# before running EVMS. Add the appropriate modprobe calls for your modules.
# Some examples are provided here. If you didn't install any kernel modules,
# simply leave these commented-out.
#
# IDE and SCSI modules
#
# Device-Mapper modules
# /sbin/modprobe dm-mod
# /sbin/modprobe dm-bbr
# /sbin/modprobe dm-sparse
#
# MD/Software-RAID modules
# /sbin/modprobe linear
# /sbin/modprobe raid0
# /sbin/modprobe raid1
# /sbin/modprobe raid5


# Activate EVMS volumes.
/sbin/evms_activate


# Get the EVMS root volume name from the kernel command line, translate to
# a device number, and set the kernel's root device. In order for this to
# work correctly, "root=/dev/evms/Root_Volume_Name" needs to be passed to
# the kernel command line (where Root_Volume_Name is replaced by your actual
# root volume's name. See the section about LILO and Grub in the
# INSTALL.initrd file.
for name in `cat /proc/cmdline`; do
	echo $name | grep '^root=' > /dev/null
	if [ $? -eq 0 ]; then
		vol=`expr "$name" : '.*=\(.*\)'`
		break
	fi
done
if [ -n "$vol" ]; then
   dev=`/sbin/get_dev_num $vol`
   echo $dev > /proc/sys/kernel/real-root-dev
fi

# Done with /proc.
umount /proc

# Unmount devfs
# Just like at the top, you should only uncomment this line if you are
# running devfs but do not have the kernel automatically mount it on /dev.
# umount /dev

