initramfs-tools: sync code with upstream 0.98.5.
This commit is contained in:
parent
9ee7b7cfa6
commit
0e4a1d574e
|
@ -3,7 +3,7 @@
|
|||
catenate_cpiogz() {
|
||||
# Sanity check
|
||||
if [ ! -e "${1}" ]; then
|
||||
echo "W:catenate_cpiogz: arg1='${1}' does not exist." >&2
|
||||
echo "W: catenate_cpiogz: arg1='${1}' does not exist." >&2
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -29,7 +29,7 @@ add_modules_from_file()
|
|||
{
|
||||
# Sanity check
|
||||
if [ ! -e "${1}" ]; then
|
||||
echo "W:add_modules_from_file: arg1='${1}' does not exist." >&2
|
||||
echo "W: add_modules_from_file: arg1='${1}' does not exist." >&2
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -73,6 +73,7 @@ manual_add_modules()
|
|||
if [ ! -e /proc/modules ] ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if grep -q "^$(basename "${kmod}" .ko)[[:space:]]" \
|
||||
/proc/modules \
|
||||
|| grep -q "^$(basename "${kmod}" .ko)" \
|
||||
|
@ -113,7 +114,7 @@ copy_exec() {
|
|||
[ -f "${src}" ] || return 1
|
||||
|
||||
if [ -d "${DESTDIR}/${target}" ]; then
|
||||
# check if already copied
|
||||
# check if already copied
|
||||
[ -e "${DESTDIR}/$target/${src##*/}" ] && return 0
|
||||
else
|
||||
[ -e "${DESTDIR}/$target" ] && return 0
|
||||
|
@ -126,10 +127,10 @@ copy_exec() {
|
|||
|
||||
# Copy the dependant libraries
|
||||
for x in $(ldd ${src} 2>/dev/null | sed -e '
|
||||
/\//!d;
|
||||
/linux-gate/d;
|
||||
/=>/ {s/.*=>[[:blank:]]*\([^[:blank:]]*\).*/\1/};
|
||||
s/[[:blank:]]*\([^[:blank:]]*\) (.*)/\1/' 2>/dev/null); do
|
||||
/\//!d;
|
||||
/linux-gate/d;
|
||||
/=>/ {s/.*=>[[:blank:]]*\([^[:blank:]]*\).*/\1/};
|
||||
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,
|
||||
|
@ -147,7 +148,7 @@ copy_exec() {
|
|||
mkdir -p "${DESTDIR}/${dirname}"
|
||||
if [ ! -e "${DESTDIR}/${dirname}/${libname}" ]; then
|
||||
ln -s "${x}" "${DESTDIR}/${dirname}"
|
||||
[ "${verbose}" = "y" ] && echo "Adding library ${x}"
|
||||
[ "${verbose}" = "y" ] && echo "Adding library ${x}" || true
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@ -165,7 +166,7 @@ copy_modules_dir()
|
|||
if [ "${verbose}" = "y" ]; then
|
||||
echo "Copying module directory ${dir}"
|
||||
if [ $# -ge 1 ]; then
|
||||
echo "(excluding $*)"
|
||||
echo "(excluding $*)"
|
||||
fi
|
||||
fi
|
||||
while [ $# -ge 1 ]; do
|
||||
|
@ -182,7 +183,7 @@ sys_walk_mod_add()
|
|||
{
|
||||
local driver_path module
|
||||
device_path="$1"
|
||||
|
||||
|
||||
while [ "${device_path}" != "/sys" ]; do
|
||||
sys_walk_modalias ${device_path}
|
||||
driver_path="$(readlink -f ${device_path}/driver/module)"
|
||||
|
@ -219,12 +220,38 @@ dep_add_modules()
|
|||
|
||||
# require mounted sysfs
|
||||
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
|
||||
fi
|
||||
|
||||
# findout root block device + fstype
|
||||
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
|
||||
root="/dev/disk/by-uuid/"$(blkid -o value -s UUID ${root}) 2>/dev/null
|
||||
fi
|
||||
|
@ -239,10 +266,10 @@ dep_add_modules()
|
|||
if [ "${FSTYPE}" = "unknown" ]; then
|
||||
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
|
||||
echo "mkinitramfs: unknown fstype on root ${root}" >&2
|
||||
echo "mkinitramfs: workaround is MODULES=most" >&2
|
||||
echo "Error please report bug on initramfs-tools" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -260,8 +287,7 @@ dep_add_modules()
|
|||
done
|
||||
# lvm on md or luks on md
|
||||
if [ "${block#md}" != "${block}" ]; then
|
||||
block=$(awk "/^${block}/{print substr(\$5, 1, 4); exit}" \
|
||||
/proc/mdstat)
|
||||
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)
|
||||
fi
|
||||
# luks or lvm on cciss or ida
|
||||
if [ "${block#cciss}" != "${block}" ] \
|
||||
|
@ -273,13 +299,15 @@ dep_add_modules()
|
|||
# md root new naming scheme /dev/md/X
|
||||
elif [ "${root#/dev/md/}" != "${root}" ]; then
|
||||
root=${root#/dev/md/}
|
||||
block=$(awk "/^md${root}/{print substr(\$5, 1, 3); exit}" \
|
||||
/proc/mdstat)
|
||||
# drop the partition number only for sdX and hdX devices
|
||||
# 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
|
||||
elif [ "${root#/dev/md}" != "${root}" ]; then
|
||||
root=${root#/dev/}
|
||||
block=$(awk "/^${root}/{print substr(\$5, 1, 3); exit}" \
|
||||
/proc/mdstat)
|
||||
root=${root#/dev/md}
|
||||
# drop the partition number only for sdX and hdX devices
|
||||
# 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
|
||||
elif [ "${root#/dev/cciss/}" != "${root}" ]; then
|
||||
block=${root#/dev/cciss/*}
|
||||
|
@ -320,9 +348,9 @@ dep_add_modules()
|
|||
|
||||
# Error out if /sys lack block dev
|
||||
if [ -z "${block}" ] || [ ! -e /sys/block/${block} ]; then
|
||||
echo "mkinitramfs: for root ${root} missing ${block} /sys/block/ entry"
|
||||
echo "mkinitramfs: workaround is MODULES=most"
|
||||
echo "mkinitramfs: Error please report the bug"
|
||||
echo "mkinitramfs: for root ${root} missing ${block} /sys/block/ entry" >&2
|
||||
echo "mkinitramfs: workaround is MODULES=most" >&2
|
||||
echo "mkinitramfs: Error please report the bug" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -347,6 +375,10 @@ dep_add_modules()
|
|||
manual_add_modules mmc_block
|
||||
fi
|
||||
|
||||
if [ -e /sys/bus/virtio ] ; then
|
||||
manual_add_modules virtio_pci
|
||||
fi
|
||||
|
||||
if [ -e /sys/bus/i2o/devices/ ]; then
|
||||
force_load i2o_block
|
||||
force_load i2o_config
|
||||
|
@ -372,7 +404,7 @@ auto_add_modules()
|
|||
case "${1:-}" in
|
||||
base)
|
||||
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 \
|
||||
af_packet atkbd i8042 virtio_pci; do
|
||||
manual_add_modules "${x}"
|
||||
|
@ -406,6 +438,11 @@ auto_add_modules()
|
|||
block)
|
||||
copy_modules_dir kernel/drivers/block
|
||||
;;
|
||||
ubi)
|
||||
for x in deflate zlib lzo ubi ubifs; do
|
||||
manual_add_modules "${x}"
|
||||
done
|
||||
;;
|
||||
ieee1394)
|
||||
for x in ohci1394 sbp2; do
|
||||
manual_add_modules "${x}"
|
||||
|
@ -455,11 +492,11 @@ usage()
|
|||
Usage: ${0} [OPTION]... -o outfile [version]
|
||||
|
||||
Options:
|
||||
-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.
|
||||
-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
|
||||
|
@ -490,9 +527,9 @@ compare_versions()
|
|||
xbps-uhelper cmpver $curv $minv
|
||||
if [ $? -eq 0 ] || [ $? -eq 1 ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# minimal supported kernel version
|
||||
|
@ -503,8 +540,7 @@ check_minkver()
|
|||
curversion="${1:-}"
|
||||
initdir="${2:-}"
|
||||
if [ -z "${initdir}" ]; then
|
||||
ARCH=$(uname -m)
|
||||
case ${ARCH} in
|
||||
case ${ARCH:-} in
|
||||
ia64|hppa)
|
||||
minversion="2.6.15"
|
||||
;;
|
||||
|
@ -521,10 +557,10 @@ check_minkver()
|
|||
fi
|
||||
set_initlist
|
||||
for cm_x in ${initlist:-}; do
|
||||
# sed: keep last line starting with MINKVER=,
|
||||
# remove MINKVER= and trailing space
|
||||
# sed: keep last line starting with MINKVER=,
|
||||
# remove MINKVER= and trailing space
|
||||
minver=$(sed '/^MINKVER=/!d;$!d;s/^MINKVER=//;s/[[:space:]]*$//' "${initdir}/${cm_x}")
|
||||
if [ -z "${tmp}" ]; then
|
||||
if [ -z "${tmp:-}" ]; then
|
||||
continue
|
||||
elif ! compare_versions "${curversion}" "${minver}"; then
|
||||
echo "W: ${cm_x} hook script requires at least kernel version ${minver}" >&2
|
||||
|
|
|
@ -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
|
|
@ -33,12 +33,13 @@ if [ -e /etc/udev/udev.conf ]; then
|
|||
. /etc/udev/udev.conf
|
||||
fi
|
||||
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
|
||||
[ -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
|
||||
mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true
|
||||
> /dev/.initramfs-tools
|
||||
mkdir /dev/.initramfs
|
||||
|
||||
|
@ -57,6 +58,7 @@ export ROOTFSTYPE=
|
|||
export IP=
|
||||
export BOOT=
|
||||
export BOOTIF=
|
||||
export UBIMTD=
|
||||
export break=
|
||||
export init=/sbin/init
|
||||
export quiet=n
|
||||
|
@ -141,6 +143,9 @@ for x in $(cat /proc/cmdline); do
|
|||
boot=*)
|
||||
BOOT=${x#boot=}
|
||||
;;
|
||||
ubi.mtd=*)
|
||||
UBIMTD=${x#ubi.mtd=}
|
||||
;;
|
||||
resume=*)
|
||||
RESUME="${x#resume=}"
|
||||
;;
|
||||
|
@ -221,12 +226,12 @@ run_scripts /scripts/init-premount
|
|||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
maybe_break mount
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Mounting root file system"
|
||||
log_begin_msg "Mounting root file system"
|
||||
. /scripts/${BOOT}
|
||||
parse_numeric ${ROOT}
|
||||
maybe_break mountroot
|
||||
mountroot
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
log_end_msg
|
||||
|
||||
maybe_break bottom
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom"
|
||||
|
@ -237,25 +242,51 @@ run_scripts /scripts/init-bottom
|
|||
mount -n -o move /sys ${rootmnt}/sys
|
||||
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
|
||||
if [ -n "${init}" ] && [ ! -x "${rootmnt}${init}" ]; then
|
||||
echo "Target filesystem doesn't have ${init}."
|
||||
init=
|
||||
if [ -n "${init}" ]; then
|
||||
if ! validate_init "$init"; then
|
||||
echo "Target filesystem doesn't have requested ${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
|
||||
break
|
||||
done
|
||||
fi
|
||||
|
||||
# No init on rootmount
|
||||
if [ ! -x "${rootmnt}${init}" ]; then
|
||||
panic "No init found. Try passing init= bootarg."
|
||||
# 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
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# No init on rootmount
|
||||
if ! validate_init "${init}" ; then
|
||||
panic "No init found. Try passing init= bootarg."
|
||||
fi
|
||||
fi
|
||||
|
||||
maybe_break init
|
||||
|
@ -272,6 +303,7 @@ unset ROOT
|
|||
unset IP
|
||||
unset BOOT
|
||||
unset BOOTIF
|
||||
unset UBIMTD
|
||||
unset blacklist
|
||||
unset break
|
||||
unset noresume
|
||||
|
@ -282,5 +314,5 @@ unset resume
|
|||
unset resume_offset
|
||||
|
||||
# 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."
|
||||
|
|
|
@ -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
|
||||
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
|
||||
frobnication of a lvm partition prior to mounting the root partition.
|
||||
|
||||
Valid boot and hook scripts names consist solely of alphabetics, numerics
|
||||
and underscores. Other scripts are discarded.
|
||||
.SH Kernel Command Line
|
||||
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
|
||||
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.
|
||||
.SS Standard
|
||||
|
||||
.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.
|
||||
|
||||
.TP
|
||||
\fB\fI root
|
||||
\fB\fI root= "<path to blockdevice>"
|
||||
the device node to mount as the root file system.
|
||||
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
|
||||
\fB\fI rootdelay
|
||||
|
@ -51,10 +41,6 @@ The default is 180 seconds.
|
|||
\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
|
||||
|
@ -66,12 +52,12 @@ Use root=/dev/nfs for NFS to kick to in. NFSOPTS can be looked up in
|
|||
\fB\fI ip
|
||||
tells how to configure the ip address. Allows to specify an different
|
||||
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
|
||||
\fB\fI BOOTIF
|
||||
is a mac adress in pxelinux format with leading "01-" and "-" as separations.
|
||||
pxelinux passes mac adress of network card used to PXE boot on with this
|
||||
is a mac address in pxelinux format with leading "01-" and "-" as separations.
|
||||
pxelinux passes mac address of network card used to PXE boot on with this
|
||||
bootarg.
|
||||
|
||||
.TP
|
||||
|
@ -106,6 +92,7 @@ mounts the rootfs read-write.
|
|||
disables load of specific modules.
|
||||
Use blacklist=module1,module2,module3 bootparameter.
|
||||
|
||||
.SS Debug
|
||||
.TP
|
||||
\fB\fI panic
|
||||
sets an timeout on panic.
|
||||
|
@ -136,6 +123,21 @@ loads generic IDE/ATA chipset support on boot.
|
|||
|
||||
.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
|
||||
/etc/initramfs-tools/hooks. They are executed during generation of the
|
||||
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
|
||||
\fB\fI MODULES
|
||||
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.
|
||||
|
||||
|
||||
|
@ -372,14 +374,14 @@ contains the following subdirectories.
|
|||
\fB\fI
|
||||
init-top
|
||||
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.
|
||||
No other device files are present yet.
|
||||
and procfs have been mounted.
|
||||
It also runs the udev hook for populating the /dev tree (udev will keep
|
||||
running until init-bottom).
|
||||
|
||||
.TP
|
||||
\fB\fI
|
||||
init-premount
|
||||
runs the udev hooks for populating the /dev tree (udev will keep running until
|
||||
init-bottom) after modules specified by hooks and /etc/initramfs-tools/modules
|
||||
happens after modules specified by hooks and /etc/initramfs-tools/modules
|
||||
have been loaded.
|
||||
|
||||
.TP
|
||||
|
@ -399,14 +401,14 @@ been mounted.
|
|||
\fB\fI
|
||||
local-bottom OR nfs-bottom
|
||||
are run after the rootfs has been mounted (local) or the NFS root share has
|
||||
been mounted. udev is stopped.
|
||||
been mounted.
|
||||
|
||||
.TP
|
||||
\fB\fI
|
||||
init-bottom
|
||||
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
|
||||
found in the mounted rootfs.
|
||||
found in the mounted rootfs. udev is stopped.
|
||||
|
||||
.SS Boot parameters
|
||||
.TP
|
||||
|
@ -496,12 +498,12 @@ init sets several variables for the boot scripts environment.
|
|||
|
||||
.TP
|
||||
\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.
|
||||
Otherwise keep it alone.
|
||||
.TP
|
||||
\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
|
||||
\fB\fI DPKG_ARCH
|
||||
allows arch specific boot actions.
|
||||
|
@ -521,10 +523,10 @@ passes the path to init(8) usually /sbin/init.
|
|||
.TP
|
||||
\fB\fI readonly
|
||||
is the default for mounting the root corresponds to the ro bootarg.
|
||||
Overriden by rw bootarg.
|
||||
Overridden by rw bootarg.
|
||||
.TP
|
||||
\fB\fI rootmnt
|
||||
is the path where root gets mounted usualy /root.
|
||||
is the path where root gets mounted usually /root.
|
||||
.TP
|
||||
\fB\fI debug
|
||||
indicates that a debug log is captured for further investigation.
|
||||
|
|
|
@ -7,12 +7,11 @@ export PATH='/usr/bin:/sbin:/bin'
|
|||
keep="n"
|
||||
CONFDIR="/etc/initramfs-tools"
|
||||
verbose="n"
|
||||
errors_to="2>/dev/null"
|
||||
|
||||
OPTIONS=`getopt -o c:d:ko:r:v -n "$0" -- "$@"`
|
||||
|
||||
# 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"
|
||||
|
||||
|
@ -68,7 +67,7 @@ for i in /usr/share/initramfs-tools/conf.d/* ${CONFDIR}/conf.d/*; do
|
|||
| grep '^[[:alnum:]][[:alnum:]\._-]*$' | grep -v '\.dpkg-.*$')";
|
||||
done
|
||||
# FIXME: deprecated those settings on mkinitramfs run
|
||||
# these conf dirs are for boot scripts and land on initramfs
|
||||
# these conf dirs are for boot scripts and land on initramfs
|
||||
for i in ${EXTRA_CONF}; do
|
||||
if [ -e ${CONFDIR}/conf.d/${i} ]; then
|
||||
. ${CONFDIR}/conf.d/${i}
|
||||
|
@ -132,25 +131,23 @@ else
|
|||
COMPRESS=${compress}
|
||||
fi
|
||||
|
||||
if ! command -v ${compress} >/dev/null 2>&1; then
|
||||
if ! command -v "${compress}" >/dev/null 2>&1; then
|
||||
compress=gzip
|
||||
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
|
||||
if ! `grep -q -i ^config_rd_${COMPRESS%p} /boot/config-${version}` ; then
|
||||
compress=gzip
|
||||
[ "${verbose}" = y ] && \
|
||||
echo "linux-2.6 misses ${COMPRESS} support, using gzip"
|
||||
fi
|
||||
|
||||
# Always use max compression.
|
||||
compress="${compress} -9"
|
||||
[ "${compress}" = lzop ] && compress="lzop -9"
|
||||
|
||||
if [ -d "${outfile}" ]; then
|
||||
echo "${outfile} is a directory"
|
||||
echo "${outfile} is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -166,6 +163,16 @@ fi
|
|||
|
||||
DESTDIR="$(mktemp -d ${TMPDIR:-/tmp}/mkinitramfs_XXXXXX)" || exit 1
|
||||
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
|
||||
|
||||
DPKG_ARCH=`uname -m`
|
||||
|
@ -191,7 +198,7 @@ done
|
|||
# Copy the modules.order file in
|
||||
if [ -f "${MODULESDIR}/modules.order" ]; then
|
||||
cp -p "${MODULESDIR}/modules.order" \
|
||||
"${DESTDIR}${MODULESDIR}/modules.order"
|
||||
"${DESTDIR}${MODULESDIR}/modules.order"
|
||||
fi
|
||||
|
||||
# MODULES=list case. Always honour.
|
||||
|
@ -217,26 +224,27 @@ list)
|
|||
# nothing to add
|
||||
;;
|
||||
*)
|
||||
echo "mkinitramfs: Warning unsupported MODULES setting: ${MODULES}."
|
||||
echo "mkinitramfs: Falling back to MODULES=most."
|
||||
echo "W: mkinitramfs: unsupported MODULES setting: ${MODULES}."
|
||||
echo "W: mkinitramfs: Falling back to MODULES=most."
|
||||
auto_add_modules
|
||||
;;
|
||||
esac
|
||||
|
||||
# Have to do each file, because cpio --dereference doesn't recurse down
|
||||
# symlinks.
|
||||
|
||||
cp -p /usr/share/initramfs-tools/init ${DESTDIR}/init
|
||||
|
||||
# add existant boot scripts
|
||||
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}")" ] \
|
||||
|| mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")"
|
||||
cp -p "/usr/share/initramfs-tools/scripts/${b}" \
|
||||
"${DESTDIR}/scripts/$(dirname "${b}")/"
|
||||
done
|
||||
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}")" ] \
|
||||
|| mkdir -p "${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
|
||||
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 "${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
|
||||
|
||||
# Copy in tsort(1).
|
||||
copy_exec /bin/tsort /bin
|
||||
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
|
||||
cache_run_scripts "${DESTDIR}" "/scripts/${b#./}"
|
||||
done
|
||||
fi
|
||||
|
||||
# generate module deps
|
||||
depmod -a -b "${DESTDIR}" ${version}
|
||||
|
@ -279,11 +300,8 @@ fi
|
|||
|
||||
# Remove any looping or broken symbolic links, since they break cpio.
|
||||
[ "${verbose}" = y ] && xargs_verbose="-t"
|
||||
find "${DESTDIR}" -type l -printf '%p %Y\n' | sed -n 's/ [LN]$//p' \
|
||||
| xargs ${xargs_verbose:-} -rL1 rm -f
|
||||
|
||||
# Copy resume from klibc
|
||||
copy_exec /bin/resume /bin
|
||||
(cd "${DESTDIR}" && find . -type l -printf '%p %Y\n' | sed -n 's/ [LN]$//p' \
|
||||
| xargs ${xargs_verbose:-} -rL1 rm -f)
|
||||
|
||||
[ "${verbose}" = y ] && echo "Building cpio ${outfile} initramfs"
|
||||
(
|
||||
|
@ -291,19 +309,28 @@ copy_exec /bin/resume /bin
|
|||
# cd "${DESTDIR}" && find . | cpio --quiet --dereference -o -H newc | gzip >"${outfile}" || exit 1
|
||||
exec 3>&1
|
||||
eval `
|
||||
# http://cfaj.freeshell.org/shell/cus-faq-2.html
|
||||
exec 4>&1 >&3 3>&-
|
||||
cd "${DESTDIR}"
|
||||
{
|
||||
find . 4>&-; echo "ec1=$?;" >&4
|
||||
} | {
|
||||
cpio --quiet --dereference -o -H newc 4>&-; echo "ec2=$?;" >&4
|
||||
} | ${compress} >"${outfile}"
|
||||
echo "ec3=$?;" >&4
|
||||
# http://cfaj.freeshell.org/shell/cus-faq-2.html
|
||||
exec 4>&1 >&3 3>&-
|
||||
cd "${DESTDIR}"
|
||||
{
|
||||
find . 4>&-; echo "ec1=$?;" >&4
|
||||
} | {
|
||||
cpio --quiet --dereference -o -H newc 4>&-; echo "ec2=$?;" >&4
|
||||
} | ${compress} >"${outfile}"
|
||||
echo "ec3=$?;" >&4
|
||||
`
|
||||
if [ "$ec1" -ne 0 ]; then exit "$ec1"; fi
|
||||
if [ "$ec2" -ne 0 ]; then exit "$ec2"; fi
|
||||
if [ "$ec3" -ne 0 ]; then exit "$ec3"; fi
|
||||
if [ "$ec1" -ne 0 ]; then
|
||||
echo "E: mkinitramfs failure find $ec1 cpio $ec2 $compress $ec3"
|
||||
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
|
||||
|
||||
if [ -s "${__TMPCPIOGZ}" ]; then
|
||||
|
|
|
@ -8,6 +8,13 @@ pre_mountroot()
|
|||
|
||||
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
|
||||
# device in /dev (ie, mtd0)
|
||||
if [ "${ROOT#/dev}" = "${ROOT}" ]; then
|
||||
|
@ -19,12 +26,9 @@ pre_mountroot()
|
|||
if [ ! -e "${ROOT}" ] || ! $(get_fstype "${ROOT}" >/dev/null); then
|
||||
log_begin_msg "Waiting for root file system"
|
||||
|
||||
# Default delay is 180s
|
||||
if [ -z "${ROOTDELAY}" ]; then
|
||||
slumber=180
|
||||
else
|
||||
slumber=${ROOTDELAY}
|
||||
fi
|
||||
# Default delay is 30s
|
||||
slumber=${ROOTDELAY:-30}
|
||||
|
||||
if [ -x /sbin/usplash_write ]; then
|
||||
/sbin/usplash_write "TIMEOUT ${slumber}" || true
|
||||
fi
|
||||
|
@ -50,7 +54,7 @@ pre_mountroot()
|
|||
# We've given up, but we'll let the user fix matters if they can
|
||||
while [ ! -e "${ROOT}" ]; do
|
||||
# give hint about renamed root
|
||||
case "${ROOT}" in
|
||||
case "${ROOT}" in
|
||||
/dev/hd*)
|
||||
suffix="${ROOT#/dev/hd}"
|
||||
major="${suffix%[[:digit:]]}"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
retry_nr=0
|
||||
|
||||
# parse nfs bootargs and mount nfs
|
||||
# parse nfs bootargs and mount nfs
|
||||
do_nfsmount()
|
||||
{
|
||||
|
||||
|
@ -62,21 +62,16 @@ mountroot()
|
|||
wait_for_udev 10
|
||||
|
||||
# Default delay is around 180s
|
||||
# FIXME: add usplash_write info
|
||||
if [ -z "${ROOTDELAY}" ]; then
|
||||
delay=180
|
||||
else
|
||||
delay=${ROOTDELAY}
|
||||
fi
|
||||
delay=${ROOTDELAY:-180}
|
||||
|
||||
# loop until nfsmount succeds
|
||||
# loop until nfsmount succeeds
|
||||
do_nfsmount
|
||||
while [ ${retry_nr} -lt ${delay} ] && [ ! -e ${rootmnt}${init} ]; do
|
||||
[ ${retry_nr} -gt 0 ] && \
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Retrying nfs mount"
|
||||
/bin/sleep 1
|
||||
do_nfsmount
|
||||
retry_nr=$(( ${retry_nr} + 1 ))
|
||||
[ ! -e ${rootmnt}${init} ] && /bin/sleep 1
|
||||
[ ${retry_nr} -gt 0 ] && [ "$quiet" != "y" ] && log_end_msg
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
done
|
||||
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-bottom"
|
||||
|
|
|
@ -131,7 +131,7 @@ backup_booted_initramfs()
|
|||
# nuke generated copy
|
||||
remove_initramfs_bak()
|
||||
{
|
||||
[ -z "${initramfs_bak}" ] && return 0
|
||||
[ -z "${initramfs_bak:-}" ] && return 0
|
||||
rm -f "${initramfs_bak}"
|
||||
verbose "Removing ${initramfs_bak}"
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ generate_initramfs()
|
|||
# minversion wasn't met, exit 0
|
||||
exit 0
|
||||
fi
|
||||
echo "update-initramfs: failed for ${initramfs}"
|
||||
echo "update-initramfs: failed for ${initramfs}" >&2
|
||||
exit $mkinitramfs_return
|
||||
fi
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ run_bootloader()
|
|||
echo "update-initramfs: please run 'grub-install ${dev}'."
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ while getopts "k:cudyvtb:h?BV" flag; do
|
|||
b)
|
||||
BOOTDIR="${OPTARG}"
|
||||
if [ ! -d "${BOOTDIR}" ]; then
|
||||
echo "Error: ${BOOTDIR} is not a directory."
|
||||
echo "Error: ${BOOTDIR} is not a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
@ -440,7 +440,7 @@ done
|
|||
shift $((${OPTIND} - 1))
|
||||
|
||||
if [ $# -ne 0 ]; then
|
||||
echo "Invalid argument for option -k."
|
||||
echo "Invalid argument for option -k." >&2
|
||||
usage
|
||||
fi
|
||||
|
||||
|
@ -469,11 +469,8 @@ if [ "${version}" = "all" ] \
|
|||
OPTS="${OPTS} -y"
|
||||
fi
|
||||
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}"
|
||||
"${0}" -${mode} -k "${u_version}" ${OPTS}
|
||||
set -e
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Template file for 'initramfs-tools'
|
||||
pkgname=initramfs-tools
|
||||
version=0.99.3.debian0.95.1
|
||||
version=0.99.4.debian0.98.5
|
||||
build_style=custom-install
|
||||
short_desc="Tools for generating an initramfs"
|
||||
maintainer="Juan RP <xtraeme@gmail.com>"
|
||||
|
@ -22,7 +22,6 @@ conf_files="
|
|||
/etc/$pkgname/update-initramfs.conf
|
||||
/etc/$pkgname/modules"
|
||||
|
||||
Add_dependency full glibc
|
||||
Add_dependency full cpio
|
||||
Add_dependency full util-linux-ng
|
||||
Add_dependency full gawk
|
||||
|
@ -97,5 +96,6 @@ do_install()
|
|||
# Scripts
|
||||
install -m 755 $FILESDIR/mkinitramfs $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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue