initramfs-tools: sync code with upstream 0.98.5.

This commit is contained in:
Juan RP 2010-11-10 23:22:48 +01:00
parent 9ee7b7cfa6
commit 0e4a1d574e
9 changed files with 263 additions and 199 deletions

View file

@ -73,6 +73,7 @@ manual_add_modules()
if [ ! -e /proc/modules ] ; then if [ ! -e /proc/modules ] ; then
continue continue
fi fi
if grep -q "^$(basename "${kmod}" .ko)[[:space:]]" \ if grep -q "^$(basename "${kmod}" .ko)[[:space:]]" \
/proc/modules \ /proc/modules \
|| grep -q "^$(basename "${kmod}" .ko)" \ || grep -q "^$(basename "${kmod}" .ko)" \
@ -147,7 +148,7 @@ copy_exec() {
mkdir -p "${DESTDIR}/${dirname}" mkdir -p "${DESTDIR}/${dirname}"
if [ ! -e "${DESTDIR}/${dirname}/${libname}" ]; then if [ ! -e "${DESTDIR}/${dirname}/${libname}" ]; then
ln -s "${x}" "${DESTDIR}/${dirname}" ln -s "${x}" "${DESTDIR}/${dirname}"
[ "${verbose}" = "y" ] && echo "Adding library ${x}" [ "${verbose}" = "y" ] && echo "Adding library ${x}" || true
fi fi
done done
} }
@ -219,12 +220,38 @@ dep_add_modules()
# require mounted sysfs # require mounted sysfs
if [ ! -d /sys/devices/ ]; then if [ ! -d /sys/devices/ ]; then
echo "mkinitramfs: MODULES dep requires mounted sysfs on /sys" echo "mkinitramfs: MODULES dep requires mounted sysfs on /sys" >&2
exit 1 exit 1
fi fi
# findout root block device + fstype # findout root block device + fstype
eval "$(mount | awk '/\/dev\// {if ($3 == "/") {print "root=" $1 "\nFSTYPE=" $5; exit}}')" eval "$(mount | awk '/\/dev\// {if ($3 == "/") {print "root=" $1 "\nFSTYPE=" $5; exit}}')"
# On failure fallback to /proc/mounts if readable
if [ -z "$root" ] && [ -r /proc/mounts ]; then
eval "$(awk '/\/dev\// {if ($2 == "/") {print "root=" $1 "\nFSTYPE=" $5; exit}}' /proc/mounts)"
fi
# recheck root device
if [ -z "$root" ]; then
echo "mkinitramfs: failed to determine root device" >&2
echo "mkinitramfs: workaround is MODULES=most" >&2
echo "Error please report bug on initramfs-tools" >&2
echo "Include the output of 'mount' and 'cat /proc/mounts'" >&2
exit 1
fi
# handle ubifs and return since ubifs root is a char device but
# most of the commands below only work with block devices.
if [ "${FSTYPE}" = "ubifs" ]; then
manual_add_modules "${FSTYPE}"
# add some modules required by ubifs on which it doesn's depend
manual_add_modules deflate
manual_add_modules zlib
manual_add_modules lzo
return
fi
if [ "${root}" = "/dev/root" ] ; then if [ "${root}" = "/dev/root" ] ; then
root="/dev/disk/by-uuid/"$(blkid -o value -s UUID ${root}) 2>/dev/null root="/dev/disk/by-uuid/"$(blkid -o value -s UUID ${root}) 2>/dev/null
fi fi
@ -239,9 +266,9 @@ dep_add_modules()
if [ "${FSTYPE}" = "unknown" ]; then if [ "${FSTYPE}" = "unknown" ]; then
FSTYPE=$(blkid -o value -s TYPE "${root}") FSTYPE=$(blkid -o value -s TYPE "${root}")
if [ -z "${FSTYPE}" ]; then if [ -z "${FSTYPE}" ]; then
echo "mkinitramfs: unknown fstype on root ${root}" echo "mkinitramfs: unknown fstype on root ${root}" >&2
echo "mkinitramfs: workaround is MODULES=most" echo "mkinitramfs: workaround is MODULES=most" >&2
echo "Error please report bug on initramfs-tools" echo "Error please report bug on initramfs-tools" >&2
exit 1 exit 1
fi fi
fi fi
@ -260,8 +287,7 @@ dep_add_modules()
done done
# lvm on md or luks on md # lvm on md or luks on md
if [ "${block#md}" != "${block}" ]; then if [ "${block#md}" != "${block}" ]; then
block=$(awk "/^${block}/{print substr(\$5, 1, 4); exit}" \ block=$(sed -ne 's/multipath/[/' -e 's/linear/[/' -e 's/raid[0-9][0-9]*/[/' -e 's/\([hs]d[a-z][a-z]*\)[0-9][0-9]*/\1/g' -e '/^'${block}' :/s/^[^[]*\[ \([^\[]*\)\[.*$/\1/p' </proc/mdstat)
/proc/mdstat)
fi fi
# luks or lvm on cciss or ida # luks or lvm on cciss or ida
if [ "${block#cciss}" != "${block}" ] \ if [ "${block#cciss}" != "${block}" ] \
@ -273,13 +299,15 @@ dep_add_modules()
# md root new naming scheme /dev/md/X # md root new naming scheme /dev/md/X
elif [ "${root#/dev/md/}" != "${root}" ]; then elif [ "${root#/dev/md/}" != "${root}" ]; then
root=${root#/dev/md/} root=${root#/dev/md/}
block=$(awk "/^md${root}/{print substr(\$5, 1, 3); exit}" \ # drop the partition number only for sdX and hdX devices
/proc/mdstat) # and keep it for other devices like loop#, dm-# devices
block=$(sed -ne 's/multipath/[/' -e 's/linear/[/' -e 's/raid[0-9][0-9]*/[/' -e 's/\([hs]d[a-z][a-z]*\)[0-9][0-9]*/\1/g' -e '/^md'$root' :/s/^[^[]*\[ \([^\[]*\)\[.*$/\1/p' </proc/mdstat)
# md root /dev/mdX # md root /dev/mdX
elif [ "${root#/dev/md}" != "${root}" ]; then elif [ "${root#/dev/md}" != "${root}" ]; then
root=${root#/dev/} root=${root#/dev/md}
block=$(awk "/^${root}/{print substr(\$5, 1, 3); exit}" \ # drop the partition number only for sdX and hdX devices
/proc/mdstat) # and keep it for other devices like loop#, dm-# devices
block=$(sed -ne 's/multipath/[/' -e 's/linear/[/' -e 's/raid[0-9][0-9]*/[/' -e 's/\([hs]d[a-z][a-z]*\)[0-9][0-9]*/\1/g' -e '/^md'$root' :/s/^[^[]*\[ \([^\[]*\)\[.*$/\1/p' </proc/mdstat)
# cciss device # cciss device
elif [ "${root#/dev/cciss/}" != "${root}" ]; then elif [ "${root#/dev/cciss/}" != "${root}" ]; then
block=${root#/dev/cciss/*} block=${root#/dev/cciss/*}
@ -320,9 +348,9 @@ dep_add_modules()
# Error out if /sys lack block dev # Error out if /sys lack block dev
if [ -z "${block}" ] || [ ! -e /sys/block/${block} ]; then if [ -z "${block}" ] || [ ! -e /sys/block/${block} ]; then
echo "mkinitramfs: for root ${root} missing ${block} /sys/block/ entry" echo "mkinitramfs: for root ${root} missing ${block} /sys/block/ entry" >&2
echo "mkinitramfs: workaround is MODULES=most" echo "mkinitramfs: workaround is MODULES=most" >&2
echo "mkinitramfs: Error please report the bug" echo "mkinitramfs: Error please report the bug" >&2
exit 1 exit 1
fi fi
@ -347,6 +375,10 @@ dep_add_modules()
manual_add_modules mmc_block manual_add_modules mmc_block
fi fi
if [ -e /sys/bus/virtio ] ; then
manual_add_modules virtio_pci
fi
if [ -e /sys/bus/i2o/devices/ ]; then if [ -e /sys/bus/i2o/devices/ ]; then
force_load i2o_block force_load i2o_block
force_load i2o_config force_load i2o_config
@ -372,7 +404,7 @@ auto_add_modules()
case "${1:-}" in case "${1:-}" in
base) base)
for x in ehci-hcd ohci-hcd uhci-hcd usbhid xhci hid-apple \ for x in ehci-hcd ohci-hcd uhci-hcd usbhid xhci hid-apple \
hid-microsoft \ hid-cherry hid-logitech hid-microsoft \
btrfs ext2 ext3 ext4 ext4dev isofs jfs nfs reiserfs udf xfs \ btrfs ext2 ext3 ext4 ext4dev isofs jfs nfs reiserfs udf xfs \
af_packet atkbd i8042 virtio_pci; do af_packet atkbd i8042 virtio_pci; do
manual_add_modules "${x}" manual_add_modules "${x}"
@ -406,6 +438,11 @@ auto_add_modules()
block) block)
copy_modules_dir kernel/drivers/block copy_modules_dir kernel/drivers/block
;; ;;
ubi)
for x in deflate zlib lzo ubi ubifs; do
manual_add_modules "${x}"
done
;;
ieee1394) ieee1394)
for x in ohci1394 sbp2; do for x in ohci1394 sbp2; do
manual_add_modules "${x}" manual_add_modules "${x}"
@ -490,9 +527,9 @@ compare_versions()
xbps-uhelper cmpver $curv $minv xbps-uhelper cmpver $curv $minv
if [ $? -eq 0 ] || [ $? -eq 1 ]; then if [ $? -eq 0 ] || [ $? -eq 1 ]; then
return 0 return 0
else
return 1
fi fi
return 1
} }
# minimal supported kernel version # minimal supported kernel version
@ -503,8 +540,7 @@ check_minkver()
curversion="${1:-}" curversion="${1:-}"
initdir="${2:-}" initdir="${2:-}"
if [ -z "${initdir}" ]; then if [ -z "${initdir}" ]; then
ARCH=$(uname -m) case ${ARCH:-} in
case ${ARCH} in
ia64|hppa) ia64|hppa)
minversion="2.6.15" minversion="2.6.15"
;; ;;
@ -524,7 +560,7 @@ check_minkver()
# sed: keep last line starting with MINKVER=, # sed: keep last line starting with MINKVER=,
# remove MINKVER= and trailing space # remove MINKVER= and trailing space
minver=$(sed '/^MINKVER=/!d;$!d;s/^MINKVER=//;s/[[:space:]]*$//' "${initdir}/${cm_x}") minver=$(sed '/^MINKVER=/!d;$!d;s/^MINKVER=//;s/[[:space:]]*$//' "${initdir}/${cm_x}")
if [ -z "${tmp}" ]; then if [ -z "${tmp:-}" ]; then
continue continue
elif ! compare_versions "${curversion}" "${minver}"; then elif ! compare_versions "${curversion}" "${minver}"; then
echo "W: ${cm_x} hook script requires at least kernel version ${minver}" >&2 echo "W: ${cm_x} hook script requires at least kernel version ${minver}" >&2

