initramfs-tools: sync with Debian 0.94.4.

Now the version also specifies what Debian version the code uses, i.e
"0.99.debian0.94.4".

--HG--
rename : srcpkgs/initramfs-tools/files/scripts/init-premount/blacklist => srcpkgs/initramfs-tools/files/scripts/init-top/blacklist
This commit is contained in:
Juan RP 2010-05-17 17:43:30 +02:00
parent 52e52a2081
commit a214baad07
18 changed files with 400 additions and 352 deletions

View File

@ -0,0 +1,35 @@
chrooted() {
# borrowed from udev's postinst
if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then
# the devicenumber/inode pair of / is the same as that of
# /sbin/init's root, so we're *not* in a chroot and hence
# return false.
return 1
fi
return 0
}
case "${ACTION}" in
pre)
mkdir -p /etc/initramfs-tools/conf.d
# First time install. Can we autodetect the RESUME partition?
if [ -r /proc/swaps ]; then
RESUME=$(tail -n $(($(wc -l /proc/swaps | awk ' { print $1 } ') - 1)) \
/proc/swaps | sort -rk3 | head -n 1 | awk ' { print $1 } ')
if command -v vol_id >/dev/null 2>&1; then
UUID=$(vol_id -u "$RESUME" || true)
elif [ -x /lib/udev/vol_id ]; then
UUID=$(/lib/udev/vol_id -u "$RESUME" || true)
fi
if [ -n "$UUID" ]; then
RESUME="UUID=$UUID"
fi
fi
# write conf.d/resume if not in a chroot
if [ -n "${RESUME}" ] && ! chrooted; then
echo "RESUME=${RESUME}" > /etc/initramfs-tools/conf.d/resume
fi
;;
esac

View File

@ -8,7 +8,7 @@
#
# MODULES: [ most | netboot | dep | list ]
#
# most - Add all framebuffer, acpi, filesystem, and harddrive drivers.
# most - Add most filesystem and all harddrive drivers.
#
# dep - Try and guess which modules to load.
#
@ -27,6 +27,12 @@ MODULES=most
KEYMAP=n
#
# COMPRESS: [ gzip | bzip2 | lzma ]
#
COMPRESS=gzip
#
# NFS Section of the config.
#
@ -55,11 +61,3 @@ DEVICE=eth0
NFSROOT=auto
#
# COMPRESSION_TYPE: [ gzip | bzip2 | lzma ]
#
# Compression type for the newly generated initramfs. By default
# it's compressed with gzip.
#
COMPRESSION_TYPE=gzip

View File

@ -1,5 +1,5 @@
#!/bin/sh
#
#
# This is an example hook script. It will be run by 'mkinitramfs'
# when it creates the image. It's job is to decide which files to
@ -8,39 +8,12 @@
# package is installed, or when the administrator runs 'mkinitramfs'
# by hand to update an initramfs image.
#
# TODO: What about the case where you install something that should be
# added to the initramfs, but the linux-image it relates to has
# already been installed previously? Does this happen often
# enough that it needs to be handled? How can it be handled?
#
# * Think about the 'usplash'. The initramfs will need to be
# updated if a theme change or update is desired. Maybe it
# should not be totally automatic, but offered on upgrade
# predicated on a user response to a debconf question? That
# issue needs to be explored and a solution specified.
#
# * Do not assume that any needed subdirectories have been created
# yet, but don't bail out if they are already there.
#
# * All of the standard system tools are available, of course, since
# this hook is running in the real system, not the initramfs.
#
# * TODO: ... ? Anything else to tell them in this bullet-list?
#
#
# The environment contains at least:
#
# CONFDIR -- usually /etc/mkinitramfs, can be set on mkinitramfs
# CONFDIR -- usually /etc/initramfs-tools, can be set on mkinitramfs
# command line.
#
# DESTDIR -- The staging directory where we are building the image.
#
# TODO: Decide what environment variables are meaningful and defined
# in this context, then document them as part of the interface.
#
# TODO: May need a version_compare function for comparison of VERSION?
#
# see initramfs-tools(8)
#
# List the soft prerequisites here. This is a space separated list of
@ -80,7 +53,7 @@ esac
# course may be other reasons to have custom logic deciding what to
# install. The version variable may be useful for this.
#
if [ -x /usr/bin/myprog ]; then
if command -v myprog >/dev/null 2>&1; then
copy_exec /usr/bin/myprog usr/bin
fi
@ -92,23 +65,4 @@ fi
# ... and it should do what is necessary to have 'myprog' get run
# inside the early runtime environment.
# Handle an error:
#
if [ -n "$an_error_occured" ];
then
#
# TODO: Do we need 'warn()', 'error()', and/or 'fatal()' for this?
#
echo "An error occured in $0: $an_error_occured" >&2
exit 1
#
# TODO: Decide if different error codes are meaningful, what they
# mean, and what the semantics of them are wrt 'mkinitramfs'
# pass or fail. Consider naming the error values with
# mnemonic symbols rather than magic numbers. They may or
# may not be the same set of errors as the set for
# in-initramfs scripts.
#
fi
exit 0

View File

