initramfs-tools: removed; unused now that we switched to dracut.

This commit is contained in:
Juan RP 2012-05-29 15:46:34 +02:00
parent ab310f5812
commit 0ab59f4506
33 changed files with 0 additions and 3673 deletions

View File

@ -1,34 +0,0 @@
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)
# 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
mkdir -p /etc/initramfs-tools/conf.d
echo "RESUME=${RESUME}" > /etc/initramfs-tools/conf.d/resume
fi
;;
esac

View File

@ -1,26 +0,0 @@
# update-initramfs(8) completion
_update_initramfs()
{
local cur prev valid_options
# TODO: this can be "_get_comp_words_by_ref cur prev" once
# bash-completion >= 1.2 is available, see #537139
cur=$(_get_cword)
prev=${COMP_WORDS[COMP_CWORD-1]}
# The only option that takes an argument is -k
if [[ "$prev" == '-k' ]]; then
# Complete with kernel versions
_kernel_versions
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} all' -- "$cur" ) )
return;
fi
# Complete with available options (obtained from -h)
valid_options=$( update-initramfs -h 2>&1 | \
sed -e '/^ -/!d;s/^ \(-\w\+\).*/\1/' )
COMPREPLY=( $( compgen -W "$valid_options" -- $cur ) )
}
complete -F _update_initramfs update-initramfs

View File

@ -1,32 +0,0 @@
#
# initramfs.conf
# Configuration file for mkinitramfs(8). See initramfs.conf(5).
#
# Note that configuration options from this file can be overridden
# by config files in the /etc/initramfs-tools/conf.d directory.
#
# MODULES: [ most | dep | list ]
#
# most - Add most filesystem and all harddrive drivers.
#
# dep - Try and guess which modules to load.
#
# list - Only include modules from the 'additional modules' list
#
MODULES=most
#
# KEYMAP: [ y | n ]
#
# Load a keymap during the initramfs stage.
#
KEYMAP=n
#
# COMPRESS: [ gzip | bzip2 | lzma | lzop | xz ]
#
COMPRESS=xz

View File

@ -1,11 +0,0 @@
# List of modules that you want to include in your initramfs.
# They will be loaded at boot time in the order below.
#
# Syntax: module_name [args ...]
#
# You must run update-initramfs(8) to effect this change.
#
# Examples:
#
# raid1
# sd_mod

View File

@ -1,20 +0,0 @@
#
# Configuration file for update-initramfs(8)
#
#
# update_initramfs [ yes | all | no ]
#
# Default is yes
# If set to all update-initramfs will update all initramfs
# If set to no disables any update to initramfs beside kernel upgrade
update_initramfs=yes
#
# backup_initramfs [ yes | no ]
#
# Default is no
# If set to no leaves no .bak backup files.
backup_initramfs=no

View File

@ -1,68 +0,0 @@
#!/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
# install, then install them into the staging area, where the
# initramfs is being created. This happens when a new 'linux-image'
# package is installed, or when the administrator runs 'mkinitramfs'
# by hand to update an initramfs image.
#
# CONFDIR -- usually /etc/initramfs-tools, can be set on mkinitramfs
# command line.
#
# DESTDIR -- The staging directory where we are building the image.
#
# see initramfs-tools(8)
#
# 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
# You can do anything you need to from here on.
#
# Source the optional 'hook-functions' scriptlet, if you need the
# functions defined within it. Read it to see what is available to
# you. It contains functions for copying dynamically linked program
# binaries, and kernel modules into the DESTDIR.
#
. /usr/share/initramfs-tools/hook-functions
# If this hook script is a conffile (and thus stored in
# /etc/mkinitramfs/hooks), it must take care to do the right thing
# when the package containing it is removed but not purged. There of
# course may be other reasons to have custom logic deciding what to
# install. The version variable may be useful for this.
#
if command -v myprog >/dev/null 2>&1; then
copy_exec /usr/bin/myprog usr/bin
fi
# To accompany this, there should usually be a script for inside the
# initramfs named something like:
#
# "/etc/mkinitramfs/local-premount/myprog"
#
# ... and it should do what is necessary to have 'myprog' get run
# inside the early runtime environment.
exit 0

View File

@ -1,35 +0,0 @@
#!/bin/sh
#
# This script is run inside of the initramfs environment during the
# 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
# 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
# Do the work here.
echo "Got here!"
exit 0

View File