View file

@ -1,29 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
. /usr/share/initramfs-tools/hook-functions
copy_exec /sbin/modprobe /sbin
copy_exec /sbin/depmod /sbin
copy_exec /sbin/rmmod /sbin
if [ -d /etc/modprobe.d ]; then
mkdir -p "${DESTDIR}/etc/modprobe.d"
cp -a /etc/modprobe.d/* "${DESTDIR}/etc/modprobe.d/"
fi
exit 0

View file

@ -33,12 +33,13 @@ if [ -e /etc/udev/udev.conf ]; then
. /etc/udev/udev.conf . /etc/udev/udev.conf
fi fi
if ! mount -t devtmpfs -o mode=0755 devtmpfs /dev; then if ! mount -t devtmpfs -o mode=0755 devtmpfs /dev; then
echo "W: devtmpfs not available, falling back to tmpfs for /dev"
mount -t tmpfs -o size=$tmpfs_size,mode=0755 udev /dev mount -t tmpfs -o size=$tmpfs_size,mode=0755 udev /dev
[ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1 [ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1
[ -e /dev/null ] || mknod /dev/null c 1 3 [ -e /dev/null ] || mknod /dev/null c 1 3
fi fi
mkdir /dev/pts mkdir /dev/pts
mount -t devpts -o noexec,nosuid,gid=5,mode=0620 none /dev/pts || true mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true
> /dev/.initramfs-tools > /dev/.initramfs-tools
mkdir /dev/.initramfs mkdir /dev/.initramfs
@ -57,6 +58,7 @@ export ROOTFSTYPE=
export IP= export IP=
export BOOT= export BOOT=
export BOOTIF= export BOOTIF=
export UBIMTD=
export break= export break=
export init=/sbin/init export init=/sbin/init
export quiet=n export quiet=n
@ -141,6 +143,9 @@ for x in $(cat /proc/cmdline); do
boot=*) boot=*)
BOOT=${x#boot=} BOOT=${x#boot=}
;; ;;
ubi.mtd=*)
UBIMTD=${x#ubi.mtd=}
;;
resume=*) resume=*)
RESUME="${x#resume=}" RESUME="${x#resume=}"
;; ;;
@ -221,12 +226,12 @@ run_scripts /scripts/init-premount
[ "$quiet" != "y" ] && log_end_msg [ "$quiet" != "y" ] && log_end_msg
maybe_break mount maybe_break mount
[ "$quiet" != "y" ] && log_begin_msg "Mounting root file system" log_begin_msg "Mounting root file system"
. /scripts/${BOOT} . /scripts/${BOOT}
parse_numeric ${ROOT} parse_numeric ${ROOT}
maybe_break mountroot maybe_break mountroot
mountroot mountroot
[ "$quiet" != "y" ] && log_end_msg log_end_msg
maybe_break bottom maybe_break bottom
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom" [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom"
@ -237,26 +242,52 @@ run_scripts /scripts/init-bottom
mount -n -o move /sys ${rootmnt}/sys mount -n -o move /sys ${rootmnt}/sys
mount -n -o move /proc ${rootmnt}/proc mount -n -o move /proc ${rootmnt}/proc
validate_init() {
checktarget="${1}"
# Work around absolute symlinks
if [ -d "${rootmnt}" ] && [ -h "${rootmnt}${checktarget}" ]; then
case $(readlink "${rootmnt}${checktarget}") in /*)
checktarget="$(chroot ${rootmnt} readlink ${checktarget})"
;;
esac
fi
# Make sure the specified init can be executed
if [ ! -x "${rootmnt}${checktarget}" ]; then
return 1
fi
# Upstart uses /etc/init as configuration directory :-/
if [ -d "${rootmnt}${checktarget}" ]; then
return 1
fi
}
# Check init bootarg # Check init bootarg
if [ -n "${init}" ] && [ ! -x "${rootmnt}${init}" ]; then if [ -n "${init}" ]; then
echo "Target filesystem doesn't have ${init}." if ! validate_init "$init"; then
echo "Target filesystem doesn't have requested ${init}."
init= init=
fi fi
# Search for valid init
if [ -z "${init}" ] ; then
for init in /sbin/init /etc/init /bin/init /bin/sh; do
if [ ! -x "${rootmnt}${init}" ]; then
continue
fi fi
# Common case: /sbin/init is present
if [ ! -x "${rootmnt}/sbin/init" ]; then
# ... if it's not available search for valid init
if [ -z "${init}" ] ; then
for inittest in /sbin/init /etc/init /bin/init /bin/sh; do
if validate_init "${inittest}"; then
init="$inittest"
break break
fi
done done
fi fi
# No init on rootmount # No init on rootmount
if [ ! -x "${rootmnt}${init}" ]; then if ! validate_init "${init}" ; then
panic "No init found. Try passing init= bootarg." panic "No init found. Try passing init= bootarg."
fi fi
fi
maybe_break init maybe_break init
@ -272,6 +303,7 @@ unset ROOT
unset IP unset IP
unset BOOT unset BOOT
unset BOOTIF unset BOOTIF
unset UBIMTD
unset blacklist unset blacklist
unset break unset break
unset noresume unset noresume
@ -282,5 +314,5 @@ unset resume
unset resume_offset unset resume_offset
# Chain to real filesystem # Chain to real filesystem
exec switch_root ${rootmnt} ${init} "$@" exec switch_root ${rootmnt} ${init} "$@" <${rootmnt}/dev/console >${rootmnt}/dev/console
panic "Could not execute run-init." panic "Could not execute run-init."

View file

@ -1,4 +1,4 @@
.TH INITRAMFS-TOOLS 8 "2010/04/10" "Linux" "mkinitramfs script overview" .TH INITRAMFS-TOOLS 8 "2010/09/23" "Linux" "mkinitramfs script overview"
.SH NAME .SH NAME
initramfs-tools \- an introduction to writing scripts for mkinitramfs initramfs-tools \- an introduction to writing scripts for mkinitramfs
@ -9,38 +9,28 @@ will be used during different phases of execution. Each of these will be
discussed separately below with the help of an imaginary tool which performs a discussed separately below with the help of an imaginary tool which performs a
frobnication of a lvm partition prior to mounting the root partition. frobnication of a lvm partition prior to mounting the root partition.
Valid boot and hook scripts names consist solely of alphabetics, numerics .SH Kernel Command Line
and underscores. Other scripts are discarded. The root filesystem used by the kernel is specified by the boot loader as
always. The traditional \fBroot=/dev/sda1\fR style device specification is
allowed. If a label is used, as in \fBroot=LABEL=rootPart\fR the initrd will
search all available devices for a filesystem with the appropriate label, and
mount that device as the root filesystem. \fBroot=UUID=uuidnumber\fR will
mount the partition with that UUID as the root filesystem.
.SS Hook scripts .SS Standard
These are used when an initramfs image is created and not included in the
image itself. They can however cause files to be included in the image.
.SS Boot scripts
These are included in the initramfs image and normally executed during
kernel boot in the early user-space before the root partition has been
mounted.
.SH INIT SCRIPT
The script which is executed first and is in charge of running all other
scripts can be found in /usr/share/initramfs-tools/init. It takes a number of
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 .TP
\fB\fI init \fB\fI init= "<path to real init>"
the binary to hand over execution to on the root fs after the initramfs scripts are done. the binary to hand over execution to on the root fs after the initramfs scripts are done.
.TP .TP
\fB\fI root \fB\fI root= "<path to blockdevice>"
the device node to mount as the root file system. the device node to mount as the root file system.
The recommended usage is to specify the UUID as followed "root=UUID=xxx". The recommended usage is to specify the UUID as followed "root=UUID=xxx".
As normal device names are not stable and may change depending on the
boot order. .TP
\fB\fI rootfstype
set the root file system type.
.TP .TP
\fB\fI rootdelay \fB\fI rootdelay
@ -51,10 +41,6 @@ The default is 180 seconds.
\fB\fI rootflags \fB\fI rootflags
set the file system mount option string. set the file system mount option string.
.TP
\fB\fI rootfstype
set the root file system type.
.TP .TP
\fB\fI nfsroot \fB\fI nfsroot
can be either "auto" to try to get the relevant information from DHCP or a can be either "auto" to try to get the relevant information from DHCP or a
@ -66,12 +52,12 @@ Use root=/dev/nfs for NFS to kick to in. NFSOPTS can be looked up in
\fB\fI ip \fB\fI ip
tells how to configure the ip address. Allows to specify an different tells how to configure the ip address. Allows to specify an different
NFS server than the DHCP server. See Documentation/filesystems/nfsroot.txt NFS server than the DHCP server. See Documentation/filesystems/nfsroot.txt
in any recent Linux source for details. Optional paramater for NFS root. in any recent Linux source for details. Optional parameter for NFS root.
.TP .TP
\fB\fI BOOTIF \fB\fI BOOTIF
is a mac adress in pxelinux format with leading "01-" and "-" as separations. is a mac address in pxelinux format with leading "01-" and "-" as separations.
pxelinux passes mac adress of network card used to PXE boot on with this pxelinux passes mac address of network card used to PXE boot on with this
bootarg. bootarg.
.TP .TP
@ -106,6 +92,7 @@ mounts the rootfs read-write.
disables load of specific modules. disables load of specific modules.
Use blacklist=module1,module2,module3 bootparameter. Use blacklist=module1,module2,module3 bootparameter.
.SS Debug
.TP .TP
\fB\fI panic \fB\fI panic
sets an timeout on panic. sets an timeout on panic.
@ -136,6 +123,21 @@ loads generic IDE/ATA chipset support on boot.
.SH HOOK SCRIPTS .SH HOOK SCRIPTS
Valid boot and hook scripts names consist solely of alphabetics, numerics,
dashes and underscores. Other scripts are discarded.
.SS Hook scripts
These are used when an initramfs image is created and not included in the
image itself. They can however cause files to be included in the image.
Hook scripts are executed under errexit. Thus a hook script can abort the
mkinitramfs build on possible errors (exitcode != 0).
.SS Boot scripts
These are included in the initramfs image and normally executed during
kernel boot in the early user-space before the root partition has been
mounted.
Hooks can be found in two places: /usr/share/initramfs-tools/hooks and Hooks can be found in two places: /usr/share/initramfs-tools/hooks and
/etc/initramfs-tools/hooks. They are executed during generation of the /etc/initramfs-tools/hooks. They are executed during generation of the
initramfs-image and are responsible for including all the necessary components initramfs-image and are responsible for including all the necessary components
@ -259,7 +261,7 @@ sets if a keymap needs to be added to initramfs.
.TP .TP
\fB\fI MODULES \fB\fI MODULES
specifies which kind of modules should land on initramfs. specifies which kind of modules should land on initramfs.
This setting shouldn't be overriden by hook script, but can guide them This setting shouldn't be overridden by hook script, but can guide them
on how much they need to include on initramfs. on how much they need to include on initramfs.
@ -372,14 +374,14 @@ contains the following subdirectories.
\fB\fI \fB\fI
init-top init-top
the scripts in this directory are the first scripts to be executed after sysfs the scripts in this directory are the first scripts to be executed after sysfs
and procfs have been mounted and /dev/console and /dev/null have been created. and procfs have been mounted.
No other device files are present yet. It also runs the udev hook for populating the /dev tree (udev will keep
running until init-bottom).
.TP .TP
\fB\fI \fB\fI
init-premount init-premount
runs the udev hooks for populating the /dev tree (udev will keep running until happens after modules specified by hooks and /etc/initramfs-tools/modules
init-bottom) after modules specified by hooks and /etc/initramfs-tools/modules
have been loaded. have been loaded.
.TP .TP
@ -399,14 +401,14 @@ been mounted.
\fB\fI \fB\fI
local-bottom OR nfs-bottom local-bottom OR nfs-bottom
are run after the rootfs has been mounted (local) or the NFS root share has are run after the rootfs has been mounted (local) or the NFS root share has
been mounted. udev is stopped. been mounted.
.TP .TP
\fB\fI \fB\fI
init-bottom init-bottom
are the last scripts to be executed before procfs and sysfs are moved to the are the last scripts to be executed before procfs and sysfs are moved to the
real rootfs and execution is turned over to the init binary which should now be real rootfs and execution is turned over to the init binary which should now be
found in the mounted rootfs. found in the mounted rootfs. udev is stopped.
.SS Boot parameters .SS Boot parameters
.TP .TP
@ -496,12 +498,12 @@ init sets several variables for the boot scripts environment.
.TP .TP
\fB\fI ROOT \fB\fI ROOT
correponds to the root boot option. corresponds to the root boot option.
Advanced boot scripts like cryptsetup or live-initramfs need to play tricks. Advanced boot scripts like cryptsetup or live-initramfs need to play tricks.
Otherwise keep it alone. Otherwise keep it alone.
.TP .TP
\fB\fI ROOTDELAY, ROOTFLAGS, ROOTFSTYPE, IP \fB\fI ROOTDELAY, ROOTFLAGS, ROOTFSTYPE, IP
correponds to the rootdelay, rootflags, rootfstype or ip boot option. corresponds to the rootdelay, rootflags, rootfstype or ip boot option.
.TP .TP
\fB\fI DPKG_ARCH \fB\fI DPKG_ARCH
allows arch specific boot actions. allows arch specific boot actions.
@ -521,10 +523,10 @@ passes the path to init(8) usually /sbin/init.
.TP .TP
\fB\fI readonly \fB\fI readonly
is the default for mounting the root corresponds to the ro bootarg. is the default for mounting the root corresponds to the ro bootarg.
Overriden by rw bootarg. Overridden by rw bootarg.
.TP .TP
\fB\fI rootmnt \fB\fI rootmnt
is the path where root gets mounted usualy /root. is the path where root gets mounted usually /root.
.TP .TP
\fB\fI debug \fB\fI debug
indicates that a debug log is captured for further investigation. indicates that a debug log is captured for further investigation.

View file

@ -7,12 +7,11 @@ export PATH='/usr/bin:/sbin:/bin'
keep="n" keep="n"
CONFDIR="/etc/initramfs-tools" CONFDIR="/etc/initramfs-tools"
verbose="n" verbose="n"
errors_to="2>/dev/null"
OPTIONS=`getopt -o c:d:ko:r:v -n "$0" -- "$@"` OPTIONS=`getopt -o c:d:ko:r:v -n "$0" -- "$@"`
# Check for non-GNU getopt # Check for non-GNU getopt
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi if [ $? != 0 ] ; then echo "W: non-GNU getopt" >&2 ; exit 1 ; fi
eval set -- "$OPTIONS" eval set -- "$OPTIONS"
@ -132,25 +131,23 @@ else
COMPRESS=${compress} COMPRESS=${compress}
fi fi
if ! command -v ${compress} >/dev/null 2>&1; then if ! command -v "${compress}" >/dev/null 2>&1; then
compress=gzip compress=gzip
COMPRESS=gzip
[ "${verbose}" = y ] && \ [ "${verbose}" = y ] && \
echo "No ${COMPRESS} in ${PATH}, using gzip" echo "No ${COMPRESS} in ${PATH}, using gzip"
fi fi
if [ -r /boot/config-${version} ]; then if ! `grep -q -i ^config_rd_${COMPRESS%p} /boot/config-${version}` ; then
if ! `grep -q -i config_rd_${COMPRESS}=y /boot/config-${version}` ; then
compress=gzip compress=gzip
[ "${verbose}" = y ] && \ [ "${verbose}" = y ] && \
echo "linux-2.6 misses ${COMPRESS} support, using gzip" echo "linux-2.6 misses ${COMPRESS} support, using gzip"
fi fi
fi
# Always use max compression. [ "${compress}" = lzop ] && compress="lzop -9"
compress="${compress} -9"
if [ -d "${outfile}" ]; then if [ -d "${outfile}" ]; then
echo "${outfile} is a directory" echo "${outfile} is a directory" >&2
exit 1 exit 1
fi fi
@ -166,6 +163,16 @@ fi
DESTDIR="$(mktemp -d ${TMPDIR:-/tmp}/mkinitramfs_XXXXXX)" || exit 1 DESTDIR="$(mktemp -d ${TMPDIR:-/tmp}/mkinitramfs_XXXXXX)" || exit 1
chmod 755 "${DESTDIR}" chmod 755 "${DESTDIR}"
# do not execute cache_run_scripts() if mounted with noexec
NOEXEC=""
if [ -r /etc/mtab ]; then
fs=$(df $DESTDIR | tail -1 | awk '{print $6}')
if [ -n "$fs" ] && mount | grep -q "on $fs .*noexec" ; then
NOEXEC=1
fi
fi
__TMPCPIOGZ="$(mktemp ${TMPDIR:-/tmp}/mkinitramfs-OL_XXXXXX)" || exit 1 __TMPCPIOGZ="$(mktemp ${TMPDIR:-/tmp}/mkinitramfs-OL_XXXXXX)" || exit 1
DPKG_ARCH=`uname -m` DPKG_ARCH=`uname -m`
@ -217,26 +224,27 @@ list)
# nothing to add # nothing to add
;; ;;
*) *)
echo "mkinitramfs: Warning unsupported MODULES setting: ${MODULES}." echo "W: mkinitramfs: unsupported MODULES setting: ${MODULES}."
echo "mkinitramfs: Falling back to MODULES=most." echo "W: mkinitramfs: Falling back to MODULES=most."
auto_add_modules auto_add_modules
;; ;;
esac esac
# Have to do each file, because cpio --dereference doesn't recurse down # Have to do each file, because cpio --dereference doesn't recurse down
# symlinks. # symlinks.
cp -p /usr/share/initramfs-tools/init ${DESTDIR}/init cp -p /usr/share/initramfs-tools/init ${DESTDIR}/init
# add existant boot scripts # add existant boot scripts
for b in $(cd /usr/share/initramfs-tools/scripts/ && find . \ for b in $(cd /usr/share/initramfs-tools/scripts/ && find . \
-regextype posix-extended -regex '.*/[[:alnum:]_.]+$' -type f); do -regextype posix-extended -regex '.*/[[:alnum:]\._-]+$' -type f); do
[ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \ [ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \
|| mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")" || mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")"
cp -p "/usr/share/initramfs-tools/scripts/${b}" \ cp -p "/usr/share/initramfs-tools/scripts/${b}" \
"${DESTDIR}/scripts/$(dirname "${b}")/" "${DESTDIR}/scripts/$(dirname "${b}")/"
done done
for b in $(cd "${CONFDIR}/scripts" && find . \ for b in $(cd "${CONFDIR}/scripts" && find . \
-regextype posix-extended -regex '.*/[[:alnum:]_.]+$' -type f); do -regextype posix-extended -regex '.*/[[:alnum:]\._-]+$' -type f); do
[ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \ [ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \
|| mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")" || mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")"
cp -p "${CONFDIR}/scripts/${b}" "${DESTDIR}/scripts/$(dirname "${b}")/" cp -p "${CONFDIR}/scripts/${b}" "${DESTDIR}/scripts/$(dirname "${b}")/"
@ -257,16 +265,29 @@ if [ -n "${ROOT:-}" ]; then
echo "ROOT=${ROOT}" > ${DESTDIR}/conf/conf.d/root echo "ROOT=${ROOT}" > ${DESTDIR}/conf/conf.d/root
fi fi
if ! command -v ldd >/dev/null 2>&1 ; then
echo "WARNING: no ldd around - install libc-bin" >&2
exit 1
fi
# module-init-tools
copy_exec /sbin/depmod /sbin
copy_exec /sbin/modprobe /sbin
copy_exec /sbin/rmmod /sbin
mkdir -p "${DESTDIR}/etc/modprobe.d"
cp -a /etc/modprobe.d/* "${DESTDIR}/etc/modprobe.d/"
run_scripts /usr/share/initramfs-tools/hooks run_scripts /usr/share/initramfs-tools/hooks
run_scripts "${CONFDIR}"/hooks run_scripts "${CONFDIR}"/hooks
# cache boot run order # cache boot run order
if [ -n "$NOEXEC" ]; then
echo "W: TMPDIR is mounted noexec, will not cache run scripts."
else
for b in $(cd "${DESTDIR}/scripts" && find . -mindepth 1 -type d); do for b in $(cd "${DESTDIR}/scripts" && find . -mindepth 1 -type d); do
cache_run_scripts "${DESTDIR}" "/scripts/${b#./}" cache_run_scripts "${DESTDIR}" "/scripts/${b#./}"
done done
fi
# Copy in tsort(1).
copy_exec /bin/tsort /bin
# generate module deps # generate module deps
depmod -a -b "${DESTDIR}" ${version} depmod -a -b "${DESTDIR}" ${version}
@ -279,11 +300,8 @@ fi
# Remove any looping or broken symbolic links, since they break cpio. # Remove any looping or broken symbolic links, since they break cpio.
[ "${verbose}" = y ] && xargs_verbose="-t" [ "${verbose}" = y ] && xargs_verbose="-t"
find "${DESTDIR}" -type l -printf '%p %Y\n' | sed -n 's/ [LN]$//p' \ (cd "${DESTDIR}" && find . -type l -printf '%p %Y\n' | sed -n 's/ [LN]$//p' \
| xargs ${xargs_verbose:-} -rL1 rm -f | xargs ${xargs_verbose:-} -rL1 rm -f)
# Copy resume from klibc
copy_exec /bin/resume /bin
[ "${verbose}" = y ] && echo "Building cpio ${outfile} initramfs" [ "${verbose}" = y ] && echo "Building cpio ${outfile} initramfs"
( (
@ -301,9 +319,18 @@ eval `
} | ${compress} >"${outfile}" } | ${compress} >"${outfile}"
echo "ec3=$?;" >&4 echo "ec3=$?;" >&4
` `
if [ "$ec1" -ne 0 ]; then exit "$ec1"; fi if [ "$ec1" -ne 0 ]; then
if [ "$ec2" -ne 0 ]; then exit "$ec2"; fi echo "E: mkinitramfs failure find $ec1 cpio $ec2 $compress $ec3"
if [ "$ec3" -ne 0 ]; then exit "$ec3"; fi exit "$ec1"
fi
if [ "$ec2" -ne 0 ]; then
echo "E: mkinitramfs failure cpio $ec2 $compress $ec3"
exit "$ec2"
fi
if [ "$ec3" -ne 0 ]; then
echo "E: mkinitramfs failure $compress $ec3"
exit "$ec3"
fi
) || exit 1 ) || exit 1
if [ -s "${__TMPCPIOGZ}" ]; then if [ -s "${__TMPCPIOGZ}" ]; then

View file

@ -8,6 +8,13 @@ pre_mountroot()
wait_for_udev 10 wait_for_udev 10
# Load ubi with the correct MTD partition and return since fstype
# doesn't work with a char device like ubi.
if [ -n "$UBIMTD" ]; then
modprobe ubi mtd=$UBIMTD
return
fi
# Don't wait for a root device that doesn't have a corresponding # Don't wait for a root device that doesn't have a corresponding
# device in /dev (ie, mtd0) # device in /dev (ie, mtd0)
if [ "${ROOT#/dev}" = "${ROOT}" ]; then if [ "${ROOT#/dev}" = "${ROOT}" ]; then
@ -19,12 +26,9 @@ pre_mountroot()
if [ ! -e "${ROOT}" ] || ! $(get_fstype "${ROOT}" >/dev/null); then if [ ! -e "${ROOT}" ] || ! $(get_fstype "${ROOT}" >/dev/null); then
log_begin_msg "Waiting for root file system" log_begin_msg "Waiting for root file system"
# Default delay is 180s # Default delay is 30s
if [ -z "${ROOTDELAY}" ]; then slumber=${ROOTDELAY:-30}
slumber=180
else
slumber=${ROOTDELAY}
fi
if [ -x /sbin/usplash_write ]; then if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "TIMEOUT ${slumber}" || true /sbin/usplash_write "TIMEOUT ${slumber}" || true
fi fi

View file

@ -62,21 +62,16 @@ mountroot()
wait_for_udev 10 wait_for_udev 10
# Default delay is around 180s # Default delay is around 180s
# FIXME: add usplash_write info delay=${ROOTDELAY:-180}
if [ -z "${ROOTDELAY}" ]; then
delay=180
else
delay=${ROOTDELAY}
fi
# loop until nfsmount succeds # loop until nfsmount succeeds
do_nfsmount
while [ ${retry_nr} -lt ${delay} ] && [ ! -e ${rootmnt}${init} ]; do while [ ${retry_nr} -lt ${delay} ] && [ ! -e ${rootmnt}${init} ]; do
[ ${retry_nr} -gt 0 ] && \
[ "$quiet" != "y" ] && log_begin_msg "Retrying nfs mount" [ "$quiet" != "y" ] && log_begin_msg "Retrying nfs mount"
/bin/sleep 1
do_nfsmount do_nfsmount
retry_nr=$(( ${retry_nr} + 1 )) retry_nr=$(( ${retry_nr} + 1 ))
[ ! -e ${rootmnt}${init} ] && /bin/sleep 1 [ "$quiet" != "y" ] && log_end_msg
[ ${retry_nr} -gt 0 ] && [ "$quiet" != "y" ] && log_end_msg
done done
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-bottom" [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-bottom"

View file

@ -131,7 +131,7 @@ backup_booted_initramfs()
# nuke generated copy # nuke generated copy
remove_initramfs_bak() remove_initramfs_bak()
{ {
[ -z "${initramfs_bak}" ] && return 0 [ -z "${initramfs_bak:-}" ] && return 0
rm -f "${initramfs_bak}" rm -f "${initramfs_bak}"
verbose "Removing ${initramfs_bak}" verbose "Removing ${initramfs_bak}"
} }
@ -155,7 +155,7 @@ generate_initramfs()
# minversion wasn't met, exit 0 # minversion wasn't met, exit 0
exit 0 exit 0
fi fi
echo "update-initramfs: failed for ${initramfs}" echo "update-initramfs: failed for ${initramfs}" >&2
exit $mkinitramfs_return exit $mkinitramfs_return
fi fi
} }
@ -181,7 +181,7 @@ run_bootloader()
echo "update-initramfs: please run 'grub-install ${dev}'." echo "update-initramfs: please run 'grub-install ${dev}'."
fi fi
if command -v grub-mkconfig 2>&1 >/dev/null; then if command -v grub-mkconfig >/dev/null 2>&1; then
grub-mkconfig -o /boot/grub/grub.cfg grub-mkconfig -o /boot/grub/grub.cfg
fi fi
} }
@ -423,7 +423,7 @@ while getopts "k:cudyvtb:h?BV" flag; do
b) b)
BOOTDIR="${OPTARG}" BOOTDIR="${OPTARG}"
if [ ! -d "${BOOTDIR}" ]; then if [ ! -d "${BOOTDIR}" ]; then
echo "Error: ${BOOTDIR} is not a directory." echo "Error: ${BOOTDIR} is not a directory." >&2
exit 1 exit 1
fi fi
;; ;;
@ -440,7 +440,7 @@ done
shift $((${OPTIND} - 1)) shift $((${OPTIND} - 1))
if [ $# -ne 0 ]; then if [ $# -ne 0 ]; then
echo "Invalid argument for option -k." echo "Invalid argument for option -k." >&2
usage usage
fi fi
@ -469,11 +469,8 @@ if [ "${version}" = "all" ] \
OPTS="${OPTS} -y" OPTS="${OPTS} -y"
fi fi
for u_version in ${version_list}; do for u_version in ${version_list}; do
# Don't stop if one version doesn't work.
set +e
verbose "Execute: ${0} -${mode} -k \"${u_version}\" ${OPTS}" verbose "Execute: ${0} -${mode} -k \"${u_version}\" ${OPTS}"
"${0}" -${mode} -k "${u_version}" ${OPTS} "${0}" -${mode} -k "${u_version}" ${OPTS}
set -e
done done
exit 0 exit 0
fi fi

View file

@ -1,6 +1,6 @@
# Template file for 'initramfs-tools' # Template file for 'initramfs-tools'
pkgname=initramfs-tools pkgname=initramfs-tools
version=0.99.3.debian0.95.1 version=0.99.4.debian0.98.5
build_style=custom-install build_style=custom-install
short_desc="Tools for generating an initramfs" short_desc="Tools for generating an initramfs"
maintainer="Juan RP <xtraeme@gmail.com>" maintainer="Juan RP <xtraeme@gmail.com>"
@ -22,7 +22,6 @@ conf_files="
/etc/$pkgname/update-initramfs.conf /etc/$pkgname/update-initramfs.conf
/etc/$pkgname/modules" /etc/$pkgname/modules"
Add_dependency full glibc
Add_dependency full cpio Add_dependency full cpio
Add_dependency full util-linux-ng Add_dependency full util-linux-ng
Add_dependency full gawk Add_dependency full gawk
@ -97,5 +96,6 @@ do_install()
# Scripts # Scripts
install -m 755 $FILESDIR/mkinitramfs $DESTDIR/usr/sbin install -m 755 $FILESDIR/mkinitramfs $DESTDIR/usr/sbin
install -m 755 $FILESDIR/update-initramfs $DESTDIR/usr/sbin install -m 755 $FILESDIR/update-initramfs $DESTDIR/usr/sbin
install -m 755 $FILESDIR/lsinitramfs $DESTDIR/usr/sbin
sed -i -e "s|@VERSION@|${version}|g" $DESTDIR/usr/sbin/update-initramfs sed -i -e "s|@VERSION@|${version}|g" $DESTDIR/usr/sbin/update-initramfs
} }