@ -1,84 +0,0 @@
#!/bin/sh
#
# The environment contains at least:
#
# CONFDIR -- usually /etc/mkinitramfs, can be set on mkinitramfs
# command line.
#
# DESTDIR -- The staging directory where we are building the image.
#
# TODO: Decide what environment variables are meaningful and defined
# in this context, then document them as part of the interface.
#
# TODO: Write a common header for these examples or move this
# documentation to a man page and reference it here. :-)
#
#
# List the soft prerequisites here. This is a space separated list of
# names, of scripts that are in the same directory as this one, that
# must be run before this one can be.
#
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
#
# Source the 'hook-functions' scriptlet (for 'catenate_cpiogz'):
#
. /usr/share/initramfs-tools/hook-functions
#
# Lets pretend it has a conffile (think debconf), and we source it
# here. Don't make debconf lookup calls here. The postinst for the
# package owning this hook script should have done that and configured
# the "/etc/default/conffile" already.
#
# TODO: How does the package ensure that it's installed BEFORE the
# corresponding 'linux-image' package? Can it declare that, in
# the case where it's an add-on that the 'linux-image' is not
# aware of? This might be an apt and dpkg issue.
#
# * Eg. an optional usplash or suspend2ui_fbsplash package.
#
. /etc/default/mypackage-initramfs
#
# Also pretend that we only include our initramfs overlay if an opion
# is not "no", and the 'linux-image' package we are generating this
# initramfs for matches the version this script's package is designed
# for. Just for example; pretend this example mkinitramfs hook script
# is part of a 'linux-image' or 'xxx-modules' package.
#
if [ "$MYOPTION" != "no" -a "$version" = "2.6.12+ss2.1.9.1" ]; then
catenate_cpiogz /usr/lib/mypackage/initramfs.cpio.gz
fi
#
# In this case, there does not have to be an (eg.):
#
# "/etc/mkinitramfs/init-top/mypackage"
#
# ... since that script is probably inside of the initramfs overlay
# already. If it's a conffile though, it does not belong in there,
# and should be placed in the appropriate location inside of
# "/etc/mkinitramfs". Remember that if it needs access to the
# settings in our "/etc/default/mypackage-initramfs", then that file
# must also get copied into a location inside of ${DESTDIR} by this
# hook script in order to make it available inside of the initramfs
# environment.
#
exit 0

View File

@ -2,45 +2,11 @@
#
# This script is run inside of the initramfs environment during the
# system boot process. It is installed there by 'mkinitramfs'. The
# package that owns it may opt to install it in either an appropriate
# location under "/usr/share/initramfs-tools/scripts/", or a similar
# location under "/etc/mkinitramfs/scripts/", depending upon whether
# it should be considered to be a user modifiable conffile or not.
#
# TODO: How do we deal with the case where the package that installed
# this has been removed but not purged, if we always arbitrarily
# copy all of these scripts into the initramfs?
#
# * The available toolset is limited inside this environment...
#
# TODO: document that toolset in the man page.
#
# * /dev, /proc, and /sys are already mounted. / is a ?? ro/rw
# filesystem... etc. more documentation.
#
# * It is expected that /proc and /sys will be umounted before
# changing over to the real root file system, so you must not keep
# any files open on them beyond these scripts.
#
# * You may like to strip these documentation comments from this
# example if you take it for a template, to save a little space in
# the initramfs, since nobody will ever read it from inside of
# there anyhow.
#
#
# The environment contains at least the following variables:
#
# TODO: Decide what environment variables are meaningful and defined
# in this context, then document them as part of the interface.
#
# Because this script will be run as a full separate process, rather
# than sourced inside the context of the driver script, if it needs to
# pass information to another script that may run after it, it must do
# so by writing data to a file location known to both scripts. Simply
# setting an environment variable will not work.
# system boot process. It is installed there by 'update-initramfs'.
# The # package that owns it may opt to install it in an appropriate
# location under "/usr/share/initramfs-tools/scripts/".
#
# see initramfs-tools(8) for more details.
#
# List the soft prerequisites here. This is a space separated list of
@ -66,25 +32,4 @@ esac
echo "Got here!"
# Handle an error:
if [ -n "$an_error_occured" ];
then
#
# TODO: Do we need 'warn()', 'error()', and/or 'fatal()' for this?
# I think we ultimately do, and that they need to be in their own
# well-documented location so that an overlay can override them.
# Think 'usplash' progress updates.
#
echo "An error occured in $0: $an_error_occured" >&2
exit 1
#
# TODO: Decide if different error codes are meaningful, what they
# mean, and what the semantics of them are wrt 'init' pass
# or panic. Consider naming the error values with mnemonic
# symbols rather than magic numbers.
#
fi
exit 0

View File

@ -33,8 +33,9 @@ add_modules_from_file()
return
fi
sed -e '/^#/d' ${1} | while read module rest; do
force_load "${module}" "${rest}"
grep '^[^#]' ${1} | while read module args; do
[ -n "$module" ] || continue
force_load "${module}" "${args}"
done
}
@ -44,7 +45,7 @@ manual_add_modules()
local mam_x firmwares firmware
for mam_x in $(modprobe --set-version="${version}" --ignore-install \
--show-depends "${1}" 2>/dev/null | awk '/^insmod/ { print $2 }'); do
--quiet --show-depends "${1}" | awk '/^insmod/ { print $2 }'); do
# Prune duplicates
if [ -e "${DESTDIR}/${mam_x}" ]; then
continue
@ -70,7 +71,12 @@ manual_add_modules()
# Only print warning for missing fw of loaded module
# or forced loaded module
if [ ! -e "/lib/firmware/${firmware}" ] \
&& [ ! -e "/lib/firmware/${version}/${firmware}" ]; then
&& [ ! -e "/lib/firmware/${version}/${firmware}" ] ; then
# Only warn about missing firmware if
# /proc/modules exists
if [ ! -e /proc/modules ] ; then
continue
fi
if grep -q "^$(basename "${mam_x}" .ko)[[:space:]]" \
/proc/modules \
|| grep -q "^$(basename "${mam_x}" .ko)" \
@ -145,6 +151,10 @@ copy_exec() {
fi
# Copy the dependant libraries
if ! command -v ldd >/dev/null 2>&1 ; then
echo "WARNING: no ldd around - install glibc package."
exit 1
fi
for x in $(ldd ${source} 2>/dev/null | sed -e '
/\//!d;
/linux-gate/d;
@ -152,8 +162,9 @@ copy_exec() {
s/[[:blank:]]*\([^[:blank:]]*\) (.*)/\1/' 2>/dev/null); do
# Try to use non-optimised libraries where possible.
# We assume that all HWCAP libraries will be in tls.
nonoptlib=$(echo "${x}" | sed -e 's#/lib/\(tls\|i686\).*/\(lib.*\)#/lib/\2#')
# We assume that all HWCAP libraries will be in tls,
# sse2, vfp or neon.
nonoptlib=$(echo "${x}" | sed -e 's#/lib/\(tls\|i686\|sse2\|neon\|vfp\).*/\(lib.*\)#/lib/\2#')
if [ -e "${nonoptlib}" ]; then
x="${nonoptlib}"
@ -176,14 +187,24 @@ copy_exec() {
copy_modules_dir()
{
local x_mod
local exclude
local dir="$1"
shift
if ! [ -d "${MODULESDIR}/${1}" ]; then
if ! [ -d "${MODULESDIR}/${dir}" ]; then
return;
fi
if [ "${verbose}" = "y" ]; then
echo "Copying module directory ${1}"
echo "Copying module directory ${dir}"
if [ $# -ge 1 ]; then
echo "(excluding $*)"
fi
fi
for x_mod in $(find "${MODULESDIR}/${1}" -name '*.ko' -print); do
while [ $# -ge 1 ]; do
exclude="$exclude -name $1 -prune -o "
shift
done
for x_mod in $(find "${MODULESDIR}/${dir}" ${exclude} -name '*.ko' -print); do
manual_add_modules $(basename ${x_mod} .ko)
done
}
@ -196,7 +217,7 @@ sys_walk_mod_add()
while [ "${device_path}" != "/sys" ]; do
sys_walk_modalias ${device_path}
driver_path="$(readlink -f ${device_path}/driver)"
driver_path="$(readlink -f ${device_path}/driver/module)"
if [ -e "$driver_path" ]; then
module="$(basename $(readlink -f $driver_path))"
if [ -n "${module}" ]; then
@ -228,10 +249,16 @@ dep_add_modules()
{
local block minor root FSTYPE root_dev_path x
# require mounted sysfs
if [ ! -d /sys/devices/ ]; then
echo "mkinitramfs: MODULES dep requires mounted sysfs on /sys"
exit 1
fi
# findout root block device + fstype
eval "$(mount | awk '/\/dev\// {if ($3 == "/") {print "root=" $1 "\nFSTYPE=" $5; exit}}')"
if [ "${root}" = "/dev/root" ] ; then
root="/dev/disk/by-uuid/"$(/sbin/blkid -s UUID -o value ${root}) 2>/dev/null
root="/dev/disk/by-uuid/"$(blkid -o value -s UUID ${root}) 2>/dev/null
fi
root="$(readlink -f ${root})"
@ -242,10 +269,13 @@ dep_add_modules()
# check that fstype rootfs recognition
if [ "${FSTYPE}" = "unknown" ]; then
echo "mkinitramfs: unknown fstype on root ${root}"
echo "mkinitramfs: workaround is MODULES=most"
echo "mkinitramfs: Error please report bug on initramfs-tools"
FSTYPE=$(blkid -o value -s TYPE "${root}")
if [ -z "${FSTYPE}" ]; then
echo "mkinitramfs: unknown fstype on root ${root}"
echo "mkinitramfs: workaround is MODULES=most"
echo "Error please report bug on initramfs-tools"
exit 1
fi
fi
# Add rootfs
@ -256,10 +286,10 @@ dep_add_modules()
|| [ "${root#/dev/dm-}" != "${root}" ]; then
minor=$((0x$(stat --format "%T" ${root}) % 256))
block=$(ls -1 /sys/block/dm-${minor}/slaves | head -n 1)
# lvm on luks or luks on lvm
if [ "${block#dm-}" != "${block}" ]; then
# lvm on luks or luks on lvm, possibly lvm snapshots
while [ "${block#dm-}" != "${block}" ]; do
block=$(ls -1 /sys/block/${block}/slaves | head -n 1)
fi
done
# lvm on md or luks on md
if [ "${block#md}" != "${block}" ]; then
block=$(awk "/^${block}/{print substr(\$5, 1, 4); exit}" \
@ -339,6 +369,10 @@ dep_add_modules()
manual_add_modules sd_mod
fi
if [ -e /sys/bus/mmc/devices/ ]; then
manual_add_modules mmc_block
fi
if [ -e /sys/bus/i2o/devices/ ]; then
force_load i2o_block
force_load i2o_config
@ -363,7 +397,7 @@ auto_add_modules()
{
case "$1" in
base)
for x in ehci-hcd ohci-hcd uhci-hcd usbhid usb-storage ext2 \
for x in ehci-hcd ohci-hcd uhci-hcd usbhid btrfs ext2 \
ext3 ext4 ext4dev isofs jfs nfs reiserfs udf xfs af_packet \
atkbd i8042 virtio_pci; do
manual_add_modules "${x}"
@ -375,19 +409,9 @@ auto_add_modules()
done
;;
net)
for x in 3c59x 8139cp 8139too 8390 atl1 atl1e b44 bmac \
bnx2 cxgb cxgb3 de2104x de4x5 defxx dl2k dmfe \
e100 e1000 e1000e ehea epic100 \
ep93xx_eth eql fealnx famachi forcedeth gelic_net \
hp100 igb ipg ixgb ixgbe mace mlx4_core mv643xx_eth myri10ge \
natsemi ne2k-pci netconsole netxen_nic niu ns83820 \
pcnet32 qla3xxx \
r8169 s2io sfc sis900 skge sky2 slhc smc911x starfire \
sundance sungem sungem_phy sunhme sunvnet tehuti tg3 tlan \
tulip typhoon via-rhine via-velocity winbond-840 \
xircom_cb xircom_tulip_cb yellowfin; do
manual_add_modules "${x}"
done
copy_modules_dir kernel/drivers/net \
appletalk arcnet bonding can hamradio irda pcmcia \
tokenring usb wan wimax wireless
;;
ide)
copy_modules_dir kernel/drivers/ide
@ -427,6 +451,9 @@ auto_add_modules()
manual_add_modules "${x}"
done
;;
usb_storage)
copy_modules_dir kernel/drivers/usb/storage
;;
*)
auto_add_modules base
auto_add_modules kms
@ -440,10 +467,12 @@ auto_add_modules()
auto_add_modules ieee1394
auto_add_modules firewire
auto_add_modules mmc
auto_add_modules usb_storage
;;
esac
}
# mkinitramfs help message
usage()
{
cat >&2 << EOF
@ -451,10 +480,11 @@ usage()
Usage: ${0} [OPTION]... -o outfile [version]
Options:
-d confdir Specify an alternative configuration directory.
-k Keep temporary directory used to make the image.
-o outfile Write to outfile.
-r root Override ROOT setting in initramfs.conf.
-c compress Override COMPRESS setting in initramfs.conf.
-d confdir Specify an alternative configuration directory.
-k Keep temporary directory used to make the image.
-o outfile Write to outfile.
-r root Override ROOT setting in initramfs.conf.
See mkinitramfs(8) for further details.
EOF
@ -462,6 +492,22 @@ EOF
}
# cache boot scripts order
cache_run_scripts()
{
DESTDIR=${1}
scriptdir=${2}
initdir=${DESTDIR}${scriptdir}
[ ! -d ${initdir} ] && return
runlist=$(get_prereq_pairs | tsort)
for crs_x in ${runlist}; do
[ -f ${initdir}/${crs_x} ] || continue
echo "${scriptdir}/${crs_x}" >> ${initdir}/ORDER
echo "[ -e /conf/param.conf ] && . /conf/param.conf" >> ${initdir}/ORDER
done
}
compare_versions()
{
local curv="$1" minv="$2"

View File

@ -32,9 +32,13 @@ tmpfs_size="10M"
if [ -e /etc/udev/udev.conf ]; then
. /etc/udev/udev.conf
fi
mount -t tmpfs -o size=$tmpfs_size,mode=0755 udev /dev
[ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1
[ -e /dev/null ] || mknod /dev/null c 1 3
if ! mount -t devtmpfs -o mode=0755 devtmpfs /dev; then
mount -t tmpfs -o size=$tmpfs_size,mode=0755 udev /dev
[ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1
[ -e /dev/null ] || mknod /dev/null c 1 3
fi
mkdir /dev/pts
mount -t devpts -o noexec,nosuid,gid=5,mode=0620 none /dev/pts || true
> /dev/.initramfs-tools
mkdir /dev/.initramfs
@ -51,6 +55,8 @@ export ROOTDELAY=
export ROOTFLAGS=
export ROOTFSTYPE=
export IP=
export BOOT=
export BOOTIF=
export break=
export init=/sbin/init
export quiet=n
@ -59,6 +65,7 @@ export rootmnt=/root
export debug=
export panic=
export blacklist=
export resume=
export resume_offset=
# Bring in the main config
@ -82,8 +89,8 @@ for x in $(cat /proc/cmdline); do
# support any / in LABEL= path (escape to \x2f)
case "${ROOT}" in
*[/]*)
if [ -x "$(command -v sed)" ]; then
*/*)
if command -v sed >/dev/null 2>&1; then
ROOT="$(echo ${ROOT} | sed 's,/,\\x2f,g')"
else
if [ "${ROOT}" != "${ROOT#/}" ]; then
@ -95,11 +102,7 @@ for x in $(cat /proc/cmdline); do
IFS='/'
newroot=
for s in $ROOT; do
if [ -z "${newroot}" ]; then
newroot="${s}"
else
newroot="${newroot}\\x2f${s}"
fi
newroot="${newroot:+${newroot}\\x2f}${s}"
done
unset IFS
ROOT="${newroot}"
@ -184,16 +187,21 @@ for x in $(cat /proc/cmdline); do
blacklist=*)
blacklist=${x#blacklist=}
;;
netconsole=*)
netconsole=${x#netconsole=}
;;
esac
done
if [ -z "${noresume}" ]; then
export resume=${RESUME}
else
if [ -n "${noresume}" ]; then
export noresume
unset resume
else
resume=${RESUME:-}
fi
depmod -a
[ -n "${netconsole}" ] && modprobe netconsole netconsole="${netconsole}"
maybe_break top
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-top"
run_scripts /scripts/init-top
@ -259,6 +267,8 @@ unset ROOTFSTYPE
unset ROOTDELAY
unset ROOT
unset IP
unset BOOT
unset BOOTIF
unset blacklist
unset break
unset noresume

View File

@ -1,4 +1,4 @@
.TH INITRAMFS-TOOLS 8 "2009/02/23" "Linux" "mkinitramfs script overview"
.TH INITRAMFS-TOOLS 8 "2010/04/05" "Linux" "mkinitramfs script overview"
.SH NAME
initramfs-tools \- an introduction to writing scripts for mkinitramfs
@ -65,8 +65,8 @@ Use root=/dev/nfs for NFS to kick to in. NFSOPTS can be looked up in
.TP
\fB\fI ip
tells how to configure the ip address. 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.
NFS server than the DHCP server. See Documentation/filesystems/nfsroot.txt
in any recent Linux source for details. Optional paramater for NFS root.
.TP
\fB\fI cryptopts
@ -123,6 +123,10 @@ The default is premount without any arg.
Beware that if both "panic" and "break" are present,
initramfs will not spawn any shells but reboot instead.
.TP
\fB\fI netconsole
loads netconsole linux modules with the chosen args.
.TP
\fB\fI all_generic_ide
loads generic IDE/ATA chipset support on boot.
@ -234,7 +238,7 @@ mkinitramfs sets several variables for the hook scripts environment.
corresponds to the linux-2.6 modules dir.
.TP
\fB\fI version
is the $(uname -r) linux-2.6 version against mkinitramfs is run.
is the $(uname \-r) linux-2.6 version against mkinitramfs is run.
.TP
\fB\fI CONFDIR
is the path of the used initramfs-tools configurations.
@ -465,6 +469,7 @@ prereqs)
;;
esac
\fR. /usr/share/initramfs-tools/hook-functions
# Begin real processing below this line
if [ ! \-x "/sbin/frobnicate" ]; then
panic "Frobnication executable not found"
@ -503,6 +508,10 @@ set according relevant boot option.
\fB\fI break
Useful for manual intervention during setup and coding an boot script.
.TP
\fB\fI REASON
Argument passed to the \fIpanic\fP helper function. Use to find out why
you landed in the initramfs shell.
.TP
\fB\fI init
passes the path to init(8) usually /sbin/init.
.TP

View File

@ -1,4 +1,4 @@
.TH INITRAMFS.CONF 5 "2010/02/20" "Linux" "initramfs.conf manual"
.TH INITRAMFS.CONF 5 "2010/04/05" "Linux" "initramfs.conf manual"
.SH NAME
initramfs.conf \- configuration file for mkinitramfs
@ -19,18 +19,12 @@ so you can override the settings in the main config file without editing it
directly.
.SH GENERAL VARIABLES
.TP
\fB COMPRESSION_TYPE
Specifies the compression type used by the generated initramfs. Possible
values are \fIgzip\fP, \fIbzip2\fP and \fIlzma\fP. If not set or any other
invalid value is set it will default to \fIgzip\fP.
.TP
\fB MODULES
Specifies the modules for the initramfs image.
The default setting is \fImost\fP.
\fImost\fP adds all the framebuffer, acpi, file system, ide, sata, scsi and usb drivers.
\fImost\fP adds most file system, all video KMS, all ide, sata, scsi and usb drivers.
\fIdep\fP tries to guess which modules are necessary for the running box.
@ -46,6 +40,18 @@ The keymap will anyway be loaded by the initscripts later, and the packages
that might need input will normally set this variable automatically, so there
should normally be no need to set this.
.TP
\fB COMPRESS
Specifies the compression method used for the initramfs image.
.B mkinitramfs
will default to gzip if the kernel lacks support (CONFIG_RD) or the
corresponding userspace utility is not present.
.TP
\fB UMASK
Set the umask value of the generated initramfs file.
Useful to not disclose eventual keys.
.SH NFS VARIABLES
.TP
\fB BOOT
@ -67,6 +73,9 @@ A root bootarg overrides that special setting.
Defaults to \fIauto\fP in order to pick up value from DHCP server.
Otherwise you need to specify \fIHOST:MOUNT\fP.
.SH FILES
.TP
.I /etc/initramfs-tools/initramfs.conf
.SH AUTHOR
The initramfs-tools are written by Maximilian Attems <maks@debian.org>,

View File

@ -9,7 +9,7 @@ CONFDIR="/etc/initramfs-tools"
verbose="n"
errors_to="2>/dev/null"
OPTIONS=`getopt -o d:ko:r:v -n "$0" -- "$@"`
OPTIONS=`getopt -o c:d:ko:r:v -n "$0" -- "$@"`
# Check for non-GNU getopt
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
@ -18,6 +18,10 @@ eval set -- "$OPTIONS"
while true; do
case "$1" in
-c)
compress="$2"
shift 2
;;
-d)
CONFDIR="$2"
shift 2
@ -73,16 +77,6 @@ for i in ${EXTRA_CONF}; do
fi
done
# Handle COMPRESSION_TYPE from initramfs.conf.
compress_cmd_args="-9"
case "${COMPRESSION_TYPE}" in
gzip) compress_cmd=gzip;;
bzip2) compress_cmd=bzip2;;
lzma) compress_cmd=lzma; compress_cmd_args="$compress_cmd_args -c";;
*) compress_cmd=gzip;;
esac
# source package confs
for i in /usr/share/initramfs-tools/conf-hooks.d/*; do
if [ -e "${i}" ]; then
@ -131,6 +125,27 @@ case "${version}" in
;;
esac
# Check userspace and kernel support for compressed initramfs images
if [ -z "${compress}" ]; then
compress=${COMPRESS}
else
COMPRESS=${compress}
fi
if ! command -v ${compress} >/dev/null 2>&1; then
compress=gzip
[ "${verbose}" = y ] && \
echo "No ${COMPRESS} in ${PATH}, using gzip"
fi
if [ -r /boot/config-${version} ]; then
if ! `grep -q -i config_rd_${COMPRESS}=y /boot/config-${version}` ; then
compress=gzip
[ "${verbose}" = y ] && \
echo "linux-2.6 misses ${COMPRESS} support, using gzip"
fi
fi
if [ -d "${outfile}" ]; then
echo "${outfile} is a directory"
exit 1
@ -139,14 +154,15 @@ fi
MODULESDIR="/lib/modules/${version}"
if [ ! -e "${MODULESDIR}" ]; then
echo "Cannot find ${MODULESDIR}"
exit 1
echo "WARNING: missing ${MODULESDIR}"
echo "Device driver support needs thus be built-in linux image!"
fi
if [ ! -e "${MODULESDIR}/modules.dep" ]; then
depmod ${version}
fi
DESTDIR="$(mktemp -t -d mkinitramfs_XXXXXX)" || exit 1
chmod 755 "${DESTDIR}"
__TMPCPIOGZ="$(mktemp -t mkinitramfs-OL_XXXXXX)" || exit 1
DPKG_ARCH=`uname -m`
@ -241,15 +257,28 @@ fi
run_scripts /usr/share/initramfs-tools/hooks
run_scripts "${CONFDIR}"/hooks
# cache boot run order
for b in $(cd "${DESTDIR}/scripts" && find . -mindepth 1 -type d); do
cache_run_scripts "${DESTDIR}" "/scripts/${b#./}"
done
# generate module deps
depmod -a -b "${DESTDIR}" ${version}
rm -f "${DESTDIR}/lib/modules/${version}"/modules.*map
# Apply DSDT to initramfs
if [ -e "${CONFDIR}/DSDT.aml" ]; then
copy_exec "${CONFDIR}/DSDT.aml" /
fi
# Remove any looping or broken symbolic links, since they break cpio.
find "${DESTDIR}" -type l -printf '%p %Y\n' | sed -n 's/ [LN]$//p' \
| xargs -rL1 rm -f
# Copy resume from klibc
copy_exec /bin/resume /bin
[ "${verbose}" = y ] && echo "Building cpio ${outfile} initramfs (${COMPRESSION_TYPE})"
[ "${verbose}" = y ] && echo "Building cpio ${outfile} initramfs"
(
# work around lack of "set -o pipefail" for the following pipe:
# cd "${DESTDIR}" && find . | cpio --quiet --dereference -o -H newc | gzip >"${outfile}" || exit 1
@ -262,7 +291,7 @@ eval `
find . 4>&-; echo "ec1=$?;" >&4
} | {
cpio --quiet --dereference -o -H newc 4>&-; echo "ec2=$?;" >&4
} | ${compress_cmd} ${compress_cmd_args} >"${outfile}"
} | ${compress} >"${outfile}"
echo "ec3=$?;" >&4
`
if [ "$ec1" -ne 0 ]; then exit "$ec1"; fi

View File

@ -1,10 +1,12 @@
.TH MKINITRAMFS 8 "2008/12/19" "Linux" "mkinitramfs manual"
.TH MKINITRAMFS 8 "2010/04/04" "Linux" "mkinitramfs manual"
.SH NAME
mkinitramfs \- low-level tool for generating an initramfs image
.SH SYNOPSIS
.B mkinitramfs
.RB [ \-c
.IR compress ]
.RB [ \-d
.IR confdir ]
.RB [ \-k ]
@ -27,7 +29,7 @@ mkinitramfs \- low-level tool for generating an initramfs image
The
.B mkinitramfs
script generates an initramfs image.
The initramfs is a gzipped cpio archive. The archive can be used on a
The initramfs is a compressed cpio archive. The archive can be used on a
different box of the same arch with the corresponding Linux kernel.
.B mkinitramfs
is meant for advanced usage. On your local box
@ -44,6 +46,13 @@ uses it as initial root file system. All finding of the root device
happens in this early userspace.
.SH OPTIONS
.TP
\fB \-c \fI compress
Override the
.B COMPRESS
setting in
.IR initramfs.conf .
.TP
\fB \-d \fI confdir
Set an alternate configuration directory.

View File

@ -42,8 +42,8 @@ panic()
fi
modprobe i8042
modprobe atkbd
echo $@
PS1='(initramfs) ' /bin/sh -i </dev/console >/dev/console 2>&1
echo "$@"
REASON="$@" PS1='(initramfs) ' /bin/sh -i </dev/console >/dev/console 2>&1
}
maybe_break()
@ -179,9 +179,22 @@ reduce_prereqs()
done
}
get_prereq_pairs()
{
set_initlist
for gp_x in ${initlist}; do
echo ${gp_x} ${gp_x}
prereqs=$(${initdir}/${gp_x} prereqs)
for prereq in ${prereqs}; do
echo ${prereq} ${gp_x}
done
done
}
call_scripts()
{
for cs_x in ${runlist}; do
[ -f ${initdir}/${cs_x} ] || continue
# mkinitramfs verbose output
if [ "${verbose}" = "y" ]; then
echo "Calling hook ${cs_x}"
@ -198,9 +211,17 @@ run_scripts()
{
initdir=${1}
[ ! -d ${initdir} ] && return
get_prereqs
reduce_prereqs
call_scripts
if [ -f ${initdir}/ORDER ]; then
. ${initdir}/ORDER
elif command -v tsort >/dev/null 2>&1; then
runlist=$(get_prereq_pairs | tsort)
call_scripts $2
else
get_prereqs
reduce_prereqs
call_scripts
fi
}
# Load custom modules first
@ -249,40 +270,114 @@ parse_numeric() {
ROOT=/dev/root
}
# Parameter: device node to check
# Echos fstype to stdout
# Return value: indicates if an fs could be recognized
get_fstype ()
{
local FS FSTYPE FSSIZE RET
FS="${1}"
# vol_id has a more complete list of file systems,
# but fstype is more robust
eval $(fstype "${FS}" 2> /dev/null)
if [ "$FSTYPE" = "unknown" ] && command -v blkid >/dev/null 2>&1 ; then
FSTYPE=$(blkid -o value -s TYPE "${FS}")
elif [ "$FSTYPE" = "unknown" ] && [ -x /lib/udev/vol_id ]; then
FSTYPE=$(/lib/udev/vol_id -t "${FS}" 2> /dev/null)
fi
RET=$?
if [ -z "${FSTYPE}" ]; then
FSTYPE="unknown"
fi
echo "${FSTYPE}"
return ${RET}
}
configure_networking()
{
if [ -n "${BOOTIF}" ]; then
# pxelinux sets BOOTIF to a value based on the mac address of the
# network card used to PXE boot, so use this value for DEVICE rather
# than a hard-coded device name from initramfs.conf. this facilitates
# network booting when machines may have multiple network cards.
# pxelinux sets BOOTIF to 01-$mac_address
# strip off the leading "01-", which isn't part of the mac
# address
temp_mac=${BOOTIF#*-}
# convert to typical mac address format by replacing "-" with ":"
bootif_mac=""
IFS='-'
for x in $temp_mac ; do
if [ -z "$bootif_mac" ]; then
bootif_mac="$x"
else
bootif_mac="$x:$bootif_mac"
fi
done
unset IFS
# look for devices with matching mac address, and set DEVICE to
# appropriate value if match is found.
for device in /sys/class/net/* ; do
if [ -f "$device/address" ]; then
current_mac=$(cat "$device/address")
if [ "$bootif_mac" = "$current_mac" ]; then
DEVICE=${device##*/}
break
fi
fi
done
fi
# networking already configured thus bail out
[ -n "${DEVICE}" ] && [ -e /tmp/net-"${DEVICE}".conf ] && return 0
# support ip options see linux sources
# Documentation/filesystems/nfsroot.txt
case ${IP} in
none|off)
# Do nothing
;;
""|on|any)
# Bring up device
ipconfig -t 180 ${DEVICE}
;;
dhcp|bootp|rarp|both)
ipconfig -t 180 -c ${IP} -d ${DEVICE}
;;
*)
ipconfig -t 180 -d $IP
# Documentation/frv/booting.txt
# grab device entry from ip option
NEW_DEVICE=${IP#*:*:*:*:*:*}
if [ "${NEW_DEVICE}" != "${IP}" ]; then
NEW_DEVICE=${NEW_DEVICE%:*}
else
# wrong parse, possibly only a partial string
NEW_DEVICE=
for ROUNDTTT in 2 3 4 6 9 16 25 36 64 100; do
# The NIC is to be configured if this file does not exist.
# Ip-Config tries to create this file and when it succeds
# creating the file, ipconfig is not run again.
if [ -e /tmp/net-"${DEVICE}".conf ]; then
break;
fi
if [ -n "${NEW_DEVICE}" ]; then
DEVICE="${NEW_DEVICE}"
fi
;;
esac
case ${IP} in
none|off)
# Do nothing
;;
""|on|any)
# Bring up device
ipconfig -t ${ROUNDTTT} ${DEVICE}
;;
dhcp|bootp|rarp|both)
ipconfig -t ${ROUNDTTT} -c ${IP} -d ${DEVICE}
;;
*)
ipconfig -t ${ROUNDTTT} -d $IP
# grab device entry from ip option
NEW_DEVICE=${IP#*:*:*:*:*:*}
if [ "${NEW_DEVICE}" != "${IP}" ]; then
NEW_DEVICE=${NEW_DEVICE%:*}
else
# wrong parse, possibly only a partial string
NEW_DEVICE=
fi
if [ -n "${NEW_DEVICE}" ]; then
DEVICE="${NEW_DEVICE}"
fi
;;
esac
done
# source ipconfig output
if [ -n "${DEVICE}" ]; then
@ -297,6 +392,6 @@ configure_networking()
# Wait for queued kernel/udev events
wait_for_udev()
{
[ -x "$(command -v udevadm)" ] || return 0
command -v udevadm >/dev/null 2>&1 || return 0
udevadm settle ${1:+--timeout=$1}
}

View File

@ -1,32 +1,13 @@
# Local filesystem mounting -*- shell-script -*-
# Parameter: device node to check
# Echos fstype to stdout
# Return value: indicates if an fs could be recognized
get_fstype ()
{
local FS FSTYPE FSSIZE RET
FS="${1}"
FSTYPE=$(/sbin/blkid -s TYPE -o value "${FS}" 2> /dev/null)
RET=$?
if [ -z "${FSTYPE}" ]; then
FSTYPE="unknown"
fi
echo "${FSTYPE}"
return ${RET}
}
pre_mountroot()
{
wait_for_udev 10
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top"
run_scripts /scripts/local-top
[ "$quiet" != "y" ] && log_end_msg
wait_for_udev 10
# Don't wait for a root device that doesn't have a corresponding
# device in /dev (ie, mtd0)
if [ "${ROOT#/dev}" = "${ROOT}" ]; then
@ -44,6 +25,9 @@ pre_mountroot()
else
slumber=${ROOTDELAY}
fi
if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "TIMEOUT ${slumber}" || true
fi
slumber=$(( ${slumber} * 10 ))
while [ ! -e "${ROOT}" ] \
@ -58,6 +42,9 @@ pre_mountroot()
else
log_end_msg 1 || true
fi
if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "TIMEOUT 15" || true
fi
fi
# We've given up, but we'll let the user fix matters if they can
@ -116,7 +103,11 @@ mountroot()
# FIXME This has no error checking
# Mount root
mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
if [ "${FSTYPE}" != "unknown" ]; then
mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
else
mount ${roflag} ${ROOTFLAGS} ${ROOT} ${rootmnt}
fi
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
run_scripts /scripts/local-bottom

View File

@ -25,8 +25,8 @@ LABEL=*)
# support any / in LABEL= path (escape to \x2f)
case "${resume}" in
*[/]*)
if [ -x "$(command -v sed)" ]; then
*/*)
if command -v sed >/dev/null 2>&1; then
resume="$(echo ${resume} | sed 's,/,\\x2f,g')"
else
if [ "${resume}" != "${resume#/}" ]; then
@ -38,11 +38,7 @@ LABEL=*)
IFS='/'
newresume=
for s in $resume; do
if [ -z "${newresume}" ]; then
newresume="${s}"
else
newresume="${newresume}\\x2f${s}"
fi
newresume="${newresume:+${newresume}\\x2f}${s}"
done
unset IFS
resume="${newresume}"

View File

@ -128,7 +128,7 @@ backup_booted_initramfs()
}
# nuke generated copy
remove_initramfs()
remove_initramfs_bak()
{
[ -z "${initramfs_bak}" ] && return 0
rm -f "${initramfs_bak}"
@ -148,7 +148,7 @@ generate_initramfs()
set_sha1
else
mkinitramfs_return="$?"
remove_initramfs
remove_initramfs_bak
rm -f "${initramfs}.new"
if [ "$mkinitramfs_return" = "2" ]; then
# minversion wasn't met, exit 0
@ -346,12 +346,14 @@ delete()
set_initramfs
if [ ! -e "${initramfs}" ]; then
panic "Cannot delete ${initramfs}, doesn't exist."
fi
if [ "${takeover}" = 0 ]; then
if [ ! -e "${initramfs}" ]; then
panic "Cannot delete ${initramfs}, doesn't exist."
fi
if ! version_exists "${version}"; then
panic "Cannot delete version ${version}: Not created by this utility."
if ! version_exists "${version}"; then
panic "Cannot delete version ${version}: Not created by this utility."
fi
fi
altered_check
@ -360,7 +362,7 @@ delete()
delete_sha1
rm -f "${initramfs}"
rm -f "${initramfs}" "${initramfs}.bak"
}
# Check for update mode on existing and modified initramfs

View File

@ -1,4 +1,4 @@
.TH UPDATE-INITRAMFS.CONF 5 "2008/12/19" "Linux" "update-initramfs.conf manual"
.TH UPDATE-INITRAMFS.CONF 5 "2010/04/05" "Linux" "update-initramfs.conf manual"
.SH NAME
update-initramfs.conf \- configuration file for update-initramfs
@ -18,7 +18,11 @@ conservative manners needs to be applied. This disables
the \fBupdate_initramfs \-u\fP call.
.TP
\fB backup_initramfs
By default \fBupdate_initramfs\fP keeps an .bak file of the previous initramfs. If set to \fIno\fP the backup initramfs will not be kept.
If set \fBupdate_initramfs\fP keeps an .bak file of the previous initramfs. If unset the backup initramfs will not be kept.
.SH FILES
.TP
.I /etc/initramfs-tools/update-initramfs.conf
.SH AUTHOR
The initramfs-tools are written by Maximilian Attems <maks@debian.org>,

View File

@ -1,6 +1,6 @@
# Template file for 'initramfs-tools'
pkgname=initramfs-tools
version=0.98.1
version=0.99.debian0.94.4
build_style=custom-install
short_desc="Tools for generating an initramfs"
maintainer="Juan RP <xtraeme@gmail.com>"