1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
#!/bin/sh
#
# Sample /linuxrc script for an init-ramdisk to be used for activating EVMS
# volumes. See the INSTALL.initrd file in the EVMS package for instructions
# on creating an init-ramdisk image to use with this script.
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
LOG="/linuxrc:"
ERR="/linuxrc: ERROR:"
# Mount /proc.
echo "$LOG Mounting /proc"
mount -t proc none /proc
# Mount /sys if a 2.6 kernel is running.
grep -q sysfs /proc/filesystems
if [ $? -eq 0 ]; then
echo "$LOG Mounting /sys"
mount -t sysfs none /sys
fi
# Mount devfs
# You should uncomment these two lines if you are running devfs but do not
# have the kernel automatically mount it on /dev.
# mount -t devfs none /dev
# mounted_devfs=1
# Run the devfs deamon, if devfs is present.
if [ -e /dev/.devfsd ]; then
echo "$LOG Running devfsd"
devfsd /dev
fi
# Load modules
#
# By default, the sample init-ramdisk does not contain any kernel modules.
# It assumes that the kernel contains static support necessary to run all
# the tools on the init-ramdisk.
#
# If you compiled kernel features as modules that you will need during the
# init-ramdisk, you need to copy those modules to the init-ramdisk in the
# /lib/modules/ directory. You also need to add appropriate commands below
# to load those modules. The modules should be loaded before running EVMS.
#
# Some examples are provided here. If you didn't install any kernel modules,
# simply leave these commented-out.
#
# NOTE: The version of insmod used by Busybox is not yet compatible with the
# new 2.6 kernel module format. If you are running a 2.6 kernel and
# want to load modules from this initrd, you will need to copy your
# systems version of "insmod" to this initrd.
#
# Device-Mapper modules
# insmod dm-mod
# insmod dm-mirror
# insmod dm-bbr
# insmod dm-sparse
#
# MD/Software-RAID modules
# insmod md
# insmod linear
# insmod raid0
# insmod raid1
# insmod xor
# insmod raid5
# insmod multipath
# Search the kernel command line for parameters needed to mount the root
# filesystem. At a minimum, "root=/dev/evms/Root_Volume_Name" needs to be
# present (where Root_Volume_Name is replaced by your actual root volume's
# name). In addition, rootfstype= and rootflags= may be set in order to
# specify the type of the root filesystem and set any necessary mount options.
# See the section about "Mounting Your Root Filesystem Through EVMS" in the
# INSTALL file in the EVMS source package.
for name in `cat /proc/cmdline`; do
# Look for "root="
echo $name | grep -q '^root='
if [ $? -eq 0 ]; then
vol=`expr "$name" : '.*=\(.*\)'`
echo "$LOG Found root = $vol"
continue;
fi
# Look for "rootflags="
echo $name | grep -q '^rootflags='
if [ $? -eq 0 ]; then
rootflags=`expr "$name" : '.*=\(.*\)'`
echo "$LOG Found rootflags = $rootflags"
continue
fi
# Look for "rootfstype="
echo $name | grep -q '^rootfstype='
if [ $? -eq 0 ]; then
rootfstype=`expr "$name" : '.*=\(.*\)'`
echo "$LOG Found rootfstype = $rootfstype"
continue
fi
done
if [ -z "$rootfstype" ]; then
rootfstype="auto"
fi
# Activate EVMS volumes.
echo "$LOG Running evms_activate"
evms_activate
# Mount the root volume, or tell the user to mount it manually.
if [ -n "$vol" ]; then
if [ -n "$rootflags" ]; then
echo "$LOG Mounting $vol on /sysroot with options: $rootflags"
mount -t $rootfstype -o ro,$rootflags $vol /sysroot
else
echo "$LOG Mounting $vol on /sysroot with no extra options."
mount -t $rootfstype -o ro $vol /sysroot
fi
else
echo "$ERR The root volume name was not found in the kernel"
echo "$ERR command-line. I don't know which volume to mount"
echo "$ERR as root. Starting a shell, where you can mount the"
echo "$ERR root volume manually on the /sysroot directory. You"
echo "$ERR can do this with the command:"
echo "$ERR mount -o ro /dev/evms/Your_Root_Volume /sysroot"
echo "$ERR When you exit the shell, I will attempt to continue"
echo "$ERR the boot process."
sh
fi
# Check that the root volume was actually mounted.
grep -q "/sysroot" /proc/mounts
if [ $? -ne 0 ]; then
echo "$ERR The root volume has not been properly mounted. Starting"
echo "$ERR a shell. Please mount the root volume manually on the"
echo "$ERR /sysroot directory. You can do this with the command:"
echo "$ERR mount -o ro /dev/evms/Your_Root_Volume /sysroot"
echo "$ERR When you exit the shell, I will attempt to continue"
echo "$ERR the boot process."
sh
fi
# Check that there is an /initrd directory on the root-fs.
if [ ! -d /sysroot/initrd ]; then
echo "$ERR The root volume must have an '/initrd' subdirectory"
echo "$ERR for pivot_root to work, but this directory does not"
echo "$ERR exist. Starting a shell, where you can attempt to"
echo "$ERR create this directory (in /sysroot). The $vol root"
echo "$ERR volume is currently mounted read-only, so you will"
echo "$ERR need to remount read-write, create the directory, and"
echo "$ERR then remount read-only. You can use the commands:"
echo "$ERR umount /sysroot"
echo "$ERR mount -o rw /dev/evms/Your_Root_Volume /sysroot"
echo "$ERR mkdir /sysroot/initrd"
echo "$ERR umount /sysroot"
echo "$ERR mount -o ro /dev/evms/Your_Root_Volume /sysroot"
echo "$ERR When you exit the shell, I will attempt to continue"
echo "$ERR the boot process."
sh
fi
# Set the real-root-dev to /dev/ram0 (1:0).
echo 0x0100 > /proc/sys/kernel/real-root-dev
# Stop the devfs daemon
if [ -e /dev/.devfsd ]; then
echo "$LOG Stopping devfsd"
killall devfsd
fi
# Unmount devfs (if we manually mounted above).
if [ -n "$mounted_devfs" ]; then
umount /dev
fi
# Unmount /sys
grep -q sysfs /proc/mounts
if [ $? -eq 0 ]; then
echo "$LOG Unmounting /sys"
umount /sys
fi
# Unmount /proc
echo "$LOG Unmounting /proc"
umount /proc
# Pivot-root to /sysroot
echo "$LOG Pivoting root to /sysroot"
cd /sysroot
if ! pivot_root . initrd; then
echo "$ERR Failed to pivot root to /sysroot. Starting a shell"
echo "$ERR where you can attempt to fix the problem manually."
echo "$ERR When you exit the shell, I will attempt to continue"
echo "$ERR the boot process."
sh
fi
echo "$LOG Done"
|