- improved nfsroo parsing

- added rootdelay and rootfstype bootargs
- document this changes
- initrd-tools backward compatible mdadm assembe and then run mdrun
- update-initramfs really checkout use_bootloader from /etc/kernel-img.conf
- tighter klibc deps
This commit is contained in:
maximilian attems 2006-08-23 09:22:54 +02:00
parent d1d6763409
commit fabe918dee
11 changed files with 196 additions and 30 deletions

13
debian/NEWS vendored
View File

@ -1,3 +1,16 @@
initramfs-tools (0.76) unstable; urgency=low
* This release features nfs auto detection in the initramfs.
The boot paramaters are parsed according to the linux source
Documentation/kernel-parameters.txt and more specifically
Documentation/nfsroot.txt.
The initramfs-tools(8) manpage documents the parsed boot parameter.
Note that the undocumented and non compliant nfsoption bootarg got
dropped.
-- maximilian attems <maks@sternwelten.at> Wed, 23 Aug 2006 08:47:26 +0200
initramfs-tools (0.61) unstable; urgency=low
* This release moves the initramfs-tools confdir from /etc/mkinitramfs to

39
debian/changelog vendored
View File

@ -1,3 +1,42 @@
initramfs-tools (0.76) unstable; urgency=medium
* debian/control: Tighten klibc to 1.4.19-2 for fixed nuke. (closes: 383730)
* mkinitramfs: Only hard code root when root arg got passed.
* init: Parse /proc/cmdline for rootfstype, initrd-tools did it too.
* init: Parse /proc/cmdline for rootdelay.
* scripts/local: Use eventual rootfstype and rootdelay info.
* initramfs-tools.8: Add more docs about boot args, s/2.6.15/2.6.17/.
* scripts/functions: Simplify parse_numeric() by arithmetic calculation,
instead of working on it's representation. Thanks to tarski.
(launchpad.net/21759) Much more elegant than the 0.58 version fix.
* mkinitramfs: Parse rootraid for sarge compatibility and pass the info
to the initramfs if etch mdadm is not yet installed.
* scripts/local-top/mdrun: Assemble the root raid first before mdrun.
Thanks martin f krafft <madduck@debian.org>. (closes: 383908, 384063)
* update-initramfs: Check if /etc/kernel-img.conf is readable,
before attempting to parse also check for the right field.
* init: Check for root=/dev/nfs. Parse ip kernel command line for nfsroot.
Drop undocumented and not compliant nfsopts.
* scripts/nfs: Add ip parsing conforming to Documentation/nfsroot.txt.
Use the nfsroot bootparam in combination with eventual ip provided
device or server-ip. Do minor code cleanups. Both items based on patches
by Vagrant Cascadian <vagrant+bugs@freegeek.org>. (closes: 380649)
* Set urgency medium due to large number of serious bug fixes.
-- maximilian attems <maks@sternwelten.at> Wed, 23 Aug 2006 08:17:51 +0200
initramfs-tools (0.75) unstable; urgency=high
* hook-functions: Add megaraid_sas to the scsi list. Thanks Kenshi Muto

2
debian/control vendored
View File

@ -8,7 +8,7 @@ Standards-Version: 3.7.2.0
Package: initramfs-tools
Architecture: all
Depends: klibc-utils (>= 1.4.11-1), busybox (>= 1:1.01-3) | busybox-cvs-static (>= 20040623-1), cpio, module-init-tools, udev (>= 0.086-1)
Depends: klibc-utils (>= 1.4.19-2), busybox (>= 1:1.01-3) | busybox-cvs-static (>= 20040623-1), cpio, module-init-tools, udev (>= 0.086-1)
Provides: linux-initramfs-tool
Description: tools for generating an initramfs
This package contains tools to create and boot an initramfs for packaged 2.6

13
init
View File

@ -59,19 +59,28 @@ for x in $(cat /proc/cmdline); do
UUID=*)
ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
;;
/dev/nfs)
BOOT=nfs
;;
esac
;;
rootflags=*)
ROOTFLAGS="-o ${x#rootflags=}"
;;
rootfstype=*)
ROOTFSTYPE="${x#rootfstype=}"
;;
rootdelay=*)
ROOTDELAY="${x#rootdelay=}"
;;
cryptopts=*)
cryptopts="${x#cryptopts=}"
;;
nfsroot=*)
NFSROOT="${x#nfsroot=}"
;;
nfsopts=*)
NFSOPTS="-o ${x#nfsopts=}"
ip=*)
IPOPTS="${x#ip=}"
;;
boot=*)
BOOT=${x#boot=}

View File

@ -1,4 +1,4 @@
.TH INITRAMFS-TOOLS 8 "Date: 2005/12/06" "" "mkinitramfs script overview"
.TH INITRAMFS-TOOLS 8 "Date: 2006/08/19" "" "mkinitramfs script overview"
.SH NAME
initramfs-tools \- an introduction to writing scripts for mkinitramfs
@ -29,18 +29,44 @@ arguments which influence the boot procedure:
.SS Boot options
The init and root are usually passed by the boot loader for local boot.
The other parameters are optional.
.TP
\fB \fI init
the binary to hand over execution to on the root fs after the initramfs scripts are done.
.TP
\fB \fI root
the device node to mount as the rootfs.
the device node to mount as the root file system.
.TP
\fB \fI rootdelay
set delay in seconds. Determines how long mountroot waits for root to appear.
.TP
\fB \fI rootflags
set the file system mount option string.
.TP
\fB \fI rootfstype
set the root file system type.
.TP
\fB \fI nfsroot
can be either "auto" to try to get the relevant information from DHCP or a
string of the form NFSSERVER:NFSPATH
string of the form NFSSERVER:NFSPATH or NFSSERVER:NFSPATH:NFSOPTS.
Use root=/dev/nfs for NFS to kick to in.
.TP
\fB \fI ip
tells how to configure the ip adress. Allows to specify an different
NFS server than the DHCP server. See Documentation/nfsroot.txt in
any recent linux source for details. Optional paramater for NFS root.
.TP
\fB \fI cryptopts
passes the args for cryptoroot. Set by the cryptsetup boot hooks.
.TP
\fB \fI boot
@ -50,27 +76,33 @@ either local or NFS (affects which initramfs scripts are run, see the "Subdirect
\fB \fI resume
On install initramfs-tools tries to autodetect the resume partition. On success
the RESUME variable is written to /etc/initramfs-tools/conf.d/resume.
The boot variable overrides it.
The boot variable noresume overrides it.
.TP
\fB \fI quiet
reduces the amount of text output to the console during boot
reduces the amount of text output to the console during boot.
.TP
\fB \fI ro
mounts the rootfs read-only
mounts the rootfs read-only.
.TP
\fB \fI rw
mounts the rootfs read-write
mounts the rootfs read-write.
.TP
\fB \fI panic
sets an timeout on panic. Currently only zero value supported.
.TP
\fB \fI debug
generates lots of output to /tmp/initramfs.debug
generates lots of output to /tmp/initramfs.debug.
.TP
\fB \fI break
spawns a shell in the initramfs image at chosen run-time
(top, modules, premount, mount, bottom, init).
The default is premount without any arg.
.SH HOOK SCRIPTS
@ -404,7 +436,7 @@ to double-check if it contains the relevant binaries, libs or modules:
.nf
mkdir tmp/initramfs
cd tmp/initramfs
gunzip -c -9 /boot/initrd.img-2.6.15-1-686 | \\
gunzip -c -9 /boot/initrd.img-2.6.17-2-686 | \\
cpio -i -d -H newc --no-absolute-filenames
.fi
.RE

View File

@ -209,7 +209,11 @@ for i in ${EXTRA_CONF}; do
copy_exec "/usr/share/initramfs-tools/conf.d/${i}" /conf/conf.d
fi
done
echo "ROOT=${ROOT}" > ${DESTDIR}/conf/conf.d/root
# ROOT hardcoding
if [ -n "${ROOT}" ]; then
echo "ROOT=${ROOT}" > ${DESTDIR}/conf/conf.d/root
fi
# Busybox
if [ "x${BUSYBOX}" = "xn" ]; then
@ -233,7 +237,18 @@ run_scripts "${CONFDIR}"/hooks
# FIXME: Remove this Raid block after Etch releases
if [ -x /sbin/mdadm -a ! -f /usr/share/initramfs-tools/hooks/mdadm ]; then
mdadm --examine --scan > $DESTDIR/conf/mdadm.conf
# use mkinitrd magic for Sarge backwards compat
rootraiddev="$(df / | sed -rne 's,^(/dev/[^[:space:]]+).*,\1,p')"
echo "rootraiddev=${rootraiddev}" > /conf/mdadm.conf
mdadm=$(mdadm --detail "${rootraiddev}")
echo "${mdadm}" | awk '
$1 == "Number" && $2 == "Major" { start = 1; next }
$1 == "UUID" { print "uuid=" $3; next }
!start { next }
$2 == 0 && $3 == 0 { next }
{ devices = devices " " $NF }
END { print "devices='\''" devices "'\''" }' \
>> /conf/mdadm.conf
copy_exec /sbin/mdadm /sbin
copy_exec /sbin/mdrun /sbin
for x in md linear multipath raid0 raid1 raid456 raid5 raid6 raid10; do

View File

@ -224,13 +224,10 @@ parse_numeric() {
minor=${1#*:}
major=${1%:*}
;;
[0-9][0-9][0-9])
minor=$((0x${1#?}))
major=$((0x${1%??}))
;;
*)
minor=$((0x${1#??}))
major=$((0x${1%??}))
value=$(( 0x${1} ))
minor=$(( ${value} % 256 ))
major=$(( ${value} / 256 ))
;;
esac

View File

@ -11,11 +11,18 @@ mountroot ()
# to deal with removable devices
if [ ! -e "${ROOT}" ]; then
log_begin_msg "Waiting for root file system..."
# Default delay is 180s
if [ -z "${ROOTDELAY}" ]; then
slumber=180
else
slumber=${ROOTDELAY}
fi
if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "TIMEOUT 180" || true
/sbin/usplash_write "TIMEOUT ${slumber}" || true
fi
slumber=1800
slumber=$(( ${slumber} * 10 ))
while [ ${slumber} -gt 0 -a ! -e "${ROOT}" ]; do
/bin/sleep 0.1
slumber=$(( ${slumber} - 1 ))
@ -38,8 +45,12 @@ mountroot ()
panic "ALERT! ${ROOT} does not exist. Dropping to a shell!"
done
# Get the root filesystem type
eval $(fstype < ${ROOT})
# Get the root filesystem type if not set
if [ -z "${ROOTFSTYPE}" ]; then
eval $(fstype < ${ROOT})
else
FSTYPE=${ROOTFSTYPE}
fi
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
run_scripts /scripts/local-premount

View File

@ -36,6 +36,11 @@ done
[ "${gotraid}" = y ] || exit
# Assemble all raid devices
# FIXME: assemble root raid first due to initrd-tools compatibility
# source the presumed root md and it's info
. ./conf/mdadm.conf
# assemble root raid first due to initrd-tools compatibility
mdadm -A ${rootraiddev} -R -u $uuid $devices
# assemble all raid devices
/sbin/mdrun /dev

View File

@ -13,13 +13,57 @@ mountroot ()
# For DHCP
modprobe -q af_packet
ipconfig ${DEVICE}
# support ip options see linux sources Documentation/nfsroot.txt
case ${IPOPTS} in
none|off)
# Do nothing
;;
""|on|any)
# Bring up device
ipconfig ${DEVICE}
;;
dhcp|bootb|rarp|both)
ipconfig -c ${IPOPTS} -d ${DEVICE}
;;
*)
ipconfig -d $IPOPTS
# grab device entry from full line
NEW_DEVICE=${IPOPTS#*:*:*:*:*:*}
NEW_DEVICE=${NEW_DEVICE%:*}
if [ -n "${NEW_DEVICE}" ]; then
DEVICE="${NEW_DEVICE}"
fi
# grab server-ip
SERVER_IP=${IPOPTS#*:}
SERVER_IP=${SERVER_IP%:*:*:*:*:*:*}
;;
esac
# FIXME: who writes that?
. /tmp/net-${DEVICE}.conf
# get nfs root from dhcp
if [ "x${NFSROOT}" = "xauto" ]; then
NFSROOT=${ROOTSERVER}:${ROOTPATH}
# nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
elif [ -n "${NFSROOT}" ]; then
# nfs options are an optional arg
if [ "${NFSROOT#*,}" != "${NFSROOT}" ]; then
NFSOPTS="-o ${NFSROOT#*,}"
fi
NFSROOT=${NFSROOT%%,*}
# server-ip could be passed by ip
if [ "${NFSROOT#*:}" = "$NFSROOT" ]; then
if [ -n "${SERVER_IP}" ]; then
NFSROOT="${SERVER_IP}:${NFSROOT}"
else
NFSROOT=${ROOTSERVER}:${ROOTPATH}
fi
fi
fi
if [ "x${NFSOPTS}" = "x" ]; then
if [ -z "${NFSOPTS}" ]; then
NFSOPTS="-o retrans=10"
fi

View File

@ -2,6 +2,7 @@
STATEDIR=/var/lib/initramfs-tools
BOOTDIR=/boot
KPKGCONF=/etc/kernel-img.conf
set -e
@ -96,8 +97,8 @@ run_bootloader()
{
if [ -x /sbin/grub -o -e /boot/grub/menu.lst ]; then
if [ -e /etc/lilo.conf ]; then
do_b=$(awk '/bootloader/{print $2}' \
/etc/kernel-img.conf)
[ -r "${KPKGCONF}" ] && \
do_b=$(awk '/bootloader/{print $3}' "${KPKGCONF}")
if [ "${do_b}" = "yes" ] || [ "${do_b}" = "Yes" ] \
|| [ "${do_b}" = "YES" ]; then
run_lilo