@ -1,548 +0,0 @@
# -*- shell-script -*-
catenate_cpiogz() {
# Sanity check
if [ ! -e "${1}" ]; then
echo "W: catenate_cpiogz: arg1='${1}' does not exist." >&2
return
fi
cat "${1}" >>"${__TMPCPIOGZ}"
}
force_load()
{
manual_add_modules ${@}
echo "${@}" >>"${DESTDIR}/conf/modules"
}
# Takes a file containing a list of modules to be added as an
# argument, figures out dependancies, and adds them.
#
# Input file syntax:
#
# # comment
# modprobe_module_name [args ...]
# [...]
#
add_modules_from_file()
{
# Sanity check
if [ ! -e "${1}" ]; then
echo "W: add_modules_from_file: arg1='${1}' does not exist." >&2
return
fi
grep '^[^#]' ${1} | while read module args; do
[ -n "$module" ] || continue
force_load "${module}" "${args}"
done
}
# Add dependent modules + eventual firmware
manual_add_modules()
{
local kmod firmware
for kmod in $(modprobe --set-version="${version}" --ignore-install \
--quiet --show-depends "${1}" | awk '/^insmod/ { print $2 }'); do
# Prune duplicates
if [ -e "${DESTDIR}/${kmod}" ]; then
continue
fi
mkdir -p "${DESTDIR}/$(dirname "${kmod}")"
cp -pL "${kmod}" "${DESTDIR}/$(dirname "${kmod}")"
if [ "${verbose}" = "y" ]; then
echo "Adding module ${kmod}"
fi
# Add required firmware
for firmware in $(modinfo -F firmware "${kmod}"); do
if [ -e "${DESTDIR}/lib/firmware/${firmware}" ] \
|| [ -e "${DESTDIR}/lib/firmware/${version}/${firmware}" ]; then
continue
fi
# Only print warning for missing fw of loaded module
# or forced loaded module
if [ ! -e "/lib/firmware/${firmware}" ] \
&& [ ! -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 "${kmod}" .ko)[[:space:]]" \
/proc/modules \
|| grep -q "^$(basename "${kmod}" .ko)" \
"${CONFDIR}/modules"; then
echo "W: Possible missing firmware /lib/firmware/${firmware} for module $(basename ${kmod} .ko)" >&2
fi
continue
fi
if [ -e "/lib/firmware/${version}/${firmware}" ]; then
copy_exec "/lib/firmware/${version}/${firmware}"
else
copy_exec "/lib/firmware/${firmware}"
fi
if [ "${verbose}" = "y" ]; then
echo "Adding firmware ${firmware}"
fi
done
done
}
# $1 = file to copy to ramdisk
# $2 (optional) Name for the file on the ramdisk
# Location of the image dir is assumed to be $DESTDIR
# We never overwrite the target if it exists.
copy_exec() {
local src target x nonoptlib
local libname dirname
src="${1}"
target="${2:-$1}"
[ -f "${src}" ] || return 1
if [ -d "${DESTDIR}/${target}" ]; then
# check if already copied
[ -e "${DESTDIR}/$target/${src##*/}" ] && return 0
else
[ -e "${DESTDIR}/$target" ] && return 0
#FIXME: inst_dir
mkdir -p "${DESTDIR}/${target%/*}"
fi
[ "${verbose}" = "y" ] && echo "Adding binary ${src}"
cp -pL "${src}" "${DESTDIR}/${target}"
# 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
# Try to use non-optimised libraries where possible.
# 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/\1\3#')
if [ -e "${nonoptlib}" ]; then
x="${nonoptlib}"
fi
libname=$(basename "${x}")
dirname=$(dirname "${x}")
# FIXME inst_lib
mkdir -p "${DESTDIR}/${dirname}"
if [ ! -e "${DESTDIR}/${dirname}/${libname}" ]; then
cp -pL "${x}" "${DESTDIR}/${dirname}"
[ "${verbose}" = "y" ] && echo "Adding library ${x}" || true
fi
done
}
# Copy entire subtrees to the initramfs
copy_modules_dir()
{
local kmod exclude
local dir="$1"
shift
if ! [ -d "${MODULESDIR}/${dir}" ]; then
return;
fi
if [ "${verbose}" = "y" ]; then
echo "Copying module directory ${dir}"
if [ $# -ge 1 ]; then
echo "(excluding $*)"
fi
fi
while [ $# -ge 1 ]; do
exclude="${exclude:-} -name $1 -prune -o "
shift
done
for kmod in $(find "${MODULESDIR}/${dir}" ${exclude:-} -name '*.ko' -print); do
manual_add_modules $(basename ${kmod} .ko)
done
}
# walk /sys for relevant modules
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)"
if [ -e "$driver_path" ]; then
module="$(basename $(readlink -f $driver_path))"
if [ -n "${module}" ]; then
force_load "${module}"
fi
fi
device_path="$(dirname ${device_path})"
done
}
# walk /sys for relevant modalias
sys_walk_modalias()
{
local device_path modalias
device_path="$(dirname "${1}")"
device_path="$(dirname "${device_path}")"
if [ -e "${device_path}/modalias" ]; then
modalias=$(cat "${device_path}/modalias")
fi
if [ -n "${modalias}" ]; then
force_load "${modalias}"
fi
}
# find and only copy root relevant modules
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" >&2
exit 1
fi
# findout root block device + fstype
eval "$( mount | while read dev foo mp foo fs opts rest ; do \
[ "$mp" = "/" ] && printf "root=$dev\nFSTYPE=$fs" \
&& break; done)"
# On failure fallback to /proc/mounts if readable
if [ -z "$root" ] && [ -r /proc/mounts ]; then
eval "$(while read dev mp fs opts rest ; do \
[ "$mp" = "/" ] && [ "$fs" != "rootfs" ] \
&& printf "root=$dev\nFSTYPE=$fs"\
&& break; done < /proc/mounts)"
fi
# recheck root device
if [ -z "$root" ]; then
echo "mkinitramfs: failed to determine root device" >&2
echo "mkinitramfs: workaround is MODULES=most, check:" >&2
echo "grep -r MODULES /etc/initramfs-tools/" >&2
echo "" >&2
echo "Error please report bug on initramfs-tools" >&2
echo "Include the output of 'mount' and 'cat /proc/mounts'" >&2
exit 1
fi
if [ "${root}" = "/dev/root" ] ; then
root="/dev/disk/by-uuid/"$(blkid -o value -s UUID ${root}) 2>/dev/null
fi
root="$(readlink -f ${root})"
# find out real rootfs on auto type
if [ "${FSTYPE}" = "auto" ]; then
eval "$(blkid -s TYPE -o value ${root})"
fi
# check that fstype rootfs recognition
if [ "${FSTYPE}" = "unknown" ]; then
FSTYPE=$(blkid -o value -s TYPE "${root}")
if [ -z "${FSTYPE}" ]; then
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
# Add rootfs
manual_add_modules "${FSTYPE}"
# lvm or luks root
if [ "${root#/dev/mapper/}" != "${root}" ] \
|| [ "${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, possibly lvm snapshots
while [ "${block#dm-}" != "${block}" ]; do
block=$(ls -1 /sys/block/${block}/slaves | head -n 1)
done
# lvm on md or luks on md
if [ "${block#md}" != "${block}" ]; then
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}" ] \
|| [ "${block#ida}" != "${block}" ]; then
block="${block%p*}"
else
block=${block%%[0-9]*}
fi
# md root new naming scheme /dev/md/X
elif [ "${root#/dev/md/}" != "${root}" ]; then
root=${root#/dev/md/}
# strip partion number
root=${root%%p[0-9]*}
# 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/md}
# strip partion number
root=${root%%p[0-9]*}
# 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/*}
block="cciss!${block%p*}"
# ida device
elif [ "${root#/dev/ida/}" != "${root}" ]; then
block=${root#/dev/ida/*}
block="ida!${block%p*}"
# loop root /dev/loopX
elif [ "${root#/dev/loop}" != "${root}" ]; then
root=${root#/dev/}
block=$(losetup -a \
| awk "/${root}/{print substr(\$3, 7, 3); exit}")
# Xen virtual device /dev/xvdX
elif [ "${root#/dev/xvd}" != "${root}" ]; then
block=${root#/dev/}
# Xen has a mode where only the individual partitions are
# registered with the kernel as well as the usual full disk
# with partition table scheme.
if [ ! -e /sys/block/${block} ] ; then
block=${block%%[0-9]*}
fi
# mmc root /dev/mmcblkXpX
elif [ "${root#/dev/mmcblk}" != "${root}" ]; then
block=${root#/dev/}
block=${block%%p[0-9]*}
# classical root device
else
block=${root#/dev/}
block=${block%%[0-9]*}
fi
# 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" >&2
echo "mkinitramfs: workaround is MODULES=most" >&2
echo "mkinitramfs: Error please report the bug" >&2
exit 1
fi
# sys walk ATA
root_dev_path=$(readlink -f /sys/block/${block}/device)
sys_walk_mod_add ${root_dev_path}
# catch old-style IDE
if [ -e /sys/bus/ide/devices/ ]; then
sys_walk_modalias ${root_dev_path}
manual_add_modules ide-gd_mod
manual_add_modules ide-cd
fi
if [ -e /sys/bus/scsi/devices/ ]; then
manual_add_modules sd_mod
fi
if [ -e /sys/bus/mmc/devices/ ]; then
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
fi
}
# The modules "most" classes added per default to the initramfs
auto_add_modules()
{
case "${1:-}" in
base)
for x in ehci-hcd ohci-hcd uhci-hcd usbhid xhci-hcd \
hid-apple hid-cherry hid-logitech hid-logitech-dj \
hid-microsoft hid-sunplus btrfs ext2 ext3 ext4 isofs \
jfs reiserfs udf xfs nilfs2 i8042 virtio_pci; do
manual_add_modules "${x}"
done
;;
ide)
copy_modules_dir kernel/drivers/ide
;;
mmc)
copy_modules_dir kernel/drivers/mmc
;;
scsi)
copy_modules_dir kernel/drivers/scsi
for x in mptfc mptsas mptscsih mptspi; do
manual_add_modules "${x}"
done
;;
ata)
copy_modules_dir kernel/drivers/ata
;;
block)
copy_modules_dir kernel/drivers/block
;;
ieee1394)
for x in ohci1394 sbp2; do
manual_add_modules "${x}"
done
;;
firewire)
for x in firewire-ohci firewire-sbp2; do
manual_add_modules "${x}"
done
;;
i2o)
for x in i2o_block; do
manual_add_modules "${x}"
done
;;
usb_storage)
copy_modules_dir kernel/drivers/usb/storage
;;
*)
auto_add_modules base
auto_add_modules ide
auto_add_modules scsi
auto_add_modules block
auto_add_modules ata
auto_add_modules i2o
auto_add_modules ieee1394
auto_add_modules firewire
auto_add_modules mmc
auto_add_modules usb_storage
;;
esac
}
# 'depmod' only looks at symbol dependencies; there is no way for
# modules to declare explicit dependencies through module information,
# so dependencies on e.g. crypto providers are hidden. Until this is
# fixed, we need to handle those hidden dependencies.
hidden_dep_add_modules()
{
for dep in "lib/libcrc32c crc32c" "deflate zlib lzo"; do
set -- $dep
if [ -f "${DESTDIR}/lib/modules/${version}/kernel/$1.ko" ]; then
shift
for i in "$@" ; do
manual_add_modules "$i"
shift
done
fi
done
}
# mkinitramfs help message
usage()
{
cat >&2 << EOF
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.
See mkinitramfs(8) for further details.
EOF
exit 1
}
# 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"
local cmpver_cmd
if ! command -v xbps-uhelper.static >/dev/null 2>&1; then
cmpver_cmd=xbps-uhelper
else
cmpver_cmd=xbps-uhelper.static
fi
${cmpver_cmd} cmpver $curv $minv
if [ $? -eq 0 ] || [ $? -eq 1 ]; then
return 0
fi
return 1
}
# minimal supported kernel version
check_minkver()
{
local curversion initdir ARCH minversion cm_x tmp
curversion="${1:-}"
initdir="${2:-}"
if [ -z "${initdir}" ]; then
case ${ARCH:-} in
ia64|hppa)
minversion="2.6.15"
;;
*)
minversion="2.6.12"
;;
esac
if ! compare_versions "${curversion}" "${minversion}"; then
echo "W: kernel ${curversion} too old for initramfs on ${DPKG_ARCH}" >&2
echo "W: not generating requested initramfs for kernel ${curversion}" >&2
exit 2
fi
return 0
fi
set_initlist
for cm_x in ${initlist:-}; do
# 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
continue
elif ! compare_versions "${curversion}" "${minver}"; then
echo "W: ${cm_x} hook script requires at least kernel version ${minver}" >&2
echo "W: not generating requested initramfs for kernel ${curversion}" >&2
exit 2
fi
done
}

View File

@ -1,23 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
# from libblkid
copy_exec ${ROOTDIR}/sbin/blkid /sbin
exit 0

View File

@ -1,26 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
copy_exec ${ROOTDIR}/bin/busybox
# Create required busybox symlinks
for f in $(/bin/busybox --list); do
[ "$f" = "modprobe" ] && continue
ln -sf /bin/busybox ${DESTDIR}/bin/${f}
done
exit 0

View File

@ -1,26 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
# Hook to add the DRM/KMS modules
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
manual_add_modules fbcon
manual_add_modules intel-agp
manual_add_modules i915
manual_add_modules radeon
exit 0

View File

@ -1,32 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
# Hook to load keymaps into the initramfs if requested by KEYMAP="y"
if [ "$KEYMAP" != "y" ] && [ "$KEYMAP" != "Y" ]; then
exit 0
fi
[ ! -x ${ROOTDIR}/usr/sbin/loadkeys -a ! -x ${ROOTDIR}/usr/sbin/dumpkeys ] && exit 0
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
${ROOTDIR}/usr/sbin/dumpkeys > ${DESTDIR}/kmap-tmp
${ROOTDIR}/usr/sbin/loadkeys -u -b ${DESTDIR}/kmap-tmp \
> ${DESTDIR}/etc/bkeymap
rm -f ${DESTDIR}/kmap-tmp
exit 0

View File

@ -1,23 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
# resume from klibc.
copy_exec ${ROOTDIR}/bin/resume /bin
exit 0

View File

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

View File

@ -1,23 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
# we need systemd-timestamp
copy_exec ${ROOTDIR}/lib/systemd/systemd-timestamp /bin
exit 0

View File

@ -1,68 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
# Hooks for loading thermal bits into the initramfs
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
case "$DPKG_ARCH" in
# copy the right modules
powerpc|ppc64)
# Only G5 Mac machines need to load
# therm_pm72 or one of the windfarm_pm* modules.
[ -r /proc/cpuinfo ] || exit 0
MODEL="`grep model /proc/cpuinfo`"
MODEL="${MODEL##*: }"
case "$MODEL" in
RackMac3,1|PowerMac7,2|PowerMac7,3)
force_load therm_pm72
;;
PowerMac8,1|PowerMac8,2)
force_load windfarm_pm81
;;
PowerMac9,1)
force_load windfarm_pm91
;;
PowerMac11,2)
force_load windfarm_pm112
;;
PowerMac12,1)
force_load windfarm_pm121
;;
*)
# No other machine needs windfarm_* modules on initrd.
exit 0
;;
esac
manual_add_modules windfarm_core
manual_add_modules windfarm_cpufreq_clamp
manual_add_modules windfarm_lm75_sensor
manual_add_modules windfarm_max6690_sensor
manual_add_modules windfarm_pid
manual_add_modules windfarm_smu_controls
manual_add_modules windfarm_smu_sat
manual_add_modules windfarm_smu_sensors
;;
i386|amd64|ia64)
manual_add_modules fan
manual_add_modules thermal
;;
esac

View File

@ -1,282 +0,0 @@
#!/bin/busybox sh
# For systemd to know how much time is spent in initramfs.
if [ -x /bin/systemd-timestamp ]; then
RD_TIMESTAMP="$(/bin/systemd-timestamp)"
fi
echo "Starting up the initramfs, please wait..."
[ -d /run ] || mkdir -m 0755 /run
[ -d /dev ] || mkdir -m 0755 -p /dev/pts
[ -d /root ] || mkdir -m 0700 /root
[ -d /sys ] || mkdir /sys
[ -d /proc ] || mkdir /proc
[ -d /tmp ] || mkdir /tmp
mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
mount -t proc -o nodev,noexec,nosuid proc /proc
# Note that this only becomes /dev on the real filesystem if udev's scripts
# are used; which they will be, but it's worth pointing out
if [ -e /etc/udev/udev.conf ]; then
. /etc/udev/udev.conf
fi
# Mount devtmpfs for /dev, fallback to tmpfs if not supported.
if ! mount -t devtmpfs -o size=10M,mode=0755 devtmpfs /dev; then
panic "Failed to mount devtmpfs on /dev!"
fi
# Also mount a tmpfs for /run directory.
mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run
mkdir -m0755 /run/udev
mkdir -m0755 /run/initramfs
# Set modprobe env
export MODPROBE_OPTIONS="-qb"
# Export relevant variables
export ROOT=
export ROOTDELAY=
export ROOTFLAGS=
export ROOTFSTYPE=
export BOOT=local
export break=
export init=/sbin/init
export quiet=n
export readonly=y
export rootmnt=/root
export debug=
export panic=
export blacklist=
export resume=
export resume_offset=
# Bring in the main config
. /conf/initramfs.conf
for conf in conf/conf.d/*; do
[ -f ${conf} ] && . ${conf}
done
. /scripts/functions
# Parse command line options
for x in $(cat /proc/cmdline); do
case $x in
init=*)
init=${x#init=}
;;
root=*)
ROOT=${x#root=}
case $ROOT in
LABEL=*)
ROOT="${ROOT#LABEL=}"
# support any / in LABEL= path (escape to \x2f)
case "${ROOT}" in
*/*)
if command -v sed >/dev/null 2>&1; then
ROOT="$(echo ${ROOT} | sed 's,/,\\x2f,g')"
else
if [ "${ROOT}" != "${ROOT#/}" ]; then
ROOT="\x2f${ROOT#/}"
fi
if [ "${ROOT}" != "${ROOT%/}" ]; then
ROOT="${ROOT%/}\x2f"
fi
IFS='/'
newroot=
for s in $ROOT; do
newroot="${newroot:+${newroot}\\x2f}${s}"
done
unset IFS
ROOT="${newroot}"
fi
esac
ROOT="/dev/disk/by-label/${ROOT}"
;;
UUID=*)
ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
;;
esac
;;
rootflags=*)
ROOTFLAGS="-o ${x#rootflags=}"
;;
rootfstype=*)
ROOTFSTYPE="${x#rootfstype=}"
;;
rootdelay=*)
ROOTDELAY="${x#rootdelay=}"
case ${ROOTDELAY} in
*[![:digit:].]*)
ROOTDELAY=
;;
esac
;;
boot=*)
BOOT=${x#boot=}
;;
resume=*)
RESUME="${x#resume=}"
;;
resume_offset=*)
resume_offset="${x#resume_offset=}"
;;
noresume)
noresume=y
;;
panic=*)
panic="${x#panic=}"
case ${panic} in
*[![:digit:].]*)
panic=
;;
esac
;;
quiet)
quiet=y
;;
ro)
readonly=y
;;
rw)
readonly=n
;;
debug)
debug=y
quiet=n
exec >/run/initramfs/initramfs.debug 2>&1
set -x
;;
debug=*)
debug=y
quiet=n
set -x
;;
break=*)
break=${x#break=}
;;
break)
break=premount
;;
blacklist=*)
blacklist=${x#blacklist=}
;;
esac
done
if [ -n "${noresume}" ]; then
export noresume
unset resume
else
resume=${RESUME:-}
fi
maybe_break top
log_begin_msg "Running /scripts/init-top"
run_scripts /scripts/init-top
log_end_msg
# Mount devpts to make plymouth happy
[ -d /dev/pts ] || mkdir -m0755 /dev/pts
mount -t devpts devpts /dev/pts
maybe_break modules
log_begin_msg "Loading essential drivers"
load_modules
log_end_msg
maybe_break premount
log_begin_msg "Running /scripts/init-premount"
run_scripts /scripts/init-premount
log_end_msg
maybe_break mount
log_begin_msg "Mounting root file system"
. /scripts/${BOOT}
maybe_break mountroot
mountroot
log_end_msg
maybe_break bottom
log_begin_msg "Running /scripts/init-bottom"
run_scripts /scripts/init-bottom
log_end_msg
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}" ]; then
if ! validate_init "$init"; then
echo "Target filesystem doesn't have requested ${init}."
init=
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
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
# don't leak too much of env - some init(8) don't clear it
# (keep init, rootmnt)
unset debug
unset MODPROBE_OPTIONS
unset ROOTFLAGS
unset ROOTFSTYPE
unset ROOTDELAY
unset ROOT
unset BOOT
unset blacklist
unset break
unset noresume
unset panic
unset quiet
unset readonly
unset resume
unset resume_offset
# move mounted filesystems to real root.
[ -d ${rootmnt}/dev/pts ] || mkdir -m0755 -p ${rootmnt}/dev/pts
[ -d /dev/pts ] && mount -o move /dev/pts ${rootmnt}/dev/pts
mount -o move /sys ${rootmnt}/sys
mount -o move /proc ${rootmnt}/proc
mount -o move /run ${rootmnt}/run
# Chain to real filesystem
exec env -i "RD_TIMESTAMP=$RD_TIMESTAMP" \
switch_root ${rootmnt} ${init} "$@" <${rootmnt}/dev/console >${rootmnt}/dev/console
panic "Could not execute run-init."

View File

@ -1,529 +0,0 @@
.TH INITRAMFS-TOOLS 8 "2012/01/13" "Linux" "mkinitramfs script overview"
.SH NAME
initramfs-tools \- an introduction to writing scripts for mkinitramfs
.SH DESCRIPTION
initramfs-tools has one main script and two different sets of subscripts which
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.
.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 Standard
.TP
\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= "<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".
.TP
\fB\fI rootfstype
set the root file system type.
.TP
\fB\fI rootdelay
set delay in seconds. Determines how long mountroot waits for root to appear.
The default is 180 seconds.
.TP
\fB\fI rootflags
set the file system mount option string.
.TP
\fB\fI resume
On install initramfs-tools tries to autodetect the resume partition. On success
the RESUME variable is written to /etc/initramfs-tools/conf.d/resume.
The boot variable noresume overrides it.
.TP
\fB\fI resume_offset
Specify the offset from the partition given by "resume=" at which the swap
header of the swap file is located.
.TP
\fB\fI quiet
reduces the amount of text output to the console during boot.
.TP
\fB\fI ro
mounts the rootfs read-only.
.TP
\fB\fI rw
mounts the rootfs read-write.
.TP
\fB\fI blacklist
disables load of specific modules.
Use blacklist=module1,module2,module3 bootparameter.
.SS Debug
.TP
\fB\fI panic
sets an timeout on panic.
panic=<sec> is a documented security feature: it disables the debug shell.
.TP
\fB\fI debug
generates lots of output. It writes a log to /run/initramfs/initramfs.debug.
Instead when invoked with an arbitrary argument output is written to console.
Use for example "debug=vc".
.TP
\fB\fI break
spawns a shell in the initramfs image at chosen run-time
(top, modules, premount, mount, mountroot, bottom, init).
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 all_generic_ide
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
in the image itself. No guarantees are made as to the order in which the
different scripts are executed unless the prereqs are setup in the script.
.SS Header
In order to support prereqs, each script should begin with the following lines:
.RS
.nf
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
\fR. /usr/share/initramfs-tools/hook-functions
# Begin real processing below this line
.fi
.RE
For example, if you are writing a new hook script which relies on lvm, the line
starting with PREREQ should be changed to PREREQ="lvm" which will ensure that
the lvm hook script is run before your custom script.
.SS Help functions
/usr/share/initramfs-tools/hook-functions contains a number of functions which
deal with some common tasks in a hook script:
.TP
\fB\fI
manual_add_modules
adds a module (and any modules which it depends on) to the initramfs image.
.RS
.PP
.B Example:
manual_add_modules isofs
.RE
.TP
\fB\fI
add_modules_from_file
reads a file containing a list of modules (one per line) to be added to the
initramfs image. The file can contain comments (lines starting with #) and
arguments to the modules by writing the arguments on the same line as the name
of the module.
.RS
.PP
.B Example:
add_modules_from_file /tmp/modlist
.RE
.TP
\fB\fI
force_load
adds a module (and its dependencies) to the initramfs image and also
unconditionally loads the module during boot. Also supports passing arguments
to the module by listing them after the module name.
.RS
.PP
.B Example:
force_load cdrom debug=1
.RE
.TP
\fB\fI
copy_modules_dir
copies an entire module directory from /lib/modules/KERNELVERSION/ into the
initramfs image.
.RS
.PP
.B Example:
copy_modules_dir kernel/drivers/ata
.RE
.SS Including binaries
If you need to copy binaries to the initramfs module, a command like this
should be used:
.PP
.RS
copy_exec /sbin/mdadm /sbin
.RE
mkinitramfs will automatically detect which libraries the executable depends on
and copy them to the initramfs. This means that most executables, unless
compiled with klibc, will automatically include glibc in the image which will
increase its size by several hundred kilobytes.
.SS Exported variables
mkinitramfs sets several variables for the hook scripts environment.
.TP
\fB\fI MODULESDIR
corresponds to the linux-2.6 modules dir.
.TP
\fB\fI version
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.
.TP
\fB\fI DESTDIR
is the root path of the newly build initramfs.
.TP
\fB\fI DPKG_ARCH
allows arch specific hook additions.
.TP
\fB\fI verbose
corresponds to the verbosity of the update-initramfs run.
.TP
\fB\fI KEYMAP
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 overridden by hook script, but can guide them
on how much they need to include on initramfs.
.SH BOOT SCRIPTS
Similarly to hook scripts, boot scripts can be found in two places
/usr/share/initramfs-tools/scripts/ and /etc/initramfs-tools/scripts/. There
are a number of subdirectories to these two directories which control the boot
stage at which the scripts are executed.
.SS Header
Like for hook scripts, there are no guarantees as to the order in which the
different scripts in one subdirectory (see "Subdirectories" below) are
executed. In order to define a certain order, a similar header as for hook
scripts should be used:
.RS
.nf
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
.fi
.RE
Where PREREQ is modified to list other scripts in the same subdirectory if necessary.
.SS Help functions
A number of functions (mostly dealing with output) are provided to boot scripts in
.I /scripts/functions
:
.TP
\fB\fI
log_success_msg
Logs a success message
.RS
.PP
.B Example:
log_success_msg "Frobnication successful"
.RE
.TP
\fB\fI
log_failure_msg
Logs a failure message
.RS
.PP
.B Example:
log_failure_msg "Frobnication component froobz missing"
.RE
.TP
\fB\fI
log_warning_msg
Logs a warning message
.RS
.PP
.B Example:
log_warning_msg "Only partial frobnication possible"
.RE
.TP
\fB\fI
log_begin_msg
Logs a message that some processing step has begun
.TP
\fB\fI
log_end_msg
Logs a message that some processing step is finished
.RS
.PP
.B Example:
.PP
.RS
.nf
log_begin_msg "Frobnication begun"
# Do something
log_end_msg
.fi
.RE
.RE
.TP
\fB\fI
panic
Logs an error message and executes a shell in the initramfs image to allow the
user to investigate the situation.
.RS
.PP
.B Example:
panic "Frobnication failed"
.RE
.SS Subdirectories
Both /usr/share/initramfs-tools/scripts and /etc/initramfs-tools/scripts
contains the following subdirectories.
.TP
\fB\fI
init-top
the scripts in this directory are the first scripts to be executed after sysfs
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
happens after modules specified by hooks and /etc/initramfs-tools/modules
have been loaded.
.TP
\fB\fI
local-top OR nfs-top
After these scripts have been executed, the root device node is expected to be
present (local) or the network interface is expected to be usable (NFS).
.TP
\fB\fI
local-premount OR nfs-premount
are run after the sanity of the root device has been verified (local) or the
network interface has been brought up (NFS), but before the actual root fs has
been mounted.
.TP
\fB\fI
local-bottom OR nfs-bottom
are run after the rootfs has been mounted (local) or the NFS root share has
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. udev is stopped.
.SS Boot parameters
.TP
\fB\fI
/conf/param.conf
allows boot scripts to change exported variables that are listed on top of init. Write the new values to it. It will be sourced after an boot script run if it exists.
.SH EXAMPLES
.SS Hook script
An example hook script would look something like this (and would usually be
placed in /etc/initramfs-tools/hooks/frobnicate):
.RS
.nf
#!/bin/sh
# Example frobnication hook script
PREREQ="lvm"
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
\fR. /usr/share/initramfs-tools/hook-functions
# Begin real processing below this line
if [ ! \-x "/sbin/frobnicate" ]; then
exit 0
fi
force_load frobnicator interval=10
cp /sbin/frobnicate "${DESTDIR}/sbin"
exit 0
.fi
.RE
.SS Boot script
An example boot script would look something like this (and would usually be placed in /etc/initramfs-tools/scripts/local-top/frobnicate):
.RS
.nf
#!/bin/sh
# Example frobnication boot script
PREREQ="lvm"
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
\fR. /scripts/functions
# Begin real processing below this line
if [ ! \-x "/sbin/frobnicate" ]; then
panic "Frobnication executable not found"
fi
if [ ! \-e "/dev/mapper/frobb" ]; then
panic "Frobnication device not found"
fi
log_begin_msg "Starting frobnication"
/sbin/frobnicate "/dev/mapper/frobb" || panic "Frobnication failed"
log_end_msg
exit 0
.fi
.RE
.SS Exported variables
init sets several variables for the boot scripts environment.
.TP
\fB\fI ROOT
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
corresponds to the rootdelay, rootflags, rootfstype or ip boot option.
.TP
\fB\fI blacklist, panic, quiet, resume, noresume, resume_offset
set according relevant boot option.
.TP
\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
\fB\fI readonly
is the default for mounting the root corresponds to the ro bootarg.
Overridden by rw bootarg.
.TP
\fB\fI rootmnt
is the path where root gets mounted usually /root.
.TP
\fB\fI debug
indicates that a debug log is captured for further investigation.
.SH DEBUG
It is easy to check the generated initramfs for its content. One may need
to double-check if it contains the relevant binaries, libs or modules:
.RS
.nf
mkdir tmp/initramfs
cd tmp/initramfs
gunzip \-c /boot/initrd.img\-2.6.18\-1\-686 | \\
cpio \-i \-d \-H newc \-\-no\-absolute\-filenames
.fi
.RE
.SH AUTHOR
The initramfs-tools are written by Maximilian Attems <maks@debian.org>,
Jeff Bailey <jbailey@raspberryginger.com> and numerous others.
.PP
This manual was written by David H\[:a]rdeman <david@hardeman.nu>,
updated by Maximilian Attems <maks@debian.org>.
.SH SEE ALSO
.BR
.IR initramfs.conf (5),
.IR mkinitramfs (8),
.IR update-initramfs(8).

View File

@ -1,73 +0,0 @@
.TH INITRAMFS.CONF 5 "2012/01/13" "Linux" "initramfs.conf manual"
.SH NAME
initramfs.conf \- configuration file for mkinitramfs
.SH DESCRIPTION
The behaviour of
.B mkinitramfs
can be modified by its configuration file.
Each line in the file can be a configuration variable, a blank line,
or a comment. The value of an variable is assigned by an statement
of the form: \fIname\fP=[\fIvalue\fP]
Configuration options can be broken out into configuration snippets and
placed in individual files in the /etc/mkinitramfs/conf.d directory. Files
in this directory are always read \fBafter\fP the main configuration file,
so you can override the settings in the main config file without editing it
directly.
.SH GENERAL VARIABLES
.TP
\fB MODULES
Specifies the modules for the initramfs image.
Modules listed in \fI/etc/initramfs-tools/modules\fP and
\fI/usr/share/initramfs-tools/modules.d/*\fP are always included in the
initramfs, and are loaded early in the boot process.
\fIlist\fP doesn't load any additional modules at boot time, other than those
listed in the above files.
\fImost\fP adds most file system, all ata, sata, scsi and usb drivers.
\fIdep\fP tries to guess which modules are necessary for the running box and
only adds those modules.
The default setting is \fImost\fP.
.TP
\fB KEYMAP
If set to 'y', the console keymap will be loaded during the initramfs stage.
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 FILES
.TP
.I /etc/initramfs-tools/initramfs.conf
.SH AUTHOR
The initramfs-tools are written by Maximilian Attems <maks@debian.org>,
Jeff Bailey <jbailey@raspberryginger.com> and numerous others.
Loosely based on mkinitrd.conf by Herbert Xu.
.SH SEE ALSO
.BR
.IR initramfs-tools (8),
.IR mkinitramfs (8),
.IR update-initramfs (8).

View File

@ -1,15 +0,0 @@
#!/bin/sh
#
# Kernel post-install hook for initramfs-tools.
#
# Arguments passed to this script: $1 pkgname, $2 version.
#
PKGNAME="$1"
VERSION="$2"
if [ ! -x /usr/sbin/update-initramfs ]; then
exit 0
fi
update-initramfs -c -t -k ${VERSION}
exit $?

View File

@ -1,15 +0,0 @@
#!/bin/sh
#
# Kernel post-remove hook for initramfs-tools.
#
# Arguments passed to this script: $1 pkgname, $2 version.
#
PKGNAME="$1"
VERSION="$2"
if [ ! -x /usr/sbin/update-initramfs ]; then
exit 0
fi
update-initramfs -d -t -k ${VERSION}
exit $?

View File

@ -1,357 +0,0 @@
#!/bin/sh
umask 0022
export PATH='/usr/bin:/usr/sbin:/sbin:/bin'
# Defaults
keep="n"
CONFDIR="${ROOTDIR}/etc/initramfs-tools"
verbose="n"
OPTIONS=`getopt -o c:d:ko:r:v -n "$0" -- "$@"`
# Check for non-GNU getopt
if [ $? != 0 ] ; then echo "W: non-GNU getopt" >&2 ; exit 1 ; fi
eval set -- "$OPTIONS"
while true; do
case "$1" in
-c)
compress="$2"
shift 2
;;
-d)
CONFDIR="$2"
shift 2
if [ ! -d "${CONFDIR}" ]; then
echo "${0}: ${CONFDIR}: Not a directory" >&2
exit 1
fi
;;
-o)
outfile="$2"
shift 2
;;
-k)
keep="y"
shift
;;
-r)
ROOT="$2"
shift 2
;;
-v)
verbose="y"
shift
;;
--)
shift
break
;;
*)
echo "Internal error!" >&2
exit 1
;;
esac
done
# For dependency ordered mkinitramfs hook scripts.
. ${ROOTDIR}/usr/share/initramfs-tools/scripts/functions
. ${ROOTDIR}/usr/share/initramfs-tools/hook-functions
. "${CONFDIR}/initramfs.conf"
EXTRA_CONF=''
for i in ${ROOTDIR}/usr/share/initramfs-tools/conf.d/* ${CONFDIR}/conf.d/*; do
[ -e $i ] && EXTRA_CONF="${EXTRA_CONF} $(basename $i \
| 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
for i in ${EXTRA_CONF}; do
if [ -e ${CONFDIR}/conf.d/${i} ]; then
. ${CONFDIR}/conf.d/${i}
elif [ -e ${ROOTDIR}/usr/share/initramfs-tools/conf.d/${i} ]; then
. ${ROOTDIR}/usr/share/initramfs-tools/conf.d/${i}
fi
done
# source package confs
for i in ${ROOTDIR}/usr/share/initramfs-tools/conf-hooks.d/*; do
if [ -e "${i}" ]; then
. "${i}"
fi
done
if [ -n "${UMASK:-}" ]; then
umask "${UMASK}"
fi
if [ -z "${outfile}" ]; then
usage
fi
touch "$outfile"
outfile="$(readlink -f "$outfile")"
# And by "version" we really mean path to kernel modules
# This is braindead, and exists to preserve the interface with mkinitrd
if [ ${#} -ne 1 ]; then
version="$(uname -r)"
else
version="${1}"
fi
# Check that we're using a new enough kernel version, first for ourselves,
# then for each of the hooks, which can have a MINKVER variable defined
check_minkver ${version}
check_minkver ${version} ${ROOTDIR}/usr/share/initramfs-tools/hooks
check_minkver ${version} ${CONFDIR}/hooks
case "${version}" in
/lib/modules/*/[!/]*)
;;
/lib/modules/[!/]*)
version="${version#/lib/modules/}"
version="${version%%/*}"
;;
esac
case "${version}" in
*/*)
echo "$PROG: ${version} is not a valid kernel version" >&2
exit 1
;;
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"
COMPRESS=gzip
fi
if ! `grep -q -i ^config_rd_${COMPRESS%p} /boot/config-${version}` ; then
compress=gzip
[ "${verbose}" = y ] && \
echo "linux kernel misses ${COMPRESS} support, using gzip"
fi
[ "$compress" = xz ] && compress="xz --check=crc32"
compress="$compress"
if [ -d "${outfile}" ]; then
echo "${outfile} is a directory" >&2
exit 1
fi
MODULESDIR="/lib/modules/${version}"
if [ ! -e "${ROOTDIR}${MODULESDIR}" ]; then
echo "WARNING: missing ${MODULESDIR}"
echo "Device driver support needs thus be built-in linux image!"
fi
if [ ! -e "${ROOTDIR}${MODULESDIR}/modules.dep" ]; then
depmod ${version}
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 ${ROOTDIR}/etc/mtab ]; then
fs=$(df -P $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`
# Export environment for hook scripts.
#
export MODULESDIR
export version
export CONFDIR
export DESTDIR
export DPKG_ARCH
export verbose
export KEYMAP
export MODULES
# Private, used by 'catenate_cpiogz'.
export __TMPCPIOGZ
for d in bin conf/conf.d etc lib/modules run sbin scripts ${MODULESDIR}; do
mkdir -p "${DESTDIR}/${d}"
done
# Copy in modules.builtin and modules.order (not generated by depmod)
for x in modules.builtin modules.order; do
if [ -f "${MODULESDIR}/${x}" ]; then
cp -p "${MODULESDIR}/${x}" "${DESTDIR}${MODULESDIR}/${x}"
fi
done
# MODULES=list case. Always honour.
for x in "${CONFDIR}/modules" ${ROOTDIR}/usr/share/initramfs-tools/modules.d/*; do
if [ -f "${x}" ]; then
add_modules_from_file "${x}"
fi
done
# MODULES=most is default
case "${MODULES}" in
dep)
dep_add_modules
;;
most)
auto_add_modules
;;
list)
# nothing to add
;;
*)
echo "W: mkinitramfs: unsupported MODULES setting: ${MODULES}."
echo "W: mkinitramfs: Falling back to MODULES=most."
auto_add_modules
;;
esac
# Resolve hidden dependencies
hidden_dep_add_modules
# First file executed by the linux kernel
cp -p ${ROOTDIR}/usr/share/initramfs-tools/init ${DESTDIR}/init
# add existant boot scripts
for b in $(cd ${ROOTDIR}/usr/share/initramfs-tools/scripts/ && find -L . \
-regextype posix-extended -regex '.*/[[:alnum:]\._-]+$' -type f); do
[ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \
|| mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")"
cp -p "${ROOTDIR}/usr/share/initramfs-tools/scripts/${b}" \
"${DESTDIR}/scripts/$(dirname "${b}")/"
done
for b in $(cd "${CONFDIR}/scripts" && find -L . \
-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}")/"
done
cp -p "${CONFDIR}/initramfs.conf" ${DESTDIR}/conf
for i in ${EXTRA_CONF}; do
if [ -e "${CONFDIR}/conf.d/${i}" ]; then
copy_exec "${CONFDIR}/conf.d/${i}" /conf/conf.d
elif [ -e "${ROOTDIR}/usr/share/initramfs-tools/conf.d/${i}" ]; then
copy_exec "${ROOTDIR}/usr/share/initramfs-tools/conf.d/${i}" /conf/conf.d
fi
done
# ROOT hardcoding
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
run_scripts ${ROOTDIR}/usr/share/initramfs-tools/hooks
run_scripts "${CONFDIR}"/hooks
# 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
cache_run_scripts "${DESTDIR}" "/scripts/${b#./}"
done
fi
# generate module deps
depmod -a -b "${DESTDIR}" ${version}
rm -f "${DESTDIR}/lib/modules/${version}"/modules.*map
# make sure that library search path is up to date
cp -ar ${ROOTDIR}/etc/ld.so.conf* "$DESTDIR"/etc/
if ! ldconfig -r "$DESTDIR" ; then
[ $(id -u) != "0" ] \
&& echo "ldconfig might need uid=0 (root) for chroot()" >&2
fi
# 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.
[ "${verbose}" = y ] && xargs_verbose="-t"
(cd "${DESTDIR}" && find . -type l -printf '%p %Y\n' | sed -n 's/ [LN]$//p' \
| xargs ${xargs_verbose:-} -rL1 rm -f)
# Remove debugging symbols from binaries.
if command -v strip 2>&1 >/dev/null; then
find ${DESTDIR} -type f | while read f; do
case "$(file -bi "$f")" in
application/x-executable*|application/x-sharedlib*|application/x-archive*)
strip --strip-unneeded "$f"
[ "${verbose}" = y ] && \
echo "Stripped symbols from $f."
esac
done
fi
[ "${verbose}" = y ] && echo "Building cpio ${outfile} initramfs"
(
# work around lack of "set -o pipefail" for the following pipe:
# cd "${DESTDIR}" && find . | cpio --quiet -R 0:0 -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 -R 0:0 -o -H newc 4>&-; echo "ec2=$?;" >&4
} | ${compress} >"${outfile}"
echo "ec3=$?;" >&4
`
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
cat "${__TMPCPIOGZ}" >>"${outfile}" || exit 1
fi
if [ "${keep}" = "y" ]; then
echo "Working files in ${DESTDIR} and overlay in ${__TMPCPIOGZ}"
else
rm -rf "${DESTDIR}"
rm -rf "${__TMPCPIOGZ}"
fi
exit 0

View File

@ -1,157 +0,0 @@
.TH MKINITRAMFS 8 "2010/04/07" "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 ]
.RB \-o
.IR outfile
.RB [ \-r
.IR root ]
.RB [ \-v ]
.RI [ version ]
.B mkinitramfs
.RB [ \-\-supported-host-version=
.IR hversion ]
.B mkinitramfs
.RB [ \-\-supported-target-version=
.IR tversion ]
.SH DESCRIPTION
The
.B mkinitramfs
script generates an initramfs image.
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
.B update-initramfs
calls
.B mkinitramfs
with the relevant parameters.
.B update-initramfs
keeps sha1sum of generated initramfs. It takes care to generate backups
and eventually runs the bootloader.
At boot time, the kernel unpacks that archive into RAM disk, mounts and
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.
.TP
\fB \-k
Keep the temporary directory used to make the image.
.TP
\fB \-o \fI outfile
Write the image to
.IR outfile .
.TP
\fB \-r \fI root
Override the
.B ROOT
setting in
.IR initramfs.conf .
.TP
\fB \-v
Set the verbose mode output.
.TP
\fI version
Set the kernel version of the initramfs image
(defaults to the running kernel).
.TP
\fB\-\-supported-host-version=\fIhversion
This option queries if mkinitramfs can create ramdisks on a running kernel of version
.IR hversion .
.TP
\fB\-\-supported-target-version=\fItversion
This option queries if mkinitramfs can create ramdisks for kernel version
.IR tversion .
.SH ENVIRONMENT
.B mkinitramfs
honours the
.B TMPDIR
environment variable. If set, it uses subdirectories in the given
directory to create its temporary working directories. Else it uses
.I /tmp
as default value for that purpose. The given directory should be on a
filesystem which allows the execution of files stored there, i.e.
should not be mounted with the
.B noexec
mount option.
.SH FILES
.TP
.I /etc/initramfs-tools/initramfs.conf
The default configuration file for the script. See
.BR initramfs.conf (5)
for a description of the available configuration parameter.
.TP
.I /etc/initramfs-tools/modules
Specified modules will be put in the generated image and loaded when the system boots. The format - one per line - is identical to that of
.I /etc/modules,
which is described in
.BR modules (5).
.TP
.I /etc/initramfs-tools/conf.d
The conf.d directory allows one to hardcode bootargs at initramfs build time
via config snippets. This allows one to set ROOT or RESUME.
This is especially useful for bootloaders, which do not pass an root bootarg.
.TP
.I /etc/initramfs-tools/DSDT.aml
If this file exists, it will be appended to the initramfs in a way that causes
it to be loaded by ACPI.
.SH EXAMPLES
Create an initramfs for current running kernel:
.PP
.B mkinitramfs -o ~/tmp/initramfs-$(uname -r)
Create an initramfs for specific kernel and keep builddirs:
.PP
.B mkinitramfs -k -o ~/tmp/initramfs-2.6.21-686 2.6.21-686
Debug initramfs creation (check out written logfile)
.PP
.B sh -x mkinitramfs -o ~/tmp/initramfs-$(uname -r) 2> ~/tmp/log
.SH AUTHOR
The initramfs-tools are written by Maximilian Attems <maks@debian.org>,
Jeff Bailey <jbailey@raspberryginger.com> and numerous others.
.SH SEE ALSO
.BR
.IR initramfs.conf (5),
.IR initramfs-tools (8),
.IR update-initramfs (8).

View File

@ -1,293 +0,0 @@
# -*- shell-script -*-
_log_msg()
{
[ "$quiet" = "y" ] && return
printf "\033[1m"
printf "$@"
printf "\033[m\n"
}
log_success_msg()
{
_log_msg "Success: $@\n"
}
log_failure_msg()
{
_log_msg "Failure: $@\n"
}
log_warning_msg()
{
_log_msg "Warning: $@\n"
}
log_begin_msg()
{
_log_msg "$@ ..."
}
log_end_msg()
{
:
}
panic()
{
if command -v chvt >/dev/null 2>&1; then
chvt 1
fi
echo "$@"
# Disallow console access
if [ -n "${panic}" ]; then
echo "Rebooting automatically due to panic= boot argument"
sleep ${panic}
reboot
fi
modprobe -v i8042
modprobe -v atkbd
modprobe -v ehci-hcd
modprobe -v uhci-hcd
modprobe -v ohci-hcd
modprobe -v usbhid
REASON="$@" PS1='(initramfs) ' /bin/sh -i </dev/console >/dev/console 2>&1
}
maybe_break()
{
if [ "${break:-}" = "$1" ]; then
panic "Spawning shell within the initramfs"
fi
}
render()
{
eval "echo -n \${$@}"
}
set_initlist()
{
unset initlist
for si_x in ${initdir}/*; do
# skip empty dirs without warning
[ "${si_x}" = "${initdir}/*" ] && return
# only allow variable name chars
case ${si_x#${initdir}/} in
*[![:alnum:]\._-]*)
[ "${verbose}" = "y" ] \
&& echo "$si_x ignored: not alphanumeric or '_' file"
continue
;;
esac
# skip non executable scripts
if [ ! -x ${si_x} ]; then
[ "${verbose}" = "y" ] \
&& echo "$si_x ignored: not executable"
continue
fi
# skip directories
if [ -d ${si_x} ]; then
[ "${verbose}" = "y" ] \
&& echo "$si_x ignored: a directory"
continue
fi
# skip bad syntax
if ! sh -n ${si_x} ; then
[ "${verbose}" = "y" ] \
&& echo "$si_x ignored: bad syntax"
continue
fi
initlist="${initlist:-} ${si_x#${initdir}/}"
done
}
reduce_satisfied()
{
deplist="$(render array_${1})"
unset tmpdeplist
for rs_y in ${deplist}; do
# only allow variable name chars
case ${rs_y} in
*[![:alnum:]\._-]*)
continue
;;
esac
# skip non executable scripts
[ ! -x ${initdir}/${rs_y} ] && continue
# skip directories
[ -d ${initdir}/${rs_y} ] && continue
# skip bad syntax
sh -n ${initdir}/${rs_y} || continue
tmpdeplist="${tmpdeplist} ${rs_y}"
done
deplist=${tmpdeplist}
for rs_x in ${runlist}; do
pop_list_item ${rs_x} ${deplist}
deplist=${tmppop}
done
eval array_${1}=\"${deplist}\"
}
get_prereqs()
{
set_initlist
for gp_x in ${initlist}; do
tmp=$(${initdir}/${gp_x} prereqs)
eval array_${gp_x}=\"${tmp}\"
done
}
count_unsatisfied()
{
set -- ${@}
return ${#}
}
# Removes $1 from initlist
pop_list_item()
{
item=${1}
shift
set -- ${@}
unset tmppop
# Iterate
for pop in ${@}; do
if [ ${pop} = ${item} ]; then
continue
fi
tmppop="${tmppop} ${pop}"
done
}
# This function generates the runlist, so we clear it first.
reduce_prereqs()
{
unset runlist
set -- ${initlist}
i=$#
# Loop until there's no more in the queue to loop through
while [ ${i} -ne 0 ]; do
oldi=${i}
for rp_x in ${initlist}; do
reduce_satisfied ${rp_x}
count_unsatisfied $(render array_${rp_x})
cnt=${?}
if [ ${cnt} -eq 0 ]; then
runlist="${runlist} ${rp_x}"
pop_list_item ${rp_x} ${initlist}
initlist=${tmppop}
i=$((${i} - 1))
fi
done
if [ ${i} -eq ${oldi} ]; then
panic "PANIC: Circular dependancy. Exiting."
fi
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()
{
set -e
for cs_x in ${runlist}; do
[ -f ${initdir}/${cs_x} ] || continue
# mkinitramfs verbose output
if [ "${verbose}" = "y" ]; then
echo "Calling hook ${cs_x}"
fi
${initdir}/${cs_x} && ec=$? || ec=$?
# allow hooks to abort build:
if [ "$ec" -ne 0 ]; then
echo "E: ${initdir}/${cs_x} failed with return $ec."
# only errexit on mkinitramfs
[ -n "${version}" ] && exit $ec
fi
# allow boot scripts to modify exported boot parameters
if [ -e /conf/param.conf ]; then
. /conf/param.conf
fi
done
set +e
}
run_scripts()
{
initdir=${1}
[ ! -d ${initdir} ] && return
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
load_modules()
{
if [ -e /conf/modules ]; then
cat /conf/modules | while read m; do
# Skip empty lines
if [ -z "$m" ]; then
continue
fi
# Skip comments - d?ash removes whitespace prefix
com=$(printf "%.1s" "${m}")
if [ "$com" = "#" ]; then
continue
fi
modprobe $m
done
fi
}
# 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=$(blkid -o value -s TYPE "${FS}")
RET=$?
if [ -z "${FSTYPE}" ]; then
FSTYPE="unknown"
fi
echo "${FSTYPE}"
return ${RET}
}
# Wait for queued kernel/udev events
wait_for_udev()
{
command -v udevadm >/dev/null 2>&1 || return 0
udevadm settle ${1:+--timeout=$1}
}

View File

@ -1,27 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
for x in $(cat /proc/cmdline); do
case ${x} in
all_generic_ide)
modprobe ata_generic all_generic_ide=1
;;
all_generic_ide=*)
if [ ${x#all_generic_ide=} ]; then
modprobe ata_generic all_generic_ide=1
fi
;;
esac
done

View File

@ -1,25 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
# sanity check
[ -z "${blacklist}" ] && exit 0
# write blacklist to modprobe.d
IFS=','
for b in ${blacklist}; do
echo "blacklist $b" >> /etc/modprobe.d/initramfs.conf
done

View File

@ -1,24 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
# Should terminal be in UTF8 mode?
if [ -x /bin/kbd_mode ]; then
/bin/kbd_mode -u -C /dev/console
fi
# Load custom keymap
if [ -x /bin/loadkmap -a -r /etc/bkeymap ]; then
/bin/loadkmap < /etc/bkeymap
fi

View File

@ -1,105 +0,0 @@
# Local filesystem mounting -*- shell-script -*-
pre_mountroot()
{
log_begin_msg "Running /scripts/local-top"
run_scripts /scripts/local-top
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
return
fi
# If the root device hasn't shown up yet, give it a little while
# to deal with removable devices
if [ ! -e "${ROOT}" ] || ! $(get_fstype "${ROOT}" >/dev/null); then
log_begin_msg "Waiting for root file system"
# Default delay is 30s
slumber=${ROOTDELAY:-30}
slumber=$(( ${slumber} * 10 ))
while [ ! -e "${ROOT}" ] \
|| ! $(get_fstype "${ROOT}" >/dev/null); do
/bin/sleep 0.1
slumber=$(( ${slumber} - 1 ))
[ ${slumber} -gt 0 ] || break
done
if [ ${slumber} -gt 0 ]; then
log_end_msg 0
else
log_end_msg 1 || true
fi
fi
# 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
/dev/hd*)
suffix="${ROOT#/dev/hd}"
major="${suffix%[[:digit:]]}"
major="${major%[[:digit:]]}"
if [ -d "/sys/block/sd${major}" ]; then
echo "WARNING bootdevice may be renamed. Try root=/dev/sd${suffix}"
fi
;;
/dev/sd*)
suffix="${ROOT#/dev/sd}"
major="${suffix%[[:digit:]]}"
major="${major%[[:digit:]]}"
if [ -d "/sys/block/hd${major}" ]; then
echo "WARNING bootdevice may be renamed. Try root=/dev/hd${suffix}"
fi
;;
esac
echo "Gave up waiting for root device. Common problems:"
echo " - Boot args (cat /proc/cmdline)"
echo " - Check rootdelay= (did the system wait long enough?)"
echo " - Check root= (did the system wait for the right device?)"
echo " - Missing modules (cat /proc/modules; ls /dev)"
panic "ALERT! ${ROOT} does not exist. Dropping to a shell!"
done
}
mountroot()
{
pre_mountroot
# Get the root filesystem type if not set
if [ -z "${ROOTFSTYPE}" ]; then
FSTYPE=$(get_fstype "${ROOT}")
else
FSTYPE=${ROOTFSTYPE}
fi
log_begin_msg "Running /scripts/local-premount"
run_scripts /scripts/local-premount
log_end_msg
if [ "${readonly}" = "y" ]; then
roflag=-r
else
roflag=-w
fi
# FIXME This has no error checking
modprobe ${FSTYPE}
# FIXME This has no error checking
# Mount root
if [ "${FSTYPE}" != "unknown" ]; then
mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
else
mount ${roflag} ${ROOTFLAGS} ${ROOT} ${rootmnt}
fi
log_begin_msg "Running /scripts/local-bottom"
run_scripts /scripts/local-bottom
log_end_msg
}

View File

@ -1,63 +0,0 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
if [ -z "${resume}" ]; then
exit 0
fi
case $resume in
LABEL=*)
resume="${resume#LABEL=}"
# support any / in LABEL= path (escape to \x2f)
case "${resume}" in
*/*)
if command -v sed >/dev/null 2>&1; then
resume="$(echo ${resume} | sed 's,/,\\x2f,g')"
else
if [ "${resume}" != "${resume#/}" ]; then
resume="\x2f${resume#/}"
fi
if [ "${resume}" != "${resume%/}" ]; then
resume="${resume%/}\x2f"
fi
IFS='/'
newresume=
for s in $resume; do
newresume="${newresume:+${newresume}\\x2f}${s}"
done
unset IFS
resume="${newresume}"
fi
esac
resume="/dev/disk/by-label/${resume}"
;;
UUID=*)
resume="/dev/disk/by-uuid/${resume#UUID=}"
;;
esac
[ ! -e "${resume}" ] && exit 0
[ ! -e /sys/power/resume ] && exit 0
# hardcode path, uswsusp ships an resume binary too
if [ -n "${resume_offset}" ]; then
/bin/resume ${resume} ${resume_offset} 2>/dev/null
else
/bin/resume ${resume} 2>/dev/null
fi

View File

@ -1,458 +0,0 @@
#!/bin/sh
export ROOTDIR="$ROOTDIR"
INITRAMFS_TOOLS_VERSION=@VERSION@
STATEDIR=${ROOTDIR}/var/lib/initramfs-tools
BOOTDIR=${ROOTDIR}/boot
CONF=${ROOTDIR}/etc/initramfs-tools/update-initramfs.conf
mode=""
version=""
[ -r ${CONF} ] && . ${CONF}
usage()
{
if [ -n "${1:-}" ]; then
printf "${*}\n\n" >&2
fi
cat >&2 << EOF
Usage: ${0} [OPTION]...
Options:
-k [version] Specify kernel version or 'all'
-c Create a new initramfs
-u Update an existing initramfs
-d Remove an existing initramfs
-t Take over a custom initramfs with this one
-b Set alternate boot directory
-v Be verbose
-V Show initramfs-tools version
-h This message
EOF
exit 1
}
# chroot check
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
}
mild_panic()
{
if [ -n "${1:-}" ]; then
printf "${*}\n" >&2
fi
exit 0
}
panic()
{
if [ -n "${1:-}" ]; then
printf "${*}\n" >&2
fi
exit 1
}
verbose()
{
if [ "${verbose}" = 1 ]; then
printf "${*}\n"
fi
}
version_exists()
{
[ -e "${STATEDIR}/${1}" ] && [ -e "${initramfs}" ]
return $?
}
set_initramfs()
{
initramfs="${BOOTDIR}/initrd.img-${version}"
}
# backup initramfs while running
backup_initramfs()
{
[ ! -r "${initramfs}" ] && return 0
initramfs_bak="${initramfs}.dpkg-bak"
[ -r "${initramfs_bak}" ] && rm -f "${initramfs_bak}"
ln -f "${initramfs}" "${initramfs_bak}" \
|| cp -a "${initramfs}" "${initramfs_bak}"
verbose "Keeping ${initramfs_bak}"
}
# keep booted initramfs
backup_booted_initramfs()
{
initramfs_bak="${initramfs}.dpkg-bak"
# first time run thus no backup
[ ! -r "${initramfs_bak}" ] && return 0
# chroot with no /proc
[ ! -r /proc/uptime ] && rm -f "${initramfs_bak}" && return 0
# no kept backup wanted
[ "${backup_initramfs}" = "no" ] && rm -f "${initramfs_bak}" && return 0
# no backup yet
if [ ! -r "${initramfs}.bak" ]; then
mv -f ${initramfs_bak} "${initramfs}.bak"
verbose "Backup ${initramfs}.bak"
return 0
fi
# keep booted initramfs
boot_initramfs=
uptime_days=$(awk '{printf "%d", $1 / 3600 / 24}' /proc/uptime)
if [ -n "$uptime_days" ]; then
boot_initramfs=$(find "${initramfs}.bak" -mtime +${uptime_days})
fi
if [ -n "${boot_initramfs}" ]; then
mv -f "${initramfs_bak}" "${initramfs}.bak"
verbose "Backup ${initramfs}.bak"
return 0
fi
verbose "Removing current backup ${initramfs_bak}"
rm -f ${initramfs_bak}
}
# nuke generated copy
remove_initramfs_bak()
{
[ -z "${initramfs_bak:-}" ] && return 0
rm -f "${initramfs_bak}"
verbose "Removing ${initramfs_bak}"
}
generate_initramfs()
{
echo "update-initramfs: Generating ${initramfs}"
OPTS="-o"
if [ "${verbose}" = 1 ]; then
OPTS="-v ${OPTS}"
fi
if mkinitramfs ${OPTS} "${initramfs}.new" "${version}"; then
mv -f "${initramfs}.new" "${initramfs}"
set_sha1
else
mkinitramfs_return="$?"
remove_initramfs_bak
rm -f "${initramfs}.new"
if [ "$mkinitramfs_return" = "2" ]; then
# minversion wasn't met, exit 0
exit 0
fi
echo "update-initramfs: failed for ${initramfs}" >&2
exit $mkinitramfs_return
fi
}
compare_sha1()
{
sha1sum "${initramfs}" | diff "${STATEDIR}/${version}" - >/dev/null 2>&1
return $?
}
# Note that this must overwrite so that updates work.
set_sha1()
{
sha1sum "${initramfs}" > "${STATEDIR}/${version}"
}
delete_sha1()
{
rm -f "${STATEDIR}/${version}"
}
# ro /boot is not modified
ro_boot_check()
{
# check irrelevant inside of a chroot
if [ ! -r /proc/mounts ] || chrooted; then
return 0
fi
boot_opts=$(awk '/boot/{if ((match($4, /^ro/) || match($4, /,ro/)) \
&& $2 == "/boot") print "ro"}' /proc/mounts)
if [ -n "${boot_opts}" ]; then
echo "WARNING: /boot is ro mounted."
echo "update-initramfs: Not updating ${initramfs}"
exit 0
fi
}
get_sorted_versions()
{
version_list=""
for gsv_x in "${STATEDIR}"/*; do
gsv_x="$(basename "${gsv_x}")"
if [ "${gsv_x}" = '*' ]; then
return 0
fi
worklist=""
for gsv_i in $version_list; do
xbps-uhelper cmpver "${gsv_x}" "${gsv_i}"
if [ $? -eq 0 ] || [ $? -eq 1 ]; then
worklist="${worklist} ${gsv_x} ${gsv_i}"
gsv_x=""
else
worklist="${worklist} ${gsv_i}"
fi
done
if [ "${gsv_x}" != "" ]; then
worklist="${worklist} ${gsv_x}"
fi
version_list="${worklist}"
done
verbose "Available versions: ${version_list}"
}
set_current_version()
{
if [ -f /boot/initrd.img-`uname -r` ]; then
version=`uname -r`
fi
}
set_linked_version()
{
linktarget=
if [ -e /initrd.img ] && [ -L /initrd.img ]; then
linktarget="$(basename "$(readlink /initrd.img)")"
fi
if [ -e /boot/initrd.img ] && [ -L /boot/initrd.img ]; then
linktarget="$(basename "$(readlink /boot/initrd.img)")"
fi
if [ -z "${linktarget}" ]; then
return
fi
version="${linktarget##initrd.img-}"
}
set_highest_version()
{
get_sorted_versions
if [ -z "${version_list}" ]; then
version=
return
fi
set -- ${version_list}
version=${1}
}
create()
{
if [ -z "${version}" ]; then
usage "Create mode requires a version argument"
fi
set_initramfs
if [ "${takeover}" = 0 ]; then
if version_exists "${version}"; then
panic "Cannot create version ${version}: already exists"
fi
if [ -e "${initramfs}" ]; then
panic "${initramfs} already exists, cannot create."
fi
fi
generate_initramfs
}
update()
{
if [ "${update_initramfs}" = "no" ]; then
echo "update-initramfs: Not updating initramfs."
exit 0
fi
if [ -z "${version}" ]; then
set_highest_version
fi
if [ -z "${version}" ]; then
set_linked_version
fi
if [ -z "${version}" ]; then
set_current_version
fi
if [ -z "${version}" ]; then
verbose "Nothing to do, exiting."
exit 0
fi
set_initramfs
ro_boot_check
altered_check
backup_initramfs
generate_initramfs
backup_booted_initramfs
}
delete()
{
if [ -z "${version}" ]; then
usage "Delete mode requires a version argument"
fi
set_initramfs
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."
fi
fi
altered_check
echo "update-initramfs: Deleting ${initramfs}"
delete_sha1
rm -f "${initramfs}" "${initramfs}.bak"
}
# Check for update mode on existing and modified initramfs
altered_check()
{
# No check on takeover
[ "${takeover}" = 1 ] && return 0
if [ ! -e "${initramfs}" ]; then
mild_panic "${initramfs} does not exist. Cannot update."
fi
if ! compare_sha1; then
echo "update-initramfs: ${initramfs} has been altered." >&2
mild_panic "update-initramfs: Cannot update. Override with -t option."
fi
}
# Defaults
verbose=0
yes=0
# We default to takeover=1 in Ubuntu, but not Debian
takeover=0
##
while getopts "k:cudyvtb:h?V" flag; do
case "${flag}" in
k)
version="${OPTARG}"
;;
c)
mode="c"
;;
d)
mode="d"
;;
u)
mode="u"
;;
v)
verbose="1"
;;
y)
yes="1"
;;
t)
takeover="1"
;;
b)
BOOTDIR="${OPTARG}"
if [ ! -d "${BOOTDIR}" ]; then
echo "Error: ${BOOTDIR} is not a directory." >&2
exit 1
fi
;;
V)
echo "${INITRAMFS_TOOLS_VERSION}"
exit 0
;;
h|?)
usage
;;
esac
done
shift $((${OPTIND} - 1))
if [ $# -ne 0 ]; then
echo "Invalid argument for option -k." >&2
usage
fi
# Validate arguments
if [ -z "${mode}" ]; then
usage "You must specify at least one of -c, -u, or -d."
fi
if [ "${version}" = "all" ] \
|| ( [ "${update_initramfs}" = "all" ] && [ -z "${version}" ] ); then
: FIXME check for --yes, and if not ask are you sure
get_sorted_versions
if [ -z "${version_list}" ]; then
verbose "Nothing to do, exiting."
exit 0
fi
OPTS="-b ${BOOTDIR}"
if [ "${verbose}" = "1" ]; then
OPTS="${OPTS} -v"
fi
if [ "${takeover}" = "1" ]; then
OPTS="${OPTS} -t"
fi
if [ "${yes}" = "1" ]; then
OPTS="${OPTS} -y"
fi
for u_version in ${version_list}; do
verbose "Execute: ${0} -${mode} -k \"${u_version}\" ${OPTS}"
"${0}" -${mode} -k "${u_version}" ${OPTS}
done
exit 0
fi
case "${mode}" in
c)
create
;;
d)
delete
;;
u)
update
;;
esac

View File

@ -1,105 +0,0 @@
.TH UPDATE-INITRAMFS 8 "2011/07/09" "Linux" "update\-initramfs manual"
.SH NAME
update\-initramfs \- generate an initramfs image
.SH SYNOPSIS
.B update\-initramfs
.RB \-c | \-d | \-u
.RB [ \-k
.IR version ]
.RB [ \-t ]
.RB [ \-v ]
.RB [ \-V ]
.RB [ \-b ]
.RB [ \-h ]
.SH DESCRIPTION
The
.B update\-initramfs
script manages your initramfs images on your local box.
It keeps track of the existing initramfs archives in /boot.
There are three modes of operation create, update or delete.
You must at least specify one of those modes.
The initramfs is a gzipped cpio archive.
At boot time, the kernel unpacks that archive into RAM disk, mounts and
uses it as initial root file system. All finding of the root device
happens in this early userspace.
.SH OPTIONS
.TP
\fB \-k \fI version
Set the specific kernel version for whom the initramfs will be generated.
For example the output of uname \-r for your currently running kernel.
This argument is optional for update. The default is the latest kernel version.
The use of "all" for the
.I version
string specifies
.B update\-initramfs
to execute the chosen action for all kernel versions, that are already known
to
.B update\-initramfs.
.TP
\fB \-c
This mode creates a new initramfs.
.TP
\fB \-u
This mode updates an existing initramfs.
.TP
\fB \-d
This mode removes an existing initramfs.
.TP
\fB \-t
Allows to take over an custom initramfs with a newer one.
.TP
\fB \-v
This option increases the amount of information you are given during
the chosen action.
.TP
\fB \-V
Prints the current initramfs-tools version.
.TP
\fB \-b
Set an different bootdir for the image creation.
.TP
\fB \-h
Print a short help page describing the available options in
.B update\-initramfs.
.SH EXAMPLES
Update the initramfs of the newest kernel:
.PP
.B update\-initramfs -u
Create the initramfs for a specific kernel:
.PP
.B update\-initramfs -c -k 2.6.18-1-686
.SH FILES
/etc/initramfs-tools/update-initramfs.conf
.SH AUTHOR
The initramfs-tools from Void GNU/Linux are maintained by
Juan Romero Pardines <xtraeme@gmail.com>, they diverged substantially
from the original implementation coming from Debian.
The initramfs-tools from Debian are written by Maximilian Attems <maks@debian.org>,
Jeff Bailey <jbailey@raspberryginger.com> and numerous others.
.SH SEE ALSO
.BR
.IR initramfs.conf (5),
.IR initramfs-tools (8),
.IR mkinitramfs (8).

View File

@ -1,35 +0,0 @@
.TH UPDATE-INITRAMFS.CONF 5 "2010/04/05" "Linux" "update-initramfs.conf manual"
.SH NAME
update-initramfs.conf \- configuration file for update-initramfs
.SH DESCRIPTION
The configuration file allows one to disable the update action from
.B update-initramfs.
.SH GENERAL VARIABLES
.TP
\fB update_initramfs
Default is \fIyes\fP for running the latest initramfs-tools hooks in the
newest Linux image.
Setting it to \fIall\fP updates any known initramfs.
It is possible to set it to \fIno\fP for remote servers or boxes where
conservative manners needs to be applied. This disables
the \fBupdate_initramfs \-u\fP call.
.TP
\fB backup_initramfs
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>,
Jeff Bailey <jbailey@raspberryginger.com> and numerous others.
.SH SEE ALSO
.BR
.IR initramfs.conf (5),
.IR initramfs-tools (8),
.IR mkinitramfs (8),
.IR update-initramfs (8).

View File

@ -1,89 +0,0 @@
# Template file for 'initramfs-tools'
pkgname=initramfs-tools
_localver=2 # This is the XBPS version
_distver=0.102 # This should match debian version
version=${_distver}.${_localver}
noextract=yes
noarch=yes
triggers="initramfs-tools"
fulldepends="cpio util-linux gawk findutils sed grep gzip bzip2 xz udev>=183 busybox>=1.19.2 klibc-resume kbd>=1.15.3_5 kmod"
short_desc="Tools for generating an initramfs"
maintainer="Juan RP <xtraeme@gmail.com>"
homepage="http://code.google.com/p/xbps"
license="GPL-2"
long_desc="
This package contains tools to create and boot an initramfs for packaged
Linux kernel. The initramfs is a gzipped cpio archive. At boot time, the
kernel unpacks that archive into RAM, mounts and uses it as initial root
file system. The mounting of the real root file system occurs in early user
space. Any boot loader with initrd support is able to load an
initramfs archive."
conf_files="
/etc/$pkgname/initramfs.conf
/etc/$pkgname/update-initramfs.conf
/etc/$pkgname/modules"
make_dirs="
/etc/$pkgname/hooks 0755 0 0
/etc/$pkgname/conf.d 0755 0 0
/etc/$pkgname/scripts/init-bottom 0755 0 0
/etc/$pkgname/scripts/init-premount 0755 0 0
/etc/$pkgname/scripts/init-top 0755 0 0
/etc/$pkgname/scripts/local-bottom 0755 0 0
/etc/$pkgname/scripts/local-top 0755 0 0
/usr/share/$pkgname/conf.d 0755 0 0
/usr/share/$pkgname/hooksconf.d 0755 0 0
/usr/share/$pkgname/modules.d 0755 0 0
/usr/share/$pkgname/scripts/init-premount 0755 0 0
/usr/share/$pkgname/scripts/local-top 0755 0 0
/var/lib/$pkgname 0755 0 0
"
do_install() {
# /etc config files
vinstall $FILESDIR/conf/initramfs.conf 644 etc/$pkgname
vinstall $FILESDIR/conf/update-initramfs.conf 644 etc/$pkgname
# Data
vinstall $FILESDIR/init 744 usr/share/$pkgname
for f in functions local; do
vinstall $FILESDIR/scripts/$f 644 usr/share/$pkgname/scripts
done
vmkdir usr/share/$pkgname/scripts/init-top
install -m755 $FILESDIR/scripts/init-top/* \
$DESTDIR/usr/share/$pkgname/scripts/init-top
vmkdir usr/share/$pkgname/scripts/local-premount
install -m755 $FILESDIR/scripts/local-premount/* \
$DESTDIR/usr/share/$pkgname/scripts/local-premount
vmkdir usr/share/$pkgname/hooks
install -m755 $FILESDIR/hooks/* $DESTDIR/usr/share/$pkgname/hooks
install -m644 $FILESDIR/hook-functions $DESTDIR/usr/share/$pkgname
vinstall $FILESDIR/conf/modules 644 etc/$pkgname
# Examples
vmkdir usr/share/doc/$pkgname/examples
install -m644 $FILESDIR/docs/* $DESTDIR/usr/share/doc/$pkgname/examples
# Manpages
vmkdir usr/share/man/man5
install -m 644 $FILESDIR/*.5 $DESTDIR/usr/share/man/man5
vmkdir usr/share/man/man8
install -m 644 $FILESDIR/*.8 $DESTDIR/usr/share/man/man8
# Scripts
vmkdir usr/sbin
install -m 755 $FILESDIR/mkinitramfs $DESTDIR/usr/sbin
install -m 755 $FILESDIR/update-initramfs $DESTDIR/usr/sbin
sed -i -e "s|@VERSION@|${version}|g" $DESTDIR/usr/sbin/update-initramfs
# bash_completion.d
install -Dm644 $FILESDIR/bash_completion.d/initramfs-tools \
${DESTDIR}/etc/bash_completion.d/initramfs-tools
# Kernel hooks
vinstall ${FILESDIR}/kernel.d/${pkgname}.postinst \
755 etc/kernel.d/post-install 10-${pkgname}
vinstall ${FILESDIR}/kernel.d/${pkgname}.postrm \
755 etc/kernel.d/post-remove 10-${pkgname}
}