[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[debian-knoppix] initrd-tools bug?



Hi,

I have a "Debian" originally installed from a Knoppix CD (3.2 I think)
and want to install a new kernel: kernel-image-2.4.23-1-686.
But when booting it (with grub), there is a kernel panic.

I guess when apt-getting it, mkinitrd is called and
/boot/initrd.img-2.4.23-1-686 is created (I am a newbie considering
initrd stuff and booting in common).  So I read man pages and changed
files and rebooted dozens of times and I got things working up to a
stage where I think the file "init" in /usr/share/initrd-tools is
broken.  First I think, /usr/share/initrd-tools/linuxrc is broken: when
booting there were errors that seem to be solved by removing the "-n"
option to mount and umount (mount says it is a builtin command and that
/etc/mtab is not supported anyway).  This advances the boot process a
big step further (lots of messages on the console).  But it comes to a
halt saying

/sbin/init: 9: syntax error: ";" unexpected

and indeed init looks wrong in a couple of places where there are for
loops like

for i; do
 ...
done

and this is where I stopped digging and decided to post to this list :).

Hope you can help me, advTHANKSance, Thomas.


Package info and my init file follow below:


> dpkg -p initrd-tools
Package: initrd-tools
Priority: optional
Section: utils
Installed-Size: 160
Maintainer: Herbert Xu <herbert@debian.org>
Architecture: all
Version: 0.1.56
Depends: coreutils | fileutils (>= 4.1.9) | stat (>= 3.0), cpio,
cramfsprogs (>= 1.1-4), dash | ash, util-linux (>= 2.11b-3)
Size: 22088
[...]


> cat /usr/share/initrd-tools/init
#!/bin/sh
#
# $Id: init,v 1.38 2003/12/06 03:31:15 herbert Exp $

mount_device() {
	unset flags fstype
	set -f
	set +f $cmdline
	for i; do
		case "$i" in
		rootflags=*)
			flags=${i#rootflags=}
			;;
		rootfstype=*)
			fstype=${i#rootfstype=}
			;;
		esac
	done
	if [ -n "$fstype" ]; then
		mount -n${ro}t "$fstype" ${flags:+-o "$flags"} $device /mnt
		return
	fi
	IFS=,
	set -f
	set +f -- $FSTYPES auto
	unset IFS
	for i; do
		mount -n${ro}t "$i" ${flags:+-o "$flags"} $device /mnt &&
			break
	done
}

