firmwares, separated by :
--kernel-only Only install kernel drivers and firmware files
--no-kernel Do not install kernel drivers and firmware files
+ --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
local -a files
local f d
- readarray -t files < <(
- for d in "$@"; do
- for i in "$d/"*"$suffix"; do
- if [[ -e "$i" ]]; then
- printf "%s" "${i##*/}"
+ 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 | sort -Vu
- )
-
- for f in "${files[@]}"; do
- for d in "$@"; do
- if [[ -e "$d/$f" ]]; then
- printf "%s" "$d/$f"
- continue 2
- fi
done
- done
+ }
}
verbosity_mod_l=0
-f|--force) force=yes;;
--kernel-only) kernel_only="yes"; no_kernel="no";;
--no-kernel) kernel_only="no"; no_kernel="yes";;
+ --early-microcode) early_microcode="yes";;
+ --no-early-microcode) early_microcode="no";;
--strip) do_strip_l="yes";;
--nostrip) do_strip_l="no";;
--hardlink) do_hardlink_l="yes";;
fi
done
export PATH="${NPATH#:}"
+unset LC_MESSAGES
+unset LC_CTYPE
+export LC_ALL=C
+export LANG=C
unset NPATH
unset LD_LIBRARY_PATH
unset GREP_OPTIONS
exit 1
}
+if [[ $early_microcode = yes ]]; then
+ readonly microcode_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_microcode.XXXXXX)"
+ [ -d "$microcode_dir" ] || {
+ printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t early_microcode.XXXXXX failed." >&2
+ exit 1
+ }
+fi
# clean up after ourselves no matter how we die.
-trap 'ret=$?;[[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";[[ $keep ]] && printf "%s\n" "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir";exit $ret; };' EXIT
+trap '
+ ret=$?;
+ [[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";
+ [[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; };
+ [[ $keep ]] && echo "Not removing $microcode_dir." >&2 || { [[ $microcode_dir ]] && rm -Rf -- "$microcode_dir"; };
+ [[ $_dlogdir ]] && rm -Rf -- "$_dlogdir";
+ exit $ret;
+ ' EXIT
+
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
dracut_args[$i]="\"${dracut_args[$i]}\""
#" keep vim happy
done
-ddebug "Executing: $0 ${dracut_args[@]}"
+dinfo "Executing: $0 ${dracut_args[@]}"
[[ $do_list = yes ]] && {
for mod in $dracutbasedir/modules.d/*; do
for mp in \
"/" \
"/etc" \
- "/usr" \
- "/usr/bin" \
- "/usr/sbin" \
- "/usr/lib" \
- "/usr/lib64" \
+ "/bin" \
+ "/sbin" \
+ "/lib" \
+ "/lib64" \
"/boot";
do
+ mp=$(readlink -f "$mp")
mountpoint "$mp" >/dev/null 2>&1 || continue
- push host_devs "$(readlink -f "/dev/block/$(find_block_device "$mp")")"
+ _dev="$(readlink -f "/dev/block/$(find_block_device "$mp")")"
+ [[ "$_mp" == "/" ]] && root_dev="$_dev"
+ push host_devs "$_dev"
done
- while read dev type rest; do
- [[ -b $dev ]] || continue
- [[ "$type" == "partition" ]] || continue
- while read _d _m _t _o _r; do
- [[ "$_d" == \#* ]] && continue
- [[ $_d ]] || continue
- [[ $_t != "swap" ]] || [[ $_m != "swap" ]] && continue
- [[ "$_o" == *noauto* ]] && continue
- [[ "$_d" == UUID\=* ]] && _d="/dev/disk/by-uuid/${_d#UUID=}"
- [[ "$_d" == LABEL\=* ]] && _d="/dev/disk/by-label/$_d#LABEL=}"
- [[ "$_d" -ef "$dev" ]] || continue
-
- while read _mapper _a _p _o; do
- [[ $_mapper = \#* ]] && continue
- [[ "$_d" -ef /dev/mapper/"$_mapper" ]] || continue
- [[ "$_o" ]] || _o="$_p"
+ if [[ -f /proc/swaps ]] && [[ -f /etc/fstab ]]; then
+ while read dev type rest; do
+ [[ -b $dev ]] || continue
+ [[ "$type" == "partition" ]] || continue
+
+ while read _d _m _t _o _r; do
+ [[ "$_d" == \#* ]] && continue
+ [[ $_d ]] || continue
+ [[ $_t != "swap" ]] || [[ $_m != "swap" ]] && continue
+ [[ "$_o" == *noauto* ]] && continue
+ [[ "$_d" == UUID\=* ]] && _d="/dev/disk/by-uuid/${_d#UUID=}"
+ [[ "$_d" == LABEL\=* ]] && _d="/dev/disk/by-label/$_d#LABEL=}"
+ [[ "$_d" -ef "$dev" ]] || continue
+
+ if [[ -f /etc/crypttab ]]; then
+ while read _mapper _a _p _o; do
+ [[ $_mapper = \#* ]] && continue
+ [[ "$_d" -ef /dev/mapper/"$_mapper" ]] || continue
+ [[ "$_o" ]] || _o="$_p"
# skip mkswap swap
- [[ $_o == *swap* ]] && continue 2
- done < /etc/crypttab
+ [[ $_o == *swap* ]] && continue 2
+ done < /etc/crypttab
+ fi
- push host_devs "$(readlink -f "$dev")"
- break
- done < /etc/fstab
- done < /proc/swaps
+ push host_devs "$(readlink -f "$dev")"
+ break
+ done < /etc/fstab
+ done < /proc/swaps
+ fi
fi
-_get_fs_type() { (
+_get_fs_type() {
[[ $1 ]] || return
if [[ -b /dev/block/$1 ]] && ID_FS_TYPE=$(get_fs_env "/dev/block/$1"); then
- printf "%s\n" "$(readlink -f "/dev/block/$1")" "$ID_FS_TYPE"
+ host_fs_types["$(readlink -f "/dev/block/$1")"]="$ID_FS_TYPE"
return 1
fi
if [[ -b $1 ]] && ID_FS_TYPE=$(get_fs_env "$1"); then
- printf "%s\n" "$(readlink -f "$1")" "$ID_FS_TYPE"
+ host_fs_types["$(readlink -f "$1")"]="$ID_FS_TYPE"
return 1
fi
if fstype=$(find_dev_fstype "$1"); then
- printf "%s\n" "$1" "$fstype"
+ host_fs_types["$1"]="$fstype"
return 1
fi
return 1
-) }
-
-for dev in "${host_devs[@]}"; do
- while read key; do
- read val
- host_fs_types["$key"]="$val"
- done < <(
- _get_fs_type "$dev"
- check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
- )
+}
+
+for dev in ${host_devs[@]}; do
+ _get_fs_type "$dev"
+ check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
done
[[ -d $udevdir ]] \
export initdir dracutbasedir dracutmodules \
fw_dir drivers_dir debug no_kernel kernel_only \
- omit_drivers mdadmconf lvmconf \
+ omit_drivers mdadmconf lvmconf root_dev \
use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug host_fs_types host_devs sshkey add_fstab \
fi
fi
-if (( maxloglvl >= 5 )); then
- ddebug "Listing sizes of included files:"
- du -c "$initdir" | sort -n | ddebug
-fi
-
PRELINK_BIN="$(command -v prelink)"
if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then
if [[ $DRACUT_FIPS_MODE ]]; then
dinfo "*** Stripping files done ***"
fi
+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="$microcode_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)
+ fi
+ cat $_fwdir/$_fw/$_src > $_dest_dir/${ucode_dest[$idx]}
+ fi
+ done
+ done
+ (cd "$microcode_dir/d"; find . | cpio -o -H newc --quiet >../ucode.cpio)
+fi
rm -f -- "$outfile"
dinfo "*** Creating image file ***"
-if ! ( umask 077; cd "$initdir"; find . | cpio -R 0:0 -H newc -o --quiet | \
- $compress > "$outfile.$$"; ); then
+if [[ $early_microcode = yes ]]; then
+ # The microcode blob is _before_ the initramfs blob, not after
+ mv $microcode_dir/ucode.cpio $outfile.$$
+fi
+if ! ( umask 077; cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \
+ $compress >> "$outfile.$$"; ); then
dfatal "dracut: creation of $outfile.$$ failed"
exit 1
fi
mv -- "$outfile.$$" "$outfile"
dinfo "*** Creating image file done ***"
-dinfo "Wrote $outfile:"
-dinfo "$(ls -l "$outfile")"
+if (( maxloglvl >= 5 )); then
+ lsinitrd "$outfile"| ddebug
+fi
exit 0