View previous topic :: View next topic |
Author |
Message |
rasto n00b
Joined: 27 Nov 2002 Posts: 43 Location: NJ
|
Posted: Sun Nov 23, 2003 7:31 pm Post subject: problems running gentoo on hw raid1 lvm root |
|
|
on my highpoint controller, mine hid.o module wont insert.
back to my configuration.
i have 2 gentoo systems. first is on /dev/hda3 second on /dev/main/root (lvm)
i have 3 disks on my highpoint controller and 1 on motherboard controller. 2 disk on highpoint form hw raid1 drive, on which i have 2 partitions, sda1-ext2-/boot and sda2-lvm. root partition uses 12GB of that lvm space.
so, in order to boot i had to create initrd which will have hpt37x2.o driver and vgscan and vgchange to recognize root partition.
while gentoo system on hda3 uses same kernel and modules as the other on lvm space and works ok, gentoo on /dev/main/root wont insert hid.o
so i tried to put hid support into kernel, but it crashes while compiling hid.
strange isnt it?
my guess is that i have created "strange" initrd . here is how i create initrd
im not mentioning that installing grub on /boot partition destroys raid1 (thats another story, after i install grub it stops on stage 1.5 i think)
Quote: |
/sbin/mkinitrd-lvm-raid-dev_main_root
|
Code: |
cmd=`basename $0`
TMPMNT=/tmp/mnt.$$
TMPLIB=/tmp/lib.$$
USEMOD=1
PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH
#FSTAB=/etc/fstab
#ROOT_DEVICE=`awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' $FSTAB`
usage () {
echo "Create an initial ramdisk image for LVM root filesystem"
echo "$cmd: [-h] [-i] [-M] [-v] [-V] [kernel version]"
echo " -h|--help print this usage message"
echo " -i|--iop specify LVM IOP version to use"
echo " -M|--nomod do not set up module support in initrd"
echo " -D|--devfs force use of devfs"
echo " -v|--verbose verbose progress messages"
echo " -V|--version print script version and exit"
}
verbose () {
[ "$VERBOSE" ] && echo "`echo $cmd | tr '[a-z0-9/_]' ' '` -- $1" || true
}
cleanup () {
[ "`mount | grep $DEVRAM`" ] && verbose "unmounting $DEVRAM" && umount $DEVRAM
[ -f $DEVRAM ] && verbose "removing $DEVRAM" && rm $DEVRAM
[ -d $TMPMNT ] && verbose "removing $TMPMNT" && rmdir $TMPMNT
[ -d $TMPLIB ] && verbose "removing $TMPLIB" && rm -r $TMPLIB
verbose "exit with code $1"
exit $1
}
trap "
verbose 'Caught interrupt'
echo 'Bye bye...'
cleanup 1
" 1 2 3 15
create_fstab () {
if [ $DEV ]; then
cat << FSTAB > $TMPMNT/etc/fstab
/dev/ram / ext2 defaults 0 0
proc /proc proc defaults 0 0
FSTAB
else
cat << FSTAB > $TMPMNT/etc/fstab
/dev/ram / ext2 defaults 0 0
proc /proc proc defaults 0 0
devfs /dev/ devfs defaults 0 0
FSTAB
fi
chmod 644 $TMPMNT/etc/fstab
}
create_linuxrc () {
echo "#!/bin/sh" > $TMPMNT/linuxrc
[ "$LVMMOD" ] && echo "/sbin/modprobe $LVMMOD" >> $TMPMNT/linuxrc
cat << LINUXRC >> $TMPMNT/linuxrc
echo "Initial RAMDISK Loading Starting..."
echo "Loading module HighPoint module"
insmod hpt37x2
/bin/mount /proc
/sbin/vgscan
/sbin/vgchange -a y
mkdir /new_root
echo 0x0100 > /proc/sys/kernel/real-root-dev
mknod /dev/sda1 b 8 1
mknod /dev/sda2 b 8 2
mknod /dev/sda3 b 8 3
mknod /dev/hda1 b 3 1
mknod /dev/hda5 b 3 5
mknod /dev/hda3 b 3 3
echo "Mounting real root dev..."
mount -n -o ro /dev/main/root /new_root
/bin/umount /proc
cd /new_root
echo "Running pivot_root..."
pivot_root . initrd
if [ -c initrd/dev/.devfsd ]; then
echo "Mounting devfs..."
mount -n -t devfs none dev
fi
if [ $$ = 1 ]; then
echo "Running init..."
exec chroot . sbin/init dev/console 2>&1
else
echo "Using bug circumvention for busybox..."
exec chroot . sbin/linuxrc dev/console 2>&1
fi
LINUXRC
chmod 555 $TMPMNT/linuxrc
}
#
# Main
#
echo "Logical Volume Manager 1.0.7 by Heinz Mauelshagen 28/03/2003"
VERSION=`uname -r`
while [ $# -gt 0 ]; do
case $1 in
-h|--help) usage; exit 0;;
-i|--iop) IOP=$2; shift;;
-M|--nomod) USEMOD="";;
-D|--devfs) DEV="";;
-V|--version) exit 0;;
-d|-v|--debug|--verbose) VERBOSE="y";;
[2-9].[0-9]*.[0-9]*) VERSION=$1;;
*) echo "$cmd -- invalid option '$1'"; usage; exit 0;;
esac
shift
done
INITRD=${INITRD:-"/boot/initrd-lvm-raid-devmainroot-$VERSION.gz"}
MODULES=/lib/modules/$VERSION
DEVRAM=/tmp/initrd.$$
DEV=${DEV-"/dev"}
echo "$cmd -- make LVM initial ram disk $INITRD"
echo ""
# Try to see if we have devfsd running. At this point $DEV is either
# "/dev" (no devfs) or "" (devfs). If it is, reset $DEV.
if [ "$DEV" = "/dev" ] && [ -a /dev/.devfsd ]; then
verbose "devfsd running, assuming -D."
DEV=""
fi
# The size of the ramdisk is automatically calculated unless this is set
#INITRDSIZE=
# Modified by Rastislav David
# adding busybox executtable
HAVE_BUSYBOX=0
LINKS=""
if [ -r /bin/busybox ]; then
echo "$cmd -- found busybox"
INITRDFILES="/bin/busybox /sbin/vgchange /sbin/vgscan"
HAVE_BUSYBOX=1
LINKS="pivot_root mount umount mkdir sh echo"
else
INITRDFILES="/sbin/vgchange /sbin/vgscan /bin/bash /bin/mount /bin/umount /bin/sh /bin/rm"
fi
##
if [ "$USEMOD" ]; then
# Check for an LVM module, otherwise it must be compiled into the kernel
if [ -r $MODULES/kernel/drivers/md/lvm-mod.o ]; then
LVMMOD="lvm-mod"
INITRDFILES="$INITRDFILES $MODULES/kernel/drivers/md/$LVMMOD.o"
elif [ -r $MODULES/block/lvm-mod.o ]; then
LVMMOD="lvm-mod"
INITRDFILES="$INITRDFILES $MODULES/block/$LVMMOD.o"
elif [ -r $MODULES/block/lvm.o ]; then
LVMMOD="lvm"
INITRDFILES="$INITRDFILES $MODULES/block/$LVMMOD.o"
fi
if [ -x "/sbin/lsmod" ]; then
if [ HAVE_BUSYBOX ]; then
LINKS="$LINKS lsmod"
else
INITRDFILES="$INITRDFILES /sbin/lsmod"
fi
fi
if [ -x "/sbin/modprobe" ]; then
if [ HAVE_BUSYBOX ]; then
LINKS="$LINKS modprobe"
else
INITRDFILES="$INITRDFILES /sbin/modprobe"
fi
elif [ "$LVMMOD" ]; then
echo "$cmd -- have $LVMMOD but not /sbin/modprobe."
cleanup 1
fi
if [ -x "/sbin/insmod" ]; then
if [ HAVE_BUSYBOX ]; then
LINKS="$LINKS insmod"
else
INITRDFILES="$INITRDFILES /sbin/insmod"
fi
elif [ "$LVMMOD" ]; then
echo "$cmd -- have $LVMMOD but not /sbin/insmod."
cleanup 1
fi
if [ -r "$MODULES/modules.dep" ]; then
INITRDFILES="$INITRDFILES $MODULES/modules.dep"
fi
# added by Rastislav David
# checking and adding hpt37x2 module for Highpoint HW RAID into ramdisk
if [ -r $MODULES/kernel/drivers/scsi/hpt37x2.o ]; then
echo "$cmd -- Including hpt37x2 driver"
INITRDFILES="$INITRDFILES $MODULES/kernel/drivers/scsi/hpt37x2.o"
else
echo "$cmd -- ERROR dont have Highpoint driver"
cleanup 1
fi
##
fi
# If we have LVM wrapper scripts in /sbin, we need to fix this by including
# the actual executables into the initrd as well.
if [ -x /sbin/lvmiopversion ]; then
# Use the IOP version, if specified. Otherwise, if we are building for
# the current kernel or there is only one IOP version installed, use it.
if [ "$IOP" ]; then
IOP="/lib/lvm-iop$IOP"
elif [ "$VERSION" = "`uname -r`" ]; then
IOP="/lib/lvm-iop`lvmiopversion`"
elif [ `ls -d /lib/lvm-iop* | wc -w` -eq 1 ]; then
IOP="`ls -d /lib/lvm-iop*`"
fi
for FILE in $INITRDFILES; do
case $FILE in
/sbin/vg*|/sbin/lv*|/sbin/pv*)
if [ "`file $FILE 2> /dev/null | grep script`" ]; then
verbose "$FILE is a wrapper script, resolving."
if [ -z "$IOP" ]; then
echo "$cmd -- need to set LVM IOP for kernel $VERSION with '-i'."
cleanup 1
fi
NEWFILE="$IOP/`basename $FILE`"
if [ -x $NEWFILE ]; then
INITRDFILES="$INITRDFILES $NEWFILE"
else
echo "$cmd -- can't find $NEWFILE, your initrd may not work."
fi
fi ;;
esac
done
INITRDFILES="$INITRDFILES /sbin/lvmiopversion"
fi
# Figure out which shared libraries we actually need in our initrd
echo "$cmd -- finding required shared libraries"
verbose "INITRDFILES: `echo $INITRDFILES`"
SHLIBS=`ldd $INITRDFILES 2>/dev/null | awk '{if (/=>/) { print $3 }}' | sort -u`
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR figuring out needed shared libraries"
exit 1
fi
verbose "need: `echo $SHLIBS`"
# Copy shared libraries to a temp directory before stripping, so that we don't
# run out of room on the ramdisk while stripping the libraries.
echo "$cmd -- stripping shared libraries"
mkdir $TMPLIB
for LIB in $SHLIBS; do
verbose "copy $LIB to $TMPLIB$LIB"
mkdir -p `dirname $TMPLIB$LIB`
cp $LIB $TMPLIB$LIB
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR copying shared library $LIB to ram disk"
cleanup 1
fi
verbose "strip $TMPLIB$LIB"
strip $TMPLIB$LIB
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR stripping shared library $LIB"
cleanup 1
fi
done
# Calculate the number of inodes needed, and the size of the ramdisk image.
# Don't forget that inodes take up space too, as does the filesystem metadata.
echo "$cmd -- calculating initrd filesystem parameters"
verbose "counting files in: $DEV $TMPLIB \$INITRDFILES"
NUMINO="`find $DEV $TMPLIB $INITRDFILES | wc -w`"
verbose "minimum: $NUMINO inodes + filesystem reserved inodes"
NUMINO=`expr $NUMINO + 64`
if [ -z "$INITRDSIZE" ]; then
echo "$cmd -- calculating loopback file size"
verbose "finding size of: $DEV $TMPLIB \$INITRDFILES"
INITRDSIZE="`du -ck $DEV $TMPLIB $INITRDFILES | tail -1 | cut -f 1`"
verbose "minimum: $INITRDSIZE kB for files + inodes + filesystem metadata"
INITRDSIZE=`expr $INITRDSIZE + $NUMINO / 8 + 512` # enough for ext2 fs + a bit
fi
echo "$cmd -- making loopback file ($INITRDSIZE kB)"
verbose "using $DEVRAM as a temporary loopback file"
dd if=/dev/zero of=$DEVRAM count=$INITRDSIZE bs=1024 > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR creating loopback file"
cleanup 1
fi
# Ext2 can only have 8 * blocksize inodes per group, so we may need to
# increase the number of groups created if there are lots of inodes.
if [ $NUMINO -gt $INITRDSIZE ]; then
if [ $NUMINO -gt 8192 ]; then
verbose "too many inodes for one group - need to create more groups"
BPG=`expr $INITRDSIZE \* 8192 / $NUMINO`
INODE_OPT="-g `expr $BPG + 8 - $BPG % 8` -N $NUMINO"
else
INODE_OPT="-N $NUMINO"
fi
else
INODE_OPT="-i `expr $INITRDSIZE \* 1024 / $NUMINO`"
fi
echo "$cmd -- making ram disk filesystem ($NUMINO inodes)"
verbose "mke2fs -F -m0 -L LVM-$VERSION $INODE_OPT $DEVRAM $INITRDSIZE"
[ "$VERBOSE" ] && OPT_Q="" || OPT_Q="-q"
mke2fs $OPT_Q -F -m0 -L LVM-$VERSION $INODE_OPT $DEVRAM $INITRDSIZE
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR making ram disk filesystem"
echo "$cmd -- ERROR you need to use mke2fs >= 1.14 or increase INITRDSIZE"
cleanup 1
fi
verbose "creating mountpoint $TMPMNT"
mkdir $TMPMNT
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR making $TMPMNT"
cleanup 1
fi
echo "$cmd -- mounting ram disk filesystem"
verbose "mount -o loop $DEVRAM $TMPMNT"
mount -oloop $DEVRAM $TMPMNT
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR mounting $DEVRAM on $TMPMNT"
cleanup 1
fi
verbose "creating /etc /proc /lib /bin /dev in $TMPMNT"
mkdir $TMPMNT/etc $TMPMNT/proc $TMPMNT/lib $TMPMNT/dev $TMPMNT/bin
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR creating directories in $TMPMNT"
cleanup 1
fi
#ls $TMPMNT
# added by Rastislav David
# checking and adding hpt37x2 module for Highpoint HW RAID into ramdisk
echo "$cmd -- creating bin soft link for sbin"
[ "$VERBOSE" ] && OPT_Q="v" || OPT_Q=""
verbose "ln -s$OPT_Q bin sbin"
(cd $TMPMNT; ln -s bin sbin)
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR linking sbin on ram disk"
cleanup 1
fi
[ "$VERBOSE" ] && OPT_Q="-v" || OPT_Q="--quiet"
##
verbose "removing $TMPMNT/lost+found"
rmdir $TMPMNT/lost+found
if [ "$USEMOD" ]; then
#
# create new modules configuration to avoid kmod complaining
# about nonexsisting modules.
#
MODCONF=/etc/modules.conf
[ ! -r $MODCONF -a -r /etc/conf.modules ] && MODCONF=/etc/conf.modules
echo "$cmd -- creating new $MODCONF"
verbose "all block and char modules will be turned off"
MAJ=0
while [ $MAJ -lt 256 ]; do
echo "alias block-major-$MAJ off"
echo "alias char-major-$MAJ off"
MAJ=`expr $MAJ + 1`
done > $TMPMNT/$MODCONF
# to ensure, that modprobe doesn complain about timestamps
echo "$cmd -- creating new modules.dep"
depmod -a $VERSION
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR running depmod"
cleanup 1
fi
fi
# copy necessary files to ram disk
[ "$VERBOSE" ] && OPT_Q="-v" || OPT_Q="--quiet"
if [ $DEV ]; then
echo "$cmd -- copying device files to ram disk"
verbose "find $DEV | cpio -pdm $TMPMNT"
(cd $DEV; find . | cpio -pdm $OPT_Q $TMPMNT/dev)
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR cpio to ram disk"
cleanup 1
fi
fi
echo "$cmd -- copying initrd files to ram disk"
verbose "find \$INITRDFILES | cpio -pdm $OPT_Q $TMPMNT"
find $INITRDFILES | cpio -pdm $OPT_Q $TMPMNT
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR cpio to ram disk"
cleanup 1
fi
# added by Rastislav David
# checking and adding hpt37x2 module for Highpoint HW RAID into ramdisk
if [ HAVE_BUSYBOX ]; then
echo "$cmd -- creating busybox soft links for echo,mount ..."
[ "$VERBOSE" ] && OPT_Q="v" || OPT_Q=""
for i in $LINKS; do
verbose "ln -s$OPT_Q busybox $i"
(cd $TMPMNT/bin; ln -s busybox $i)
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR linking files on ram disk"
cleanup 1
fi
done
[ "$VERBOSE" ] && OPT_Q="-v" || OPT_Q="--quiet"
fi
##
#ls $TMPMNT/bin
echo "$cmd -- copying shared libraries to ram disk"
verbose "find $TMPLIB | cpio -pdm $OPT_Q $TMPMNT"
(cd $TMPLIB; find * | cpio -pdm $OPT_Q $TMPMNT)
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR copying shared libraries to ram disk"
cleanup 1
fi
echo "$cmd -- creating new /linuxrc"
create_linuxrc
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR creating linuxrc"
cleanup
exit 1
fi
echo "$cmd -- creating new /etc/fstab"
#create_fstab
cp -a /etc/fstab $TMPMNT/etc
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR creating /etc/fstab"
cleanup 1
fi
echo "$cmd -- ummounting ram disk"
umount $DEVRAM
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR umounting $DEVRAM"
cleanup 1
fi
echo "$cmd -- creating compressed initrd $INITRD"
verbose "dd if=$DEVRAM bs=1k count=$INITRDSIZE | gzip -9"
dd if=$DEVRAM bs=1k count=$INITRDSIZE 2>/dev/null | gzip -9 > $INITRD
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR creating $INITRD"
cleanup 1
fi
cleanup 0
|
|
|
Back to top |
|
|
cyrillic Watchman
Joined: 19 Feb 2003 Posts: 7313 Location: Groton, Massachusetts USA
|
Posted: Mon Nov 24, 2003 12:13 am Post subject: |
|
|
rasto wrote: | im not mentioning that installing grub on /boot partition destroys raid1 (thats another story, after i install grub it stops on stage 1.5 i think) |
I'm not sure about your other problems, but the GRUB / Highpoint conflict is easy to fix.
The Highpoint BIOS uses sector 9 on the harddrives to store RAID array info, GRUB's stage 1.5 overwrites this area of the drive, and destroys the array in the process. The workaround is to delete GRUB's *stage1_5 files from /boot/grub before you run GRUB's setup (hd0) command. Luckily stage 1.5 is optional, and GRUB works just fine without it. |
|
Back to top |
|
|
rasto n00b
Joined: 27 Nov 2002 Posts: 43 Location: NJ
|
Posted: Mon Nov 24, 2003 12:56 am Post subject: thanx for help on grub |
|
|
really makes my life easier. now I dont need to have disk on motherboard anymore (maybe after I install steam into wine(x) ill get rid of windows 98 too |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|