try_name() {
	[ -f /sys/block/$1/dev ] || return 1
	read dev < /sys/block/$1/dev
	case $dev in
	*:*)
		minor=${dev#*:}
		major=${dev%:*}
		;;
	*)
		minor=$((0x${dev#??}))
		major=$((0x${dev%??}))
		;;
	esac
	if ! [ $2 ]; then
		return
	fi

	[ -f /sys/block/$1/range ] || return 1
	read range < /sys/block/$1/range
	[ $2 -lt $range ] || return 1
	minor=$(($minor + $2))
}

get_sysfs_device() {
	case $ROOT in
	/dev/*)
		;;
	*)
		return
		;;
	esac

	IFS=/
	set -f
	set +f ${ROOT#/dev/}
	IFS=.
	root=$*
	unset IFS
	try_name "$root" && return

	part=${root##*[!0-9]}
	root=${root%$part}
	if [ -z "$root" ]; then
		return
	fi
	try_name "$root" $part && return

	case $root in
	*[0-9]p)
		;;
	*)
		return 0
		;;
	esac
	try_name "${root%p}" $part
	return 0
}

get_device() {
	major=$(($rootdev >> 8))
	minor=$(($rootdev & 255))
	if [ $rootdev -eq 0 ] || [ $major -eq 58 ] || [ $major -eq 254 ]; then
		if [ -b "$ROOT" ]; then
			device=$ROOT
			return
		fi
		if mount -nt sysfs sysfs sys > /dev/null 2>&1; then
			get_sysfs_device
			umount -n sysfs
		fi
	fi
	mknod dev2/root2 b $major $minor
	device=/dev2/root2
}

mount_root() {
	mount -nt proc proc proc
	mount -nt tmpfs tmpfs dev2
	mount -nt devfs devfs devfs
	get_device
	mount_device
	umount -n devfs
	umount -n dev2
	umount -n proc
}

get_cmdline() {
	init=/sbin/init
	root=
	ide_options=
	ro=r
	for i in $(cat proc/cmdline); do
		case $i in
		init=*)
			init=${i#init=}
			;;
		root=*)
			root=${i#root=}
			;;
		ide*= | hd[!=]*=)
			ide_options="$ide_options $i"
			;;
		ro)
			ro=r
			;;
		rw)
			ro=
			;;
		esac
	done
	case $root in
	/dev/*)
		ROOT=$root
		;;
	esac
}

ide_module_to_driver() {
	ret=$1
	case $ret in
	aec62xx)
		ret='AEC62xx IDE'
		;;
	alim15x3)
		ret='ALI15x3 IDE'
		;;
	amd74xx)
		ret='AMD IDE'
		;;
	cmd64x)
		ret='CMD64x IDE'
		;;
	cs5520)
		ret='CyrixIDE'
		;;
	cs5530)
		ret='CS5530 IDE'
		;;
	cy82c693)
		ret='Cypress IDE'
		;;
	generic)
		ret='PCI IDE'
		;;
	hpt34x)
		ret='HPT34x IDE'
		;;
	hpt366)
		ret='HPT366 IDE'
		;;
	it8172)
		ret='IT8172IDE'
		;;
	ns87415)
		ret='NS87415IDE'
		;;
	opti621)
		ret='Opti621 IDE'
		;;
	pdc202xx_new)
		ret='Promise IDE'
		;;
	pdc202xx_old)
		ret='Promise Old IDE'
		;;
	piix)
		ret='PIIX IDE'
		;;
	rz1000)
		ret='RZ1000 IDE'
		;;
	sc1200)
		ret='SC1200 IDE'
		;;
	serverworks)
		ret='Serverworks IDE'
		;;
	siimage)
		ret='SiI IDE'
		;;
	sis5513)
		ret='SIS IDE'
		;;
	sl82c105)
		ret='W82C105 IDE'
		;;
	slc90e66)
		ret='SLC90e66 IDE'
		;;
	triflex)
		ret='TRIFLEX IDE'
		;;
	trm290)
		ret='TRM290 IDE'
		;;
	via82cxxx)
		ret='VIA IDE'
		;;
	esac
}

unload_unused_ide() {
	oldstyle=$1
	shift

	if ! [ $oldstyle ]; then
		mount -nt sysfs sysfs sys
	fi

	for i; do
		if [ $oldstyle ]; then
			modprobe -r $i > /dev/null 2>&1
			continue
		fi

		ide_module_to_driver $i
		if [ -z "$ret" ]; then
			continue
		fi

		set -- /sys/bus/pci/drivers/"$ret"/*:*
		if [ ! -h "$1" ]; then
			modprobe -r $i
		fi
	done

	if ! [ $oldstyle ]; then
		umount -n sysfs
	fi
}

call() {
	. "$@"
}

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

. /linuxrc.conf

echo "initrd-tools: $VERSION"

read root < tmp/root
umount -n tmp
mount -nt proc proc proc
echo $root > proc/sys/kernel/real-root-dev

get_cmdline

[ -c /dev/.devfsd ] && DEVFS=yes

mount -nt devfs devfs devfs
if [ -n "$ide_options" ]; then
	echo modprobe -k ide-mod "options=\"$ide_options\""
	modprobe -k ide-mod options="$ide_options"
fi
call /loadmodules

if [ $DELAY -gt 0 ]; then
	echo "Waiting for $DELAY seconds, press ENTER to obtain a shell."

	trap "timeout=yes" USR1
	timeout=
	{ sleep $DELAY; kill -USR1 $$ 2> /dev/null; }&
	pid=$!
	read line
	trap "" USR1
	kill $pid
	wait

	[ $timeout ] || exec sh
fi

call /script
umount -n devfs

umount -n proc

for i in /scripts/*; do
	[ -f "$i" ] || continue
	case "$i" in
	*.sh)
		(. $i)
		;;
	*)
		$i
		;;
	esac
done

cd /
mount -nt proc proc proc
rootdev=$(cat proc/sys/kernel/real-root-dev)
cmdline=$(cat /proc/cmdline)
umount -n proc
if [ $rootdev != 256 ]; then
	mount_root
	cd mnt
	[ $DEVFS ] && mount -nt devfs devfs dev
	pivot_root . initrd
fi
if ! [ -x ${init#/} ]; then
	init=/sbin/init
fi
if type chroot > /dev/null 2>&1; then
	exec chroot . $init "$@" < dev/console > dev/console 2>&1
fi
exec $init "$@" < dev/console > dev/console 2>&1


-- 
Thomas Maier <Thomas.Maier@uni-kassel.de>


_______________________________________________
debian-knoppix mailing list
debian-knoppix@linuxtag.org
http://mailman.linuxtag.org/mailman/listinfo/debian-knoppix


Reply to: