�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!usr/bin/dracut000075500000207076152525014710007353 0ustar00#!/bin/bash -p # # Generator script for a dracut initramfs # Tries to retain some degree of compatibility with the command line # of the various mkinitrd implementations out there # # Copyright 2005-2013 Red Hat, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # store for logging unset BASH_ENV unset GZIP # Verify bash version, current minimum is 4 if (( BASH_VERSINFO[0] < 4 )); then printf -- 'You need at least Bash 4 to use dracut, sorry.' >&2 exit 1 fi dracut_args=( "$@" ) readonly dracut_cmd="$(readlink -f $0)" set -o pipefail usage() { [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut if [[ -f $dracutbasedir/dracut-version.sh ]]; then . $dracutbasedir/dracut-version.sh fi # 80x25 linebreak here ^ cat << EOF Usage: $dracut_cmd [OPTION]... [ []] Version: $DRACUT_VERSION Creates initial ramdisk images for preloading modules -h, --help Display all options If a [LIST] has multiple arguments, then you have to put these in quotes. For example: # dracut --add-drivers "module1 module2" ... EOF } long_usage() { [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut if [[ -f $dracutbasedir/dracut-version.sh ]]; then . $dracutbasedir/dracut-version.sh fi # 80x25 linebreak here ^ cat << EOF Usage: $dracut_cmd [OPTION]... [ []] Version: $DRACUT_VERSION Creates initial ramdisk images for preloading modules --kver [VERSION] Set kernel version to [VERSION]. -f, --force Overwrite existing initramfs file. -a, --add [LIST] Add a space-separated list of dracut modules. --rebuild Append arguments to those of existing image and rebuild -m, --modules [LIST] Specify a space-separated list of dracut modules to call when building the initramfs. Modules are located in /usr/lib/dracut/modules.d. -o, --omit [LIST] Omit a space-separated list of dracut modules. --force-add [LIST] Force to add a space-separated list of dracut modules to the default set of modules, when -H is specified. -d, --drivers [LIST] Specify a space-separated list of kernel modules to exclusively include in the initramfs. --add-drivers [LIST] Specify a space-separated list of kernel modules to add to the initramfs. --force-drivers [LIST] Specify a space-separated list of kernel modules to add to the initramfs and make sure they are tried to be loaded via modprobe same as passing rd.driver.pre=DRIVER kernel parameter. --omit-drivers [LIST] Specify a space-separated list of kernel modules not to add to the initramfs. --filesystems [LIST] Specify a space-separated list of kernel filesystem modules to exclusively include in the generic initramfs. -k, --kmoddir [DIR] Specify the directory, where to look for kernel modules --fwdir [DIR] Specify additional directories, where to look for firmwares, separated by : --kernel-only Only install kernel drivers and firmware files --no-kernel Do not install kernel drivers and firmware files --print-cmdline Print the kernel command line for the given disk layout --early-microcode Combine early microcode with ramdisk --no-early-microcode Do not combine early microcode with ramdisk --kernel-cmdline [PARAMETERS] Specify default kernel command line parameters --strip Strip binaries in the initramfs --nostrip Do not strip binaries in the initramfs --hardlink Hardlink files in the initramfs --nohardlink Do not hardlink files in the initramfs --prefix [DIR] Prefix initramfs files with [DIR] --noprefix Do not prefix initramfs files --mdadmconf Include local /etc/mdadm.conf --nomdadmconf Do not include local /etc/mdadm.conf --lvmconf Include local /etc/lvm/lvm.conf --nolvmconf Do not include local /etc/lvm/lvm.conf --fscks [LIST] Add a space-separated list of fsck helpers. --nofscks Inhibit installation of any fsck helpers. --ro-mnt Mount / and /usr read-only by default. -h, --help This message --debug Output debug information of the build process --profile Output profile information of the build process -L, --stdlog [0-6] Specify logging level (to standard error) 0 - suppress any messages 1 - only fatal errors 2 - all errors 3 - warnings 4 - info 5 - debug info (here starts lots of output) 6 - trace info (and even more) -v, --verbose Increase verbosity level -q, --quiet Decrease verbosity level -c, --conf [FILE] Specify configuration file to use. Default: /etc/dracut.conf --confdir [DIR] Specify configuration directory to use *.conf files from. Default: /etc/dracut.conf.d --tmpdir [DIR] Temporary directory to be used instead of default /var/tmp. -l, --local Local mode. Use modules from the current working directory instead of the system-wide installed in /usr/lib/dracut/modules.d. Useful when running dracut from a git checkout. -H, --hostonly Host-Only mode: Install only what is needed for booting the local host instead of a generic host. -N, --no-hostonly Disables Host-Only mode --hostonly-mode Specify the hostonly mode to use. could be one of "sloppy" or "strict". "sloppy" mode is used by default. In "sloppy" hostonly mode, extra drivers and modules will be installed, so minor hardware change won't make the image unbootable (eg. changed keyboard), and the image is still portable among similar hosts. With "strict" mode enabled, anything not necessary for booting the local host in its current state will not be included, and modules may do some extra job to save more space. Minor change of hardware or environment could make the image unbootable. DO NOT use "strict" mode unless you know what you are doing. --hostonly-cmdline Store kernel command line arguments needed in the initramfs --no-hostonly-cmdline Do not store kernel command line arguments needed in the initramfs --no-hostonly-default-device Do not generate implicit host devices like root, swap, fstab, etc. Use "--mount" or "--add-device" to explicitly add devices as needed. --hostonly-i18n Install only needed keyboard and font files according to the host configuration (default). --no-hostonly-i18n Install all keyboard and font files available. --hostonly-nics [LIST] Only enable listed NICs in the initramfs. --persistent-policy [POLICY] Use [POLICY] to address disks and partitions. POLICY can be any directory name found in /dev/disk. E.g. "by-uuid", "by-label" --fstab Use /etc/fstab to determine the root device. --add-fstab [FILE] Add file to the initramfs fstab --mount "[DEV] [MP] [FSTYPE] [FSOPTS]" Mount device [DEV] on mountpoint [MP] with filesystem [FSTYPE] and options [FSOPTS] in the initramfs --mount "[MP]" Same as above, but [DEV], [FSTYPE] and [FSOPTS] are determined by looking at the current mounts. --add-device "[DEV]" Bring up [DEV] in initramfs -i, --include [SOURCE] [TARGET] Include the files in the SOURCE directory into the Target directory in the final initramfs. If SOURCE is a file, it will be installed to TARGET in the final initramfs. -I, --install [LIST] Install the space separated list of files into the initramfs. --install-optional [LIST] Install the space separated list of files into the initramfs, if they exist. --gzip Compress the generated initramfs using gzip. This will be done by default, unless another compression option or --no-compress is passed. --bzip2 Compress the generated initramfs using bzip2. Make sure your kernel has bzip2 decompression support compiled in, otherwise you will not be able to boot. --lzma Compress the generated initramfs using lzma. Make sure your kernel has lzma support compiled in, otherwise you will not be able to boot. --xz Compress the generated initramfs using xz. Make sure that your kernel has xz support compiled in, otherwise you will not be able to boot. --lzo Compress the generated initramfs using lzop. Make sure that your kernel has lzo support compiled in, otherwise you will not be able to boot. --lz4 Compress the generated initramfs using lz4. Make sure that your kernel has lz4 support compiled in, otherwise you will not be able to boot. --zstd Compress the generated initramfs using Zstandard. Make sure that your kernel has zstd support compiled in, otherwise you will not be able to boot. --compress [COMPRESSION] Compress the generated initramfs with the passed compression program. Make sure your kernel knows how to decompress the generated initramfs, otherwise you will not be able to boot. --no-compress Do not compress the generated initramfs. This will override any other compression options. --list-modules List all available dracut modules. -M, --show-modules Print included module's name to standard output during build. --keep Keep the temporary initramfs for debugging purposes --printsize Print out the module install size --sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module) --logfile [FILE] Logfile to use (overrides configuration setting) --reproducible Create reproducible images --no-reproducible Do not create reproducible images --loginstall [DIR] Log all files installed from the host to [DIR] --uefi Create an UEFI executable with the kernel cmdline and kernel combined --uefi-stub [FILE] Use the UEFI stub [FILE] to create an UEFI executable --kernel-image [FILE] Location of the kernel image --regenerate-all Regenerate all initramfs images at the default location for the kernel versions found on the system If [LIST] has multiple arguments, then you have to put these in quotes. For example: # dracut --add-drivers "module1 module2" ... EOF } # Fills up host_devs stack variable and makes sure there are no duplicates push_host_devs() { local _dev for _dev in "$@"; do [[ " ${host_devs[@]} " == *" $_dev "* ]] && return host_devs+=( "$_dev" ) done } # Little helper function for reading args from the commandline. # it automatically handles -a b and -a=b variants, and returns 1 if # we need to shift $3. read_arg() { # $1 = arg name # $2 = arg value # $3 = arg parameter local rematch='^[^=]*=(.*)$' if [[ $2 =~ $rematch ]]; then read "$1" <<< "${BASH_REMATCH[1]}" else read "$1" <<< "$3" # There is no way to shift our callers args, so # return 1 to indicate they should do it instead. return 1 fi } check_conf_file() { if grep -H -e '^[^#]*[+]=\("[^ ]\|.*[^ ]"\)' "$@"; then printf '\ndracut: WARNING: +=" ": should have surrounding white spaces!\n' >&2 printf 'dracut: WARNING: This will lead to unwanted side effects! Please fix the configuration file.\n\n' >&2 fi } dropindirs_sort() { local suffix=$1; shift local -a files local f d for d in "$@"; do for i in "$d/"*"$suffix"; do if [[ -e "$i" ]]; then printf "%s\n" "${i##*/}" fi done done | sort -Vu | { readarray -t files for f in "${files[@]}"; do for d in "$@"; do if [[ -e "$d/$f" ]]; then printf "%s\n" "$d/$f" continue 2 fi done done } } rearrange_params() { # Workaround -i, --include taking 2 arguments newat=() for i in "$@"; do if [[ $i == "-i" ]] || [[ $i == "--include" ]]; then newat+=("++include") # Replace --include by ++include else newat+=("$i") fi done set -- "${newat[@]}" # Set new $@ TEMP=$(unset POSIXLY_CORRECT; getopt \ -o "a:m:o:d:I:k:c:L:fvqlHhMN" \ --long kver: \ --long add: \ --long force-add: \ --long add-drivers: \ --long force-drivers: \ --long omit-drivers: \ --long modules: \ --long omit: \ --long drivers: \ --long filesystems: \ --long install: \ --long install-optional: \ --long fwdir: \ --long libdirs: \ --long fscks: \ --long add-fstab: \ --long mount: \ --long device: \ --long add-device: \ --long nofscks \ --long ro-mnt \ --long kmoddir: \ --long conf: \ --long confdir: \ --long tmpdir: \ --long stdlog: \ --long compress: \ --long prefix: \ --long rebuild: \ --long force \ --long kernel-only \ --long no-kernel \ --long print-cmdline \ --long kernel-cmdline: \ --long strip \ --long nostrip \ --long hardlink \ --long nohardlink \ --long noprefix \ --long mdadmconf \ --long nomdadmconf \ --long lvmconf \ --long nolvmconf \ --long debug \ --long profile \ --long sshkey: \ --long logfile: \ --long verbose \ --long quiet \ --long local \ --long hostonly \ --long host-only \ --long no-hostonly \ --long no-host-only \ --long hostonly-mode: \ --long hostonly-cmdline \ --long no-hostonly-cmdline \ --long no-hostonly-default-device \ --long persistent-policy: \ --long fstab \ --long help \ --long bzip2 \ --long lzma \ --long xz \ --long lzo \ --long lz4 \ --long zstd \ --long no-compress \ --long gzip \ --long list-modules \ --long show-modules \ --long keep \ --long printsize \ --long regenerate-all \ --long noimageifnotneeded \ --long early-microcode \ --long no-early-microcode \ --long reproducible \ --long no-reproducible \ --long loginstall: \ --long uefi \ --long uefi-stub: \ --long kernel-image: \ --long no-hostonly-i18n \ --long hostonly-i18n \ --long hostonly-nics: \ --long no-machineid \ -- "$@") if (( $? != 0 )); then usage exit 1 fi } verbosity_mod_l=0 unset kernel unset outfile rearrange_params "$@" eval set -- "$TEMP" # parse command line args to check if '--rebuild' option is present unset append_args_l unset rebuild_file while : do if [ "$1" == "--" ]; then shift; break fi if [ "$1" == "--rebuild" ]; then append_args_l="yes" rebuild_file=$2 if [ ! -e $rebuild_file ]; then echo "Image file '$rebuild_file', for rebuild, does not exist!" exit 1 fi abs_rebuild_file=$(readlink -f "$rebuild_file") && rebuild_file="$abs_rebuild_file" shift; continue fi shift done # get output file name and kernel version from command line arguments while (($# > 0)); do case ${1%%=*} in ++include) shift 2;; *) if ! [[ ${outfile+x} ]]; then outfile=$1 elif ! [[ ${kernel+x} ]]; then kernel=$1 else printf "\nUnknown arguments: %s\n\n" "$*" >&2 usage; exit 1; fi ;; esac shift done # extract input image file provided with rebuild option to get previous parameters, if any if [[ $append_args_l == "yes" ]]; then unset rebuild_param # determine resultant file if ! [[ $outfile ]]; then outfile=$rebuild_file fi if ! rebuild_param=$(lsinitrd $rebuild_file '*lib/dracut/build-parameter.txt'); then echo "Image '$rebuild_file' has no rebuild information stored" exit 1 fi # prepend previous parameters to current command line args if [[ $rebuild_param ]]; then TEMP="$rebuild_param $TEMP" eval set -- "$TEMP" rearrange_params "$@" fi fi unset PARMS_TO_STORE PARMS_TO_STORE="" eval set -- "$TEMP" while :; do if [ $1 != "--" ] && [ $1 != "--rebuild" ]; then PARMS_TO_STORE+=" $1"; fi case $1 in --kver) kernel="$2"; PARMS_TO_STORE+=" '$2'"; shift;; -a|--add) add_dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --force-add) force_add_dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --add-drivers) add_drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --force-drivers) force_drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --omit-drivers) omit_drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; -m|--modules) dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; -o|--omit) omit_dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; -d|--drivers) drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --filesystems) filesystems_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; -I|--install) install_items_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --install-optional) install_optional_items_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --fwdir) fw_dir_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --libdirs) libdirs_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --fscks) fscks_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --add-fstab) add_fstab_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --mount) fstab_lines+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --add-device|--device) add_device_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --kernel-cmdline) kernel_cmdline_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --nofscks) nofscks_l="yes";; --ro-mnt) ro_mnt_l="yes";; -k|--kmoddir) drivers_dir_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;; -c|--conf) conffile="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --confdir) confdir="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --tmpdir) tmpdir_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;; -L|--stdlog) stdloglvl_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --compress) compress_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --prefix) prefix_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --loginstall) loginstall_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --rebuild) if [ $rebuild_file == $outfile ]; then force=yes fi shift ;; -f|--force) force=yes;; --kernel-only) kernel_only="yes"; no_kernel="no";; --no-kernel) kernel_only="no"; no_kernel="yes";; --print-cmdline) print_cmdline="yes"; hostonly_l="yes"; kernel_only="yes"; no_kernel="yes";; --early-microcode) early_microcode_l="yes";; --no-early-microcode) early_microcode_l="no";; --strip) do_strip_l="yes";; --nostrip) do_strip_l="no";; --hardlink) do_hardlink_l="yes";; --nohardlink) do_hardlink_l="no";; --noprefix) prefix_l="/";; --mdadmconf) mdadmconf_l="yes";; --nomdadmconf) mdadmconf_l="no";; --lvmconf) lvmconf_l="yes";; --nolvmconf) lvmconf_l="no";; --debug) debug="yes";; --profile) profile="yes";; --sshkey) sshkey="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --logfile) logfile_l="$2"; shift;; -v|--verbose) ((verbosity_mod_l++));; -q|--quiet) ((verbosity_mod_l--));; -l|--local) allowlocal="yes" [[ -f "$(readlink -f "${0%/*}")/dracut-init.sh" ]] \ && dracutbasedir="$(readlink -f "${0%/*}")" ;; -H|--hostonly|--host-only) hostonly_l="yes" ;; -N|--no-hostonly|--no-host-only) hostonly_l="no" ;; --hostonly-mode) hostonly_mode_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --hostonly-cmdline) hostonly_cmdline_l="yes" ;; --hostonly-i18n) i18n_install_all_l="no" ;; --hostonly-nics) hostonly_nics_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --no-hostonly-i18n) i18n_install_all_l="yes" ;; --no-hostonly-cmdline) hostonly_cmdline_l="no" ;; --no-hostonly-default-device) hostonly_default_device="no" ;; --persistent-policy) persistent_policy_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --fstab) use_fstab_l="yes" ;; -h|--help) long_usage; exit 1 ;; -i|--include) include_src+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;; --bzip2) compress_l="bzip2";; --lzma) compress_l="lzma";; --xz) compress_l="xz";; --lzo) compress_l="lzo";; --lz4) compress_l="lz4";; --zstd) compress_l="zstd";; --no-compress) _no_compress_l="cat";; --gzip) compress_l="gzip";; --list-modules) do_list="yes";; -M|--show-modules) show_modules_l="yes" ;; --keep) keep="yes";; --printsize) printsize="yes";; --regenerate-all) regenerate_all="yes";; --noimageifnotneeded) noimageifnotneeded="yes";; --reproducible) reproducible_l="yes";; --no-reproducible) reproducible_l="no";; --uefi) uefi="yes";; --uefi-stub) uefi_stub_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --kernel-image) kernel_image_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;; --no-machineid) machine_id_l="no";; --) shift; break;; *) # should not even reach this point printf "\n!Unknown option: '%s'\n\n" "$1" >&2; usage; exit 1;; esac shift done # getopt cannot handle multiple arguments, so just handle "-I,--include" # the old fashioned way while (($# > 0)); do if [ "${1%%=*}" == "++include" ]; then include_src+=("$2") include_target+=("$3") PARMS_TO_STORE+=" --include '$2' '$3'" shift 2 fi shift done if [[ $regenerate_all == "yes" ]]; then ret=0 if [[ $kernel ]]; then printf -- "--regenerate-all cannot be called with a kernel version\n" >&2 exit 1 fi if [[ $outfile ]]; then printf -- "--regenerate-all cannot be called with a image file\n" >&2 exit 1 fi ((len=${#dracut_args[@]})) for ((i=0; i < len; i++)); do [[ ${dracut_args[$i]} == "--regenerate-all" ]] && \ unset dracut_args[$i] done cd /lib/modules for i in *; do [[ -f $i/modules.dep ]] || [[ -f $i/modules.dep.bin ]] || continue "$dracut_cmd" --kver="$i" "${dracut_args[@]}" ((ret+=$?)) done exit $ret fi if ! [[ $kernel ]]; then kernel=$(uname -r) fi export LC_ALL=C export LANG=C unset LC_MESSAGES unset LC_CTYPE unset LD_LIBRARY_PATH unset LD_PRELOAD unset GREP_OPTIONS export DRACUT_LOG_LEVEL=warning [[ $debug ]] && { export DRACUT_LOG_LEVEL=debug export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '; set -x } [[ $profile ]] && { export PS4='+ $(date "+%s.%N") ${BASH_SOURCE}@${LINENO}: '; set -x debug=yes } [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut # if we were not passed a config file, try the default one if [[ ! -f $conffile ]]; then if [[ $allowlocal ]]; then conffile="$dracutbasedir/dracut.conf" else conffile="/etc/dracut.conf" fi fi if [[ ! -d $confdir ]]; then if [[ $allowlocal ]]; then confdir="$dracutbasedir/dracut.conf.d" else confdir="/etc/dracut.conf.d" fi fi # source our config file if [[ -f $conffile ]]; then check_conf_file "$conffile" . "$conffile" fi # source our config dir for f in $(dropindirs_sort ".conf" "$confdir" "$dracutbasedir/dracut.conf.d"); do check_conf_file "$f" [[ -e $f ]] && . "$f" done DRACUT_PATH=${DRACUT_PATH:-/sbin /bin /usr/sbin /usr/bin} for i in $DRACUT_PATH; do rl=$i if [ -L "$i" ]; then rl=$(readlink -f $i) fi if [[ "$NPATH" != *:$rl* ]] ; then NPATH+=":$rl" fi done export PATH="${NPATH#:}" unset NPATH export SYSTEMCTL=${SYSTEMCTL:-systemctl} # these options add to the stuff in the config file (( ${#add_dracutmodules_l[@]} )) && add_dracutmodules+=" ${add_dracutmodules_l[@]} " (( ${#force_add_dracutmodules_l[@]} )) && force_add_dracutmodules+=" ${force_add_dracutmodules_l[@]} " (( ${#fscks_l[@]} )) && fscks+=" ${fscks_l[@]} " (( ${#add_fstab_l[@]} )) && add_fstab+=" ${add_fstab_l[@]} " (( ${#fstab_lines_l[@]} )) && fstab_lines+=( "${fstab_lines_l[@]}" ) (( ${#install_items_l[@]} )) && install_items+=" ${install_items_l[@]} " (( ${#install_optional_items_l[@]} )) && install_optional_items+=" ${install_optional_items_l[@]} " (( ${#hostonly_nics_l[@]} )) && hostonly_nics+=" ${hostonly_nics_l[@]} " # these options override the stuff in the config file (( ${#dracutmodules_l[@]} )) && dracutmodules="${dracutmodules_l[@]}" (( ${#omit_dracutmodules_l[@]} )) && omit_dracutmodules="${omit_dracutmodules_l[@]}" (( ${#filesystems_l[@]} )) && filesystems="${filesystems_l[@]}" (( ${#fw_dir_l[@]} )) && fw_dir="${fw_dir_l[@]}" (( ${#libdirs_l[@]} ))&& libdirs="${libdirs_l[@]}" [[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l [[ ! $stdloglvl ]] && stdloglvl=4 stdloglvl=$((stdloglvl + verbosity_mod_l)) ((stdloglvl > 6)) && stdloglvl=6 ((stdloglvl < 0)) && stdloglvl=0 [[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l [[ $do_strip_l ]] && do_strip=$do_strip_l [[ $do_strip ]] || do_strip=yes [[ $do_hardlink_l ]] && do_hardlink=$do_hardlink_l [[ $do_hardlink ]] || do_hardlink=yes [[ $prefix_l ]] && prefix=$prefix_l [[ $prefix = "/" ]] && unset prefix [[ $hostonly_l ]] && hostonly=$hostonly_l [[ $hostonly_cmdline_l ]] && hostonly_cmdline=$hostonly_cmdline_l [[ $hostonly_mode_l ]] && hostonly_mode=$hostonly_mode_l [[ "$hostonly" == "yes" ]] && ! [[ $hostonly_cmdline ]] && hostonly_cmdline="yes" [[ $i18n_install_all_l ]] && i18n_install_all=$i18n_install_all_l [[ $persistent_policy_l ]] && persistent_policy=$persistent_policy_l [[ $use_fstab_l ]] && use_fstab=$use_fstab_l [[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l [[ $lvmconf_l ]] && lvmconf=$lvmconf_l [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut [[ $fw_dir ]] || fw_dir="/lib/firmware/updates:/lib/firmware:/lib/firmware/$kernel" [[ $tmpdir_l ]] && tmpdir="$tmpdir_l" [[ $tmpdir ]] || tmpdir=/var/tmp [[ $INITRD_COMPRESS ]] && compress=$INITRD_COMPRESS [[ $compress_l ]] && compress=$compress_l [[ $show_modules_l ]] && show_modules=$show_modules_l [[ $nofscks_l ]] && nofscks="yes" [[ $ro_mnt_l ]] && ro_mnt="yes" [[ $early_microcode_l ]] && early_microcode=$early_microcode_l [[ $early_microcode ]] || early_microcode=yes [[ $logfile_l ]] && logfile="$logfile_l" [[ $reproducible_l ]] && reproducible="$reproducible_l" [[ $loginstall_l ]] && loginstall="$loginstall_l" [[ $uefi_stub_l ]] && uefi_stub="$uefi_stub_l" [[ $kernel_image_l ]] && kernel_image="$kernel_image_l" [[ $machine_id_l ]] && machine_id="$machine_id_l" if ! [[ $outfile ]]; then if [[ $machine_id != "no" ]]; then [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id fi if [[ $uefi == "yes" ]]; then BUILD_ID=$(cat /etc/os-release /usr/lib/os-release \ | while read -r line || [[ $line ]]; do \ [[ $line =~ BUILD_ID\=* ]] && eval "$line" && echo "$BUILD_ID" && break; \ done) if [[ -d /efi ]] && mountpoint -q /efi; then efidir=/efi else efidir=/boot/EFI if [[ -d /boot/efi/EFI ]] && mountpoint -q /boot/efi; then efidir=/boot/efi/EFI fi fi mkdir -p "$efidir/Linux" outfile="$efidir/Linux/linux-$kernel${MACHINE_ID:+-${MACHINE_ID}}${BUILD_ID:+-${BUILD_ID}}.efi" else if [[ -e "/boot/vmlinuz-$kernel" ]]; then outfile="/boot/initramfs-$kernel.img" elif [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then outfile="/boot/${MACHINE_ID}/$kernel/initrd" else outfile="/boot/initramfs-$kernel.img" fi fi fi # eliminate IFS hackery when messing with fw_dir export DRACUT_FIRMWARE_PATH=${fw_dir// /:} fw_dir=${fw_dir//:/ } # check for logfile and try to create one if it doesn't exist if [[ -n "$logfile" ]];then if [[ ! -f "$logfile" ]];then touch "$logfile" if [ ! $? -eq 0 ] ;then printf "%s\n" "dracut: touch $logfile failed." >&2 fi fi fi # handle compression options. if [[ $_no_compress_l = "cat" ]]; then compress="cat" fi [[ $hostonly = yes ]] && hostonly="-h" [[ $hostonly != "-h" ]] && unset hostonly case $hostonly_mode in '') [[ $hostonly ]] && hostonly_mode="sloppy" ;; sloppy|strict) if [[ ! $hostonly ]]; then unset hostonly_mode fi ;; *) printf "%s\n" "dracut: Invalid hostonly mode '$hostonly_mode'." >&2 exit 1 esac [[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1 readonly TMPDIR="$(realpath -e "$tmpdir")" [ -d "$TMPDIR" ] || { printf "%s\n" "dracut: Invalid tmpdir '$tmpdir'." >&2 exit 1 } readonly DRACUT_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t dracut.XXXXXX)" [ -d "$DRACUT_TMPDIR" ] || { printf "%s\n" "dracut: mktemp -p '$TMPDIR/' -d -t dracut.XXXXXX failed." >&2 exit 1 } # Cache file used to optimize get_maj_min() declare -x -r get_maj_min_cache_file="${DRACUT_TMPDIR}/majmin_cache" : > "$get_maj_min_cache_file" # clean up after ourselves no matter how we die. trap ' ret=$?; [[ $keep ]] && echo "Not removing $DRACUT_TMPDIR." >&2 || { [[ $DRACUT_TMPDIR ]] && rm -rf -- "$DRACUT_TMPDIR"; }; exit $ret; ' EXIT # clean up after ourselves no matter how we die. trap 'exit 1;' SIGINT readonly initdir="${DRACUT_TMPDIR}/initramfs" mkdir "$initdir" if [[ $early_microcode = yes ]] || ( [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]] ); then readonly early_cpio_dir="${DRACUT_TMPDIR}/earlycpio" mkdir "$early_cpio_dir" fi export DRACUT_RESOLVE_LAZY="1" if [[ $print_cmdline ]]; then stdloglvl=0 sysloglvl=0 fileloglvl=0 kmsgloglvl=0 fi if [[ -f $dracutbasedir/dracut-version.sh ]]; then . $dracutbasedir/dracut-version.sh fi if [[ -f $dracutbasedir/dracut-init.sh ]]; then . $dracutbasedir/dracut-init.sh else printf "%s\n" "dracut: Cannot find $dracutbasedir/dracut-init.sh." >&2 printf "%s\n" "dracut: Are you running from a git checkout?" >&2 printf "%s\n" "dracut: Try passing -l as an argument to $dracut_cmd" >&2 exit 1 fi if [[ $no_kernel != yes ]] && ! [[ -d $srcmods ]]; then printf "%s\n" "dracut: Cannot find module directory $srcmods" >&2 printf "%s\n" "dracut: and --no-kernel was not specified" >&2 exit 1 fi if ! [[ $print_cmdline ]]; then inst /bin/sh if ! $DRACUT_INSTALL ${initdir:+-D "$initdir"} -R "$initdir/bin/sh" &>/dev/null; then unset DRACUT_RESOLVE_LAZY export DRACUT_RESOLVE_DEPS=1 fi rm -fr -- ${initdir}/* fi dracutfunctions=$dracutbasedir/dracut-functions.sh export dracutfunctions (( ${#drivers_l[@]} )) && drivers="${drivers_l[@]}" drivers=${drivers/-/_} (( ${#add_drivers_l[@]} )) && add_drivers+=" ${add_drivers_l[@]} " add_drivers=${add_drivers/-/_} (( ${#force_drivers_l[@]} )) && force_drivers+=" ${force_drivers_l[@]} " force_drivers=${force_drivers/-/_} (( ${#omit_drivers_l[@]} )) && omit_drivers+=" ${omit_drivers_l[@]} " omit_drivers=${omit_drivers/-/_} (( ${#kernel_cmdline_l[@]} )) && kernel_cmdline+=" ${kernel_cmdline_l[@]} " omit_drivers_corrected="" for d in $omit_drivers; do [[ " $drivers $add_drivers " == *\ $d\ * ]] && continue [[ " $drivers $force_drivers " == *\ $d\ * ]] && continue omit_drivers_corrected+="$d|" done omit_drivers="${omit_drivers_corrected%|}" unset omit_drivers_corrected # prepare args for logging for ((i=0; i < ${#dracut_args[@]}; i++)); do [[ "${dracut_args[$i]}" == *\ * ]] && \ dracut_args[$i]="\"${dracut_args[$i]}\"" #" keep vim happy done dinfo "Executing: $dracut_cmd ${dracut_args[@]}" [[ $do_list = yes ]] && { for mod in $dracutbasedir/modules.d/*; do [[ -d $mod ]] || continue; [[ -e $mod/install || -e $mod/installkernel || \ -e $mod/module-setup.sh ]] || continue printf "%s\n" "${mod##*/??}" done exit 0 } # This is kinda legacy -- eventually it should go away. case $dracutmodules in ""|auto) dracutmodules="all" ;; esac abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile" if [[ $no_kernel != yes ]] && [[ -d $srcmods ]]; then if ! [[ -f $srcmods/modules.dep ]]; then if [[ -n "$(find "$srcmods" -name '*.ko*')" ]]; then dfatal "$srcmods/modules.dep is missing. Did you run depmod?" exit 1 else dwarn "$srcmods/modules.dep is missing. Did you run depmod?" fi elif ! ( command -v gzip &>/dev/null && command -v xz &>/dev/null); then read _mod < $srcmods/modules.dep _mod=${_mod%%:*} if [[ -f $srcmods/"$_mod" ]]; then # Check, if kernel modules are compressed, and if we can uncompress them case "$_mod" in *.ko.gz) kcompress=gzip;; *.ko.xz) kcompress=xz;; esac if [[ $kcompress ]]; then if ! command -v "$kcompress" &>/dev/null; then dfatal "Kernel modules are compressed with $kcompress, but $kcompress is not available." exit 1 fi fi fi fi fi if [[ ! $print_cmdline ]]; then if [[ -f $outfile && ! $force ]]; then dfatal "Will not override existing initramfs ($outfile) without --force" exit 1 fi outdir=${outfile%/*} [[ $outdir ]] || outdir="/" if [[ ! -d "$outdir" ]]; then dfatal "Can't write to $outdir: Directory $outdir does not exist or is not accessible." exit 1 elif [[ ! -w "$outdir" ]]; then dfatal "No permission to write to $outdir." exit 1 elif [[ -f "$outfile" && ! -w "$outfile" ]]; then dfatal "No permission to write $outfile." exit 1 fi if [[ $loginstall ]]; then if ! mkdir -p "$loginstall"; then dfatal "Could not create directory to log installed files to '$loginstall'." exit 1 fi loginstall=$(readlink -f "$loginstall") fi if [[ $uefi = yes ]]; then if ! command -v objcopy &>/dev/null; then dfatal "Need 'objcopy' to create a UEFI executable" exit 1 fi unset EFI_MACHINE_TYPE_NAME case $(arch) in x86_64) EFI_MACHINE_TYPE_NAME=x64;; ia32) EFI_MACHINE_TYPE_NAME=ia32;; *) dfatal "Architecture '$(arch)' not supported to create a UEFI executable" exit 1 ;; esac if ! [[ -s $uefi_stub ]]; then for uefi_stub in \ "${systemdutildir}/boot/efi/linux${EFI_MACHINE_TYPE_NAME}.efi.stub" \ "/usr/lib/gummiboot/linux${EFI_MACHINE_TYPE_NAME}.efi.stub"; do [[ -s $uefi_stub ]] || continue break done fi if ! [[ -s $uefi_stub ]]; then dfatal "Can't find a uefi stub '$uefi_stub' to create a UEFI executable" exit 1 fi if ! [[ $kernel_image ]]; then for kernel_image in "/lib/modules/$kernel/vmlinuz" "/boot/vmlinuz-$kernel"; do [[ -s "$kernel_image" ]] || continue break done fi if ! [[ -s $kernel_image ]]; then dfatal "Can't find a kernel image '$kernel_image' to create a UEFI executable" exit 1 fi fi fi if [[ $acpi_override = yes ]] && ! ( check_kernel_config CONFIG_ACPI_TABLE_UPGRADE || check_kernel_config CONFIG_ACPI_INITRD_TABLE_OVERRIDE ); then dwarn "Disabling ACPI override, because kernel does not support it. CONFIG_ACPI_INITRD_TABLE_OVERRIDE!=y or CONFIG_ACPI_TABLE_UPGRADE!=y" unset acpi_override fi if [[ $early_microcode = yes ]]; then if [[ $hostonly ]]; then if [[ $(get_cpu_vendor) == "AMD" || $(get_cpu_vendor) == "Intel" ]]; then check_kernel_config CONFIG_MICROCODE || unset early_microcode else unset early_microcode fi else ! check_kernel_config CONFIG_MICROCODE \ && unset early_microcode fi # Do not complain on non-x86 architectures as it makes no sense case $(uname -m) in x86_64|i?86) [[ $early_microcode != yes ]] \ && dwarn "Disabling early microcode, because kernel does not support it. CONFIG_MICROCODE!=y" ;; *) ;; esac fi # Need to be able to have non-root users read stuff (rpcbind etc) chmod 755 "$initdir" if [[ $hostonly ]]; then for i in /sys /proc /run /dev; do if ! findmnt --target "$i" &>/dev/null; then dwarning "Turning off host-only mode: '$i' is not mounted!" unset hostonly fi done fi declare -A host_fs_types for line in "${fstab_lines[@]}"; do set -- $line dev="$1" #dev mp fs fsopts case "$dev" in UUID=*) dev=$(blkid -l -t UUID=${dev#UUID=} -o device) ;; LABEL=*) dev=$(blkid -l -t LABEL=${dev#LABEL=} -o device) ;; PARTUUID=*) dev=$(blkid -l -t PARTUUID=${dev#PARTUUID=} -o device) ;; PARTLABEL=*) dev=$(blkid -l -t PARTLABEL=${dev#PARTLABEL=} -o device) ;; esac [ -z "$dev" ] && dwarn "Bad fstab entry $@" && continue if [[ "$3" == btrfs ]]; then for i in $(btrfs_devs "$2"); do push_host_devs "$i" done fi push_host_devs "$dev" host_fs_types["$dev"]="$3" done for f in $add_fstab; do [[ -e $f ]] || continue while read dev rest || [ -n "$dev" ]; do push_host_devs "$dev" done < "$f" done for dev in $add_device; do push_host_devs "$dev" done if (( ${#add_device_l[@]} )); then add_device+=" ${add_device_l[@]} " push_host_devs "${add_device_l[@]}" fi if [[ $hostonly ]] && [[ "$hostonly_default_device" != "no" ]]; then # in hostonly mode, determine all devices, which have to be accessed # and examine them for filesystem types for mp in \ "/" \ "/etc" \ "/bin" \ "/sbin" \ "/lib" \ "/lib64" \ "/usr" \ "/usr/bin" \ "/usr/sbin" \ "/usr/lib" \ "/usr/lib64" \ "/boot" \ "/boot/efi" \ "/boot/zipl" \ ; do mp=$(readlink -f "$mp") mountpoint "$mp" >/dev/null 2>&1 || continue _dev=$(find_block_device "$mp") _bdev=$(readlink -f "/dev/block/$_dev") [[ -b $_bdev ]] && _dev=$_bdev [[ "$mp" == "/" ]] && root_devs+=("$_dev") push_host_devs "$_dev" if [[ $(find_mp_fstype "$mp") == btrfs ]]; then for i in $(btrfs_devs "$mp"); do [[ "$mp" == "/" ]] && root_devs+=("$i") push_host_devs "$i" done fi done if [[ -f /proc/swaps ]] && [[ -f /etc/fstab ]]; then while read dev type rest || [ -n "$dev" ]; do [[ -b $dev ]] || continue [[ "$type" == "partition" ]] || continue while read _d _m _t _o _r || [ -n "$_d" ]; do [[ "$_d" == \#* ]] && continue [[ $_d ]] || continue [[ $_t != "swap" ]] && continue [[ $_m != "swap" ]] && [[ $_m != "none" ]] && continue [[ "$_o" == *noauto* ]] && continue _d=$(expand_persistent_dev "$_d") [[ "$_d" -ef "$dev" ]] || continue if [[ -f /etc/crypttab ]]; then while read _mapper _a _p _o || [ -n "$_mapper" ]; do [[ $_mapper = \#* ]] && continue [[ "$_d" -ef /dev/mapper/"$_mapper" ]] || continue [[ "$_o" ]] || _o="$_p" # skip entries with password files [[ "$_p" == /* ]] && [[ -f $_p ]] && continue 2 # skip mkswap swap [[ $_o == *swap* ]] && continue 2 done < /etc/crypttab fi _dev="$(readlink -f "$dev")" push_host_devs "$_dev" swap_devs+=("$_dev") break done < /etc/fstab done < /proc/swaps fi # collect all "x-initrd.mount" entries from /etc/fstab if [[ -f /etc/fstab ]]; then while read _d _m _t _o _r || [ -n "$_d" ]; do [[ "$_d" == \#* ]] && continue [[ $_d ]] || continue [[ "$_o" != *x-initrd.mount* ]] && continue _dev=$(expand_persistent_dev "$_d") _dev="$(readlink -f "$_dev")" [[ -b $_dev ]] || continue push_host_devs "$_dev" if [[ "$_t" == btrfs ]]; then for i in $(btrfs_devs "$_m"); do push_host_devs "$i" done fi done < /etc/fstab fi fi unset m unset rest _get_fs_type() { [[ $1 ]] || return if [[ -b /dev/block/$1 ]]; then ID_FS_TYPE=$(get_fs_env "/dev/block/$1") && host_fs_types["$(readlink -f "/dev/block/$1")"]="$ID_FS_TYPE" return 1 fi if [[ -b $1 ]]; then ID_FS_TYPE=$(get_fs_env "$1") && host_fs_types["$(readlink -f "$1")"]="$ID_FS_TYPE" return 1 fi if fstype=$(find_dev_fstype "$1"); then host_fs_types["$1"]="$fstype" return 1 fi return 1 } for dev in "${host_devs[@]}"; do _get_fs_type "$dev" check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")" done for dev in "${!host_fs_types[@]}"; do [[ ${host_fs_types[$dev]} = "reiserfs" ]] || [[ ${host_fs_types[$dev]} = "xfs" ]] || continue rootopts=$(find_dev_fsopts "$dev") if [[ ${host_fs_types[$dev]} = "reiserfs" ]]; then journaldev=$(fs_get_option $rootopts "jdev") elif [[ ${host_fs_types[$dev]} = "xfs" ]]; then journaldev=$(fs_get_option $rootopts "logdev") fi if [[ $journaldev ]]; then dev="$(readlink -f "$dev")" push_host_devs "$dev" _get_fs_type "$dev" check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")" fi done [[ -d $udevdir ]] \ || udevdir="$(pkg-config udev --variable=udevdir 2>/dev/null)" if ! [[ -d "$udevdir" ]]; then [[ -e /lib/udev/collect ]] && udevdir=/lib/udev [[ -e /usr/lib/udev/collect ]] && udevdir=/usr/lib/udev fi [[ -d $udevconfdir ]] \ || udevconfdir="$(pkg-config udev --variable=udevconfdir 2>/dev/null)" if ! [[ -d "$udevconfdir" ]]; then [[ -d /etc/udev ]] && udevconfdir=/etc/udev fi [[ -d $systemdutildir ]] \ || systemdutildir=$(pkg-config systemd --variable=systemdutildir 2>/dev/null) if ! [[ -d "$systemdutildir" ]]; then [[ -e /lib/systemd/systemd-udevd ]] && systemdutildir=/lib/systemd [[ -e /usr/lib/systemd/systemd-udevd ]] && systemdutildir=/usr/lib/systemd fi [[ -d $systemdsystemunitdir ]] \ || systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null) [[ -d "$systemdsystemunitdir" ]] || systemdsystemunitdir=${systemdutildir}/system [[ -d $systemdsystemconfdir ]] \ || systemdsystemconfdir=$(pkg-config systemd --variable=systemdsystemconfdir 2>/dev/null) [[ -d "$systemdsystemconfdir" ]] || systemdsystemconfdir=/etc/systemd/system [[ -d $tmpfilesdir ]] \ || tmpfilesdir=$(pkg-config systemd --variable=tmpfilesdir 2>/dev/null) if ! [[ -d "$tmpfilesdir" ]]; then [[ -d /lib/tmpfiles.d ]] && tmpfilesdir=/lib/tmpfiles.d [[ -d /usr/lib/tmpfiles.d ]] && tmpfilesdir=/usr/lib/tmpfiles.d fi export initdir dracutbasedir \ dracutmodules force_add_dracutmodules add_dracutmodules omit_dracutmodules \ mods_to_load \ fw_dir drivers_dir debug no_kernel kernel_only \ omit_drivers mdadmconf lvmconf root_devs \ use_fstab fstab_lines libdirs fscks nofscks ro_mnt \ stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \ debug host_fs_types host_devs swap_devs sshkey add_fstab \ DRACUT_VERSION udevdir prefix filesystems drivers \ systemdutildir systemdsystemunitdir systemdsystemconfdir \ hostonly_cmdline loginstall \ tmpfilesdir mods_to_load="" # check all our modules to see if they should be sourced. # This builds a list of modules that we will install next. for_each_module_dir check_module for_each_module_dir check_mount dracut_module_included "fips" && export DRACUT_FIPS_MODE=1 do_print_cmdline() { local -A _mods_to_print for i in $modules_loaded $mods_to_load; do _mods_to_print[$i]=1 done # source our modules. for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]} [[ ${_mods_to_print[$_d_mod]} ]] || continue module_cmdline "$_d_mod" "$moddir" done unset moddir } if [[ $print_cmdline ]]; then do_print_cmdline printf "\n" exit 0 fi # Create some directory structure first [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}" [[ -h /lib ]] || mkdir -m 0755 -p "${initdir}${prefix}/lib" [[ $prefix ]] && ln -sfn "${prefix#/}/lib" "$initdir/lib" if [[ $prefix ]]; then for d in bin etc lib sbin tmp usr var $libdirs; do [[ "$d" == */* ]] && continue ln -sfn "${prefix#/}/${d#/}" "$initdir/$d" done fi if [[ $kernel_only != yes ]]; then for d in usr/bin usr/sbin bin etc lib sbin tmp usr var var/tmp $libdirs; do [[ -e "${initdir}${prefix}/$d" ]] && continue if [ -L "/$d" ]; then inst_symlink "/$d" "${prefix}/$d" else mkdir -m 0755 -p "${initdir}${prefix}/$d" fi done for d in dev proc sys sysroot root run; do if [ -L "/$d" ]; then inst_symlink "/$d" else mkdir -m 0755 -p "$initdir/$d" fi done ln -sfn ../run "$initdir/var/run" ln -sfn ../run/lock "$initdir/var/lock" else for d in lib "$libdir"; do [[ -e "${initdir}${prefix}/$d" ]] && continue if [ -h "/$d" ]; then inst "/$d" "${prefix}/$d" else mkdir -m 0755 -p "${initdir}${prefix}/$d" fi done fi if [[ $kernel_only != yes ]]; then mkdir -p "${initdir}/etc/cmdline.d" for _d in $hookdirs; do mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d done if [[ "$EUID" = "0" ]]; then [ -c ${initdir}/dev/null ] || mknod ${initdir}/dev/null c 1 3 [ -c ${initdir}/dev/kmsg ] || mknod ${initdir}/dev/kmsg c 1 11 [ -c ${initdir}/dev/console ] || mknod ${initdir}/dev/console c 5 1 [ -c ${initdir}/dev/random ] || mknod ${initdir}/dev/random c 1 8 [ -c ${initdir}/dev/urandom ] || mknod ${initdir}/dev/urandom c 1 9 fi fi _isize=0 #initramfs size modules_loaded=" " # source our modules. for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]} [[ "$mods_to_load" == *\ $_d_mod\ * ]] || continue if [[ $show_modules = yes ]]; then printf "%s\n" "$_d_mod" else dinfo "*** Including module: $_d_mod ***" fi if [[ $kernel_only == yes ]]; then module_installkernel "$_d_mod" "$moddir" || { dfatal "installkernel failed in module $_d_mod" exit 1 } else module_install "$_d_mod" "$moddir" if [[ $no_kernel != yes ]]; then module_installkernel "$_d_mod" "$moddir" || { dfatal "installkernel failed in module $_d_mod" exit 1 } fi fi mods_to_load=${mods_to_load// $_d_mod /} modules_loaded+="$_d_mod " #print the module install size if [ -n "$printsize" ]; then _isize_new=$(du -sk ${initdir}|cut -f1) _isize_delta=$((_isize_new - _isize)) printf "%s\n" "$_d_mod install size: ${_isize_delta}k" _isize=$_isize_new fi done unset moddir for i in $modules_loaded; do mkdir -p $initdir/lib/dracut printf "%s\n" "$i" >> $initdir/lib/dracut/modules.txt done dinfo "*** Including modules done ***" ## final stuff that has to happen if [[ $no_kernel != yes ]]; then if [[ $hostonly ]]; then echo "$(get_loaded_kernel_modules)" > $initdir/lib/dracut/loaded-kernel-modules.txt fi if [[ $drivers ]]; then hostonly='' instmods $drivers fi if [[ -n "${add_drivers// }" ]]; then hostonly='' instmods -c $add_drivers fi if [[ $force_drivers ]]; then hostonly='' instmods -c $force_drivers rm -f $initdir/etc/cmdline.d/20-force_driver.conf for mod in $force_drivers; do echo "rd.driver.pre=$mod" >>$initdir/etc/cmdline.d/20-force_drivers.conf done fi if [[ $filesystems ]]; then hostonly='' instmods -c $filesystems fi dinfo "*** Installing kernel module dependencies ***" dracut_kernel_post dinfo "*** Installing kernel module dependencies done ***" if [[ $noimageifnotneeded == yes ]] && [[ $hostonly ]]; then if [[ ! -f "$initdir/lib/dracut/need-initqueue" ]] && \ [[ -f ${initdir}/lib/modules/$kernel/modules.dep && ! -s ${initdir}/lib/modules/$kernel/modules.dep ]]; then for i in ${initdir}/etc/cmdline.d/*.conf; do # We need no initramfs image and do not generate one. [[ $i == "${initdir}/etc/cmdline.d/*.conf" ]] && exit 0 done fi fi fi if [[ $kernel_only != yes ]]; then (( ${#install_items[@]} > 0 )) && inst_multiple ${install_items[@]} (( ${#install_optional_items[@]} > 0 )) && inst_multiple -o ${install_optional_items[@]} [[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf" for line in "${fstab_lines[@]}"; do line=($line) if [ -z "${line[1]}" ]; then # Determine device and mount options from current system mountpoint -q "${line[0]}" || derror "${line[0]} is not a mount point!" line=($(findmnt --raw -n --target "${line[0]}" --output=source,target,fstype,options)) dinfo "Line for ${line[1]}: ${line[@]}" else # Use default options [ -z "${line[3]}" ] && line[3]="defaults" fi # Default options for freq and passno [ -z "${line[4]}" ] && line[4]="0" [ -z "${line[5]}" ] && line[5]="2" strstr "${line[2]}" "nfs" && line[5]="0" echo "${line[@]}" >> "${initdir}/etc/fstab" done for f in $add_fstab; do cat "$f" >> "${initdir}/etc/fstab" done if [[ $systemdutildir ]]; then if [ -d ${initdir}/$systemdutildir ]; then mkdir -p ${initdir}/etc/conf.d { printf "%s\n" "systemdutildir=\"$systemdutildir\"" printf "%s\n" "systemdsystemunitdir=\"$systemdsystemunitdir\"" printf "%s\n" "systemdsystemconfdir=\"$systemdsystemconfdir\"" } > ${initdir}/etc/conf.d/systemd.conf fi fi if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then dinfo "*** Resolving executable dependencies ***" find "$initdir" -type f -perm /0111 -not -path '*.ko' -print0 \ | xargs -r -0 $DRACUT_INSTALL ${initdir:+-D "$initdir"} -R ${DRACUT_FIPS_MODE:+-f} -- dinfo "*** Resolving executable dependencies done***" fi # Now we are done with lazy resolving, always install dependencies unset DRACUT_RESOLVE_LAZY export DRACUT_RESOLVE_DEPS=1 fi for ((i=0; i < ${#include_src[@]}; i++)); do src="${include_src[$i]}" target="${include_target[$i]}" if [[ $src && $target ]]; then if [[ -f $src ]]; then inst $src $target else ddebug "Including directory: $src" destdir="${initdir}/${target}" mkdir -p "$destdir" # check for preexisting symlinks, so we can cope with the # symlinks to $prefix # Objectname is a file or a directory reset_dotglob="$(shopt -p dotglob)" shopt -q -s dotglob for objectname in "$src"/*; do [[ -e $objectname || -L $objectname ]] || continue if [[ -d $objectname ]] && [[ ! -L $objectname ]]; then # objectname is a directory, let's compute the final directory name object_destdir=${destdir}/${objectname#$src/} if ! [[ -e "$object_destdir" ]]; then mkdir -m 0755 -p "$object_destdir" chmod --reference="$objectname" "$object_destdir" fi $DRACUT_CP -t "$object_destdir" "$objectname"/. else $DRACUT_CP -t "$destdir" "$objectname" fi done eval "$reset_dotglob" fi fi done if [[ $kernel_only != yes ]]; then # make sure that library links are correct and up to date build_ld_cache fi if [[ $do_hardlink = yes ]] && command -v hardlink >/dev/null; then dinfo "*** Hardlinking files ***" hardlink "$initdir" 2>&1 dinfo "*** Hardlinking files done ***" fi # strip binaries if [[ $do_strip = yes ]] ; then # Prefer strip from elfutils for package size declare strip_cmd=$(command -v eu-strip) test -z "$strip_cmd" && strip_cmd="strip" for p in $strip_cmd xargs find; do if ! type -P $p >/dev/null; then dinfo "Could not find '$p'. Not stripping the initramfs." do_strip=no fi done fi # cleanup empty ldconfig_paths directories for d in $(ldconfig_paths); do rmdir -p --ignore-fail-on-non-empty "$initdir/$d" >/dev/null 2>&1 done if [[ $early_microcode = yes ]]; then dinfo "*** Generating early-microcode cpio image ***" ucode_dir=(amd-ucode intel-ucode) ucode_dest=(AuthenticAMD.bin GenuineIntel.bin) _dest_dir="$early_cpio_dir/d/kernel/x86/microcode" _dest_idx="0 1" mkdir -p $_dest_dir if [[ $hostonly ]]; then [[ $(get_cpu_vendor) == "AMD" ]] && _dest_idx="0" [[ $(get_cpu_vendor) == "Intel" ]] && _dest_idx="1" fi for idx in $_dest_idx; do _fw=${ucode_dir[$idx]} for _fwdir in $fw_dir; do if [[ -d $_fwdir && -d $_fwdir/$_fw ]]; then _src="*" dinfo "*** Constructing ${ucode_dest[$idx]} ***" if [[ $hostonly ]]; then _src=$(get_ucode_file) [[ $_src ]] || break [[ -r $_fwdir/$_fw/$_src ]] || break fi for i in $_fwdir/$_fw/$_src; do [ -e "$i" ] && break break 2 done for i in $_fwdir/$_fw/$_src; do [[ -e "$i" ]] || continue # skip gpg files str_ends "$i" ".asc" && continue cat "$i" >> $_dest_dir/${ucode_dest[$idx]} done create_early_cpio="yes" fi done done fi if [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]]; then dinfo "*** Packaging ACPI tables to override BIOS provided ones ***" _dest_dir="$early_cpio_dir/d/kernel/firmware/acpi" mkdir -p $_dest_dir for table in $acpi_table_dir/*.aml; do dinfo " Adding ACPI table: $table" $DRACUT_CP $table $_dest_dir create_early_cpio="yes" done fi dinfo "*** Store current command line parameters ***" if ! ( echo $PARMS_TO_STORE > $initdir/lib/dracut/build-parameter.txt ); then dfatal "Could not store the current command line parameters" exit 1 fi if [[ $hostonly_cmdline == "yes" ]] ; then unset _stored_cmdline if [ -d $initdir/etc/cmdline.d ];then dinfo "Stored kernel commandline:" for conf in $initdir/etc/cmdline.d/*.conf ; do [ -e "$conf" ] || continue dinfo "$(< $conf)" _stored_cmdline=1 done fi if ! [[ $_stored_cmdline ]]; then dinfo "No dracut internal kernel commandline stored in the initramfs" fi fi if [[ $kernel_only != yes ]]; then # libpthread workaround: pthread_cancel wants to dlopen libgcc_s.so for _dir in $libdirs; do for _f in "$dracutsysrootdir$_dir/libpthread.so"*; do [[ -e "$_f" ]] || continue inst_libdir_file "libgcc_s.so*" break 2 done done # FIPS workaround for Fedora/RHEL: libcrypto needs libssl when FIPS is enabled if [[ $DRACUT_FIPS_MODE ]]; then for _dir in $libdirs; do for _f in "$dracutsysrootdir$_dir/libcrypto.so"*; do [[ -e "$_f" ]] || continue inst_libdir_file -o "libssl.so*" break 2 done done fi fi if dracut_module_included "squash"; then readonly squash_dir="$initdir/squash/root" readonly squash_img="$initdir/squash-root.img" mkdir -p "$squash_dir" dinfo "*** Install squash loader ***" DRACUT_SQUASH_POST_INST=1 module_install "squash" fi if [[ $do_strip = yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then dinfo "*** Stripping files ***" find "$initdir" -type f \ -executable -not -path '*/lib/modules/*.ko' -print0 \ | xargs -r -0 $strip_cmd -g -p 2>/dev/null # strip kernel modules, but do not touch signed modules find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \ | while read -r -d $'\0' f || [ -n "$f" ]; do SIG=$(tail -c 28 "$f" | tr -d '\000') [[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; } done | xargs -r -0 $strip_cmd -g -p dinfo "*** Stripping files done ***" fi if dracut_module_included "squash"; then dinfo "*** Squashing the files inside the initramfs ***" declare squash_compress_arg # shellcheck disable=SC2086 if [[ $compress ]]; then if ! mksquashfs /dev/null "$DRACUT_TMPDIR"/.squash-test.img -no-progress -comp $compress &>/dev/null; then dwarn "mksquashfs doesn't support compressor '$compress', failing back to default compressor." else squash_compress_arg="$compress" fi fi # shellcheck disable=SC2086 if ! mksquashfs "$squash_dir" "$squash_img" \ -no-xattrs -no-exports -noappend -no-recovery -always-use-fragments \ -no-progress ${squash_compress_arg:+-comp $squash_compress_arg} 1> /dev/null; then dfatal "dracut: Failed making squash image" exit 1 fi rm -rf "$squash_dir" dinfo "*** Squashing the files inside the initramfs done ***" # Skip initramfs compress compress="cat" fi dinfo "*** Creating image file '$outfile' ***" if [[ $uefi = yes ]]; then readonly uefi_outdir="$DRACUT_TMPDIR/uefi" mkdir "$uefi_outdir" fi if [[ $DRACUT_REPRODUCIBLE ]]; then find "$initdir" -newer "$dracutbasedir/dracut-functions.sh" -print0 \ | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh" if [[ "$(cpio --help)" == *--reproducible* ]]; then CPIO_REPRODUCIBLE=1 else dinfo "cpio does not support '--reproducible'. Resulting image will not be reproducible." fi fi [[ "$EUID" != 0 ]] && cpio_owner_root="-R 0:0" if [[ $create_early_cpio = yes ]]; then echo 1 > "$early_cpio_dir/d/early_cpio" if [[ $DRACUT_REPRODUCIBLE ]]; then find "$early_cpio_dir/d" -newer "$dracutbasedir/dracut-functions.sh" -print0 \ | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh" fi # The microcode blob is _before_ the initramfs blob, not after if ! ( umask 077; cd "$early_cpio_dir/d" find . -print0 | sort -z \ | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null $cpio_owner_root -H newc -o --quiet > "${DRACUT_TMPDIR}/initramfs.img" ); then dfatal "dracut: creation of $outfile failed" exit 1 fi fi if ! [[ $compress ]]; then # check all known compressors, if none specified for i in pigz gzip lz4 lzop zstd lzma xz lbzip2 bzip2 cat; do command -v "$i" &>/dev/null || continue compress="$i" break done if [[ $compress = cat ]]; then printf "%s\n" "dracut: no compression tool available. Initramfs image is going to be big." >&2 fi fi # choose the right arguments for the compressor case $compress in bzip2|lbzip2) if [[ "$compress" = lbzip2 ]] || command -v lbzip2 &>/dev/null; then compress="lbzip2 -9" else compress="bzip2 -9" fi ;; lzma) compress="lzma -9 -T0" ;; xz) compress="xz --check=crc32 --lzma2=dict=1MiB -T0" ;; gzip|pigz) if [[ "$compress" = pigz ]] || command -v pigz &>/dev/null; then compress="pigz -9 -n -T -R" elif command -v gzip &>/dev/null && gzip --help 2>&1 | grep -q rsyncable; then compress="gzip -n -9 --rsyncable" else compress="gzip -n -9" fi ;; lzo|lzop) compress="lzop -9" ;; lz4) compress="lz4 -l -9" ;; zstd) compress="zstd -15 -q -T0" ;; esac if ! ( umask 077; cd "$initdir" find . -print0 | sort -z \ | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null $cpio_owner_root -H newc -o --quiet \ | $compress >> "${DRACUT_TMPDIR}/initramfs.img" ); then dfatal "dracut: creation of $outfile failed" exit 1 fi if (( maxloglvl >= 5 )) && (( verbosity_mod_l >= 0 )); then if [[ $allowlocal ]]; then "$dracutbasedir/lsinitrd.sh" "${DRACUT_TMPDIR}/initramfs.img"| ddebug else lsinitrd "${DRACUT_TMPDIR}/initramfs.img"| ddebug fi fi umask 077 if [[ $uefi = yes ]]; then if [[ $kernel_cmdline ]]; then echo -n "$kernel_cmdline" > "$uefi_outdir/cmdline.txt" elif [[ $hostonly_cmdline = yes ]] && [ -d $initdir/etc/cmdline.d ];then for conf in $initdir/etc/cmdline.d/*.conf ; do [ -e "$conf" ] || continue printf "%s " "$(< $conf)" >> "$uefi_outdir/cmdline.txt" done else do_print_cmdline > "$uefi_outdir/cmdline.txt" fi echo -ne "\x00" >> "$uefi_outdir/cmdline.txt" dinfo "Using UEFI kernel cmdline:" dinfo $(< "$uefi_outdir/cmdline.txt") [[ -s /usr/lib/os-release ]] && uefi_osrelease="/usr/lib/os-release" [[ -s /etc/os-release ]] && uefi_osrelease="/etc/os-release" if objcopy \ ${uefi_osrelease:+--add-section .osrel=$uefi_osrelease --change-section-vma .osrel=0x20000} \ --add-section .cmdline="${uefi_outdir}/cmdline.txt" --change-section-vma .cmdline=0x30000 \ --add-section .linux="$kernel_image" --change-section-vma .linux=0x40000 \ --add-section .initrd="${DRACUT_TMPDIR}/initramfs.img" --change-section-vma .initrd=0x3000000 \ "$uefi_stub" "${uefi_outdir}/linux.efi" \ && cp --reflink=auto "${uefi_outdir}/linux.efi" "$outfile"; then dinfo "*** Creating UEFI image file '$outfile' done ***" else rm -f -- "$outfile" dfatal "*** Creating UEFI image file '$outfile' failed ***" exit 1 fi else if cp --reflink=auto "${DRACUT_TMPDIR}/initramfs.img" "$outfile"; then dinfo "*** Creating initramfs image file '$outfile' done ***" else rm -f -- "$outfile" dfatal "dracut: creation of $outfile failed" exit 1 fi fi command -v restorecon &>/dev/null && restorecon -- "$outfile" # We sync/fsfreeze only if we're operating on a live booted system. # It's possible for e.g. `kernel` to be installed as an RPM BuildRequires or equivalent, # and there's no reason to sync, and *definitely* no reason to fsfreeze. # Another case where this happens is rpm-ostree, which performs its own sync/fsfreeze # globally. See e.g. https://github.com/ostreedev/ostree/commit/8642ef5ab3fec3ac8eb8f193054852f83a8bc4d0 if test -d /run/systemd/system; then if ! sync "$outfile" 2> /dev/null; then dinfo "dracut: sync operation on newly created initramfs $outfile failed" exit 1 fi # use fsfreeze only if we're not writing to / if [[ "$(stat -c %m -- "$outfile")" != "/" && "$(stat -f -c %T -- "$outfile")" != "msdos" ]]; then if ! $(fsfreeze -f $(dirname "$outfile") 2>/dev/null && fsfreeze -u $(dirname "$outfile") 2>/dev/null); then dinfo "dracut: warning: could not fsfreeze $(dirname "$outfile")" fi fi fi exit 0 dracut-logger.sh000075500000031770152525045230007655 0ustar00#!/bin/bash # # logging faciality module for dracut both at build- and boot-time # # Copyright 2010 Amadeusz Żołnowski # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . __DRACUT_LOGGER__=1 ## @brief Logging facility module for dracut both at build- and boot-time. # # @section intro Introduction # # The logger takes a bit from Log4j philosophy. There are defined 6 logging # levels: # - TRACE (6) # The TRACE Level designates finer-grained informational events than the # DEBUG. # - DEBUG (5) # The DEBUG Level designates fine-grained informational events that are most # useful to debug an application. # - INFO (4) # The INFO level designates informational messages that highlight the # progress of the application at coarse-grained level. # - WARN (3) # The WARN level designates potentially harmful situations. # - ERROR (2) # The ERROR level designates error events that might still allow the # application to continue running. # - FATAL (1) # The FATAL level designates very severe error events that will presumably # lead the application to abort. # Descriptions are borrowed from Log4j documentation: # http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html # # @section usage Usage # # First of all you have to start with dlog_init() function which initializes # required variables. Don't call any other logging function before that one! # If you're ready with this, you can use following functions which corresponds # clearly to levels listed in @ref intro Introduction. Here they are: # - dtrace() # - ddebug() # - dinfo() # - dwarn() # - derror() # - dfatal() # They take all arguments given as a single message to be logged. See dlog() # function for details how it works. Note that you shouldn't use dlog() by # yourself. It's wrapped with above functions. # # @see dlog_init() dlog() # # @section conf Configuration # # Logging is controlled by following global variables: # - @var stdloglvl - logging level to standard error (console output) # - @var sysloglvl - logging level to syslog (by logger command) # - @var fileloglvl - logging level to file # - @var kmsgloglvl - logging level to /dev/kmsg (only for boot-time) # - @var logfile - log file which is used when @var fileloglvl is higher # than 0 # and two global variables: @var maxloglvl and @var syslogfacility which must # not be overwritten. Both are set by dlog_init(). @var maxloglvl holds # maximum logging level of those three and indicates that dlog_init() was run. # @var syslogfacility is set either to 'user' (when building initramfs) or # 'daemon' (when booting). # # Logging level set by the variable means that messages from this logging level # and above (FATAL is the highest) will be shown. Logging levels may be set # independently for each destination (stderr, syslog, file, kmsg). # # @see dlog_init() ## @brief Initializes dracut Logger. # # @retval 1 if something has gone wrong # @retval 0 on success. # # @note This function need to be called before any other from this file. # # If any of the variables is not set, this function set it to default: # - @var stdloglvl = 4 (info) # - @var sysloglvl = 0 (no logging) # - @var fileloglvl is set to 4 when @var logfile is set too, otherwise it's # - @var kmsgloglvl = 0 (no logging) # set to 0 # # @warning Function sets global variables @var maxloglvl and @syslogfacility. # See file doc comment for details. dlog_init() { local __oldumask local ret=0; local errmsg [ -z "$stdloglvl" ] && stdloglvl=4 [ -z "$sysloglvl" ] && sysloglvl=0 [ -z "$kmsgloglvl" ] && kmsgloglvl=0 # Skip initialization if it's already done. [ -n "$maxloglvl" ] && return 0 if [ -z "$fileloglvl" ]; then [ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0 elif (( $fileloglvl > 0 )); then if [[ $logfile ]]; then __oldumask=$(umask) umask 0377 ! [ -e "$logfile" ] && >"$logfile" umask $__oldumask if [ -w "$logfile" -a -f "$logfile" ]; then # Mark new run in the log file echo >>"$logfile" if command -v date >/dev/null; then echo "=== $(date) ===" >>"$logfile" else echo "===============================================" >>"$logfile" fi echo >>"$logfile" else # We cannot log to file, so turn this facility off. fileloglvl=0 ret=1 errmsg="'$logfile' is not a writable file" fi fi fi if (( $UID != 0 )); then kmsgloglvl=0 sysloglvl=0 fi if (( $sysloglvl > 0 )); then if [[ -d /run/systemd/journal ]] \ && type -P systemd-cat &>/dev/null \ && systemctl --quiet is-active systemd-journald.socket &>/dev/null \ && { echo "dracut-$DRACUT_VERSION" | systemd-cat -t 'dracut' &>/dev/null; } ; then readonly _systemdcatfile="$DRACUT_TMPDIR/systemd-cat" mkfifo "$_systemdcatfile" readonly _dlogfd=15 systemd-cat -t 'dracut' --level-prefix=true <"$_systemdcatfile" & exec 15>"$_systemdcatfile" elif ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null; then # We cannot log to syslog, so turn this facility off. kmsgloglvl=$sysloglvl sysloglvl=0 ret=1 errmsg="No '/dev/log' or 'logger' included for syslog logging" fi fi if (($sysloglvl > 0)) || (($kmsgloglvl > 0 )); then if [ -n "$dracutbasedir" ]; then readonly syslogfacility=user else readonly syslogfacility=daemon fi export syslogfacility fi local lvl; local maxloglvl_l=0 for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do (( $lvl > $maxloglvl_l )) && maxloglvl_l=$lvl done readonly maxloglvl=$maxloglvl_l export maxloglvl if (($stdloglvl < 6)) && (($kmsgloglvl < 6)) && (($fileloglvl < 6)) && (($sysloglvl < 6)); then unset dtrace dtrace() { :; }; fi if (($stdloglvl < 5)) && (($kmsgloglvl < 5)) && (($fileloglvl < 5)) && (($sysloglvl < 5)); then unset ddebug ddebug() { :; }; fi if (($stdloglvl < 4)) && (($kmsgloglvl < 4)) && (($fileloglvl < 4)) && (($sysloglvl < 4)); then unset dinfo dinfo() { :; }; fi if (($stdloglvl < 3)) && (($kmsgloglvl < 3)) && (($fileloglvl < 3)) && (($sysloglvl < 3)); then unset dwarn dwarn() { :; }; unset dwarning dwarning() { :; }; fi if (($stdloglvl < 2)) && (($kmsgloglvl < 2)) && (($fileloglvl < 2)) && (($sysloglvl < 2)); then unset derror derror() { :; }; fi if (($stdloglvl < 1)) && (($kmsgloglvl < 1)) && (($fileloglvl < 1)) && (($sysloglvl < 1)); then unset dfatal dfatal() { :; }; fi [ -n "$errmsg" ] && derror "$errmsg" return $ret } ## @brief Converts numeric logging level to the first letter of level name. # # @param lvl Numeric logging level in range from 1 to 6. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes first letter of level name. _lvl2char() { case "$1" in 1) echo F;; 2) echo E;; 3) echo W;; 4) echo I;; 5) echo D;; 6) echo T;; *) return 1;; esac } ## @brief Converts numeric level to logger priority defined by POSIX.2. # # @param lvl Numeric logging level in range from 1 to 6. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes logger priority. _lvl2syspri() { printf $syslogfacility. case "$1" in 1) echo crit;; 2) echo error;; 3) echo warning;; 4) echo info;; 5) echo debug;; 6) echo debug;; *) return 1;; esac } ## @brief Converts dracut-logger numeric level to syslog log level # # @param lvl Numeric logging level in range from 1 to 6. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes kernel console numeric log level # # Conversion is done as follows: # # # none -> LOG_EMERG (0) # none -> LOG_ALERT (1) # FATAL(1) -> LOG_CRIT (2) # ERROR(2) -> LOG_ERR (3) # WARN(3) -> LOG_WARNING (4) # none -> LOG_NOTICE (5) # INFO(4) -> LOG_INFO (6) # DEBUG(5) -> LOG_DEBUG (7) # TRACE(6) / # # # @see /usr/include/sys/syslog.h _dlvl2syslvl() { local lvl case "$1" in 1) lvl=2;; 2) lvl=3;; 3) lvl=4;; 4) lvl=6;; 5) lvl=7;; 6) lvl=7;; *) return 1;; esac [ "$syslogfacility" = user ] && echo $((8+$lvl)) || echo $((24+$lvl)) } ## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg # given message with given level (priority). # # @param lvl Numeric logging level. # @param msg Message. # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use # dtrace(), ddebug(), or others instead which wrap this one. # # This is core logging function which logs given message to standard error, file # and/or syslog (with POSIX shell command logger) and/or to /dev/kmsg. # The format is following: # # X: some message # # where @c X is the first letter of logging level. See module description for # details on that. # # Message to syslog is sent with tag @c dracut. Priorities are mapped as # following: # - @c FATAL to @c crit # - @c ERROR to @c error # - @c WARN to @c warning # - @c INFO to @c info # - @c DEBUG and @c TRACE both to @c debug _do_dlog() { local lvl="$1"; shift local lvlc=$(_lvl2char "$lvl") || return 0 local msg="$*" local lmsg="$lvlc: $*" (( $lvl <= $stdloglvl )) && printf -- 'dracut: %s\n' "$msg" >&2 if (( $lvl <= $sysloglvl )); then if [[ "$_dlogfd" ]]; then printf -- "<%s>%s\n" "$(($(_dlvl2syslvl $lvl) & 7))" "$msg" >&$_dlogfd else logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) -- "$msg" fi fi if (( $lvl <= $fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then echo "$lmsg" >>"$logfile" fi (( $lvl <= $kmsgloglvl )) && \ echo "<$(_dlvl2syslvl $lvl)>dracut[$$] $msg" >/dev/kmsg } ## @brief Internal helper function for _do_dlog() # # @param lvl Numeric logging level. # @param msg Message. # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use # dtrace(), ddebug(), or others instead which wrap this one. # # This function calls _do_dlog() either with parameter msg, or if # none is given, it will read standard input and will use every line as # a message. # # This enables: # dwarn "This is a warning" # echo "This is a warning" | dwarn dlog() { [ -z "$maxloglvl" ] && return 0 (( $1 <= $maxloglvl )) || return 0 if (( $# > 1 )); then _do_dlog "$@" else while read line || [ -n "$line" ]; do _do_dlog "$1" "$line" done fi } ## @brief Logs message at TRACE level (6) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. dtrace() { set +x dlog 6 "$@" [ -n "$debug" ] && set -x || : } ## @brief Logs message at DEBUG level (5) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. ddebug() { set +x dlog 5 "$@" [ -n "$debug" ] && set -x || : } ## @brief Logs message at INFO level (4) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. dinfo() { set +x dlog 4 "$@" [ -n "$debug" ] && set -x || : } ## @brief Logs message at WARN level (3) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. dwarn() { set +x dlog 3 "$@" [ -n "$debug" ] && set -x || : } ## @brief It's an alias to dwarn() function. # # @param msg Message. # @retval 0 It's always returned, even if logging failed. dwarning() { set +x dwarn "$@" [ -n "$debug" ] && set -x || : } ## @brief Logs message at ERROR level (2) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. derror() { set +x dlog 2 "$@" [ -n "$debug" ] && set -x || : } ## @brief Logs message at FATAL level (1) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. dfatal() { set +x dlog 1 "$@" [ -n "$debug" ] && set -x || : } dracut-install000075500000224160152525045230007430 0ustar00ELF>P>@0 @8 @! @@@ !!p x   ! !    DD!!Std Ptd444ddQtdRtd!!P P /lib64/ld-linux-x86-64.so.2GNUGNUGNU|),(U.j  jlbAPv2rc8D7x ?K!%g#>>Y  LjF9 7".I T=.`xETg iniS0~S($*! !K !(!\0!libkmod.so.2__gmon_start___ITM_deregisterTMCloneTable_ITM_registerTMCloneTablekmod_module_get_modulekmod_module_dependency_symbol_get_symbolkmod_get_dirnamekmod_unrefkmod_module_new_from_loadedkmod_module_new_from_lookupkmod_module_get_namekmod_module_get_softdepskmod_list_nextkmod_module_info_get_keykmod_module_unref_listkmod_module_get_infokmod_module_info_free_listkmod_module_get_dependency_symbolskmod_module_unrefkmod_module_get_dependencieskmod_module_dependency_symbols_free_listkmod_module_get_pathkmod_module_new_from_pathkmod_module_info_get_valuekmod_module_symbol_get_symbolkmod_newlibgcc_s.so.1_Unwind_Resume__gcc_personality_v0libc.so.6__xpg_basenamestrcpy__printf_chkfopenstrncmpoptindregexec__open64_2putsforkfutimes__stack_chk_fail__lxstatunlinkmkdirreallocabort_exitmemchrstrpbrkpopengetpidstrspnstrdupfts_closeisattyfeofsymlinkexeclpfgetscallocstrlenwritevstrstrstrcspn__errno_locationmemcmpstrndup__fprintf_chkfchownfts_readmemcpyfclose__vsnprintf_chkstrtoulmallocumaskrealpath__ctype_b_locgetenvfts_setregcompoptargioctl__snprintf_chkgetopt_longpcloseusleep__getdelimgeteuidwaitpidstrchrprogram_invocation_short_nameqsort__cxa_finalizesyscallfts_open__xstatunamestrcmpstrerror__asprintf_chk__libc_start_mainstpcpysysconffree__prognameGCC_3.0GCC_3.3.1GLIBC_2.14GLIBC_2.4GLIBC_2.7GLIBC_2.3GLIBC_2.8GLIBC_2.3.4GLIBC_2.2.5LIBKMOD_22LIBKMOD_5    p0P&y Va_& ^ hii sii }ii ii ti ui "& j!0?!>!!!! !S@!`! !!!"!+!4 !8@!?`!D!P!W!g!y ! !@ !A` ! ! ! ! !9 !E !J@ !=H !NP !TX !Y` !]h !ep !lx !!!!#!*!1! !k(!l0!m ! ! ! ! ! ! ! ! ! ! ! !  ! ! ! !( !0 !8 !@ !H !P !X !` !h !p !x ! ! ! !! !" !$ !% !& !' !( !) !+ !, !- !. !/ !0!1!2!3!4 !5(!60!78!8@!9H!:P!;X!<`!=h!>p!?x!@!A!B!C!D!E!F!G!H!I!J!K!L!M!N!O!P!Q!R!S!T !U(!V0!W8!X@!YH!ZP![X!\`!]h!^p!_x!`!a!b!c!d!e!f!g!h!iHHy HtH52 %3 hhhhhhhhqhah Qh Ah 1h !h hhhhhhhhhhqhahQhAh1h!hhhh h!h"h#h$h%h&h'qh(ah)Qh*Ah+1h,!h-h.h/h0h1h2h3h4h5h6h7qh8ah9Qh:Ah;1h<!h=h>h?h@hAhBhChDhEhFhGqhHahIQhJAhK1hL!hMhNhOhPhQhRhShThUhVhWqhXahYQhZAh[1h\!h]h^h_h`hahbhc% D% D% D% D% D% D% D% D% D% D% D% D% D% D%} D%u D%m D%e D%] D%U D%M D%E D%= D%5 D%- D%% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D%} D%u D%m D%e D%] D%U D%M D%E D%= D%5 D%- D%% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D%} D%u D%m D%e D%] D%U D%M D%E D%= D%5 D%- D%% D% D% D% D% D% D% D% D% D% D% DE1H|$Ht.MtLMtLDH,HHH|$HtLHH|$HH?H<$fHH1HHDH8HHHDžHLHHLLA詁AtD蛁LpAIHDžKHEE1E1LHEH}{LsLkH}bHEIH}RHtHLH}9HHHEE1E1HEE1E1uHEE1E1bD躀HEE1E1EIn1gH}H}LH}HH(H HtH1H}HtH}HtHtHHEHtHL1I1II1H}HtKH}Ht=HtH0LH11111111H}Ht I1II1I1v1o1h1a1Z1S1L1E1>17101)1"HHH HLH_HDžPHPHHtH@HtH3E1LHHtHHHDžPHDžPHDžPsHDžPcHDžPSE10L#HH] HDžPE1BE1:LHH1HH6fDAWAVAUATIUSH(dH%(HD$1t,1%gi= eL5SL-SLLS=` H tQH== 1vHH HD$H\$ HH= 1HZHu1H=HHIL1H >H5&"dHH5CoH 2H HL;CH5Hj1HHY HH@LLRLLH RH= H H H= H HtPvHHAH= 1H= H5H H;Lc- EuLA9}EJH5 M<H$I?u"AEH$9AM9u IDI)݀=N ,$=< =2 $I/O4OdLhH  LLA@Åt<= u@PH KMAVL1H5aZY= 1cHL$dH3 %(H([]A\A]A^A_H=H+ H8HH HLH g1H5H?aH=( Ht @HH=i YHu DHH=Y YHu DHpH=1 YHuH=( SQH= GQH= ;QH=< /H= fH= fO$E11J  LAHI`Lt = AID94$5M $X1LH ͝H5_M,$/LLHeHD$HtL|$1 IM/MM`1L+H YH5_  LL AvŅuMc1LH H567_nM $q1LDH ܜH5_H|$TeIٺLH ߝH5DŽ^K49H== 1H1O,E1HHHHVMuIH= LQHtLH?t$LH= HHOLi!AID9<$7Me1H5L{MH ՛]H5 LH[MZDL 1 L H H5]\LH$H\L<$1L-f II/HAQMIH AV<H5>18]AZAA[  LH%ÅuVL؆IAVH ?1H5\_AXdH<$2cLa1H H5\HL H H5s1r\L4H `H5CD\zLsH 7HHH1I^HHPTLH /H=R H= H H9tH> Ht H=i H5b H)HHH?HHtH HtfD== u+UH= Ht H= Id ]wHt;SHHHu*HHt</HBu|/tH[f11[fAW1Ҿ AVAUATUSHHH<$H|$ dH%(H$81HiHD$HD$ HD$(yHIHbHL$Lt$0HL$fDHxpHD$H5€Hx(H5 IH[H¾LHbL H!%tDHJHDщHL)"H|0 uD0HT$H<$LH\$HtcH0HIHLHrH= HHJH|$HcHHuH|$HtLdLHH<$Ht$EÅLd$Ll$LMDHD$LHH$H H= H55|aH~ H= Hy  H$dH3 %(HĐ[]A\W LH={1J -H5f H= E}` H5: H=^ 6       H5 H=*  a\ UH5 H=r m )H5b H= A=Z H=6 H  H= H H= = u!= t H=y t 9tntjH=zHHJILy1H H5ySH5yH_H 1LyH q1H5]yYSHHtHH L  LH H5y1REL LJH ֑L L.H L LچH L u LH kL1H cH5VxWRff.fAVAUATUSL$HH $L9uH dH%(H$@1HHIHD$HHH1HIDIHLWIULDH9v+A8/u%JT-HfHz/uIH9u1H|$LHw#H|$D$Hw1fD/HHVuDE}HsDE1f/HIVuMA8D1E1:uHHt2H*IMPH yH5r1LXZHuH$H$dH3%(HuFHĸ[]A\A]A^A_1ԿLr1H H5OrPL=4 SHu=( uR[E111HH= uIٺLH H5qK1[E111HH= tIٺ1LH aH5qK1[ÐUH0rHSHH  dH%(HD$1HH$H<$H5rHHtHHH1HqHoH<$HD$dH3%(u:H[]L $M1L9H H5pJgL)qH ɉ1FH5pJHHfDSHHH=> 1Hq+x[DH5 I1YLH H5oIXZ[fUIHAWELpAVAUATISH0HqH dH%(HE1VH5oHDžIH= XLZ@Ań%EtHH= LLL>IHHH H=Z HH?:H1HHKo9/LH Z 1{ HLoH8H{HH[HH޿#At (%=@2=It'= tH1L3DLuo1H DH5mGHM1LXoH H5mG= _AXt= u H= LDžH0LhH%=RL1c5HL1:AŅǾ @1kPLDtKPDt4ML4nH H5NlJFHxDHHDžHDžHHEHDZ^DR^DADLt(LlH 1H5kE1E1H HDH]dH3%(He[A\A]A^A_]f.Mt1LzH H5kE1ADIRLzH j1H5jDLA1ELLk1H !yH5jDfDHIك8LkH ߂1H5SjODHHHHHA1ɺH`HDL *\f.{ADžVLH81LDxDLk1H KH5ViRCDDuH=* tLE1LjH H5iCfILi1H `H5hBfLhH= HH4LiH 1H5hBHDžHALLi1H H57h3BHAf.1L&IHE1HHaLL:ADž[HL1H 2 HDžHA}/HgMD1(LHL HIH1AVLhH H5gAHA[LXrH~Hr= L]EDžumHMLvDAVH ~H5f@XZM1LgH ~H5OfP@ApDHMLv1AVH H~GH5f@XZf.L(DLL"g1H I~H5e?(H@΀5AIٺ1LuH }H5set?AM1LfH }H5:e;?WfH1Le ;HL1LfAVH c}H5d>AYAZLAeH 9}1H5d>!H5d1>8LdH |1H5`d\>u@VH5FfL fjLqtHH fAVHfATH QH5f1L ejLeHH eAVHeATH  I+I0I@I'IMII2I|ujIULC:I%Iff.UHAWAVAUATSHXH}dH%(HE1HEHE2HEHH}H5d5HHHM1H}HdH}H5;eFHHEEHEHEHE@HPHuH}Hٺ H~LM1LAdH zH5a;HEH5rHInHH5dLVH-H5dL>HH5dL&HH5dLHH5dLHH5dLHH5dLHH5 LIHH5cL/HIDHIH< L t HuLA11HHIHEpE=HuMZLoqH xx1H5$`%:XZL}H5CcLHt!@A11LLZH}qLyHHEMIH!HYHI.IHBH:HIHEHHHEHH}LaLI H=}bLeHH}ME 1H5ScHL1*VA11HHI:H5bLH@A11LLLM1LaH vH5^8M1LbH vH5h^i8EDH}HtH*H}EH]dH3%(He[A\A]A^A_]@LM\1LaH :vH5]7fE1LeH}\LTLLH}CMME1HEE1LMf1L`H uH5e]f7wE1HEsH}1AąxH}ILAH/\1h1H}ILH\CLXH p15H5YXU2&LXH mp1#H51X-2s1LXH )p1)H5W1LYXH p1/H5W1HUHAWAVH AUATSHHdH%(HE1HDž Å<L MwL0@H LyIHLHǹ H5ZuLIILZ1H nH5V0HP H%H;DžL({f.H(A11HH(u.IL!ZH knH5NVO0H(HH;1MHVLHDž(H &H(LDL(L^V1H mH5U/cfZHHMLgPH mH5nU1h/XZ1H HtHMdH3 %(He[A\A]A^A_]ÉHIHI1AWLRfH mH5T.^_1LLUH l1H5T.UHHff.fUHAWAVAUATSHHdH%(HE1H_HEIIE1HEHEL=K HELHHE̿HHpH=a HH=R HBH}Y=ʣ tE111HL~H57 11HAHAH HEHILGWPH YkH5\S1HEHEF-H}Y^H}HHAƅH}HtH}HtHtHӿH}HtLLIHHMdH3 %(DHe[A\A]A^A_]fHEHtHfHIL:dPH ejH5hR1b,XZhHUHuH}臾Aƅ H}H}AEDDH}AH70-E1"蛿II54III @UHAWAVAUATISH(dH%(HE1HEHEؼ=I H= LHHH=x HH=i H1E1H}HtƽH}Ht踽HtH諽HMdH3 %(DHe[A\A]A^A_]fDH= HaNIٺ)1LkbH iH5_P`*bH=; HE=% H HILSH h<HH5OP1)H5o XA1ZH1HAƅ=e 1ۀ=U L!ILS1CH 1hH5|Ox)1}HuL$<HE=J I?HL5 fDH}LdIHL耻E111HLI軹uLoHI1AUL(aH agH5N(_H}AXHt 蟼Iٺ81LBaH 3gH5~N(1A~fE111HH=o  Iٺ$1L`H fH5(N)(+@L9`H f1H5M'HE= IMLŻLHILxQ1@H XfH5M'LLHHAƅHUHuL詹AƅjH}H}AEAEAFf.HEIMxLkHEIǀ= MKL5| f.H}LIHtL4E111HLIouL#HI1AUL _H eH5sLt&H}Y^H?P51AWAL=3 ٹI颾IɾII鹾I鱾I驾I顾I陾I鑾H鉾II I闾I钾}`I{IvIqIlIgIbI]IXISIUUHAWAVI1AUAATSHH=] dH%(HE1HDžx~HI3H5NHHQHt H)H = 1EAELhIDE1HHHH`HxHXHhLoN1H bH5 JL $H뿀=m =_ dAVMLQ1SH }WH5>JL HHHhLQH +WH5>>L15>苫8H@HtHH蒩H膩HzwATML1Q1SH VH5=^_HhAPMLAH sV0H5=1~^_L^BH IV1H5U=Q*= t HhLOBH UH5=L1 貪Lt=H U1.H5<"LD=H U1(H5<L=H |U14H5<HHׯ˯HH(HŰHHѯH(H)H*H.H)H-H)H*齯H8H3H/f.Df1H9Bff.HHtwHHN HF(HtAHA(HF(Ht=HH HNHFHtHAHFHt&HHG tkG HHGHuHOHL(H TH5SH=@AH TH5SH=X!H TH5SH=SHHtHHD(HHFHVHHtHrH0HGHF HF(Ht$HHp G HwtkHfDHHwH SH5SH=?YfH SH5RH=W1H SH5RH=RH ySH5RH=RH YSH5{RH=RATUSHHt$P H9szJHHrH H[]A\@HI*H1H|HH!HGHH耣HtI$X@ HI$f.ɸBȉff.ATUSHtGHIH\(Hu#H[HtLH;UuH[]A\f1H[]A\fDH IR(H5[QH=;>USHHtuHHHH>UHHiHΉH )H))Љ}$tHr Hk HH[]ÐHH[]2fH QH5PH==H QH5PH=USHwHHtH(HsHu{$tH H H[fDH[駢tHu鷤ATUHSH=*AĄHk HHHX HzH1HHǂHH) HHHB HDHHHBHDHBHH*HZDb$[]A\@ H=܇ HHk1[H]A\f HHk1АSHHt3H?t 1[fHHHHu[fDH OH5NH=;Htfff.@HtGUSHHHwHt"HnH HtH謠HsHuHH[]Dff.@Ht/SHwHHtf.HHsHu[DAUATUSHHIHHIAULHiHډH )))HƉHt!L9`EH[]A\A]DA}$t9H5҅ HtmHHÅ H.LLfH[]A\A]f0膞HHu˸H M6H5LH=9A0H=\ _Hf.ATUSHtkHHHIUHHiHщH ))H)ȉHtHL`1[]A\LHH[]A\nfDH MVH53LH=9fHtgUHSHHHH߉HiH IȉD)D))HHtH@H[]H1[]1ff.fUSHHtaHHHHiHωH )H))HHt HhHHHH[]1HH[]@HAWAVIAUIATIHUHSHA$LHiH )))HƉIHtxLA$LHiHH )))LƉHu#LLM/LMwL1H[]A\A]A^A_úHAWAVIAUIATIHUHSHA$LHiH )))HƉIHLA$LHiHH )))LƉHtI9t HL'LLM/LMwL1H[]A\A]A^A_øHtwATIUHHSHUHiHωH )H))L#HtH9XuHH}H[]A\D[1]A\f1ff.fHtgHtJHHtAHt,HH HHHDHHtHH H@HGHuH1HtHfHH HH5HH=JHm ff.fHtWHt:HHt2HtHH(HHtHH H@DHGHuH1HtHfHH %HH5GH=G ff.fHtgATIUHHSHUHHiH IȉD)D))LaHt H[H@]A\[1]A\f1ff.fHtHGHtH@f1ff.fHtHGHtHf.1ff.fHtHGHtH@f1ff.fSHtHwHtH^H[1H[ÐSHtHwHt HH[1H[fHtG 1ff.fHtG fDfUSHHtAHt-H^HHt!HSH3Htx H[ Hu1H[]fDH EvH5[EH=;2AVAUATUSHIHLvHMI>Mf UH‰HiH )))IƉHuEI>AULHiHΉH )L))Љ!LHMMp[]A\A]A^H DH5cDH=C1fHAVIAUIATIUSHHAUL‰HiH )))LƉ2HLA$LHiHH )))LƉIHt^HƉLLL1[]A\A]A^f1DH CH5cCH=C0f뾸fUSHHt1HwHH?"HHtHHOx+HH[]ÐH 9CH5BH=/AH1F@AVAUATIUSHdH%(HD$1G xHHHtPI1LH$LHtY@1LLHDLcHHuJDHHL$dH3 %(HuH[]A\A]A^fDH薖fDAWAVAUATUSHhdH%(HD$X1= HIL5CL-n)HH5FH耕H\;H5fFH1ђHtHhD=x ExfHL4$AD$AD$(AD$8ID$HHD$H\$谓LDHD$Ll$ HD$(=HL?=1HL$XdH3 %(uHh[]A\A]A^A_Zf.AWIAVAAUIATUSH(HL$Hl$dH%(H$1ĔLL$MHD HþHDLƄ$ID#H$dH3 %(uH([]A\A]A^A_謔ff.UIH=x S1HHQRVrH HHx z aS]v x 謑t[D9v [ff.@f.ff.;=u H~ 1fLLHbfHILL$Ht7)D$P)L$`)T$p)$)$)$)$)$dH%(HD$1H$$(HD$HD$ HD$1;=Cu D$0~HL$dH3 %(uHDHLLff.t S1ۅx[3tt [þH=n?t x-L@H A1IH5P?D؉_EL?H LAIH5?1Ht \ff.PXL?Hjf.PXH @\H5>H=>Hff.9u s @Hff.@PXL?Hf.Hx/=} H@H !@H5$>H=C>!H @H5>H=/>Hsxus 1H} Dr DwHcHl H1ff.fAUL-sl ATIH=V=US1HdH%(HD$1D$Mu`I|Ht L|t*HH uHt$LQxLl$GHT$dH3%(u2H[]A\A]ÐH >%H5<H=&ՏDH#x81HÐfSH=<HtHHxUH=<HHt H8x[fIL=[H =H5 <1vIٺ 1LH=H =H5;Mf.H6H?UHSHH?HtH@裌HH;HuHH[]鉌f1H?tHH?ufff.@ATUSHtSHHt;H/IHu#fDHt"H+HtLH_uH[]A\1[H]A\fDH > H5=H=&AUATUSHHtmHHtUH/Ht=HI貋IDHt2H+HtLLH|uHLtHH[]A\A]fH1[H]A\A]H I=,H5n<H=&1Htbfff.@ATUSHtkH{xHIHt=H;HHuWf.HH;HHt=ˌHEHuLE1[]LA\螉HHtIHEL[]A\Htf1ff.fATUSH dH%(HD$1HKo1HIH$HNxHL$%fDƒHʉ$HHt*HNj$/vHT$HBHD$HHuHʈHHIL謋HHAf.E/w7ƒHUEH:Ht7HtiDHHt]EA/vHUHBHEH:HuJHHt$dH34%(HuEH []A\fDE1xH(1@HHu1DHHt$(HT$0HL$8LD$@LL$Ht7)D$P)L$`)T$p)$)$)$)$)$dH%(HD$1H$H$HD$HD$ D$0HD$HT$dH3%(uH&fDAUATIUSHHHHUHK|HΆIHt?H}HHu]HH}HHtD蚉HHuLE1HL[]A\A]fkHHtHII<$HuHHL[]A\A]DHH[]A\A]fDAVAUATUHSHHIIjHHW|HڅIHt8H}HHuT@HH}HHt?誈HHuLE1[]LA\A]A^LHHtHII<$HuHL[]A\A]A^@xHDHHtI[]A\A]A^AWAVAUATUSH(dH%(HD$1HLl$L|$IHLLHHD$H1DLLLHDsxHu{H藄IHtkLLLHHD$EH1!LLLHHtGHt$HIHuLE1THL$dH3 %(LuPH([]A\A]A^A_fIHH 6H55H=*L̆ff.AWAVAUATUSH(dH%(HD$1HLd$Lt$HHD$LLH1 DLLDkHkHu{H*IHtgLLHHD$;H1fDLLHHtRHt$HM|IHuLE1HL$dH3 %(LuWH([]A\A]A^A_fIDHfH 95H54H=<Q'L\ff.USHHtQH55HHt.Ht"H,H}Ht?u HEHH[]DH y4.H53H=AWAVAUATUHSHHHI藂IHLmI1LMuzI<$HtJ;HHEWHIuH{EHHHfDLhHHt?LmMt6HH9tHLCHοHHtKHfHH[]A\A]A^A_AL50"謀HHHu1ff.fAUIATUSHHHHxHYIHt:H;HHuD@HH;HHt0+HEHuLE1GHL[]A\A]fLHEHtHEHL[]A\A]fH[]A\A]HL11[]A\A]f.HtWATUHSHHHtMHpAHH諃Ht8DHAT$HHE1[]A\1DE1뻸UHHSHHt1HHH\xH[]ÐH߉D$ D$ H[]øfHtD1ff.fAVIAUATUSHtdIHtlHIHHuD@HI$IH]Ht+LH蠁uHH@H]HuI$[L]A\A]A^@H 0H560H=fUHSHHt'H7HtH H3HtHHHuHH[]ff.fAWIAVAUATUSHHtpIHt~HIHHu"QfDIt2HHW~H]Ht1LV~LHHI5}tHIIH]HuIHL[]A\A]A^A_@H y/H5/H=AWAVAUATUSHHHu H=HTH,3HE1H9v8A~u AVAHH9u|3H$HE1H9w8fDHHHT$H)-HT$HItFHZAH9vwI1HI)LP{H $HDLSDRЉA DRA@A7ACDSEZDA  EZAAAJɅHH ʈPA HH) HH HH HH HH HHHHHH\HHD[DA0Dڃ0kA00~0ExvxrAAHHE D @hL'HH9"HH)\HL[]A\A]A^f.E1[]LA\A]A^Ð\HHHDL`oHtI0'\xHHfPf.H $H5"H=AJ AJWfD1DAVAUATUSHIHHHHH5!HHDHpH3@@'tUIL-!@"@\LpHu IA6@uLH)I$HLu[]A\A]A^fSHsHu)H1Cf.'PHHtHȀ\uxPHHuHH)I$9HHHHM[]A\A]A^fA~3AvIFI@ ?CHK!H<\tQ<"tfHBRt\t?"t HuHH)I4$8HHHEH[]A\A]A^HЀxHP@uHHH)@1H[]A\A]A^f.H a"H5H=H A"H5H=H !"H5H=aHHH)IHHH H1ff.fAUATUSHHHHD߀;tC?t>IHHHIZnLHHoIEHHEHH[]A\A]H1H[]A\A]G< v%G<vG<w'@G@G@Gf.G<w @GDfAWIAVIAUAATL%F UH-F SL)HocHt1LLDAHH9uH[]A\A]A^A_ff.HH/sys/devicesmodaliasinstall/dracut-install.c2madfhlL:oD:HRp:P:s:S:N:DRACUT_FIRMWARE_PATHDRACUT_FIRMWARE_PATH=%sNo SOURCE argument given%s/%sOut of memory!stat(%s) != 0find_binary(%s) == %s%s/lib/dracut/hostonly-filesa%s dracut_install('%s', '%s')hash hit items for '%s'ERROR: stat '%s': %m'%s' already existsdest dir '%s' does not existmkdir '%s''%s' install errorlstat '%s': %mln -s '%s' '%s'ERROR: ln -s '%s' '%s': %mdracut_install ret = %dcp '%s' '%s'Failed to chown %s: %m-fL--sparse=auto--reflink=autocp--preserve=mode,timestampscp ret = %d.soScript install: '%s'ERROR: failed to install '%s'ldd %s 2>&1ldd: '%s'Not a valid dynamic programcannot execute binary filenot a dynamic executableloader cannot load itselfnot regular filecannot read headercannot be preloaded=>Lib install: '%s'.so.glibc-hwcaps/lib/fipscheck/lib64/fipscheck/lib/hmaccalc/lib64/hmaccalc%s/.%s.hmac%s/%s.hmachmac cp '%s' '%s')firmwareFirmware %sdracut_install '%s' OKdracut_install '%s' '%s' OKdracut_install '%s' '%s'dracut_install '%s' ERROR/lib/modules/DRACUT_KERNEL_MODALIASESHandle module '%s'Failed to find module '%s' %sERROR: installing module '%s'Handling =%s%s/kernel/%s%s/extra/%s%s/updates/%sSkipping %sIgnoring %sHandling %sFTS ERROR: %m.ko.ko.xz.ko.gzFailed to find module '%s'ERROR: installing '%s'PATH is not setDESTROOTDIROut of memory%s/%d.logresolve_deps('%s')Handle '%s'dracut_install '%s'helpversiondebugverboselddresolvelazyoptionalhostonlyallmodulefipsdestrootdirlogdirmod-filter-pathmod-filter-nopathmod-filter-symbolmod-filter-nosymbolmod-filter-nonamesilentkerneldirfirmwaredirsCould not get list of loaded modules: %m. Switching to non-hostonly mode.Usage: %s -D DESTROOTDIR [OPTION]... -a SOURCE... or: %s -D DESTROOTDIR [OPTION]... SOURCE DEST or: %s -D DESTROOTDIR [OPTION]... -m KERNELMODULE [KERNELMODULE …] Install SOURCE to DEST in DESTROOTDIR with all needed dependencies. KERNELMODULE can have the format: with a leading / =[/…] like '=drivers/hid' -D --destrootdir Install all files to DESTROOTDIR as the root -a --all Install all SOURCE arguments to DESTROOTDIR -o --optional If SOURCE does not exist, do not fail -d --dir SOURCE is a directory -l --ldd Also install shebang executables and libraries -L --logdir Log files, which were installed from the host to -R --resolvelazy Only install shebang executables and libraries for all SOURCE files -H --hostonly Mark all SOURCE files as hostonly -f --fips Also install all '.SOURCE.hmac' files --module,-m Install kernel modules, instead of files --kerneldir Specify the kernel module directory --firmwaredirs Specify the firmware directory search path with : separation --silent Don't display error messages for kernel module install --modalias Only generate module list from /sys/devices modalias list -o --optional If kernel module does not exist, do not fail -p --mod-filter-path Filter kernel modules by path regexp -P --mod-filter-nopath Exclude kernel modules by path regexp -s --mod-filter-symbol Filter kernel modules by symbol regexp -S --mod-filter-nosymbol Exclude kernel modules by symbol regexp -N --mod-filter-noname Exclude kernel modules by name regexp -v --verbose Show more output --debug Show debug output --version Show package version -h --help Show this help Module path filter %s is not a regular expressionModule symbol filter %s is not a regular expressionEnvironment variable DRACUT_FIRMWARE_PATH is not setconvert_abs_rel(): target '%s' directory has no realpath.Path %s matched exclusion filterPath %s matched inclusion filterCould not open '%s' for writing.Could not append '%s' to logfile '%s': %mhash hit items_failed for '%s''%s' already exists, but checking for any depsERROR: failed to create directory '%s'--preserve=mode,xattr,timestampsFailed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %sFailed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %syou do not have execution permissionERROR: failed to install '%s' for '%s'could not get modinfo from '%s': %s Possible missing firmware %s for kernel module %sdracut_install '%s' '%s' ERRORdracut_install '%s' is excludeddracut_install '%s' not hostonlykmod_module_get_dependency_symbols failedModule %s: symbol %s matched exclusion filterModule %s: symbol %s matched inclusion filterNo symbol or path match for '%s'Adding module '%s' to hostonly module listFailed to lookup modules path '%s': %mFailed to get name for module '%s'3 Failed to lookup alias '%s': %dFailed to lookup alias '%s': %mEnvironment DESTROOTDIR or argument -D is not set!Environment DESTROOTDIR or argument -D is set to '/'!Environment DESTROOTDIR or argument -D is set to '%s': %mCould not open %s for logging: %mERROR: installing '%s' to '%s''qrrrqrrrqrprprpsprrrrrrrrrrrrrgprr[prOprqrrrCp7pr+porrorrorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrooyodoHon_entries >= 1!h->iterate_list_headihashmap_copyhashmap_move_onehashmap_movehashmap_mergehashmap_iterate_backwardshashmap_iteratehashmap_replacelink_entryhash_scanhashmap_putunlink_entryremove_entryhashmap_ensure_allocateddracut-install: /dev/consoleinstall/log.c(level & 0x07) == leveltarget >= 0target < _LOG_TARGET_MAXDRACUT_LOG_TARGETDRACUT_LOG_LEVELsafenullFailed to open /dev/console for logging: %sSuccessfully opened /dev/console for logging.Assertion '%s' failed at %s:%u, function %s(). Aborting.Code should not be reached '%s' at %s:%u, function %s(). Aborting.Failed to parse log target %s. Ignoring.Failed to parse log level %s. Ignoring.log_target_from_stringlog_parse_environmentlog_set_targetlog_set_max_levellog_open_consoleinstall/strv.cs || l == 0i == cstrv_parse_nulstrstrv_remove_prefixstrv_removestrv_split_newlinesstrv_split_quotedstrv_splitstrv_find_prefixstrv_findinstall/util.cpostfixfd >= 0close_nointr(fd) == 0ret_uemergstate alertcriterrwarningnoticeinfo(r = sysconf(_SC_PAGESIZE)) > 0 split_quotedcunescape_length_with_prefixlog_level_from_stringsafe_atouclose_nointr_nofailclose_nointrendswithpage_size;`,B|HNO5OWO`PP Q` :Q Q R SP S ]| ^\^\bbfjklm<n,oL|xll x ,0 l ̣ ܥ 0 h < L L  ̩$ ,P ll , 0,d HL`ܰx\L0lDX |@<|, |L̸pܸ̺$,8LTpܻ,, ܽDX,\ܾ| 4!hSd vlR"o+H4a8m?fDDPLWpgPysSNA9EJ=NTY]elp @# !!oh    !` xh ooooo& !p#########$$ $0$@$P$`$p$$$$$$$$$%% %0%@%P%`%p%%%%%%%%%&& &0&@&P&`&p&&&&&&&&&'' '0'@'P'`'p'''''''''(( (0(@(P(`(p((((((((()) )0)@)P)`)p))))GA$3a1@#> GA$3p1113/GA*GA$annobin gcc 8.5.0 20210514GA$plugin name: gcc-annobinGA$running gcc 8.5.0 20210514GA*GA*GA! GA*FORTIFYGA+GLIBCXX_ASSERTIONS GA*GOW*GA*cf_protectionGA+omit_frame_pointerGA+stack_clashGA!stack_realignGA$3a1>% GA$3p1113ЄGA*GA$annobin gcc 8.5.0 20210514GA$plugin name: gcc-annobinGA$running gcc 8.5.0 20210514GA*GA! GA*FORTIFYGA+GLIBCXX_ASSERTIONSGA*cf_protectionGA+omit_frame_pointerGA+stack_clashGA!stack_realignGA*ЄI GA*GOW*GA* GA*GOW* GA*FORTIFY@?GA+GLIBCXX_ASSERTIONS GA*FORTIFYЄGA+GLIBCXX_ASSERTIONSdracut-install-049-246.git20260728.el8_10.x86_64.debug*7zXZִF!t/%g _]?Eh=ڊ2Nc } M89iCu]E7CX:e5,o=Dy֤ #s؈6ˠYĦ {$s)R v8poׄxOKX>-[Tա# y b<יkZˁF,<0 4x33P6ʬ 9M\p} !=^yN"#t_;aӹ{l/zsܵLٹ]ҷ́@(]s0_ []fCQrYmDTO%p6FԎ2>̱b?gz3f|B:=!܏P[ 0CFF>( DßbQ,4p(0/ĥ![bHFS~HlaN'l-O1+@eb6/V>t"WGg+|dڨ#t !tgjL&^v5-L ټLؽ|Oƻqhd1Pfxph71E6ݲ,k1dӺZ` ђGD!e3K,@ѐSNE˛v78.sjLi߲U7(uSx̭b#1YoIyKqBCM|0qT @N|Y޲lYS[*Њ6ȃ,t=FbYNgp؂_Yg!{i:x-V,m~SIۡ+'Xd8vs]O05iiA eWvd63IN ؚX>t.]O(|vUP,bB*n[g~jmSH8O|z{>VI1{ _, rkO<>ۢp5Oz;nApc~9 }liXd4"L96f} qDeO$-(77IMzmDI#LTKgJn5/ߺ~ d8,/"ڿ]dž6PLD5V*t==?jЯKȖ6%>`pqwBJmoG{ۿ+q.br`|~Kv|t 7dV,..S5^[=w}Q pҩV5beVAgӟ3EnYwOg'ãjx̅cE`<V49evlk(OXL5pFNڰvߎ sR/Ugml=3;;"5뉩XNr<~אBNGH|;Y6C.qC_u[65MU n'\],rm lQĵ-['?C59V ]Shu}/yV[1蛼EK2?Z-|<)TT/Ƅֶ]YOJ$ȱgYZ.shstrtab.interp.note.gnu.property.note.ABI-tag.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.plt.sec.text.fini.rodata.eh_frame_hdr.eh_frame.gcc_except_table.tbss.init_array.fini_array.data.rel.ro.dynamic.got.data.bss.gnu.build.attributes.gnu_debuglink.gnu_debugdata  &   4@@$Gohh4Q P Y aono}xxhB` @#@#`#`#P))@//% 00!44d@!!!!  !  ! `!  !  "(a 8<G8 Vdracut-version.sh000064400000000052152525045230010045 0ustar00DRACUT_VERSION=049-246.git20260728.el8_10 modules.d/03rescue/module-setup.sh000075500000000571152525045230013057 0ustar00#!/bin/bash # called by dracut check() { # do not add this module by default return 255 } # called by dracut depends() { return 0 } # called by dracut install() { inst_multiple -o ps grep more cat rm strace free showmount \ ping netstat rpcinfo vi scp ping6 ssh \ fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.f2fs fsck.vfat e2fsck } modules.d/01systemd-initrd/module-setup.sh000075500000003451152525045230014546 0ustar00#!/bin/bash # called by dracut check() { [[ $mount_needs ]] && return 1 if ! dracut_module_included "systemd"; then derror "systemd-initrd needs systemd in the initramfs" return 1 fi return 0 } # called by dracut depends() { echo "systemd" } installkernel() { return 0 } # called by dracut install() { local _mods inst_multiple -o \ $systemdsystemunitdir/initrd.target \ $systemdsystemunitdir/initrd-fs.target \ $systemdsystemunitdir/initrd-root-device.target \ $systemdsystemunitdir/initrd-root-fs.target \ $systemdsystemunitdir/initrd-switch-root.target \ $systemdsystemunitdir/initrd-switch-root.service \ $systemdsystemunitdir/initrd-cleanup.service \ $systemdsystemunitdir/initrd-udevadm-cleanup-db.service \ $systemdsystemunitdir/initrd-parse-etc.service systemctl -q --root "$initdir" set-default initrd.target local VERSION="" local PRETTY_NAME="" if [ -e /etc/os-release ]; then . /etc/os-release [[ -n ${VERSION} ]] && VERSION+=" " [[ -n ${PRETTY_NAME} ]] && PRETTY_NAME+=" " fi NAME=dracut ID=dracut VERSION+="dracut-$DRACUT_VERSION" PRETTY_NAME+="dracut-$DRACUT_VERSION (Initramfs)" VERSION_ID=$DRACUT_VERSION ANSI_COLOR="0;34" { echo NAME=\"$NAME\" echo VERSION=\"$VERSION\" echo ID=$ID echo VERSION_ID=$VERSION_ID echo PRETTY_NAME=\"$PRETTY_NAME\" echo ANSI_COLOR=\"$ANSI_COLOR\" } > $initdir/usr/lib/initrd-release echo dracut-$DRACUT_VERSION > $initdir/lib/dracut/dracut-$DRACUT_VERSION ln -sf ../usr/lib/initrd-release $initdir/etc/initrd-release ln -sf initrd-release $initdir/usr/lib/os-release ln -sf initrd-release $initdir/etc/os-release } modules.d/97biosdevname/parse-biosdevname.sh000075500000000465152525045230015065 0ustar00#!/bin/sh if ! getargbool 1 biosdevname; then info "biosdevname=0: removing biosdevname network renaming" udevproperty UDEV_BIOSDEVNAME= rm -f -- /etc/udev/rules.d/71-biosdevname.rules else info "biosdevname=1: activating biosdevname network renaming" udevproperty UDEV_BIOSDEVNAME=1 fi modules.d/97biosdevname/module-setup.sh000075500000000437152525045230014103 0ustar00#!/bin/bash # called by dracut check() { [[ "$mount_needs" ]] && return 1 require_binaries biosdevname || return 1 return 0 } # called by dracut depends() { return 0 } # called by dracut install() { inst_multiple biosdevname inst_rules 71-biosdevname.rules } modules.d/90crypt/crypt-run-generator.sh000075500000001402152525045230014236 0ustar00#!/bin/sh . /lib/dracut-lib.sh type crypttab_contains >/dev/null 2>&1 || . /lib/dracut-crypt-lib.sh dev=$1 luks=$2 crypttab_contains "$luks" "$dev" && exit 0 allowdiscards="-" # parse for allow-discards if strstr "$(cryptsetup --help)" "allow-discards"; then if discarduuids=$(getargs "rd.luks.allow-discards"); then discarduuids=$(str_replace "$discarduuids" 'luks-' '') if strstr " $discarduuids " " ${luks##luks-}"; then allowdiscards="discard" fi elif getargbool 0 rd.luks.allow-discards; then allowdiscards="discard" fi fi echo "$luks $dev - timeout=0,$allowdiscards" >> /etc/crypttab if command -v systemctl >/dev/null; then systemctl daemon-reload systemctl start cryptsetup.target fi exit 0 modules.d/90crypt/crypt-lib.sh000075500000016743152525045230012232 0ustar00#!/bin/sh command -v getarg >/dev/null || . /lib/dracut-lib.sh # check if the crypttab contains an entry for a LUKS UUID crypttab_contains() { local luks="$1" local dev="$2" local l d rest if [ -f /etc/crypttab ]; then while read l d rest || [ -n "$l" ]; do strstr "${l##luks-}" "${luks##luks-}" && return 0 strstr "$d" "${luks##luks-}" && return 0 if [ -n "$dev" ]; then for _dev in $(devnames $d); do [ "$dev" -ef "$_dev" ] && return 0 done fi if [ -e /etc/block_uuid.map ]; then # search for line starting with $d _line=$(sed -n "\,^$d .*$,{p}" /etc/block_uuid.map) [ -z "$_line" ] && continue # get second column with uuid _uuid="$(echo $_line | sed 's,^.* \(.*$\),\1,')" strstr "$_uuid" "${luks##luks-}" && return 0 fi done < /etc/crypttab fi return 1 } # ask_for_password # # Wraps around plymouth ask-for-password and adds fallback to tty password ask # if plymouth is not present. # # --cmd command # Command to execute. Required. # --prompt prompt # Password prompt. Note that function already adds ':' at the end. # Recommended. # --tries n # How many times repeat command on its failure. Default is 3. # --ply-[cmd|prompt|tries] # Command/prompt/tries specific for plymouth password ask only. # --tty-[cmd|prompt|tries] # Command/prompt/tries specific for tty password ask only. # --tty-echo-off # Turn off input echo before tty command is executed and turn on after. # It's useful when password is read from stdin. ask_for_password() { local cmd; local prompt; local tries=3 local ply_cmd; local ply_prompt; local ply_tries=3 local tty_cmd; local tty_prompt; local tty_tries=3 local ret while [ $# -gt 0 ]; do case "$1" in --cmd) ply_cmd="$2"; tty_cmd="$2"; shift;; --ply-cmd) ply_cmd="$2"; shift;; --tty-cmd) tty_cmd="$2"; shift;; --prompt) ply_prompt="$2"; tty_prompt="$2"; shift;; --ply-prompt) ply_prompt="$2"; shift;; --tty-prompt) tty_prompt="$2"; shift;; --tries) ply_tries="$2"; tty_tries="$2"; shift;; --ply-tries) ply_tries="$2"; shift;; --tty-tries) tty_tries="$2"; shift;; --tty-echo-off) tty_echo_off=yes;; esac shift done { flock -s 9; # Prompt for password with plymouth, if installed and running. if type plymouth >/dev/null 2>&1 && plymouth --ping 2>/dev/null; then plymouth ask-for-password \ --prompt "$ply_prompt" --number-of-tries=$ply_tries \ --command="$ply_cmd" ret=$? else if [ "$tty_echo_off" = yes ]; then stty_orig="$(stty -g)" stty -echo fi local i=1 while [ $i -le $tty_tries ]; do [ -n "$tty_prompt" ] && \ printf "$tty_prompt [$i/$tty_tries]:" >&2 eval "$tty_cmd" && ret=0 && break ret=$? i=$(($i+1)) [ -n "$tty_prompt" ] && printf '\n' >&2 done [ "$tty_echo_off" = yes ] && stty $stty_orig fi } 9>/.console_lock [ $ret -ne 0 ] && echo "Wrong password" >&2 return $ret } # Try to mount specified device (by path, by UUID or by label) and check # the path with 'test'. # # example: # test_dev -f LABEL="nice label" /some/file1 test_dev() { local test_op=$1; local dev="$2"; local f="$3" local ret=1; local mount_point=$(mkuniqdir /mnt testdev) local path [ -n "$dev" -a -n "$*" ] || return 1 [ -d "$mount_point" ] || die 'Mount point does not exist!' if mount -r "$dev" "$mount_point" >/dev/null 2>&1; then test $test_op "${mount_point}/${f}" ret=$? umount "$mount_point" fi rmdir "$mount_point" return $ret } # match_dev devpattern dev # # Returns true if 'dev' matches 'devpattern'. Both 'devpattern' and 'dev' are # expanded to kernel names and then compared. If name of 'dev' is on list of # names of devices matching 'devpattern', the test is positive. 'dev' and # 'devpattern' may be anything which function 'devnames' recognizes. # # If 'devpattern' is empty or '*' then function just returns true. # # Example: # match_dev UUID=123 /dev/dm-1 # Returns true if /dev/dm-1 UUID starts with "123". match_dev() { [ -z "$1" -o "$1" = '*' ] && return 0 local devlist; local dev devlist="$(devnames "$1")" || return 255 dev="$(devnames "$2")" || return 255 strstr " $devlist " " $dev " } # getkey keysfile for_dev # # Reads file produced by probe-keydev and looks for first line to # which device matches. The successful result is printed in format # ":". When nothing found, just false is returned. # # Example: # getkey /tmp/luks.keys /dev/sdb1 # May print: # /dev/sdc1:/keys/some.key getkey() { local keys_file="$1"; local for_dev="$2" local luks_dev; local key_dev; local key_path [ -z "$keys_file" -o -z "$for_dev" ] && die 'getkey: wrong usage!' [ -f "$keys_file" ] || return 1 local IFS=: while read luks_dev key_dev key_path || [ -n "$luks_dev" ]; do if match_dev "$luks_dev" "$for_dev"; then echo "${key_dev}:${key_path}" return 0 fi done < "$keys_file" return 1 } # readkey keypath keydev device # # Mounts , reads key from file , optionally processes it (e.g. # if encrypted with GPG) and prints to standard output which is supposed to be # read by cryptsetup. is just passed to helper function for # informational purpose. readkey() { local keypath="$1" local keydev="$2" local device="$3" # No mounting needed if the keyfile resides inside the initrd if [ "/" == "$keydev" ]; then local mntp=/ else # This creates a unique single mountpoint for *, or several for explicitly # given LUKS devices. It accomplishes unlocking multiple LUKS devices with # a single password entry. local mntp="/mnt/$(str_replace "keydev-$keydev-$keypath" '/' '-')" if [ ! -d "$mntp" ]; then mkdir "$mntp" mount -r "$keydev" "$mntp" || die 'Mounting rem. dev. failed!' fi fi case "${keypath##*.}" in gpg) if [ -f /lib/dracut-crypt-gpg-lib.sh ]; then . /lib/dracut-crypt-gpg-lib.sh gpg_decrypt "$mntp" "$keypath" "$keydev" "$device" else die "No GPG support to decrypt '$keypath' on '$keydev'." fi ;; img) if [ -f /lib/dracut-crypt-loop-lib.sh ]; then . /lib/dracut-crypt-loop-lib.sh loop_decrypt "$mntp" "$keypath" "$keydev" "$device" printf "%s\n" "umount \"$mntp\"; rmdir \"$mntp\";" > ${hookdir}/cleanup/"crypt-loop-cleanup-99-${mntp##*/}".sh return 0 else die "No loop file support to decrypt '$keypath' on '$keydev'." fi ;; *) cat "$mntp/$keypath" ;; esac # No unmounting if the keyfile resides inside the initrd if [ "/" != "$keydev" ]; then # General unmounting mechanism, modules doing custom cleanup should return earlier # and install a pre-pivot cleanup hook umount "$mntp" rmdir "$mntp" fi } modules.d/90crypt/parse-crypt.sh000075500000015741152525045230012573 0ustar00#!/bin/sh type crypttab_contains >/dev/null 2>&1 || . /lib/dracut-crypt-lib.sh _cryptgetargsname() { debug_off local _o _found _key unset _o unset _found CMDLINE=$(getcmdline) _key="$1" set -- for _o in $CMDLINE; do if [ "$_o" = "$_key" ]; then _found=1; elif [ "${_o%=*}" = "${_key%=}" ]; then [ -n "${_o%=*}" ] && set -- "$@" "${_o#*=}"; _found=1; fi done if [ -n "$_found" ]; then [ $# -gt 0 ] && printf '%s' "$*" return 0 fi return 1; } if ! getargbool 1 rd.luks -d -n rd_NO_LUKS; then info "rd.luks=0: removing cryptoluks activation" rm -f -- /etc/udev/rules.d/70-luks.rules else { echo 'SUBSYSTEM!="block", GOTO="luks_end"' echo 'ACTION!="add|change", GOTO="luks_end"' } > /etc/udev/rules.d/70-luks.rules.new PARTUUID=$(getargs rd.luks.partuuid -d rd_LUKS_PARTUUID) SERIAL=$(getargs rd.luks.serial -d rd_LUKS_SERIAL) LUKS=$(getargs rd.luks.uuid -d rd_LUKS_UUID) tout=$(getarg rd.luks.key.tout) if [ -e /etc/crypttab ]; then while read -r _ _dev _ || [ -n "$_dev" ]; do set_systemd_timeout_for_dev "$_dev" done < /etc/crypttab fi if [ -n "$PARTUUID" ]; then for uuid in $PARTUUID; do uuid=${uuid##luks-} if luksname=$(_cryptgetargsname "rd.luks.name=$uuid="); then luksname="${luksname#$uuid=}" else luksname="luks-$uuid" fi if [ -z "$DRACUT_SYSTEMD" ]; then { printf -- 'ENV{ID_PART_ENTRY_UUID}=="*%s*", ' "$uuid" printf -- 'RUN+="%s --settled --unique --onetime ' "$(command -v initqueue)" printf -- '--name cryptroot-ask-%%k %s ' "$(command -v cryptroot-ask)" printf -- '$env{DEVNAME} %s %s"\n' "$luksname" "$tout" } >> /etc/udev/rules.d/70-luks.rules.new else luksname=$(dev_unit_name "$luksname") luksname="$(str_replace "$luksname" '\' '\\')" if ! crypttab_contains "$uuid"; then { printf -- 'ENV{ID_PART_ENTRY_UUID}=="*%s*", ' "$uuid" printf -- 'RUN+="%s --settled --unique --onetime ' "$(command -v initqueue)" printf -- '--name systemd-cryptsetup-%%k %s start ' "$(command -v systemctl)" printf -- 'systemd-cryptsetup@%s.service"\n' "$luksname" } >> /etc/udev/rules.d/70-luks.rules.new fi fi done elif [ -n "$SERIAL" ]; then for serialid in $SERIAL; do serialid=${serialid##luks-} if luksname=$(_cryptgetargsname "rd.luks.name=$serialid="); then luksname="${luksname#$serialid=}" else luksname="luks-$serialid" fi if [ -z "$DRACUT_SYSTEMD" ]; then { printf -- 'ENV{ID_SERIAL_SHORT}=="*%s*", ' "$serialid" printf -- 'RUN+="%s --settled --unique --onetime ' "$(command -v initqueue)" printf -- '--name cryptroot-ask-%%k %s ' "$(command -v cryptroot-ask)" printf -- '$env{DEVNAME} %s %s"\n' "$luksname" "$tout" } >> /etc/udev/rules.d/70-luks.rules.new else luksname=$(dev_unit_name "$luksname") luksname="$(str_replace "$luksname" '\' '\\')" if ! crypttab_contains "$serialid"; then { printf -- 'ENV{ID_SERIAL_SHORT}=="*%s*", ' "$serialid" printf -- 'RUN+="%s --settled --unique --onetime ' "$(command -v initqueue)" printf -- '--name systemd-cryptsetup-%%k %s start ' "$(command -v systemctl)" printf -- 'systemd-cryptsetup@%s.service"\n' "$luksname" } >> /etc/udev/rules.d/70-luks.rules.new fi fi done elif [ -n "$LUKS" ]; then for luksid in $LUKS; do luksid=${luksid##luks-} if luksname=$(_cryptgetargsname "rd.luks.name=$luksid="); then luksname="${luksname#$luksid=}" else luksname="luks-$luksid" fi if [ -z "$DRACUT_SYSTEMD" ]; then { printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", ' printf -- 'ENV{ID_FS_UUID}=="*%s*", ' "$luksid" printf -- 'RUN+="%s --settled --unique --onetime ' "$(command -v initqueue)" printf -- '--name cryptroot-ask-%%k %s ' "$(command -v cryptroot-ask)" printf -- '$env{DEVNAME} %s %s"\n' "$luksname" "$tout" } >> /etc/udev/rules.d/70-luks.rules.new else luksname=$(dev_unit_name "$luksname") luksname="$(str_replace "$luksname" '\' '\\')" if ! crypttab_contains "$luksid"; then { printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", ' printf -- 'ENV{ID_FS_UUID}=="*%s*", ' "$luksid" printf -- 'RUN+="%s --settled --unique --onetime ' "$(command -v initqueue)" printf -- '--name systemd-cryptsetup-%%k %s start ' "$(command -v systemctl)" printf -- 'systemd-cryptsetup@%s.service"\n' "$luksname" } >> /etc/udev/rules.d/70-luks.rules.new fi fi uuid=$luksid while [ "$uuid" != "${uuid#*-}" ]; do uuid=${uuid%%-*}${uuid#*-}; done printf -- '[ -e /dev/disk/by-id/dm-uuid-CRYPT-LUKS?-*%s*-* ] || exit 1\n' $uuid \ >> "$hookdir/initqueue/finished/90-crypt.sh" { printf -- '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid printf -- 'warn "crypto LUKS UUID "%s" not found"\n' $luksid } >> "$hookdir/emergency/90-crypt.sh" done elif getargbool 0 rd.auto; then if [ -z "$DRACUT_SYSTEMD" ]; then { printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' "$(command -v initqueue)" printf -- '--unique --settled --onetime --name cryptroot-ask-%%k ' printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' "$(command -v cryptroot-ask)" "$tout" } >> /etc/udev/rules.d/70-luks.rules.new else { printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' "$(command -v initqueue)" printf -- '--unique --settled --onetime --name crypt-run-generator-%%k ' printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID}"\n' "$(command -v crypt-run-generator)" } >> /etc/udev/rules.d/70-luks.rules.new fi fi echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules.new mv /etc/udev/rules.d/70-luks.rules.new /etc/udev/rules.d/70-luks.rules fi modules.d/90crypt/crypt-cleanup.sh000075500000000672152525045230013105 0ustar00#!/bin/sh # close everything which is not busy rm -f -- /etc/udev/rules.d/70-luks.rules >/dev/null 2>&1 if ! getarg rd.luks.uuid -d rd_LUKS_UUID >/dev/null 2>&1 && getargbool 1 rd.luks -d -n rd_NO_LUKS >/dev/null 2>&1; then while true; do local do_break="y" for i in /dev/mapper/luks-*; do cryptsetup luksClose $i >/dev/null 2>&1 && do_break=n done [ "$do_break" = "y" ] && break done fi modules.d/90crypt/probe-keydev.sh000075500000000576152525045230012716 0ustar00#!/bin/sh . /lib/dracut-crypt-lib.sh real_keydev="$1"; keypath="$2"; luksdev="$3" [ -z "$real_keydev" -o -z "$keypath" ] && die 'probe-keydev: wrong usage!' [ -z "$luksdev" ] && luksdev='*' info "Probing $real_keydev for $keypath..." test_dev -f "$real_keydev" "$keypath" || exit 1 info "Found $keypath on $real_keydev" echo "$luksdev:$real_keydev:$keypath" >> /tmp/luks.keys modules.d/90crypt/parse-keydev.sh000075500000002541152525045230012713 0ustar00#!/bin/sh if getargbool 1 rd.luks -n rd_NO_LUKS && \ [ -n "$(getarg rd.luks.key)" ]; then exec 7>/etc/udev/rules.d/65-luks-keydev.rules echo 'SUBSYSTEM!="block", GOTO="luks_keydev_end"' >&7 echo 'ACTION!="add|change", GOTO="luks_keydev_end"' >&7 for arg in $(getargs rd.luks.key); do unset keypath keydev luksdev splitsep : "$arg" keypath keydev luksdev info "rd.luks.key: keypath='$keypath' keydev='$keydev' luksdev='$luksdev'" if [ -z "$keypath" ]; then warn 'keypath required!' continue fi # A keydev of '/' is treated as the initrd itself if [ "/" == "$keydev" ]; then [ -z "$luksdev" ] && luksdev='*' echo "$luksdev:$keydev:$keypath" >> /tmp/luks.keys continue elif [ -n "$keydev" ]; then udevmatch "$keydev" >&7 || { warn 'keydev incorrect!' continue } printf ', ' >&7 fi { printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue) printf -- '--name probe-keydev-%%k ' printf -- '%s /dev/%%k %s %s"\n' \ $(command -v probe-keydev) "${keypath}" "${luksdev}" } >&7 done unset arg keypath keydev luksdev echo 'LABEL="luks_keydev_end"' >&7 exec 7>&- fi modules.d/90crypt/cryptroot-ask.sh000075500000011406152525045230013135 0ustar00#!/bin/sh PATH=/usr/sbin:/usr/bin:/sbin:/bin NEWROOT=${NEWROOT:-"/sysroot"} # do not ask, if we already have root [ -f $NEWROOT/proc ] && exit 0 . /lib/dracut-lib.sh # if device name is /dev/dm-X, convert to /dev/mapper/name if [ "${1##/dev/dm-}" != "$1" ]; then device="/dev/mapper/$(dmsetup info -c --noheadings -o name "$1")" else device="$1" fi # default luksname - luks-UUID luksname=$2 # number of tries numtries=${3:-10} # TODO: improve to support what cmdline does if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -d -n rd_NO_CRYPTTAB; then while read name dev luksfile luksoptions || [ -n "$name" ]; do # ignore blank lines and comments if [ -z "$name" -o "${name#\#}" != "$name" ]; then continue fi # PARTUUID used in crypttab if [ "${dev%%=*}" = "PARTUUID" ]; then if [ "luks-${dev##PARTUUID=}" = "$luksname" ]; then luksname="$name" break fi # UUID used in crypttab elif [ "${dev%%=*}" = "UUID" ]; then if [ "luks-${dev##UUID=}" = "$luksname" ]; then luksname="$name" break fi # ID used in crypttab elif [ "${dev%%=*}" = "ID" ]; then if [ "luks-${dev##ID=}" = "$luksname" ]; then luksname="$name" break fi # path used in crypttab else cdev=$(readlink -f $dev) mdev=$(readlink -f $device) if [ "$cdev" = "$mdev" ]; then luksname="$name" break fi fi done < /etc/crypttab unset name dev fi # check if destination already exists [ -b /dev/mapper/$luksname ] && exit 0 # we already asked for this device asked_file=/tmp/cryptroot-asked-$luksname [ -f $asked_file ] && exit 0 # load dm_crypt if it is not already loaded [ -d /sys/module/dm_crypt ] || modprobe dm_crypt . /lib/dracut-crypt-lib.sh # # Open LUKS device # info "luksOpen $device $luksname $luksfile $luksoptions" OLD_IFS="$IFS" IFS=, set -- $luksoptions IFS="$OLD_IFS" while [ $# -gt 0 ]; do case $1 in noauto) # skip this exit 0 ;; swap) # skip this exit 0 ;; tmp) # skip this exit 0 ;; allow-discards) allowdiscards="--allow-discards" ;; header=*) cryptsetupopts="${cryptsetupopts} --${1}" ;; esac shift done # parse for allow-discards if strstr "$(cryptsetup --help)" "allow-discards"; then if discarduuids=$(getargs "rd.luks.allow-discards"); then discarduuids=$(str_replace "$discarduuids" 'luks-' '') if strstr " $discarduuids " " ${luksdev##luks-}"; then allowdiscards="--allow-discards" fi elif getargbool 0 rd.luks.allow-discards; then allowdiscards="--allow-discards" fi fi if strstr "$(cryptsetup --help)" "allow-discards"; then cryptsetupopts="$cryptsetupopts $allowdiscards" fi unset allowdiscards # fallback to passphrase ask_passphrase=1 if [ -n "$luksfile" -a "$luksfile" != "none" -a -e "$luksfile" ]; then if cryptsetup --key-file "$luksfile" $cryptsetupopts luksOpen "$device" "$luksname"; then ask_passphrase=0 fi else while [ -n "$(getarg rd.luks.key)" ]; do if tmp=$(getkey /tmp/luks.keys $device); then keydev="${tmp%%:*}" keypath="${tmp#*:}" else if [ $numtries -eq 0 ]; then warn "No key found for $device. Fallback to passphrase mode." break fi sleep 1 info "No key found for $device. Will try $numtries time(s) more later." initqueue --unique --onetime --settled \ --name cryptroot-ask-$luksname \ $(command -v cryptroot-ask) "$device" "$luksname" "$(($numtries-1))" exit 0 fi unset tmp info "Using '$keypath' on '$keydev'" readkey "$keypath" "$keydev" "$device" \ | cryptsetup -d - $cryptsetupopts luksOpen "$device" "$luksname" unset keypath keydev ask_passphrase=0 break done fi if [ $ask_passphrase -ne 0 ]; then luks_open="$(command -v cryptsetup) $cryptsetupopts luksOpen" _timeout=$(getargs "rd.luks.timeout") _timeout=${_timeout:-0} ask_for_password --ply-tries 5 \ --ply-cmd "$luks_open -T1 $device $luksname" \ --ply-prompt "Password ($device)" \ --tty-tries 1 \ --tty-cmd "$luks_open -T5 -t $_timeout $device $luksname" unset luks_open unset _timeout fi unset device luksname luksfile # mark device as asked >> $asked_file need_shutdown udevsettle exit 0 modules.d/90crypt/module-setup.sh000075500000011154152525045230012737 0ustar00#!/bin/bash # called by dracut check() { local _rootdev # if cryptsetup is not installed, then we cannot support encrypted devices. require_any_binary $systemdutildir/systemd-cryptsetup cryptsetup || return 1 [[ $hostonly ]] || [[ $mount_needs ]] && { for fs in "${host_fs_types[@]}"; do [[ $fs = "crypto_LUKS" ]] && return 0 done return 255 } return 0 } # called by dracut depends() { echo dm rootfs-block return 0 } # called by dracut installkernel() { hostonly="" instmods drbg arch=$(arch) [[ $arch == x86_64 ]] && arch=x86 [[ $arch == s390x ]] && arch=s390 instmods dm_crypt =crypto =drivers/crypto =arch/$arch/crypto } # called by dracut cmdline() { local dev UUID for dev in "${!host_fs_types[@]}"; do [[ "${host_fs_types[$dev]}" != "crypto_LUKS" ]] && continue UUID=$( blkid -u crypto -o export $dev \ | while read line || [ -n "$line" ]; do [[ ${line#UUID} = $line ]] && continue printf "%s" "${line#UUID=}" break done ) [[ ${UUID} ]] || continue printf "%s" " rd.luks.uuid=luks-${UUID}" done } # called by dracut install() { if [[ $hostonly_cmdline == "yes" ]]; then local _cryptconf=$(cmdline) [[ $_cryptconf ]] && printf "%s\n" "$_cryptconf" >> "${initdir}/etc/cmdline.d/90crypt.conf" fi inst_hook cmdline 30 "$moddir/parse-crypt.sh" if ! dracut_module_included "systemd"; then inst_multiple cryptsetup rmdir readlink umount inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask inst_script "$moddir"/probe-keydev.sh /sbin/probe-keydev inst_hook cmdline 10 "$moddir/parse-keydev.sh" inst_hook cleanup 30 "$moddir/crypt-cleanup.sh" fi if [[ $hostonly ]] && [[ -f /etc/crypttab ]]; then # filter /etc/crypttab for the devices we need while read _mapper _dev _luksfile _luksoptions || [ -n "$_mapper" ]; do [[ $_mapper = \#* ]] && continue [[ $_dev ]] || continue [[ $_dev == PARTUUID=* ]] && \ _dev="/dev/disk/by-partuuid/${_dev#PARTUUID=}" [[ $_dev == UUID=* ]] && \ _dev="/dev/disk/by-uuid/${_dev#UUID=}" [[ $_dev == ID=* ]] && \ _dev="/dev/disk/by-id/${_dev#ID=}" echo "$_dev $(blkid $_dev -s UUID -o value)" >> "${initdir}/etc/block_uuid.map" # loop through the options to check for the force option luksoptions=${_luksoptions} OLD_IFS="${IFS}" IFS=, set -- ${luksoptions} IFS="${OLD_IFS}" while [ $# -gt 0 ]; do case $1 in force) forceentry="yes" break ;; esac shift done # include the entry regardless if [ "${forceentry}" = "yes" ]; then echo "$_mapper $_dev $_luksfile $_luksoptions" else for _hdev in "${!host_fs_types[@]}"; do [[ ${host_fs_types[$_hdev]} == "crypto_LUKS" ]] || continue if [[ $_hdev -ef $_dev ]] || [[ /dev/block/$_hdev -ef $_dev ]]; then echo "$_mapper $_dev $_luksfile $_luksoptions" break fi done fi done < /etc/crypttab > $initdir/etc/crypttab mark_hostonly /etc/crypttab fi inst_simple "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh" if dracut_module_included "systemd"; then # the cryptsetup targets are already pulled in by 00systemd, but not # the enablement symlinks inst_multiple -o \ $systemdutildir/system-generators/systemd-cryptsetup-generator \ $systemdutildir/systemd-cryptsetup \ $systemdsystemunitdir/systemd-ask-password-console.path \ $systemdsystemunitdir/systemd-ask-password-console.service \ $systemdsystemunitdir/cryptsetup.target \ $systemdsystemunitdir/sysinit.target.wants/cryptsetup.target \ $systemdsystemunitdir/remote-cryptsetup.target \ $systemdsystemunitdir/initrd-root-device.target.wants/remote-cryptsetup.target \ systemd-ask-password systemd-tty-ask-password-agent inst_script "$moddir"/crypt-run-generator.sh /sbin/crypt-run-generator fi dracut_need_initqueue } modules.d/90kernel-network-modules/module-setup.sh000075500000002614152525045230016214 0ustar00#!/bin/bash # called by dracut check() { return 255 } # called by dracut depends() { return 0 } # called by dracut installkernel() { # Include wired net drivers, excluding wireless local _arch=$(uname -m) local _net_symbols='eth_type_trans|register_virtio_device|usbnet_open' local _unwanted_drivers='/(wireless|isdn|uwb|net/ethernet|net/phy|net/team)/' local _net_drivers if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then dracut_instmods -o -P ".*${_unwanted_drivers}.*" -s "$_net_symbols" "=drivers/s390/net" fi if [[ $hostonly_mode == 'strict' ]] && [[ -n ${hostonly_nics+x} ]]; then for _nic in $hostonly_nics; do _net_drivers=$(get_dev_module /sys/class/net/$_nic) if ! [[ $_net_drivers ]]; then derror "--hostonly-nics contains invalid NIC '$_nic'" continue fi hostonly="" instmods $_net_drivers done return 0 fi dracut_instmods -o -P ".*${_unwanted_drivers}.*" -s "$_net_symbols" "=drivers/net" #instmods() will take care of hostonly instmods \ =drivers/net/phy \ =drivers/net/team \ =drivers/net/ethernet \ ecb arc4 bridge stp llc ipv6 bonding 8021q ipvlan macvlan af_packet virtio_net xennet hostonly="" instmods iscsi_ibft crc32c iscsi_boot_sysfs } # called by dracut install() { return 0 } modules.d/04watchdog-modules/module-setup.sh000075500000003623152525045230015041 0ustar00#!/bin/bash # called by dracut check() { return 255 } # called by dracut depends() { return 0 } # called by dracut install() { return 0 } installkernel() { local -A _drivers local _alldrivers _wdtdrv _wdtppath _dir [[ -d /sys/class/watchdog/ ]] || return for _dir in /sys/class/watchdog/*; do [[ -d "$_dir" ]] || continue [[ -f "$_dir/state" ]] || continue # device/modalias will return driver of this device _wdtdrv=$(< "$_dir/device/modalias") # There can be more than one module represented by same # modalias. Currently load all of them. # TODO: Need to find a way to avoid any unwanted module # represented by modalias _wdtdrv=$(modprobe --set-version "$kernel" -R $_wdtdrv 2>/dev/null) if [[ $_wdtdrv ]]; then instmods $_wdtdrv for i in $_wdtdrv; do _drivers[$i]=1 done fi # however in some cases, we also need to check that if there is # a specific driver for the parent bus/device. In such cases # we also need to enable driver for parent bus/device. _wdtppath=$(readlink -f "$_dir/device") while [[ -d "$_wdtppath" ]] && [[ "$_wdtppath" != "/sys" ]]; do _wdtppath=$(readlink -f "$_wdtppath/..") [[ -f "$_wdtppath/modalias" ]] || continue _wdtdrv=$(< "$_wdtppath/modalias") _wdtdrv=$(modprobe --set-version "$kernel" -R $_wdtdrv 2>/dev/null) if [[ $_wdtdrv ]]; then instmods $_wdtdrv for i in $_wdtdrv; do _drivers[$i]=1 done fi done done # ensure that watchdog module is loaded as early as possible _alldrivers="${!_drivers[*]}" [[ $_alldrivers ]] && echo "rd.driver.pre=${_alldrivers// /,}" > ${initdir}/etc/cmdline.d/00-watchdog.conf return 0 } modules.d/98dracut-systemd/dracut-mount.sh000075500000002034152525045230014552 0ustar00#!/bin/sh export DRACUT_SYSTEMD=1 if [ -f /dracut-state.sh ]; then . /dracut-state.sh 2>/dev/null fi type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh source_conf /etc/conf.d make_trace_mem "hook mount" '1:shortmem' '2+:mem' '3+:slab' getarg 'rd.break=mount' -d 'rdbreak=mount' && emergency_shell -n mount "Break mount" # mount scripts actually try to mount the root filesystem, and may # be sourced any number of times. As soon as one suceeds, no more are sourced. i=0 while :; do if ismounted "$NEWROOT"; then usable_root "$NEWROOT" && break; umount "$NEWROOT" fi for f in $hookdir/mount/*.sh; do [ -f "$f" ] && . "$f" if ismounted "$NEWROOT"; then usable_root "$NEWROOT" && break; warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook" umount "$NEWROOT" rm -f -- "$f" fi done i=$(($i+1)) [ $i -gt 20 ] && emergency_shell "Can't mount root filesystem" done export -p > /dracut-state.sh exit 0 modules.d/98dracut-systemd/dracut-pre-pivot.service.8.asc000064400000000655152525045230017302 0ustar00DRACUT-PRE-PIVOT.SERVICE(8) =========================== :doctype: manpage :man source: dracut :man manual: dracut NAME ---- dracut-pre-pivot.service - runs the dracut hooks before switching root SYNOPSIS -------- dracut-pre-pivot.service DESCRIPTION ----------- This service runs all dracut hooks before the system switched to the real root. AUTHORS ------- Harald Hoyer SEE ALSO -------- *dracut.bootup*(7) *dracut*(8) modules.d/98dracut-systemd/dracut-initqueue.service000064400000001465152525045230016452 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=dracut initqueue hook Documentation=man:dracut-initqueue.service(8) DefaultDependencies=no Before=remote-fs-pre.target Wants=remote-fs-pre.target After=systemd-udev-trigger.service Wants=systemd-udev-trigger.service ConditionPathExists=/usr/lib/initrd-release ConditionPathExists=|/lib/dracut/need-initqueue ConditionKernelCommandLine=|rd.break=initqueue Conflicts=shutdown.target emergency.target [Service] Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot Type=oneshot ExecStart=-/bin/dracut-initqueue StandardInput=null StandardOutput=syslog StandardError=syslog+console KillMode=process RemainAfterExit=yes # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP modules.d/98dracut-systemd/dracut-cmdline.service000064400000001610152525045230016045 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=dracut cmdline hook Documentation=man:dracut-cmdline.service(8) DefaultDependencies=no Before=dracut-pre-udev.service After=systemd-journald.socket Wants=systemd-journald.socket ConditionPathExists=/usr/lib/initrd-release ConditionPathExistsGlob=|/etc/cmdline.d/*.conf ConditionDirectoryNotEmpty=|/lib/dracut/hooks/cmdline ConditionKernelCommandLine=|rd.break=cmdline ConditionKernelCommandLine=|resume ConditionKernelCommandLine=|noresume Conflicts=shutdown.target emergency.target [Service] Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot Type=oneshot ExecStart=-/bin/dracut-cmdline StandardInput=null StandardOutput=syslog StandardError=syslog+console KillMode=process RemainAfterExit=yes # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP modules.d/98dracut-systemd/dracut-pre-mount.service000064400000001466152525045230016371 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=dracut pre-mount hook Documentation=man:dracut-pre-mount.service(8) DefaultDependencies=no Before=initrd-root-fs.target sysroot.mount systemd-fsck-root.service After=dracut-initqueue.service cryptsetup.target ConditionPathExists=/usr/lib/initrd-release ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-mount ConditionKernelCommandLine=|rd.break=pre-mount Conflicts=shutdown.target emergency.target [Service] Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot Type=oneshot ExecStart=-/bin/dracut-pre-mount StandardInput=null StandardOutput=syslog StandardError=syslog+console KillMode=process RemainAfterExit=yes # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP modules.d/98dracut-systemd/dracut-pre-mount.sh000075500000000766152525045230015350 0ustar00#!/bin/sh export DRACUT_SYSTEMD=1 if [ -f /dracut-state.sh ]; then . /dracut-state.sh 2>/dev/null fi type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh source_conf /etc/conf.d make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' # pre pivot scripts are sourced just before we doing cleanup and switch over # to the new root. getarg 'rd.break=pre-mount' 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount" source_hook pre-mount export -p > /dracut-state.sh exit 0 modules.d/98dracut-systemd/dracut-emergency.sh000075500000002546152525045230015376 0ustar00#!/bin/sh export DRACUT_SYSTEMD=1 if [ -f /dracut-state.sh ]; then . /dracut-state.sh 2>/dev/null fi type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh source_conf /etc/conf.d type plymouth >/dev/null 2>&1 && plymouth quit export _rdshell_name="dracut" action="Boot" hook="emergency" _emergency_action=$(getarg rd.emergency) if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then FSTXT="/run/dracut/fsck/fsck_help_$fstype.txt" source_hook "$hook" echo rdsosreport echo echo echo 'Entering emergency mode. Exit the shell to continue.' echo 'Type "journalctl" to view system logs.' echo 'You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot' echo 'after mounting them and attach it to a bug report.' echo echo [ -f "$FSTXT" ] && cat "$FSTXT" [ -f /etc/profile ] && . /etc/profile [ -z "$PS1" ] && export PS1="$_name:\${PWD}# " exec sh -i -l else export hook="shutdown-emergency" warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line." source_hook "$hook" [ -z "$_emergency_action" ] && _emergency_action=halt fi /bin/rm -f -- /.console_lock case "$_emergency_action" in reboot) reboot || exit 1;; poweroff) poweroff || exit 1;; halt) halt || exit 1;; esac exit 0 modules.d/98dracut-systemd/dracut-pre-udev.service.8.asc000064400000000650152525045230017077 0ustar00DRACUT-PRE-UDEV.SERVICE(8) ========================== :doctype: manpage :man source: dracut :man manual: dracut NAME ---- dracut-pre-udev.service - runs the dracut hooks before udevd is started SYNOPSIS -------- dracut-pre-udev.service DESCRIPTION ----------- This service runs all dracut hooks before udevd is started in the initramfs. AUTHORS ------- Harald Hoyer SEE ALSO -------- *dracut.bootup*(7) *dracut*(8) modules.d/98dracut-systemd/dracut-mount.service.8000064400000002773152525045230015755 0ustar00'\" t .\" Title: dracut-mount.service .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/09/2018 .\" Manual: dracut .\" Source: dracut .\" Language: English .\" .TH "DRACUT\-MOUNT\&.SERV" "8" "10/09/2018" "dracut" "dracut" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" dracut-mount.service \- runs the dracut hooks after /sysroot is mounted .SH "SYNOPSIS" .sp dracut\-mount\&.service .SH "DESCRIPTION" .sp This service runs all dracut hooks after the real root is mounted on /sysroot\&. .SH "AUTHORS" .sp Harald Hoyer .SH "SEE ALSO" .sp \fBdracut\&.bootup\fR(7) \fBdracut\fR(8) modules.d/98dracut-systemd/dracut-shutdown-onfailure.service000064400000000465152525045230020276 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=Service executing upon dracut-shutdown failure to perform cleanup Documentation=man:dracut-shutdown.service(8) DefaultDependencies=no [Service] Type=oneshot ExecStart=-/bin/rm /run/initramfs/shutdown StandardError=null modules.d/98dracut-systemd/dracut-cmdline-ask.service000064400000001517152525045230016627 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=dracut ask for additional cmdline parameters DefaultDependencies=no Before=dracut-cmdline.service After=systemd-journald.socket After=systemd-vconsole-setup.service Requires=systemd-vconsole-setup.service Wants=systemd-journald.socket ConditionPathExists=/usr/lib/initrd-release ConditionKernelCommandLine=|rd.cmdline=ask ConditionPathExistsGlob=|/etc/cmdline.d/*.conf Conflicts=shutdown.target emergency.target [Service] Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot Type=oneshot ExecStart=-/bin/dracut-cmdline-ask StandardInput=tty StandardOutput=inherit StandardError=inherit RemainAfterExit=yes KillMode=process IgnoreSIGPIPE=no # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP modules.d/98dracut-systemd/dracut-pre-pivot.sh000075500000001577152525045230015350 0ustar00#!/bin/sh export DRACUT_SYSTEMD=1 if [ -f /dracut-state.sh ]; then . /dracut-state.sh 2>/dev/null fi type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh source_conf /etc/conf.d make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' # pre pivot scripts are sourced just before we doing cleanup and switch over # to the new root. getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot" source_hook pre-pivot # pre pivot cleanup scripts are sourced just before we switch over to the new root. getarg 'rd.break=cleanup' 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup" source_hook cleanup _bv=$(getarg rd.break -d rdbreak) && [ -z "$_bv" ] && emergency_shell -n switch_root "Break before switch_root" unset _bv # remove helper symlink [ -h /dev/root ] && rm -f -- /dev/root [ -h /dev/nfs ] && rm -f -- /dev/nfs exit 0 modules.d/98dracut-systemd/dracut-pre-trigger.service.8.asc000064400000000670152525045230017601 0ustar00DRACUT-PRE-TRIGGER.SERVICE(8) ============================= :doctype: manpage :man source: dracut :man manual: dracut NAME ---- dracut-pre-trigger.service - runs the dracut hooks before udevd is triggered SYNOPSIS -------- dracut-pre-trigger.service DESCRIPTION ----------- This service runs all dracut hooks before udevd is triggered in the initramfs. AUTHORS ------- Harald Hoyer SEE ALSO -------- *dracut.bootup*(7) *dracut*(8) modules.d/98dracut-systemd/dracut-pre-trigger.service000064400000001622152525045230016664 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=dracut pre-trigger hook Documentation=man:dracut-pre-trigger.service(8) DefaultDependencies=no Before=systemd-udev-trigger.service dracut-initqueue.service After=dracut-pre-udev.service systemd-udevd.service systemd-tmpfiles-setup-dev.service Wants=dracut-pre-udev.service systemd-udevd.service ConditionPathExists=/usr/lib/initrd-release ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-trigger ConditionKernelCommandLine=|rd.break=pre-trigger Conflicts=shutdown.target emergency.target [Service] Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot Type=oneshot ExecStart=-/bin/dracut-pre-trigger StandardInput=null StandardOutput=syslog StandardError=syslog+console KillMode=process RemainAfterExit=yes # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP modules.d/98dracut-systemd/dracut-pre-udev.service.8000064400000003001152525045230016323 0ustar00'\" t .\" Title: dracut-pre-udev.service .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/09/2018 .\" Manual: dracut .\" Source: dracut .\" Language: English .\" .TH "DRACUT\-PRE\-UDEV\&." "8" "10/09/2018" "dracut" "dracut" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" dracut-pre-udev.service \- runs the dracut hooks before udevd is started .SH "SYNOPSIS" .sp dracut\-pre\-udev\&.service .SH "DESCRIPTION" .sp This service runs all dracut hooks before udevd is started in the initramfs\&. .SH "AUTHORS" .sp Harald Hoyer .SH "SEE ALSO" .sp \fBdracut\&.bootup\fR(7) \fBdracut\fR(8) modules.d/98dracut-systemd/dracut-shutdown.service.8.asc000064400000003530152525045230017223 0ustar00DRACUT-SHUTDOWN.SERVICE(8) =========================== :doctype: manpage :man source: dracut :man manual: dracut NAME ---- dracut-shutdown.service - unpack the initramfs to /run/initramfs SYNOPSIS -------- dracut-shutdown.service DESCRIPTION ----------- This service unpacks the initramfs image to /run/initramfs. systemd pivots into /run/initramfs at shutdown, so the root filesystem can be safely unmounted. The following steps are executed during a shutdown: * systemd switches to the shutdown.target * systemd starts /lib/systemd/system/shutdown.target.wants/dracut-shutdown.service * dracut-shutdown.service executes /usr/lib/dracut/dracut-initramfs-restore which unpacks the initramfs to /run/initramfs * systemd finishes shutdown.target * systemd kills all processes * systemd tries to unmount everything and mounts the remaining read-only * systemd checks, if there is a /run/initramfs/shutdown executable * if yes, it does a pivot_root to /run/initramfs and executes ./shutdown. The old root is then mounted on /oldroot. /usr/lib/dracut/modules.d/99shutdown/shutdown.sh is the shutdown executable. * shutdown will try to umount every /oldroot mount and calls the various shutdown hooks from the dracut modules This ensures, that all devices are disassembled and unmounted cleanly. To debug the shutdown process, you can get a shell in the shutdown procedure by injecting "rd.break=pre-shutdown rd.shell" or "rd.break=shutdown rd.shell". ---- # mkdir -p /run/initramfs/etc/cmdline.d # echo "rd.break=pre-shutdown rd.shell" > /run/initramfs/etc/cmdline.d/debug.conf # touch /run/initramfs/.need_shutdown ---- In case the unpack of the initramfs fails, dracut-shutdown-onfailure.service executes to make sure switch root doesn't happen, since it would result in switching to an incomplete initramfs. AUTHORS ------- Harald Hoyer SEE ALSO -------- *dracut*(8) modules.d/98dracut-systemd/dracut-pre-trigger.sh000075500000000723152525045230015642 0ustar00#!/bin/sh export DRACUT_SYSTEMD=1 if [ -f /dracut-state.sh ]; then . /dracut-state.sh 2>/dev/null fi type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh source_conf /etc/conf.d make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' source_hook pre-trigger getarg 'rd.break=pre-trigger' 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break pre-trigger" udevadm control --reload >/dev/null 2>&1 || : export -p > /dracut-state.sh exit 0 modules.d/98dracut-systemd/dracut-initqueue.service.8.asc000064400000000667152525045230017370 0ustar00DRACUT-INITQUEUE.SERVICE(8) =========================== :doctype: manpage :man source: dracut :man manual: dracut NAME ---- dracut-initqueue.service - runs the dracut main loop to find the real root SYNOPSIS -------- dracut-initqueue.service DESCRIPTION ----------- This service runs all the main loop of dracut in the initramfs to find the real root. AUTHORS ------- Harald Hoyer SEE ALSO -------- *dracut.bootup*(7) *dracut*(8) modules.d/98dracut-systemd/dracut-initqueue.service.8000064400000003016152525045230016612 0ustar00'\" t .\" Title: dracut-initqueue.service .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/09/2018 .\" Manual: dracut .\" Source: dracut .\" Language: English .\" .TH "DRACUT\-INITQUEUE\&." "8" "10/09/2018" "dracut" "dracut" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" dracut-initqueue.service \- runs the dracut main loop to find the real root .SH "SYNOPSIS" .sp dracut\-initqueue\&.service .SH "DESCRIPTION" .sp This service runs all the main loop of dracut in the initramfs to find the real root\&. .SH "AUTHORS" .sp Harald Hoyer .SH "SEE ALSO" .sp \fBdracut\&.bootup\fR(7) \fBdracut\fR(8) modules.d/98dracut-systemd/dracut-pre-udev.sh000075500000002605152525045230015143 0ustar00#!/bin/sh export DRACUT_SYSTEMD=1 if [ -f /dracut-state.sh ]; then . /dracut-state.sh 2>/dev/null fi type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh source_conf /etc/conf.d make_trace_mem "hook pre-udev" '1:shortmem' '2+:mem' '3+:slab' # pre pivot scripts are sourced just before we doing cleanup and switch over # to the new root. getarg 'rd.break=pre-udev' 'rdbreak=pre-udev' && emergency_shell -n pre-udev "Break pre-udev" source_hook pre-udev _modprobe_d=/etc/modprobe.d if [ -d /usr/lib/modprobe.d ] ; then _modprobe_d=/usr/lib/modprobe.d elif [ -d /lib/modprobe.d ] ; then _modprobe_d=/lib/modprobe.d elif [ ! -d $_modprobe_d ] ; then mkdir -p $_modprobe_d fi for i in $(getargs rd.driver.pre -d rdloaddriver=); do ( IFS=, for p in $i; do modprobe $p 2>&1 | vinfo done ) done [ -d /etc/modprobe.d ] || mkdir -p /etc/modprobe.d for i in $(getargs rd.driver.blacklist -d rdblacklist=); do ( IFS=, for p in $i; do echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf done ) done for p in $(getargs rd.driver.post -d rdinsmodpost=); do echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf _do_insmodpost=1 done [ -n "$_do_insmodpost" ] && initqueue --settled --unique --onetime insmodpost.sh unset _do_insmodpost _modprobe_d unset i export -p > /dracut-state.sh exit 0 modules.d/98dracut-systemd/dracut-pre-pivot.service000064400000002145152525045230016363 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=dracut pre-pivot and cleanup hook Documentation=man:dracut-pre-pivot.service(8) DefaultDependencies=no After=initrd.target initrd-parse-etc.service sysroot.mount After=dracut-initqueue.service dracut-pre-mount.service dracut-mount.service Before=initrd-cleanup.service Wants=remote-fs.target After=remote-fs.target ConditionPathExists=/usr/lib/initrd-release ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-pivot ConditionDirectoryNotEmpty=|/lib/dracut/hooks/cleanup ConditionKernelCommandLine=|rd.break=pre-pivot ConditionKernelCommandLine=|rd.break=cleanup ConditionKernelCommandLine=|rd.break ConditionPathExists=|/dev/root ConditionPathExists=|/dev/nfs Conflicts=shutdown.target emergency.target [Service] Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot Type=oneshot ExecStart=-/bin/dracut-pre-pivot StandardInput=null StandardOutput=syslog StandardError=syslog+console KillMode=process RemainAfterExit=yes # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP modules.d/98dracut-systemd/dracut-mount.service000064400000001431152525045230015575 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=dracut mount hook Documentation=man:dracut-mount.service(8) After=initrd-root-fs.target initrd-parse-etc.service After=dracut-initqueue.service dracut-pre-mount.service ConditionPathExists=/usr/lib/initrd-release ConditionDirectoryNotEmpty=|/lib/dracut/hooks/mount ConditionKernelCommandLine=|rd.break=mount DefaultDependencies=no Conflicts=shutdown.target emergency.target [Service] Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot Type=oneshot ExecStart=-/bin/dracut-mount StandardInput=null StandardOutput=syslog StandardError=syslog+console KillMode=process RemainAfterExit=yes # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP modules.d/98dracut-systemd/dracut-pre-mount.service.8000064400000003012152525045230016524 0ustar00'\" t .\" Title: dracut-pre-mount.service .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/09/2018 .\" Manual: dracut .\" Source: dracut .\" Language: English .\" .TH "DRACUT\-PRE\-MOUNT\&" "8" "10/09/2018" "dracut" "dracut" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" dracut-pre-mount.service \- runs the dracut hooks before /sysroot is mounted .SH "SYNOPSIS" .sp dracut\-pre\-mount\&.service .SH "DESCRIPTION" .sp This service runs all dracut hooks before the real root is mounted on /sysroot\&. .SH "AUTHORS" .sp Harald Hoyer .SH "SEE ALSO" .sp \fBdracut\&.bootup\fR(7) \fBdracut\fR(8) modules.d/98dracut-systemd/dracut-mount.service.8.asc000064400000000640152525045230016511 0ustar00DRACUT-MOUNT.SERVICE(8) ======================= :doctype: manpage :man source: dracut :man manual: dracut NAME ---- dracut-mount.service - runs the dracut hooks after /sysroot is mounted SYNOPSIS -------- dracut-mount.service DESCRIPTION ----------- This service runs all dracut hooks after the real root is mounted on /sysroot. AUTHORS ------- Harald Hoyer SEE ALSO -------- *dracut.bootup*(7) *dracut*(8) modules.d/98dracut-systemd/dracut-pre-udev.service000064400000001741152525045230016166 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=dracut pre-udev hook Documentation=man:dracut-pre-udev.service(8) DefaultDependencies=no Before=systemd-udevd.service dracut-pre-trigger.service After=dracut-cmdline.service Wants=dracut-cmdline.service ConditionPathExists=/usr/lib/initrd-release ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-udev ConditionKernelCommandLine=|rd.break=pre-udev ConditionKernelCommandLine=|rd.driver.blacklist ConditionKernelCommandLine=|rd.driver.pre ConditionKernelCommandLine=|rd.driver.post ConditionPathExistsGlob=|/etc/cmdline.d/*.conf Conflicts=shutdown.target emergency.target [Service] Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot Type=oneshot ExecStart=-/bin/dracut-pre-udev StandardInput=null StandardOutput=syslog StandardError=syslog+console KillMode=process RemainAfterExit=yes # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP modules.d/98dracut-systemd/dracut-cmdline.service.8.asc000064400000000672152525045230016767 0ustar00DRACUT-CMDLINE.SERVICE(8) ========================= :doctype: manpage :man source: dracut :man manual: dracut NAME ---- dracut-cmdline.service - runs the dracut hooks to parse the kernel command line SYNOPSIS -------- dracut-cmdline.service DESCRIPTION ----------- This service runs all the dracut hooks to parse the kernel command line in the initramfs. AUTHORS ------- Harald Hoyer SEE ALSO -------- *dracut.bootup*(7) *dracut*(8) modules.d/98dracut-systemd/dracut-pre-pivot.service.8000064400000003005152525045230016525 0ustar00'\" t .\" Title: dracut-pre-pivot.service .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/09/2018 .\" Manual: dracut .\" Source: dracut .\" Language: English .\" .TH "DRACUT\-PRE\-PIVOT\&" "8" "10/09/2018" "dracut" "dracut" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" dracut-pre-pivot.service \- runs the dracut hooks before switching root .SH "SYNOPSIS" .sp dracut\-pre\-pivot\&.service .SH "DESCRIPTION" .sp This service runs all dracut hooks before the system switched to the real root\&. .SH "AUTHORS" .sp Harald Hoyer .SH "SEE ALSO" .sp \fBdracut\&.bootup\fR(7) \fBdracut\fR(8) modules.d/98dracut-systemd/dracut-shutdown.service.8000064400000007345152525045230016466 0ustar00'\" t .\" Title: dracut-shutdown.service .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 08/13/2026 .\" Manual: dracut .\" Source: dracut .\" Language: English .\" .TH "DRACUT\-SHUTDOWN\&.S" "8" "08/13/2026" "dracut" "dracut" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" dracut-shutdown.service \- unpack the initramfs to /run/initramfs .SH "SYNOPSIS" .sp dracut\-shutdown\&.service .SH "DESCRIPTION" .sp This service unpacks the initramfs image to /run/initramfs\&. systemd pivots into /run/initramfs at shutdown, so the root filesystem can be safely unmounted\&. .sp The following steps are executed during a shutdown: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} systemd switches to the shutdown\&.target .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} systemd starts /lib/systemd/system/shutdown\&.target\&.wants/dracut\-shutdown\&.service .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} dracut\-shutdown\&.service executes /usr/lib/dracut/dracut\-initramfs\-restore which unpacks the initramfs to /run/initramfs .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} systemd finishes shutdown\&.target .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} systemd kills all processes .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} systemd tries to unmount everything and mounts the remaining read\-only .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} systemd checks, if there is a /run/initramfs/shutdown executable .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} if yes, it does a pivot_root to /run/initramfs and executes \&./shutdown\&. The old root is then mounted on /oldroot\&. /usr/lib/dracut/modules\&.d/99shutdown/shutdown\&.sh is the shutdown executable\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} shutdown will try to umount every /oldroot mount and calls the various shutdown hooks from the dracut modules .RE .sp This ensures, that all devices are disassembled and unmounted cleanly\&. .sp To debug the shutdown process, you can get a shell in the shutdown procedure by injecting "rd\&.break=pre\-shutdown rd\&.shell" or "rd\&.break=shutdown rd\&.shell"\&. .sp .if n \{\ .RS 4 .\} .nf # mkdir \-p /run/initramfs/etc/cmdline\&.d # echo "rd\&.break=pre\-shutdown rd\&.shell" > /run/initramfs/etc/cmdline\&.d/debug\&.conf # touch /run/initramfs/\&.need_shutdown .fi .if n \{\ .RE .\} .sp In case the unpack of the initramfs fails, dracut\-shutdown\-onfailure\&.service executes to make sure switch root doesn\(cqt happen, since it would result in switching to an incomplete initramfs\&. .SH "AUTHORS" .sp Harald Hoyer .SH "SEE ALSO" .sp \fBdracut\fR(8) modules.d/98dracut-systemd/emergency.service000064400000001264152525045230015135 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=Emergency Shell DefaultDependencies=no After=systemd-vconsole-setup.service Wants=systemd-vconsole-setup.service Conflicts=shutdown.target Before=shutdown.target [Service] Environment=HOME=/ Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot WorkingDirectory=/ ExecStart=/bin/dracut-emergency ExecStopPost=-/usr/bin/systemctl --fail --no-block default Type=idle StandardInput=tty-force StandardOutput=inherit StandardError=inherit KillMode=process IgnoreSIGPIPE=no TasksMax=infinity # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP modules.d/98dracut-systemd/dracut-pre-mount.service.8.asc000064400000000662152525045230017301 0ustar00DRACUT-PRE-MOUNT.SERVICE(8) =========================== :doctype: manpage :man source: dracut :man manual: dracut NAME ---- dracut-pre-mount.service - runs the dracut hooks before /sysroot is mounted SYNOPSIS -------- dracut-pre-mount.service DESCRIPTION ----------- This service runs all dracut hooks before the real root is mounted on /sysroot. AUTHORS ------- Harald Hoyer SEE ALSO -------- *dracut.bootup*(7) *dracut*(8) modules.d/98dracut-systemd/rootfs-generator.sh000075500000010070152525045230015427 0ustar00#!/bin/sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh generator_wait_for_dev() { local _name local _timeout _name="$(str_replace "$1" '/' '\x2f')" _timeout=$(getarg rd.timeout) _timeout=${_timeout:-0} if ! [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ]; then # If a LUKS device needs unlocking via systemd in the initrd, assume # it's for the root device. In that case, don't block on it if it's # after remote-fs-pre.target since the initqueue is ordered before it so # it will never actually show up (think Tang-pinned rootfs). cat > "$hookdir/initqueue/finished/devexists-${_name}.sh" << EOF if ! grep -q After=remote-fs-pre.target /run/systemd/generator/systemd-cryptsetup@*.service 2>/dev/null; then [ -e "$1" ] fi EOF { printf '[ -e "%s" ] || ' $1 printf 'warn "\"%s\" does not exist"\n' $1 } >> "$hookdir/emergency/80-${_name}.sh" fi _name=$(dev_unit_name "$1") if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/${_name}.device ]; then [ -d "$GENERATOR_DIR"/initrd.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd.target.wants ln -s ../${_name}.device "$GENERATOR_DIR"/initrd.target.wants/${_name}.device fi if ! [ -f "$GENERATOR_DIR"/${_name}.device.d/timeout.conf ]; then mkdir -p "$GENERATOR_DIR"/${_name}.device.d { echo "[Unit]" echo "JobTimeoutSec=$_timeout" echo "JobRunningTimeoutSec=$_timeout" } > "$GENERATOR_DIR"/${_name}.device.d/timeout.conf fi } generator_mount_rootfs() { local _type=$2 local _flags=$3 local _name [ -z "$1" ] && return 0 _name=$(dev_unit_name "$1") [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR" if ! [ -f "$GENERATOR_DIR"/sysroot.mount ]; then { echo "[Unit]" echo "Before=initrd-root-fs.target" echo "Requires=systemd-fsck@${_name}.service" echo "After=systemd-fsck@${_name}.service" echo "[Mount]" echo "Where=/sysroot" echo "What=$1" echo "Options=${_flags}" echo "Type=${_type}" } > "$GENERATOR_DIR"/sysroot.mount fi if ! [ -L "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount ]; then [ -d "$GENERATOR_DIR"/initrd-root-fs.target.requires ] || mkdir -p "$GENERATOR_DIR"/initrd-root-fs.target.requires ln -s ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount fi } generator_fsck_after_pre_mount() { local _name [ -z "$1" ] && return 0 _name=$(dev_unit_name "$1") [ -d /run/systemd/generator/systemd-fsck@${_name}.service.d ] || mkdir -p /run/systemd/generator/systemd-fsck@${_name}.service.d if ! [ -f /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf ]; then { echo "[Unit]" echo "After=dracut-pre-mount.service" } > /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf fi } root=$(getarg root=) case "$root" in block:LABEL=*|LABEL=*) root="${root#block:}" root="$(echo $root | sed 's,/,\\x2f,g')" root="block:/dev/disk/by-label/${root#LABEL=}" rootok=1 ;; block:UUID=*|UUID=*) root="${root#block:}" root="block:/dev/disk/by-uuid/${root#UUID=}" rootok=1 ;; block:PARTUUID=*|PARTUUID=*) root="${root#block:}" root="block:/dev/disk/by-partuuid/${root#PARTUUID=}" rootok=1 ;; block:PARTLABEL=*|PARTLABEL=*) root="${root#block:}" root="block:/dev/disk/by-partlabel/${root#PARTLABEL=}" rootok=1 ;; /dev/nfs) # ignore legacy /dev/nfs ;; /dev/*) root="block:${root}" rootok=1 ;; esac GENERATOR_DIR="$1" if [ "$rootok" = "1" ]; then generator_wait_for_dev "${root#block:}" "$RDRETRY" generator_fsck_after_pre_mount "${root#block:}" strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)" fi exit 0 modules.d/98dracut-systemd/dracut-emergency.service000064400000001251152525045230016411 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=Dracut Emergency Shell DefaultDependencies=no After=systemd-vconsole-setup.service Wants=systemd-vconsole-setup.service Conflicts=shutdown.target emergency.target [Service] Environment=HOME=/ Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot WorkingDirectory=/ ExecStart=-/bin/dracut-emergency ExecStopPost=-/bin/rm -f -- /.console_lock Type=oneshot StandardInput=tty-force StandardOutput=inherit StandardError=inherit KillMode=process IgnoreSIGPIPE=no TasksMax=infinity # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP modules.d/98dracut-systemd/dracut-tmpfiles.conf000064400000000207152525045230015543 0ustar00d /run/initramfs 0755 root root - d /run/initramfs/log 0755 root root - L /var/log - - - - ../run/initramfs/log modules.d/98dracut-systemd/dracut-cmdline-ask.sh000075500000000642152525045230015602 0ustar00#!/bin/bash type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh getarg "rd.cmdline=ask" || exit 0 sleep 0.5 echo sleep 0.5 echo sleep 0.5 echo echo echo echo echo "Enter additional kernel command line parameter (end with ctrl-d or .)" while read -e -p "> " line || [ -n "$line" ]; do [[ "$line" == "." ]] && break [[ "$line" ]] && printf -- "%s\n" "$line" >> /etc/cmdline.d/99-cmdline-ask.conf done exit 0 modules.d/98dracut-systemd/module-setup.sh000075500000004030152525045230014551 0ustar00#!/bin/bash # called by dracut check() { [[ $mount_needs ]] && return 1 if ! dracut_module_included "systemd-initrd"; then derror "dracut-systemd needs systemd-initrd in the initramfs" return 1 fi return 0 } # called by dracut depends() { echo "systemd-initrd" return 0 } installkernel() { return 0 } # called by dracut install() { local _mods inst_script "$moddir/dracut-emergency.sh" /bin/dracut-emergency inst_simple "$moddir/emergency.service" ${systemdsystemunitdir}/emergency.service inst_simple "$moddir/dracut-emergency.service" ${systemdsystemunitdir}/dracut-emergency.service inst_simple "$moddir/emergency.service" ${systemdsystemunitdir}/rescue.service ln_r "${systemdsystemunitdir}/initrd.target" "${systemdsystemunitdir}/default.target" inst_script "$moddir/dracut-cmdline.sh" /bin/dracut-cmdline inst_script "$moddir/dracut-cmdline-ask.sh" /bin/dracut-cmdline-ask inst_script "$moddir/dracut-pre-udev.sh" /bin/dracut-pre-udev inst_script "$moddir/dracut-pre-trigger.sh" /bin/dracut-pre-trigger inst_script "$moddir/dracut-initqueue.sh" /bin/dracut-initqueue inst_script "$moddir/dracut-pre-mount.sh" /bin/dracut-pre-mount inst_script "$moddir/dracut-mount.sh" /bin/dracut-mount inst_script "$moddir/dracut-pre-pivot.sh" /bin/dracut-pre-pivot inst_script "$moddir/rootfs-generator.sh" $systemdutildir/system-generators/dracut-rootfs-generator mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants" for i in \ dracut-cmdline.service \ dracut-cmdline-ask.service \ dracut-initqueue.service \ dracut-mount.service \ dracut-pre-mount.service \ dracut-pre-pivot.service \ dracut-pre-trigger.service \ dracut-pre-udev.service \ ; do inst_simple "$moddir/${i}" "$systemdsystemunitdir/${i}" systemctl -q --root "$initdir" add-wants initrd.target "$i" done inst_simple "$moddir/dracut-tmpfiles.conf" "$tmpfilesdir/dracut-tmpfiles.conf" } modules.d/98dracut-systemd/dracut-cmdline.service.8000064400000003023152525045230016213 0ustar00'\" t .\" Title: dracut-cmdline.service .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/09/2018 .\" Manual: dracut .\" Source: dracut .\" Language: English .\" .TH "DRACUT\-CMDLINE\&.SE" "8" "10/09/2018" "dracut" "dracut" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" dracut-cmdline.service \- runs the dracut hooks to parse the kernel command line .SH "SYNOPSIS" .sp dracut\-cmdline\&.service .SH "DESCRIPTION" .sp This service runs all the dracut hooks to parse the kernel command line in the initramfs\&. .SH "AUTHORS" .sp Harald Hoyer .SH "SEE ALSO" .sp \fBdracut\&.bootup\fR(7) \fBdracut\fR(8) modules.d/98dracut-systemd/dracut-pre-trigger.service.8000064400000003016152525045230017031 0ustar00'\" t .\" Title: dracut-pre-trigger.service .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/09/2018 .\" Manual: dracut .\" Source: dracut .\" Language: English .\" .TH "DRACUT\-PRE\-TRIGGER" "8" "10/09/2018" "dracut" "dracut" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" dracut-pre-trigger.service \- runs the dracut hooks before udevd is triggered .SH "SYNOPSIS" .sp dracut\-pre\-trigger\&.service .SH "DESCRIPTION" .sp This service runs all dracut hooks before udevd is triggered in the initramfs\&. .SH "AUTHORS" .sp Harald Hoyer .SH "SEE ALSO" .sp \fBdracut\&.bootup\fR(7) \fBdracut\fR(8) modules.d/98dracut-systemd/dracut-shutdown.service000064400000000670152525045230016312 0ustar00# This file is part of dracut. # # See dracut.bootup(7) for details [Unit] Description=Restore /run/initramfs on shutdown Documentation=man:dracut-shutdown.service(8) After=local-fs.target boot.mount boot.automount Wants=local-fs.target ConditionPathExists=!/run/initramfs/bin/sh OnFailure=dracut-shutdown-onfailure.service [Service] RemainAfterExit=yes Type=oneshot ExecStart=/bin/true ExecStop=/usr/lib/dracut/dracut-initramfs-restore modules.d/98dracut-systemd/dracut-initqueue.sh000075500000004143152525045230015423 0ustar00#!/bin/sh export DRACUT_SYSTEMD=1 if [ -f /dracut-state.sh ]; then . /dracut-state.sh 2>/dev/null fi type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh source_conf /etc/conf.d make_trace_mem "hook initqueue" '1:shortmem' '2+:mem' '3+:slab' getarg 'rd.break=initqueue' -d 'rdbreak=initqueue' && emergency_shell -n initqueue "Break before initqueue" RDRETRY=$(getarg rd.retry -d 'rd_retry=') RDRETRY=${RDRETRY:-180} RDRETRY=$(($RDRETRY*2)) export RDRETRY main_loop=0 export main_loop while :; do check_finished && break udevadm settle --exit-if-exists=$hookdir/initqueue/work check_finished && break if [ -f $hookdir/initqueue/work ]; then rm -f -- "$hookdir/initqueue/work" fi for job in $hookdir/initqueue/*.sh; do [ -e "$job" ] || break job=$job . $job check_finished && break 2 done udevadm settle --timeout=0 >/dev/null 2>&1 || continue for job in $hookdir/initqueue/settled/*.sh; do [ -e "$job" ] || break job=$job . $job check_finished && break 2 done udevadm settle --timeout=0 >/dev/null 2>&1 || continue # no more udev jobs and queues empty. sleep 0.5 for i in /run/systemd/ask-password/ask.*; do [ -e "$i" ] && continue 2 done if [ $main_loop -gt $((2*$RDRETRY/3)) ]; then warn "dracut-initqueue timeout - starting timeout scripts" for job in $hookdir/initqueue/timeout/*.sh; do [ -e "$job" ] || break job=$job . $job udevadm settle --timeout=0 >/dev/null 2>&1 || main_loop=0 [ -f $hookdir/initqueue/work ] && main_loop=0 [ $main_loop -eq 0 ] && break done fi main_loop=$(($main_loop+1)) if [ $main_loop -gt $RDRETRY ]; then if ! [ -f /sysroot/etc/fstab ] || ! [ -e /sysroot/sbin/init ] ; then emergency_shell "Could not boot." fi warn "Not all disks have been found." warn "You might want to regenerate your initramfs." break fi done unset job unset queuetriggered unset main_loop unset RDRETRY export -p > /dracut-state.sh exit 0 modules.d/98dracut-systemd/dracut-cmdline.sh000075500000005133152525045230015026 0ustar00#!/bin/sh if [ -f /dracut-state.sh ]; then . /dracut-state.sh 2>/dev/null fi type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh [ -f /usr/lib/initrd-release ] && . /usr/lib/initrd-release [ -n "$VERSION" ] && info "dracut-$VERSION" if ! getargbool 1 'rd.hostonly'; then [ -f /etc/cmdline.d/99-cmdline-ask.conf ] && mv /etc/cmdline.d/99-cmdline-ask.conf /tmp/99-cmdline-ask.conf remove_hostonly_files [ -f /tmp/99-cmdline-ask.conf ] && mv /tmp/99-cmdline-ask.conf /etc/cmdline.d/99-cmdline-ask.conf fi info "Using kernel command line parameters:" $(getcmdline) getargbool 0 rd.udev.log-priority=info -d rd.udev.info -d -n -y rdudevinfo && echo 'udev_log="info"' >> /etc/udev/udev.conf getargbool 0 rd.udev.log-priority=debug -d rd.udev.debug -d -n -y rdudevdebug && echo 'udev_log="debug"' >> /etc/udev/udev.conf source_conf /etc/conf.d # Get the "root=" parameter from the kernel command line, but differentiate # between the case where it was set to the empty string and the case where it # wasn't specified at all. if ! root="$(getarg root=)"; then root_unset='UNSET' fi rflags="$(getarg rootflags=)" getargbool 0 ro && rflags="${rflags},ro" getargbool 0 rw && rflags="${rflags},rw" rflags="${rflags#,}" fstype="$(getarg rootfstype=)" if [ -z "$fstype" ]; then fstype="auto" fi export root export rflags export fstype make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' # run scriptlets to parse the command line getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline" source_hook cmdline [ -f /lib/dracut/parse-resume.sh ] && . /lib/dracut/parse-resume.sh case "${root}${root_unset}" in block:LABEL=*|LABEL=*) root="${root#block:}" root="$(echo $root | sed 's,/,\\x2f,g')" root="block:/dev/disk/by-label/${root#LABEL=}" rootok=1 ;; block:UUID=*|UUID=*) root="${root#block:}" root="block:/dev/disk/by-uuid/${root#UUID=}" rootok=1 ;; block:PARTUUID=*|PARTUUID=*) root="${root#block:}" root="block:/dev/disk/by-partuuid/${root#PARTUUID=}" rootok=1 ;; block:PARTLABEL=*|PARTLABEL=*) root="${root#block:}" root="block:/dev/disk/by-partlabel/${root#PARTLABEL=}" rootok=1 ;; /dev/*) root="block:${root}" rootok=1 ;; UNSET|gpt-auto) # systemd's gpt-auto-generator handles this case. rootok=1 ;; esac [ -z "${root}${root_unset}" ] && die "Empty root= argument" [ -z "$rootok" ] && die "Don't know how to handle 'root=$root'" export root rflags fstype netroot NEWROOT export -p > /dracut-state.sh exit 0 modules.d/95lunmask/parse-lunmask.sh000075500000002313152525045230013411 0ustar00#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh create_udev_rule() { local transport=$1 local tgtid=$2 local lun=$3 local _rule=/etc/udev/rules.d/51-${transport}-lunmask-${tgtid}.rules local _cu_type _dev_type [ -e ${_rule} ] && return 0 if [ ! -f "$_rule" ] ; then if [ "$transport" = "fc" ] ; then cat > $_rule < $_rule < /sys/module/scsi_mod/parameters/scan elif [ ! -f /etc/modprobe.d/95lunmask.conf ] ; then echo "options scsi_mod scan=manual" > /etc/modprobe.d/95lunmask.conf fi create_udev_rule $1 $2 $3 ) done modules.d/95lunmask/sas_transport_scan_lun.sh000075500000001070152525045230015412 0ustar00#!/bin/bash # # sas_transport_lun_scan # # Selectively enable individual LUNs behind a SAS end device # # ACTION=="add", SUBSYSTEM=="sas_transport", ATTR{sas_address}=="sas_addr", \ # PROGRAM="sas_transport_lun_scan lun" # [ -z $DEVPATH ] && exit 1 if [ -n "$1" ] ; then LUN=$1 else LUN=- fi ID=${DEVPATH##*/end_device-} HOST=${ID%%:*} CHANNEL=${ID%%-*} CHANNEL=${CHANNEL#*:} if [ -f /sys$DEVPATH/scsi_target_id ] ; then TARGET=$(cat /sys$DEVPATH/scsi_target_id) fi [ -z "$TARGET" ] && exit 1 echo 0 $TARGET $LUN > /sys/class/scsi_host/host$HOST/scan modules.d/95lunmask/fc_transport_scan_lun.sh000075500000001062152525045230015215 0ustar00#!/bin/bash # # fc_transport_lun_scan # # Selectively enable individual LUNs behind an FC remote port # # ACTION=="add", SUBSYSTEM=="fc_transport", ATTR{port_name}=="wwpn", \ # PROGRAM="fc_transport_lun_scan lun" # [ -z $DEVPATH ] && exit 1 if [ -n "$1" ] ; then LUN=$1 else LUN=- fi ID=${DEVPATH##*/rport-} HOST=${ID%%:*} CHANNEL=${ID%%-*} CHANNEL=${CHANNEL#*:} if [ -f /sys$DEVPATH/scsi_target_id ] ; then TARGET=$(cat /sys$DEVPATH/scsi_target_id) fi [ -z "$TARGET" ] && exit 1 echo $CHANNEL $TARGET $LUN > /sys/class/scsi_host/host$HOST/scan modules.d/95lunmask/module-setup.sh000075500000004316152525045230013257 0ustar00#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # called by dracut cmdline() { get_lunmask() { local _dev=$1 local _devpath=$(cd -P /sys/dev/block/$_dev ; echo $PWD) local _sdev _lun _rport _end_device _classdev _wwpn _sas_address [ "${_devpath#*/sd}" == "$_devpath" ] && return 1 _sdev="${_devpath%%/block/*}" _lun="${_sdev##*:}" # Check for FibreChannel _rport="${_devpath##*/rport-}" if [ "$_rport" != "$_devpath" ] ; then _rport="${_rport%%/*}" _classdev="/sys/class/fc_remote_ports/rport-${_rport}" [ -d "$_classdev" ] || return 1 _wwpn=$(cat ${_classdev}/port_name) echo "rd.lunmask=fc,${_wwpn},${_lun}" return 0 fi # Check for SAS _end_device="${_devpath##*/end_device-}" if [ "$_end_device" != "$_devpath" ] ; then _end_device="${_end_device%%/*}" _classdev="/sys/class/sas_device/end_device-${_end_device}" [ -e "$_classdev" ] || return 1 _sas_address=$(cat ${_classdev}/sas_address) echo "rd.lunmask=sas,${_sas_address},${_lun}" return 0 fi return 1 } [[ $hostonly ]] || [[ $mount_needs ]] && { for_each_host_dev_and_slaves_all get_lunmask } | sort | uniq } # called by dracut check() { [[ $hostonly ]] || [[ $mount_needs ]] && { [ -w /sys/module/scsi_mod/parameters/scan ] || return 255 scan_type=$(cat /sys/module/scsi_mod/parameters/scan) [ "$scan_type" = "manual" ] && return 0 return 255 } return 0 } # called by dracut depends() { return 0 } # called by dracut install() { inst_script "$moddir/fc_transport_scan_lun.sh" /usr/lib/udev/fc_transport_scan_lun.sh inst_script "$moddir/sas_transport_scan_lun.sh" /usr/lib/udev/sas_transport_scan_lun.sh inst_hook cmdline 30 "$moddir/parse-lunmask.sh" if [[ $hostonly_cmdline == "yes" ]] ; then local _lunmask for _lunmask in $(cmdline) ; do printf "%s\n" "$_lunmask" >> "${initdir}/etc/cmdline.d/95lunmask.conf" done fi } modules.d/30convertfs/do-convertfs.sh000075500000000302152525045230013560 0ustar00#!/bin/bash if getargbool 0 rd.convertfs; then if getargbool 0 rd.debug; then bash -x convertfs "$NEWROOT" 2>&1 | vinfo else convertfs "$NEWROOT" 2>&1 | vinfo fi fi modules.d/30convertfs/convertfs.sh000075500000013623152525045230013172 0ustar00#!/bin/bash ROOT="$1" if [[ ! -d "$ROOT" ]]; then echo "Usage: $0 " exit 1 fi if [[ "$ROOT" -ef / ]]; then echo "Can't convert the running system." echo "Please boot with 'rd.convertfs' on the kernel command line," echo "to update with the help of the initramfs," echo "or run this script from a rescue system." exit 1 fi while [[ "$ROOT" != "${ROOT%/}" ]]; do ROOT=${ROOT%/} done if [ ! -L $ROOT/var/run -a -e $ROOT/var/run ]; then echo "Converting /var/run to symlink" mv -f $ROOT/var/run $ROOT/var/run.runmove~ ln -sfn ../run $ROOT/var/run fi if [ ! -L $ROOT/var/lock -a -e $ROOT/var/lock ]; then echo "Converting /var/lock to symlink" mv -f $ROOT/var/lock $ROOT/var/lock.lockmove~ ln -sfn ../run/lock $ROOT/var/lock fi needconvert() { for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64"; do if [[ -e "$dir" ]]; then [[ -L "$dir" ]] || return 0 fi done return 1 } if ! [ -e "$ROOT/usr/bin" ]; then echo "$ROOT/usr/bin does not exist!" echo "Make sure, the kernel command line has enough information" echo "to mount /usr (man dracut.cmdline)" exit 1 fi if ! needconvert; then echo "Your system is already converted." exit 0 fi testfile="$ROOT/.usrmovecheck$$" rm -f -- "$testfile" > "$testfile" if [[ ! -e "$testfile" ]]; then echo "Cannot write to $ROOT/" exit 1 fi rm -f -- "$testfile" testfile="$ROOT/usr/.usrmovecheck$$" rm -f -- "$testfile" > "$testfile" if [[ ! -e "$testfile" ]]; then echo "Cannot write to $ROOT/usr/" exit 1 fi rm -f -- "$testfile" find_mount() { local dev mnt etc wanted_dev wanted_dev="$(readlink -e -q $1)" while read dev mnt etc || [ -n "$dev" ]; do [ "$dev" = "$wanted_dev" ] && echo "$dev" && return 0 done < /proc/mounts return 1 } # usage: ismounted # usage: ismounted /dev/ if command -v findmnt >/dev/null; then ismounted() { findmnt "$1" > /dev/null 2>&1 } else ismounted() { if [ -b "$1" ]; then find_mount "$1" > /dev/null && return 0 return 1 fi while read a m a || [ -n "$m" ]; do [ "$m" = "$1" ] && return 0 done < /proc/mounts return 1 } fi # clean up after ourselves no matter how we die. cleanup() { echo "Something failed. Move back to the original state" for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64" \ "$ROOT/usr/bin" "$ROOT/usr/sbin" "$ROOT/usr/lib" \ "$ROOT/usr/lib64"; do [[ -d "${dir}.usrmove-new" ]] && rm -fr -- "${dir}.usrmove-new" if [[ -d "${dir}.usrmove-old" ]]; then mv "$dir" "${dir}.del~" mv "${dir}.usrmove-old" "$dir" rm -fr -- "${dir}.del~" fi done } trap 'ret=$?; [[ $ret -ne 0 ]] && cleanup;exit $ret;' EXIT trap 'exit 1;' SIGINT ismounted "$ROOT/usr" || CP_HARDLINK="-l" set -e # merge / and /usr in new dir in /usr for dir in bin sbin lib lib64; do rm -rf -- "$ROOT/usr/${dir}.usrmove-new" [[ -L "$ROOT/$dir" ]] && continue [[ -d "$ROOT/$dir" ]] || continue echo "Make a copy of \`$ROOT/usr/$dir'." [[ -d "$ROOT/usr/$dir" ]] \ && cp -ax -l "$ROOT/usr/$dir" "$ROOT/usr/${dir}.usrmove-new" echo "Merge the copy with \`$ROOT/$dir'." [[ -d "$ROOT/usr/${dir}.usrmove-new" ]] \ || mkdir -p "$ROOT/usr/${dir}.usrmove-new" cp -axT $CP_HARDLINK --backup --suffix=.usrmove~ "$ROOT/$dir" "$ROOT/usr/${dir}.usrmove-new" echo "Clean up duplicates in \`$ROOT/usr/$dir'." # delete all symlinks that have been backed up find "$ROOT/usr/${dir}.usrmove-new" -type l -name '*.usrmove~' -delete || : # replace symlink with backed up binary find "$ROOT/usr/${dir}.usrmove-new" \ -name '*.usrmove~' \ -type f \ -exec bash -c 'p="{}";o=${p%%%%.usrmove~}; [[ -L "$o" ]] && mv -f "$p" "$o"' ';' || : done # switch over merged dirs in /usr for dir in bin sbin lib lib64; do [[ -d "$ROOT/usr/${dir}.usrmove-new" ]] || continue echo "Switch to new \`$ROOT/usr/$dir'." rm -fr -- "$ROOT/usr/${dir}.usrmove-old" mv "$ROOT/usr/$dir" "$ROOT/usr/${dir}.usrmove-old" mv "$ROOT/usr/${dir}.usrmove-new" "$ROOT/usr/$dir" done # replace dirs in / with links to /usr for dir in bin sbin lib lib64; do [[ -L "$ROOT/$dir" ]] && continue [[ -d "$ROOT/$dir" ]] || continue echo "Create \`$ROOT/$dir' symlink." rm -fr -- "$ROOT/${dir}.usrmove-old" || : mv "$ROOT/$dir" "$ROOT/${dir}.usrmove-old" ln -sfn usr/$dir "$ROOT/$dir" done echo "Clean up backup files." # everything seems to work; cleanup for dir in bin sbin lib lib64; do # if we get killed in the middle of "rm -rf", ensure not to leave # an incomplete directory, which is moved back by cleanup() [[ -d "$ROOT/usr/${dir}.usrmove-old" ]] \ && mv "$ROOT/usr/${dir}.usrmove-old" "$ROOT/usr/${dir}.usrmove-old~" [[ -d "$ROOT/${dir}.usrmove-old" ]] \ && mv "$ROOT/${dir}.usrmove-old" "$ROOT/${dir}.usrmove-old~" done for dir in bin sbin lib lib64; do [[ -d "$ROOT/usr/${dir}.usrmove-old~" ]] \ && rm -rf -- "$ROOT/usr/${dir}.usrmove-old~" || : [[ -d "$ROOT/${dir}.usrmove-old~" ]] \ && rm -rf -- "$ROOT/${dir}.usrmove-old~" || : done for dir in lib lib64; do [[ -d "$ROOT/$dir" ]] || continue for lib in "$ROOT"/usr/${dir}/lib*.so*.usrmove~; do [[ -f $lib ]] || continue mv $lib ${lib/.so/_so} done done set +e echo "Run ldconfig." ldconfig -r "$ROOT" . $ROOT/etc/selinux/config if [ -n "$(command -v setfiles)" ] && [ "$SELINUX" != "disabled" ] && [ -f /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts ]; then echo "Fixing SELinux labels" setfiles -r $ROOT -p /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts $ROOT/sbin $ROOT/bin $ROOT/lib $ROOT/lib64 $ROOT/usr/lib $ROOT/usr/lib64 $ROOT/etc/ld.so.cache $ROOT/var/cache/ldconfig || : fi echo "Done." exit 0 modules.d/30convertfs/module-setup.sh000075500000000520152525045230013574 0ustar00#!/bin/bash # called by dracut check() { [[ $mount_needs ]] && return 1 return 255 } # called by dracut depends() { return 0 } # called by dracut install() { inst_multiple bash find ldconfig mv rm cp ln inst_hook pre-pivot 99 "$moddir/do-convertfs.sh" inst_script "$moddir/convertfs.sh" /usr/bin/convertfs } modules.d/00bash/module-setup.sh000075500000000551152525045230012501 0ustar00#!/bin/bash # called by dracut check() { require_binaries /bin/bash } # called by dracut depends() { return 0 } # called by dracut install() { # If another shell is already installed, do not use bash [[ -x $initdir/bin/sh ]] && return # Prefer bash as /bin/sh if it is available. inst /bin/bash && ln -sf bash "${initdir}/bin/sh" } modules.d/95fcoe/stop-fcoe.sh000075500000000157152525045230011774 0ustar00#!/bin/bash for f in /sys/bus/fcoe/devices/ctlr_* ; do [ -e $f ] || continue echo 0 > $f/enabled done modules.d/95fcoe/parse-fcoe.sh000075500000003766152525045230012132 0ustar00#!/bin/sh # # Supported formats: # fcoe=:: # fcoe=:: # # Note currently only nodcb is supported, the dcb option is reserved for # future use. # # Note letters in the macaddress must be lowercase! # # Examples: # fcoe=eth0:nodcb:vn2vn # fcoe=4a:3f:4c:04:f8:d7:nodcb:fabric if ! getargbool 1 rd.fcoe -d -n rd.nofcoe ; then info "rd.fcoe=0: skipping fcoe" return 0 fi [ -z "$fcoe" ] && fcoe=$(getarg fcoe=) # If it's not set we don't continue [ -z "$fcoe" ] && return [ -e /sys/bus/fcoe/ctlr_create ] || modprobe -b -a fcoe || modprobe -b -a libfcoe || die "FCoE requested but kernel/initrd does not support FCoE" initqueue --onetime modprobe -b -q bnx2fc parse_fcoe_opts() { local OLDIFS="$IFS" local IFS=: set $fcoe IFS="$OLDIFS" case $# in 2) fcoe_interface=$1 fcoe_dcb=$2 fcoe_mode="fabric" return 0 ;; 3) fcoe_interface=$1 fcoe_dcb=$2 fcoe_mode=$3 return 0 ;; 7) fcoe_mac=$1:$2:$3:$4:$5:$6 fcoe_dcb=$7 fcoe_mode="fabric" return 0 ;; 8) fcoe_mac=$1:$2:$3:$4:$5:$6 fcoe_dcb=$7 fcoe_mode=$8 return 0 ;; *) warn "Invalid arguments for fcoe=$fcoe" return 1 ;; esac } parse_fcoe_opts if [ "$fcoe_interface" = "edd" ]; then if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ] ; then warn "Invalid FCoE DCB option: $fcoe_dcb" fi /sbin/initqueue --settled --unique /sbin/fcoe-edd $fcoe_dcb else for fcoe in $(getargs fcoe=); do unset fcoe_mac unset fcoe_interface parse_fcoe_opts if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ] ; then warn "Invalid FCoE DCB option: $fcoe_dcb" fi . $(command -v fcoe-genrules.sh) done fi modules.d/95fcoe/fcoe-up.sh000075500000004743152525045230011440 0ustar00#!/bin/sh # # We get called like this: # fcoe-up # # Note currently only nodcb is supported, the dcb option is reserved for # future use. PATH=/usr/sbin:/usr/bin:/sbin:/bin type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh # Huh? Missing arguments ?? [ -z "$1" -o -z "$2" ] && exit 1 netif=$1 dcb=$2 mode=$3 vlan="yes" iflink=$(cat /sys/class/net/$netif/iflink) ifindex=$(cat /sys/class/net/$netif/ifindex) if [ "$iflink" != "$ifindex" ] ; then # Skip VLAN devices exit 0 fi ip link set dev $netif up linkup "$netif" # Some fcoemon implementations expect --syslog=true syslogopt="--syslog" if fcoemon -h|grep syslog|grep -q yes; then fcoemonyes="$syslogopt=yes" fi netdriver=$(readlink -f /sys/class/net/$netif/device/driver) netdriver=${netdriver##*/} write_fcoemon_cfg() { [ -f /etc/fcoe/cfg-$netif ] && return echo FCOE_ENABLE=\"yes\" > /etc/fcoe/cfg-$netif if [ "$dcb" = "dcb" ]; then echo DCB_REQUIRED=\"yes\" >> /etc/fcoe/cfg-$netif else echo DCB_REQUIRED=\"no\" >> /etc/fcoe/cfg-$netif fi if [ "$vlan" = "yes" ]; then echo AUTO_VLAN=\"yes\" >> /etc/fcoe/cfg-$netif else echo AUTO_VLAN=\"no\" >> /etc/fcoe/cfg-$netif fi if [ "$mode" = "vn2vn" ] ; then echo MODE=\"vn2vn\" >> /etc/fcoe/cfg-$netif else echo MODE=\"fabric\" >> /etc/fcoe/cfg-$netif fi } if [ "$netdriver" = "bnx2x" ]; then # If driver is bnx2x, do not use /sys/module/fcoe/parameters/create but fipvlan modprobe 8021q udevadm settle --timeout=30 # Sleep for 13 s to allow dcb negotiation sleep 13 fipvlan "$netif" -c -s need_shutdown exit fi if [ "$dcb" = "dcb" ]; then # wait for lldpad to be ready i=0 while [ $i -lt 60 ]; do lldptool -p && break info "Waiting for lldpad to be ready" sleep 1 i=$(($i+1)) done while [ $i -lt 60 ]; do dcbtool sc "$netif" dcb on && break info "Retrying to turn dcb on" sleep 1 i=$(($i+1)) done while [ $i -lt 60 ]; do dcbtool sc "$netif" pfc e:1 a:1 w:1 && break info "Retrying to turn dcb on" sleep 1 i=$(($i+1)) done while [ $i -lt 60 ]; do dcbtool sc "$netif" app:fcoe e:1 a:1 w:1 && break info "Retrying to turn fcoe on" sleep 1 i=$(($i+1)) done sleep 1 fi write_fcoemon_cfg fcoemon $syslogopt need_shutdown modules.d/95fcoe/fcoe-genrules.sh000075500000002264152525045230012634 0ustar00#!/bin/sh # We use (fcoe_interface or fcoe_mac) and fcoe_dcb as set by parse-fcoe.sh # If neither mac nor interface are set we don't continue [ -z "$fcoe_interface" -a -z "$fcoe_mac" ] && return # Write udev rules { if [ -n "$fcoe_mac" ] ; then printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s %s"\n' "$fcoe_mac" "$fcoe_dcb" "$fcoe_mode" printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue --onetime --timeout --unique --name fcoe-timeout-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s %s"\n' "$fcoe_mac" "$fcoe_dcb" "$fcoe_mode" else printf 'ACTION=="add", SUBSYSTEM=="net", NAME=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s %s"\n' "$fcoe_interface" "$fcoe_dcb" "$fcoe_mode" printf 'ACTION=="add", SUBSYSTEM=="net", NAME=="%s", RUN+="/sbin/initqueue --onetime --timeout --unique --name fcoe-timeout-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s %s"\n' "$fcoe_interface" "$fcoe_dcb" "$fcoe_mode" fi } >> /etc/udev/rules.d/92-fcoe.rules modules.d/95fcoe/fcoe-edd.sh000075500000002212152525045230011535 0ustar00#!/bin/sh dcb="$1" _modprobe_r_edd="0" check_edd() { local cnt=0 [ -d /sys/firmware/edd ] && return 0 _modprobe_r_edd="1" modprobe edd || return $? while [ $cnt -lt 600 ]; do [ -d /sys/firmware/edd ] && return 0 cnt=$(($cnt+1)) sleep 0.1 done return 1 } check_edd || exit 1 for disk in /sys/firmware/edd/int13_*; do [ -d "$disk" ] || continue if [ -e "${disk}/pci_dev/driver" ]; then driver=$(readlink "${disk}/pci_dev/driver") driver=${driver##*/} fi # i40e uses dev_port 1 for a virtual fcoe function if [ "${driver}" = "i40e" ]; then dev_port=1 fi for nic in "${disk}"/pci_dev/net/*; do [ -d "$nic" ] || continue if [ -n "${dev_port}" -a -e "${nic}/dev_port" ]; then if [ "$(cat ${nic}/dev_port)" -ne "${dev_port}" ]; then continue fi fi if [ -e ${nic}/address ]; then fcoe_interface=${nic##*/} if ! [ -e "/tmp/.fcoe-$fcoe_interface" ]; then /sbin/fcoe-up "$fcoe_interface" "$dcb" > "/tmp/.fcoe-$fcoe_interface" fi fi done done [ "$_modprobe_r_edd" = "1" ] && modprobe -r edd unset _modprobe_r_edd modules.d/95fcoe/cleanup-fcoe.sh000075500000001040152525045230012426 0ustar00#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh if [ -e /var/run/lldpad.pid ]; then lldpad -k # with systemd version 230, this is not necessary anymore # systemd commit cacf980ed44a28e276a6cc7f8fc41f991e2ab354 if [ -z "$DRACUT_SYSTEMD" ]; then mkdir -m 0755 -p /run/initramfs/state/dev/shm cp /dev/shm/lldpad.state /run/initramfs/state/dev/shm/ > /dev/null 2>&1 echo "files /dev/shm/lldpad.state" >> /run/initramfs/rwtab fi fi modules.d/95fcoe/module-setup.sh000075500000006534152525045230012525 0ustar00#!/bin/bash # called by dracut check() { is_fcoe() { block_is_fcoe $1 || return 1 } [[ $hostonly ]] || [[ $mount_needs ]] && { for_each_host_dev_and_slaves is_fcoe || return 255 } require_binaries dcbtool fipvlan lldpad ip readlink fcoemon fcoeadm || return 1 return 0 } # called by dracut depends() { echo network rootfs-block return 0 } # called by dracut installkernel() { instmods fcoe libfcoe 8021q edd bnx2fc } get_vlan_parent() { local link=$1 [ -d $link ] || return read iflink < $link/iflink for if in /sys/class/net/* ; do read idx < $if/ifindex if [ $idx -eq $iflink ] ; then echo ${if##*/} fi done } # called by dracut cmdline() { { for c in /sys/bus/fcoe/devices/ctlr_* ; do [ -L $c ] || continue read enabled < $c/enabled read mode < $c/mode [ $enabled -eq 0 ] && continue if [ $mode = "VN2VN" ] ; then mode="vn2vn" else mode="fabric" fi d=$(cd -P $c; echo $PWD) i=${d%/*} ifname=${i##*/} read mac < ${i}/address s=$(dcbtool gc ${i##*/} dcb 2>/dev/null | sed -n 's/^DCB State:\t*\(.*\)/\1/p') if [ -z "$s" ] ; then p=$(get_vlan_parent ${i}) if [ "$p" ] ; then s=$(dcbtool gc ${p} dcb 2>/dev/null | sed -n 's/^DCB State:\t*\(.*\)/\1/p') ifname=${p##*/} fi fi if [ "$s" = "on" ] ; then dcb="dcb" else dcb="nodcb" fi # Some Combined Network Adapters(CNAs) implement DCB in firmware. # Do not run software-based DCB or LLDP on CNAs that implement DCB. # If the network interface provides hardware DCB/DCBX capabilities, # DCB_REQUIRED in "/etc/fcoe/cfg-xxx" is expected to set to "no". # # Force "nodcb" if there's any DCB_REQUIRED="no"(child or vlan parent). grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${i##*/} &>/dev/null [ $? -eq 0 ] && dcb="nodcb" if [ "$p" ] ; then grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${p} &>/dev/null [ $? -eq 0 ] && dcb="nodcb" fi echo "ifname=${ifname}:${mac}" echo "fcoe=${ifname}:${dcb}:${mode}" done } | sort | uniq } # called by dracut install() { inst_multiple ip dcbtool fipvlan lldpad readlink lldptool fcoemon fcoeadm if [ -e "/etc/hba.conf" ]; then inst_libdir_file 'libhbalinux.so*' inst_simple "/etc/hba.conf" fi mkdir -m 0755 -p "$initdir/var/lib/lldpad" mkdir -m 0755 -p "$initdir/etc/fcoe" if [[ $hostonly_cmdline == "yes" ]] ; then local _fcoeconf=$(cmdline) [[ $_fcoeconf ]] && printf "%s\n" "$_fcoeconf" >> "${initdir}/etc/cmdline.d/95fcoe.conf" fi inst_multiple /etc/fcoe/cfg-* inst "$moddir/fcoe-up.sh" "/sbin/fcoe-up" inst "$moddir/fcoe-edd.sh" "/sbin/fcoe-edd" inst "$moddir/fcoe-genrules.sh" "/sbin/fcoe-genrules.sh" inst_hook pre-trigger 03 "$moddir/lldpad.sh" inst_hook cmdline 99 "$moddir/parse-fcoe.sh" inst_hook cleanup 90 "$moddir/cleanup-fcoe.sh" inst_hook shutdown 40 "$moddir/stop-fcoe.sh" dracut_need_initqueue } modules.d/95fcoe/lldpad.sh000075500000000730152525045230011332 0ustar00#!/bin/bash if ! getargbool 1 rd.fcoe -d -n rd.nofcoe ; then info "rd.fcoe=0: skipping lldpad activation" return 0 fi # Note lldpad will stay running after switchroot, the system initscripts # are to kill it and start a new lldpad to take over. Data is transfered # between the 2 using a shm segment lldpad -d # wait for lldpad to be ready i=0 while [ $i -lt 60 ]; do lldptool -p && break info "Waiting for lldpad to be ready" sleep 1 i=$(($i+1)) done modules.d/99base/init.sh000075500000027025152525045230011045 0ustar00#!/bin/sh # # Licensed under the GPLv2 # # Copyright 2008-2010, Red Hat, Inc. # Harald Hoyer # Jeremy Katz export -p > /tmp/export.orig NEWROOT="/sysroot" [ -d $NEWROOT ] || mkdir -p -m 0755 $NEWROOT OLDPATH=$PATH PATH=/usr/sbin:/usr/bin:/sbin:/bin export PATH # mount some important things [ ! -d /proc/self ] && \ mount -t proc -o nosuid,noexec,nodev proc /proc >/dev/null if [ "$?" != "0" ]; then echo "Cannot mount proc on /proc! Compile the kernel with CONFIG_PROC_FS!" exit 1 fi [ ! -d /sys/kernel ] && \ mount -t sysfs -o nosuid,noexec,nodev sysfs /sys >/dev/null if [ "$?" != "0" ]; then echo "Cannot mount sysfs on /sys! Compile the kernel with CONFIG_SYSFS!" exit 1 fi RD_DEBUG="" . /lib/dracut-lib.sh setdebug if ! ismounted /dev; then mount -t devtmpfs -o mode=0755,noexec,nosuid,strictatime devtmpfs /dev >/dev/null fi if ! ismounted /dev; then echo "Cannot mount devtmpfs on /dev! Compile the kernel with CONFIG_DEVTMPFS!" exit 1 fi # prepare the /dev directory [ ! -h /dev/fd ] && ln -s /proc/self/fd /dev/fd >/dev/null 2>&1 [ ! -h /dev/stdin ] && ln -s /proc/self/fd/0 /dev/stdin >/dev/null 2>&1 [ ! -h /dev/stdout ] && ln -s /proc/self/fd/1 /dev/stdout >/dev/null 2>&1 [ ! -h /dev/stderr ] && ln -s /proc/self/fd/2 /dev/stderr >/dev/null 2>&1 if ! ismounted /dev/pts; then mkdir -m 0755 /dev/pts mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null fi if ! ismounted /dev/shm; then mkdir -m 0755 /dev/shm mount -t tmpfs -o mode=1777,noexec,nosuid,nodev,strictatime tmpfs /dev/shm >/dev/null fi if ! ismounted /run; then mkdir -m 0755 /newrun if ! str_starts "$(readlink -f /bin/sh)" "/run/"; then mount -t tmpfs -o mode=0755,noexec,nosuid,nodev,strictatime tmpfs /newrun >/dev/null else # the initramfs binaries are located in /run, so don't mount it with noexec mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs /newrun >/dev/null fi cp -a /run/* /newrun >/dev/null 2>&1 mount --move /newrun /run rm -fr -- /newrun fi if command -v kmod >/dev/null 2>/dev/null; then kmod static-nodes --format=tmpfiles 2>/dev/null | \ while read type file mode a a a majmin || [ -n "$type" ]; do type=${type%\!} case $type in d) mkdir -m $mode -p $file ;; c) mknod -m $mode $file $type ${majmin%:*} ${majmin#*:} ;; esac done fi trap "emergency_shell Signal caught!" 0 export UDEVVERSION=$(udevadm --version | { read v _ ; echo $v ; }) if [ $UDEVVERSION -gt 166 ]; then # newer versions of udev use /run/udev/rules.d export UDEVRULESD=/run/udev/rules.d [ -d /run/udev ] || mkdir -p -m 0755 /run/udev [ -d $UDEVRULESD ] || mkdir -p -m 0755 $UDEVRULESD else mkdir -m 0755 /dev/.udev /dev/.udev/rules.d export UDEVRULESD=/dev/.udev/rules.d fi if [ "$RD_DEBUG" = "yes" ]; then mkfifo /run/initramfs/loginit.pipe loginit $DRACUT_QUIET /dev/console 2>&1 & exec >/run/initramfs/loginit.pipe 2>&1 else exec 0<>/dev/console 1<>/dev/console 2<>/dev/console fi [ -f /usr/lib/initrd-release ] && . /usr/lib/initrd-release [ -n "$VERSION_ID" ] && info "$NAME-$VERSION_ID" source_conf /etc/conf.d if getarg "rd.cmdline=ask"; then echo "Enter additional kernel command line parameter (end with ctrl-d or .)" while read -p "> " line || [ -n "$line" ]; do [ "$line" = "." ] && break echo "$line" >> /etc/cmdline.d/99-cmdline-ask.conf done fi if ! getargbool 1 'rd.hostonly'; then [ -f /etc/cmdline.d/99-cmdline-ask.conf ] && mv /etc/cmdline.d/99-cmdline-ask.conf /tmp/99-cmdline-ask.conf remove_hostonly_files [ -f /tmp/99-cmdline-ask.conf ] && mv /tmp/99-cmdline-ask.conf /etc/cmdline.d/99-cmdline-ask.conf fi # run scriptlets to parse the command line make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline" source_hook cmdline [ -z "$root" ] && die "No or empty root= argument" [ -z "$rootok" ] && die "Don't know how to handle 'root=$root'" export root rflags fstype netroot NEWROOT # pre-udev scripts run before udev starts, and are run only once. make_trace_mem "hook pre-udev" '1:shortmem' '2+:mem' '3+:slab' getarg 'rd.break=pre-udev' -d 'rdbreak=pre-udev' && emergency_shell -n pre-udev "Break before pre-udev" source_hook pre-udev UDEV_LOG=err getargbool 0 rd.udev.info -d -y rdudevinfo && UDEV_LOG=info getargbool 0 rd.udev.debug -d -y rdudevdebug && UDEV_LOG=debug # start up udev and trigger cold plugs UDEV_LOG=$UDEV_LOG $systemdutildir/systemd-udevd --daemon --resolve-names=never UDEV_QUEUE_EMPTY="udevadm settle --timeout=0" if [ $UDEVVERSION -lt 140 ]; then UDEV_QUEUE_EMPTY="udevadm settle --timeout=1" fi udevproperty "hookdir=$hookdir" make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' getarg 'rd.break=pre-trigger' -d 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger" source_hook pre-trigger udevadm control --reload >/dev/null 2>&1 || : # then the rest udevadm trigger --type=subsystems --action=add >/dev/null 2>&1 udevadm trigger --type=devices --action=add >/dev/null 2>&1 make_trace_mem "hook initqueue" '1:shortmem' '2+:mem' '3+:slab' getarg 'rd.break=initqueue' -d 'rdbreak=initqueue' && emergency_shell -n initqueue "Break before initqueue" RDRETRY=$(getarg rd.retry -d 'rd_retry=') RDRETRY=${RDRETRY:-180} RDRETRY=$(($RDRETRY*2)) export RDRETRY main_loop=0 export main_loop while :; do check_finished && break udevsettle check_finished && break if [ -f $hookdir/initqueue/work ]; then rm -f -- $hookdir/initqueue/work fi for job in $hookdir/initqueue/*.sh; do [ -e "$job" ] || break job=$job . $job check_finished && break 2 done $UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue for job in $hookdir/initqueue/settled/*.sh; do [ -e "$job" ] || break job=$job . $job check_finished && break 2 done $UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue # no more udev jobs and queues empty. sleep 0.5 if [ $main_loop -gt $((2*$RDRETRY/3)) ]; then for job in $hookdir/initqueue/timeout/*.sh; do [ -e "$job" ] || break job=$job . $job udevadm settle --timeout=0 >/dev/null 2>&1 || main_loop=0 [ -f $hookdir/initqueue/work ] && main_loop=0 done fi main_loop=$(($main_loop+1)) [ $main_loop -gt $RDRETRY ] \ && { flock -s 9 ; emergency_shell "Could not boot."; } 9>/.console_lock done unset job unset queuetriggered unset main_loop unset RDRETRY # pre-mount happens before we try to mount the root filesystem, # and happens once. make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' getarg 'rd.break=pre-mount' -d 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount" source_hook pre-mount getarg 'rd.break=mount' -d 'rdbreak=mount' && emergency_shell -n mount "Break mount" # mount scripts actually try to mount the root filesystem, and may # be sourced any number of times. As soon as one suceeds, no more are sourced. _i_mount=0 while :; do if ismounted "$NEWROOT"; then usable_root "$NEWROOT" && break; umount "$NEWROOT" fi for f in $hookdir/mount/*.sh; do [ -f "$f" ] && . "$f" if ismounted "$NEWROOT"; then usable_root "$NEWROOT" && break; warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook" umount "$NEWROOT" rm -f -- "$f" fi done _i_mount=$(($_i_mount+1)) [ $_i_mount -gt 20 ] \ && { flock -s 9 ; emergency_shell "Can't mount root filesystem"; } 9>/.console_lock done { printf "Mounted root filesystem " while read dev mp rest || [ -n "$dev" ]; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts } | vinfo # pre pivot scripts are sourced just before we doing cleanup and switch over # to the new root. make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' getarg 'rd.break=pre-pivot' -d 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot" source_hook pre-pivot make_trace_mem "hook cleanup" '1:shortmem' '2+:mem' '3+:slab' # pre pivot cleanup scripts are sourced just before we switch over to the new root. getarg 'rd.break=cleanup' -d 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup" source_hook cleanup # By the time we get here, the root filesystem should be mounted. # Try to find init. for i in "$(getarg real_init=)" "$(getarg init=)" $(getargs rd.distroinit=) /sbin/init; do [ -n "$i" ] || continue __p=$(readlink -f "${NEWROOT}/${i}") if [ -x "$__p" -o -x "${NEWROOT}/${__p}" ]; then INIT="$i" break fi done [ "$INIT" ] || { echo "Cannot find init!" echo "Please check to make sure you passed a valid root filesystem!" emergency_shell } if [ $UDEVVERSION -lt 168 ]; then # stop udev queue before killing it udevadm control --stop-exec-queue HARD="" while pidof udevd >/dev/null 2>&1; do for pid in $(pidof udevd); do kill $HARD $pid >/dev/null 2>&1 done HARD="-9" done else udevadm control --exit udevadm info --cleanup-db fi debug_off # Turn off debugging for this section # unexport some vars export_n root rflags fstype netroot NEWROOT export RD_TIMESTAMP # Clean up the environment for i in $(export -p); do i=${i#declare -x} i=${i#export} strstr "$i" "=" || continue i=${i%%=*} [ -z "$i" ] && continue case $i in root|PATH|HOME|TERM|PS4|RD_*) :;; *) unset "$i";; esac done . /tmp/export.orig 2>/dev/null || : rm -f -- /tmp/export.orig initargs="" read CLINE /dev/null ; then ignoreargs="console BOOT_IMAGE" # only pass arguments after init= to the init CLINE=${CLINE#*init=} set -- $CLINE shift # clear out the rest of the "init=" arg for x in "$@"; do for s in $ignoreargs; do [ "${x%%=*}" = $s ] && continue 2 done initargs="$initargs $x" done unset CLINE else debug_off # Turn off debugging for this section set -- $CLINE for x in "$@"; do case "$x" in [0-9]|s|S|single|emergency|auto ) \ initargs="$initargs $x" ;; esac done fi debug_on if ! [ -d "$NEWROOT"/run ]; then NEWRUN=/dev/.initramfs mkdir -m 0755 "$NEWRUN" mount --rbind /run/initramfs "$NEWRUN" fi wait_for_loginit # remove helper symlink [ -h /dev/root ] && rm -f -- /dev/root bv=$(getarg rd.break -d rdbreak) && [ -z "$bv" ] && emergency_shell -n switch_root "Break before switch_root" unset bv info "Switching root" unset PS4 CAPSH=$(command -v capsh) SWITCH_ROOT=$(command -v switch_root) PATH=$OLDPATH export PATH if [ -f /etc/capsdrop ]; then . /etc/capsdrop info "Calling $INIT with capabilities $CAPS_INIT_DROP dropped." unset RD_DEBUG exec $CAPSH --drop="$CAPS_INIT_DROP" -- \ -c "exec switch_root \"$NEWROOT\" \"$INIT\" $initargs" || \ { warn "Command:" warn capsh --drop=$CAPS_INIT_DROP -- -c exec switch_root "$NEWROOT" "$INIT" $initargs warn "failed." emergency_shell } else unset RD_DEBUG exec $SWITCH_ROOT "$NEWROOT" "$INIT" $initargs || { warn "Something went very badly wrong in the initramfs. Please " warn "file a bug against dracut." emergency_shell } fi modules.d/99base/rdsosreport.sh000075500000002502152525045230012461 0ustar00#!/bin/sh echo 'Generating "/run/initramfs/rdsosreport.txt"' [ -d /run/initramfs ] || mkdir -p /run/initramfs exec >/run/initramfs/rdsosreport.txt 2>&1 PWFILTER='s/\(ftp:\/\/.*\):.*@/\1:*******@/g;s/\(cifs:\/\/.*\):.*@/\1:*******@/g;s/cifspass=[^ ]*/cifspass=*******/g;s/iscsi:.*@/iscsi:******@/g;s/rd.iscsi.password=[^ ]*/rd.iscsi.password=******/g;s/rd.iscsi.in.password=[^ ]*/rd.iscsi.in.password=******/g' set -x cat /lib/dracut/dracut-* cat /proc/cmdline | sed -e "$PWFILTER" [ -f /etc/cmdline ] && cat /etc/cmdline | sed -e "$PWFILTER" for _i in /etc/cmdline.d/*.conf; do [ -f "$_i" ] || break echo $_i cat $_i | sed -e "$PWFILTER" done cat /proc/self/mountinfo cat /proc/mounts blkid blkid -o udev ls -l /dev/disk/by* for _i in /etc/conf.d/*.conf; do [ -f "$_i" ] || break echo $_i cat $_i | sed -e "$PWFILTER" done if command -v lvm >/dev/null 2>/dev/null; then lvm pvdisplay lvm vgdisplay lvm lvdisplay fi command -v dmsetup >/dev/null 2>/dev/null && dmsetup ls --tree cat /proc/mdstat command -v ip >/dev/null 2>/dev/null && ip addr if command -v journalctl >/dev/null 2>/dev/null; then journalctl -ab --no-pager -o short-monotonic | sed -e "$PWFILTER" else dmesg | sed -e "$PWFILTER" [ -f /run/initramfs/init.log ] && cat /run/initramfs/init.log | sed -e "$PWFILTER" fi modules.d/99base/initqueue.sh000075500000002243152525045230012105 0ustar00#!/bin/sh # # Licensed under the GPLv2+ # # Copyright 2008-2010, Red Hat, Inc. # Harald Hoyer PATH=/usr/sbin:/usr/bin:/sbin:/bin type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh while [ $# -gt 0 ]; do case "$1" in --onetime) onetime="yes";; --online) qname="/online";; --settled) qname="/settled";; --finished) qname="/finished";; --timeout) qname="/timeout";; --unique) unique="yes";; --name) name="$2";shift;; --env) env="$2"; shift;; *) break;; esac shift done if [ -z "$unique" ]; then job="${name}$$" else job="${name:-$1}" job=${job##*/} fi exe=$1 shift [ -x "$exe" ] || exe=$(command -v $exe) if [ -z "$exe" ] ; then echo "Invalid command" exit 1 fi { [ -n "$onetime" ] && echo '[ -e "$job" ] && rm -f -- "$job"' [ -n "$env" ] && echo "$env" printf '%q ' "$exe" "$@" printf '\n' } > "/tmp/$$-${job}.sh" mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${qname}/${job}.sh" [ -z "$qname" ] && >> $hookdir/initqueue/work exit 0 modules.d/99base/dracut-lib.sh000075500000102111152525045230012116 0ustar00#!/bin/sh export DRACUT_SYSTEMD export NEWROOT if [ -n "$NEWROOT" ]; then [ -d $NEWROOT ] || mkdir -p -m 0755 $NEWROOT fi if ! [ -d /run/initramfs ]; then mkdir -p -m 0755 /run/initramfs/log ln -sfn /run/initramfs/log /var/log fi [ -d /run/lock ] || mkdir -p -m 0755 /run/lock [ -d /run/log ] || mkdir -p -m 0755 /run/log debug_off() { set +x } debug_on() { [ "$RD_DEBUG" = "yes" ] && set -x } # returns OK if $1 contains literal string $2 (and isn't empty) strstr() { [ "${1##*"$2"*}" != "$1" ] } # returns OK if $1 matches (completely) glob pattern $2 # An empty $1 will not be considered matched, even if $2 is * which technically # matches; as it would match anything, it's not an interesting case. strglob() { [ -n "$1" -a -z "${1##$2}" ] } # returns OK if $1 contains (anywhere) a match of glob pattern $2 # An empty $1 will not be considered matched, even if $2 is * which technically # matches; as it would match anything, it's not an interesting case. strglobin() { [ -n "$1" -a -z "${1##*$2*}" ] } # returns OK if $1 contains literal string $2 at the beginning, and isn't empty str_starts() { [ "${1#"$2"*}" != "$1" ] } # returns OK if $1 contains literal string $2 at the end, and isn't empty str_ends() { [ "${1%*"$2"}" != "$1" ] } trim() { local var="$*" var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters printf "%s" "$var" } if [ -z "$DRACUT_SYSTEMD" ]; then warn() { check_quiet echo "<28>dracut Warning: $*" > /dev/kmsg echo "dracut Warning: $*" >&2 } info() { check_quiet echo "<30>dracut: $*" > /dev/kmsg [ "$DRACUT_QUIET" != "yes" ] && \ echo "dracut: $*" >&2 } else warn() { echo "Warning: $*" >&2 } info() { echo "$*" } fi vwarn() { while read line || [ -n "$line" ]; do warn $line; done } vinfo() { while read line || [ -n "$line" ]; do info $line; done } # replaces all occurrences of 'search' in 'str' with 'replacement' # # str_replace str search replacement # # example: # str_replace ' one two three ' ' ' '_' str_replace() { local in="$1"; local s="$2"; local r="$3" local out='' while strstr "${in}" "$s"; do chop="${in%%"$s"*}" out="${out}${chop}$r" in="${in#*"$s"}" done echo "${out}${in}" } killall_proc_mountpoint() { local _pid local _t local _killed=0 for _pid in /proc/*; do _pid=${_pid##/proc/} case $_pid in *[!0-9]*) continue;; esac [ -e "/proc/$_pid/exe" ] || continue [ -e "/proc/$_pid/root" ] || continue if strstr "$(ls -l -- "/proc/$_pid" "/proc/$_pid/fd" 2>/dev/null)" "$1" ; then kill -9 "$_pid" _killed=1 fi done return $_killed } getcmdline() { local _line local _i local CMDLINE_ETC_D local CMDLINE_ETC local CMDLINE_PROC unset _line if [ -e /etc/cmdline ]; then while read -r _line || [ -n "$_line" ]; do CMDLINE_ETC="$CMDLINE_ETC $_line"; done ", we want the exact match if [ "$_o" = "$1" ]; then _val="1"; unset _doecho fi continue fi if [ "${_o#*=}" = "$_o" ]; then # if cmdline argument has no "=", we assume "=1" _val="1"; unset _doecho continue fi _val="${_o#*=}" _doecho=1 fi done if [ -n "$_val" ]; then [ "x$_doecho" != "x" ] && echo "$_val"; return 0; fi return 1; } getarg() { debug_off local _deprecated _newoption while [ $# -gt 0 ]; do case $1 in -d) _deprecated=1; shift;; -y) if _dogetarg $2 >/dev/null; then if [ "$_deprecated" = "1" ]; then [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated." fi echo 1 debug_on return 0 fi _deprecated=0 shift 2;; -n) if _dogetarg $2 >/dev/null; then echo 0; if [ "$_deprecated" = "1" ]; then [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated." fi debug_on return 1 fi _deprecated=0 shift 2;; *) if [ -z "$_newoption" ]; then _newoption="$1" fi if _dogetarg $1; then if [ "$_deprecated" = "1" ]; then [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated." fi debug_on return 0; fi _deprecated=0 shift;; esac done debug_on return 1 } # getargbool # False if "getarg " returns "0", "no", or "off". # True if getarg returns any other non-empty string. # If not found, assumes - usually 0 for false, 1 for true. # example: getargbool 0 rd.info # true: rd.info, rd.info=1, rd.info=xxx # false: rd.info=0, rd.info=off, rd.info not present (default val is 0) getargbool() { local _b unset _b local _default _default="$1"; shift _b=$(getarg "$@") [ $? -ne 0 -a -z "$_b" ] && _b="$_default" if [ -n "$_b" ]; then [ $_b = "0" ] && return 1 [ $_b = "no" ] && return 1 [ $_b = "off" ] && return 1 fi return 0 } isdigit() { case "$1" in *[!0-9]*|"") return 1;; esac return 0 } # getargnum # Will echo the arg if it's in range [minval - maxval]. # If it's not set or it's not valid, will set it . # Note all values are required to be >= 0 here. # should be with [minval -maxval]. getargnum() { local _b unset _b local _default _min _max _default="$1"; shift _min="$1"; shift _max="$1"; shift _b=$(getarg "$1") [ $? -ne 0 -a -z "$_b" ] && _b=$_default if [ -n "$_b" ]; then isdigit "$_b" && _b=$(($_b)) && \ [ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return fi echo $_default } _dogetargs() { debug_off local _o _found _key unset _o unset _found CMDLINE=$(getcmdline) _key="$1" set -- for _o in $CMDLINE; do if [ "$_o" = "$_key" ]; then _found=1; elif [ "${_o%%=*}" = "${_key%=}" ]; then [ -n "${_o%%=*}" ] && set -- "$@" "${_o#*=}"; _found=1; fi done if [ -n "$_found" ]; then [ $# -gt 0 ] && printf '%s' "$*" return 0 fi return 1; } getargs() { debug_off local _val _i _args _gfound _deprecated unset _val unset _gfound _newoption="$1" _args="$@" set -- for _i in $_args; do if [ "$_i" = "-d" ]; then _deprecated=1 continue fi _val="$(_dogetargs $_i)" if [ $? -eq 0 ]; then if [ "$_deprecated" = "1" ]; then [ -n "$_newoption" ] && warn "Option '$_i' is deprecated, use '$_newoption' instead." || warn "Option $_i is deprecated!" fi _gfound=1 fi [ -n "$_val" ] && set -- "$@" "$_val" _deprecated=0 done if [ -n "$_gfound" ]; then if [ $# -gt 0 ]; then printf '%s' "$*" fi debug_on return 0 fi debug_on return 1; } # Prints value of given option. If option is a flag and it's present, # it just returns 0. Otherwise 1 is returned. # $1 = options separated by commas # $2 = option we are interested in # # Example: # $1 = cipher=aes-cbc-essiv:sha256,hash=sha256,verify # $2 = hash # Output: # sha256 getoptcomma() { local line=",$1,"; local opt="$2"; local tmp case "${line}" in *,${opt}=*,*) tmp="${line#*,${opt}=}" echo "${tmp%%,*}" return 0 ;; *,${opt},*) return 0;; esac return 1 } # Splits given string 'str' with separator 'sep' into variables 'var1', 'var2', # 'varN'. If number of fields is less than number of variables, remaining are # not set. If number of fields is greater than number of variables, the last # variable takes remaining fields. In short - it acts similary to 'read'. # # splitsep sep str var1 var2 varN # # example: # splitsep ':' 'foo:bar:baz' v1 v2 # in result: # v1='foo', v2='bar:baz' # # TODO: ':' inside fields. splitsep() { debug_off local sep="$1"; local str="$2"; shift 2 local tmp while [ -n "$str" -a "$#" -gt 1 ]; do tmp="${str%%$sep*}" local -n _splitsep_ref="$1" _splitsep_ref="$tmp" unset -n _splitsep_ref str="${str#"$tmp"}" str="${str#$sep}" shift done if [ -n "$str" -a -n "$1" ]; then local -n _splitsep_ref="$1" _splitsep_ref="$str" unset -n _splitsep_ref fi debug_on return 0 } setdebug() { [ -f /usr/lib/initrd-release ] || return if [ -z "$RD_DEBUG" ]; then if [ -e /proc/cmdline ]; then RD_DEBUG=no if getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then RD_DEBUG=yes [ -n "$BASH" ] && \ export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '; fi fi export RD_DEBUG fi debug_on } setdebug source_all() { local f local _dir _dir=$1; shift [ "$_dir" ] && [ -d "/$_dir" ] || return for f in "/$_dir"/*.sh; do [ -e "$f" ] && . "$f" "$@"; done } hookdir=/lib/dracut/hooks export hookdir source_hook() { local _dir _dir=$1; shift source_all "/lib/dracut/hooks/$_dir" "$@" } check_finished() { local f for f in $hookdir/initqueue/finished/*.sh; do [ "$f" = "$hookdir/initqueue/finished/*.sh" ] && return 0 { [ -e "$f" ] && ( . "$f" ) ; } || return 1 done return 0 } source_conf() { local f [ "$1" ] && [ -d "/$1" ] || return for f in "/$1"/*.conf; do [ -e "$f" ] && . "$f"; done } die() { { echo "<24>dracut: FATAL: $*"; echo "<24>dracut: Refusing to continue"; } > /dev/kmsg { printf 'warn dracut: FATAL: %q\n' "$*" echo "warn dracut: Refusing to continue" } >> $hookdir/emergency/01-die.sh [ -d /run/initramfs ] || mkdir -p -- /run/initramfs > /run/initramfs/.die if getargbool 0 "rd.shell"; then emergency_shell else source_hook "shutdown-emergency" fi if [ -n "$DRACUT_SYSTEMD" ]; then systemctl --no-block --force halt fi exit 1 } check_quiet() { if [ -z "$DRACUT_QUIET" ]; then DRACUT_QUIET="yes" getargbool 0 rd.info -d -y rdinfo && DRACUT_QUIET="no" getargbool 0 rd.debug -d -y rdinitdebug && DRACUT_QUIET="no" getarg quiet || DRACUT_QUIET="yes" a=$(getarg loglevel=) [ -n "$a" ] && [ $a -ge 28 ] && DRACUT_QUIET="yes" export DRACUT_QUIET fi } check_occurances() { # Count the number of times the character $ch occurs in $str # Return 0 if the count matches the expected number, 1 otherwise local str="$1" local ch="$2" local expected="$3" local count=0 while [ "${str#*$ch}" != "${str}" ]; do str="${str#*$ch}" count=$(( $count + 1 )) done [ $count -eq $expected ] } incol2() { debug_off local dummy check; local file="$1"; local str="$2"; [ -z "$file" ] && return 1; [ -z "$str" ] && return 1; while read dummy check restofline || [ -n "$check" ]; do if [ "$check" = "$str" ]; then debug_on return 0 fi done < $file debug_on return 1 } udevsettle() { [ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version | { read v _ ; echo $v ; }) if [ $UDEVVERSION -ge 143 ]; then udevadm settle --exit-if-exists=$hookdir/initqueue/work $settle_exit_if_exists else udevadm settle --timeout=30 fi } udevproperty() { [ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version | { read v _ ; echo $v ; }) if [ $UDEVVERSION -ge 143 ]; then for i in "$@"; do udevadm control --property=$i; done else for i in "$@"; do udevadm control --env=$i; done fi } find_mount() { local dev mnt etc wanted_dev wanted_dev="$(readlink -e -q $1)" while read dev mnt etc || [ -n "$dev" ]; do [ "$dev" = "$wanted_dev" ] && echo "$dev" && return 0 done < /proc/mounts return 1 } # usage: ismounted # usage: ismounted /dev/ if command -v findmnt >/dev/null; then ismounted() { findmnt "$1" > /dev/null 2>&1 } else ismounted() { if [ -b "$1" ]; then find_mount "$1" > /dev/null && return 0 return 1 fi while read a m a || [ -n "$m" ]; do [ "$m" = "$1" ] && return 0 done < /proc/mounts return 1 } fi # root=nfs:[:][:] # root=nfs4:[:][:] nfsroot_to_var() { # strip nfs[4]: local arg="$@:" nfs="${arg%%:*}" arg="${arg##$nfs:}" # check if we have a server if strstr "$arg" ':/' ; then server="${arg%%:/*}" arg="/${arg##*:/}" fi path="${arg%%:*}" # rest are options options="${arg##$path}" # strip leading ":" options="${options##:}" # strip ":" options="${options%%:}" # Does it really start with '/'? [ -n "${path%%/*}" ] && path="error"; #Fix kernel legacy style separating path and options with ',' if [ "$path" != "${path#*,}" ] ; then options=${path#*,} path=${path%%,*} fi } # Create udev rule match for a device with its device name, or the udev property # ID_FS_UUID or ID_FS_LABEL # # example: # udevmatch LABEL=boot # prints: # ENV{ID_FS_LABEL}="boot" # # TODO: symlinks udevmatch() { case "$1" in UUID=????????-????-????-????-????????????|LABEL=*|PARTLABEL=*|PARTUUID=????????-????-????-????-????????????) printf 'ENV{ID_FS_%s}=="%s"' "${1%%=*}" "${1#*=}" ;; UUID=*) printf 'ENV{ID_FS_UUID}=="%s*"' "${1#*=}" ;; PARTUUID=*) printf 'ENV{ID_FS_PARTUUID}=="%s*"' "${1#*=}" ;; /dev/?*) printf -- 'KERNEL=="%s"' "${1#/dev/}" ;; *) return 255 ;; esac } # Prints unique path for potential file inside specified directory. It consists # of specified directory, prefix and number at the end which is incremented # until non-existing file is found. # # funiq dir prefix # # example: # # ls /mnt # cdrom0 cdrom1 # # # funiq /mnt cdrom # /mnt/cdrom2 funiq() { local dir="$1"; local prefix="$2" local i=0 [ -d "${dir}" ] || return 1 while [ -e "${dir}/${prefix}$i" ]; do i=$(($i+1)) || return 1 done echo "${dir}/${prefix}$i" } # Creates unique directory and prints its path. It's using funiq to generate # path. # # mkuniqdir subdir new_dir_name mkuniqdir() { local dir="$1"; local prefix="$2" local retdir; local retdir_new [ -d "${dir}" ] || mkdir -m 0755 -p "${dir}" || return 1 retdir=$(funiq "${dir}" "${prefix}") || return 1 until mkdir -m 0755 "${retdir}" 2>/dev/null; do retdir_new=$(funiq "${dir}" "${prefix}") || return 1 [ "$retdir_new" = "$retdir" ] && return 1 retdir="$retdir_new" done echo "${retdir}" } # Copy the contents of SRC into DEST, merging the contents of existing # directories (kinda like rsync, or cpio -p). # Creates DEST if it doesn't exist. Overwrites files with the same names. # # copytree SRC DEST copytree() { local src="$1" dest="$2" mkdir -p "$dest"; dest=$(readlink -e -q "$dest") ( cd "$src"; cp -af . -t "$dest" ) } # Evaluates command for UUIDs either given as arguments for this function or all # listed in /dev/disk/by-uuid. UUIDs doesn't have to be fully specified. If # beginning is given it is expanded to all matching UUIDs. To pass full UUID to # your command use '$___' as a place holder. Remember to escape '$'! # # foreach_uuid_until [ -p prefix ] command UUIDs # # prefix - string to put just before $___ # command - command to be evaluated # UUIDs - list of UUIDs separated by space # # The function returns after *first successful evaluation* of the given command # with status 0. If evaluation fails for every UUID function returns with # status 1. # # Example: # foreach_uuid_until "mount -U \$___ /mnt; echo OK; umount /mnt" \ # "01234 f512 a235567f-12a3-c123-a1b1-01234567abcb" foreach_uuid_until() ( cd /dev/disk/by-uuid [ "$1" = -p ] && local prefix="$2" && shift 2 local cmd="$1"; shift; local uuids_list="$*" local uuid; local full_uuid; local ___ [ -n "${cmd}" ] || return 1 for uuid in ${uuids_list:-*}; do for full_uuid in ${uuid}*; do [ -e "${full_uuid}" ] || continue ___="${prefix}${full_uuid}" eval ${cmd} && return 0 done done return 1 ) # Get kernel name for given device. Device may be the name too (then the same # is returned), a symlink (full path), UUID (prefixed with "UUID=") or label # (prefixed with "LABEL="). If just a beginning of the UUID is specified or # even an empty, function prints all device names which UUIDs match - every in # single line. # # NOTICE: The name starts with "/dev/". # # Example: # devnames UUID=123 # May print: # /dev/dm-1 # /dev/sdb1 # /dev/sdf3 devnames() { local dev="$1"; local d; local names case "$dev" in UUID=*) dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \ && return 255 [ -z "$dev" ] && return 255 ;; LABEL=*) dev="$(blkid -L "${dev#LABEL=}")" || return 255 ;; /dev/?*) ;; *) return 255 ;; esac for d in $dev; do names="$names $(readlink -e -q "$d")" || return 255 done echo "${names# }" } usable_root() { local _i [ -d "$1" ] || return 1 for _i in "$1"/usr/lib*/ld-*.so "$1"/lib*/ld-*.so; do [ -e "$_i" ] && return 0 done for _i in proc sys dev; do [ -e "$1"/$_i ] || return 1 done return 0 } inst_hook() { local _hookname _unique _name _job _exe while [ $# -gt 0 ]; do case "$1" in --hook) _hookname="/$2";shift;; --unique) _unique="yes";; --name) _name="$2";shift;; *) break;; esac shift done if [ -z "$_unique" ]; then _job="${_name}$$" else _job="${_name:-$1}" _job=${_job##*/} fi _exe=$1 shift [ -x "$_exe" ] || _exe=$(command -v $_exe) if [ -n "$onetime" ]; then { echo '[ -e "$_job" ] && rm -f -- "$_job"' echo "$_exe $@" } > "/tmp/$$-${_job}.sh" else echo "$_exe $@" > "/tmp/$$-${_job}.sh" fi mv -f "/tmp/$$-${_job}.sh" "$hookdir/${_hookname}/${_job}.sh" } # inst_mount_hook