]> git.ipfire.org Git - thirdparty/dracut.git/blame - dracut.sh
Check kernel config for early microcode and ACPI override
[thirdparty/dracut.git] / dracut.sh
CommitLineData
c0815e4e 1#!/bin/bash
cc02093d
HH
2# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3# ex: ts=8 sw=4 sts=4 et filetype=sh
3b403b32 4#
641cc356
JK
5# Generator script for a dracut initramfs
6# Tries to retain some degree of compatibility with the command line
7# of the various mkinitrd implementations out there
8#
70c26b7f 9
7d848c55 10# Copyright 2005-2013 Red Hat, Inc. All rights reserved.
4f18fe82
HH
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
ec9315e5 25
58dad702 26# store for logging
ffa71b4a 27dracut_args=( "$@" )
5616feb0 28
7abd4264
HH
29set -o pipefail
30
5616feb0 31usage() {
dbf8f6ba
HH
32 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
33 if [[ -f $dracutbasedir/dracut-version.sh ]]; then
34 . $dracutbasedir/dracut-version.sh
35 fi
36
5616feb0 37# 80x25 linebreak here ^
cc02093d 38 cat << EOF
ffa71b4a
HH
39Usage: $0 [OPTION]... [<initramfs> [<kernel-version>]]
40
41Version: $DRACUT_VERSION
42
43Creates initial ramdisk images for preloading modules
44
45 -h, --help Display all options
46
47If a [LIST] has multiple arguments, then you have to put these in quotes.
48
49For example:
50
51 # dracut --add-drivers "module1 module2" ...
52
53EOF
54}
55
56long_usage() {
57 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
58 if [[ -f $dracutbasedir/dracut-version.sh ]]; then
59 . $dracutbasedir/dracut-version.sh
60 fi
61
62# 80x25 linebreak here ^
63 cat << EOF
64Usage: $0 [OPTION]... [<initramfs> [<kernel-version>]]
dbf8f6ba
HH
65
66Version: $DRACUT_VERSION
67
5616feb0
AT
68Creates initial ramdisk images for preloading modules
69
e65caf36 70 --kver [VERSION] Set kernel version to [VERSION].
39ff0682 71 -f, --force Overwrite existing initramfs file.
54e7d7c3 72 -a, --add [LIST] Add a space-separated list of dracut modules.
659dc319 73 --rebuild Append arguments to those of existing image and rebuild
5616feb0
AT
74 -m, --modules [LIST] Specify a space-separated list of dracut modules to
75 call when building the initramfs. Modules are located
c5a65990 76 in /usr/lib/dracut/modules.d.
39ff0682 77 -o, --omit [LIST] Omit a space-separated list of dracut modules.
ea3c4e82
HH
78 --force-add [LIST] Force to add a space-separated list of dracut modules
79 to the default set of modules, when -H is specified.
5616feb0 80 -d, --drivers [LIST] Specify a space-separated list of kernel modules to
ea3c4e82
HH
81 exclusively include in the initramfs.
82 --add-drivers [LIST] Specify a space-separated list of kernel
83 modules to add to the initramfs.
fcbcb252 84 --omit-drivers [LIST] Specify a space-separated list of kernel
ea3c4e82 85 modules not to add to the initramfs.
8fa510d4 86 --filesystems [LIST] Specify a space-separated list of kernel filesystem
ea3c4e82
HH
87 modules to exclusively include in the generic
88 initramfs.
3b403b32 89 -k, --kmoddir [DIR] Specify the directory, where to look for kernel
ea3c4e82 90 modules
3b403b32 91 --fwdir [DIR] Specify additional directories, where to look for
ea3c4e82 92 firmwares, separated by :
33ee031c
HH
93 --kernel-only Only install kernel drivers and firmware files
94 --no-kernel Do not install kernel drivers and firmware files
1743473b 95 --print-cmdline Print the kernel command line for the given disk layout
5bbfd484 96 --early-microcode Combine early microcode with ramdisk
5f2c30d9 97 --no-early-microcode Do not combine early microcode with ramdisk
d20fb951 98 --kernel-cmdline [PARAMETERS] Specify default kernel command line parameters
54e7d7c3 99 --strip Strip binaries in the initramfs
6c128565 100 --nostrip Do not strip binaries in the initramfs
f4a94278
HH
101 --prelink Prelink binaries in the initramfs
102 --noprelink Do not prelink binaries in the initramfs
54e7d7c3 103 --hardlink Hardlink files in the initramfs
04d18f55 104 --nohardlink Do not hardlink files in the initramfs
fd786adc 105 --prefix [DIR] Prefix initramfs files with [DIR]
54e7d7c3 106 --noprefix Do not prefix initramfs files
2f02ae9d
HH
107 --mdadmconf Include local /etc/mdadm.conf
108 --nomdadmconf Do not include local /etc/mdadm.conf
7a34efa5 109 --lvmconf Include local /etc/lvm/lvm.conf
cc02093d 110 --nolvmconf Do not include local /etc/lvm/lvm.conf
25b45979
MS
111 --fscks [LIST] Add a space-separated list of fsck helpers.
112 --nofscks Inhibit installation of any fsck helpers.
ff3953ef 113 --ro-mnt Mount / and /usr read-only by default.
5616feb0 114 -h, --help This message
00531568 115 --debug Output debug information of the build process
57258a2c 116 --profile Output profile information of the build process
e103615b
117 -L, --stdlog [0-6] Specify logging level (to standard error)
118 0 - suppress any messages
119 1 - only fatal errors
120 2 - all errors
121 3 - warnings
54e7d7c3 122 4 - info
e103615b
123 5 - debug info (here starts lots of output)
124 6 - trace info (and even more)
54e7d7c3
HH
125 -v, --verbose Increase verbosity level
126 -q, --quiet Decrease verbosity level
5616feb0
AT
127 -c, --conf [FILE] Specify configuration file to use.
128 Default: /etc/dracut.conf
3b403b32 129 --confdir [DIR] Specify configuration directory to use *.conf files
cc02093d 130 from. Default: /etc/dracut.conf.d
882c4c5a
131 --tmpdir [DIR] Temporary directory to be used instead of default
132 /var/tmp.
5616feb0
AT
133 -l, --local Local mode. Use modules from the current working
134 directory instead of the system-wide installed in
c5a65990 135 /usr/lib/dracut/modules.d.
5616feb0 136 Useful when running dracut from a git checkout.
7c179686 137 -H, --hostonly Host-Only mode: Install only what is needed for
324ea606 138 booting the local host instead of a generic host.
472189da 139 -N, --no-hostonly Disables Host-Only mode
ab9457ef
HH
140 --hostonly-cmdline Store kernel command line arguments needed
141 in the initramfs
142 --no-hostonly-cmdline Do not store kernel command line arguments needed
143 in the initramfs
324ea606
HH
144 --persistent-policy [POLICY]
145 Use [POLICY] to address disks and partitions.
146 POLICY can be any directory name found in /dev/disk.
147 E.g. "by-uuid", "by-label"
7c179686 148 --fstab Use /etc/fstab to determine the root device.
70cb8a68
HH
149 --add-fstab [FILE] Add file to the initramfs fstab
150 --mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
151 Mount device [DEV] on mountpoint [MP] with filesystem
152 [FSTYPE] and options [FSOPTS] in the initramfs
c586b033 153 --add-device "[DEV]" Bring up [DEV] in initramfs
5616feb0 154 -i, --include [SOURCE] [TARGET]
39ff0682
AT
155 Include the files in the SOURCE directory into the
156 Target directory in the final initramfs.
3b403b32 157 If SOURCE is a file, it will be installed to TARGET
4fea3ea6 158 in the final initramfs.
39ff0682
AT
159 -I, --install [LIST] Install the space separated list of files into the
160 initramfs.
54b68829
HH
161 --install-optional [LIST] Install the space separated list of files into the
162 initramfs, if they exist.
5b158ad3 163 --gzip Compress the generated initramfs using gzip.
cc02093d
HH
164 This will be done by default, unless another
165 compression option or --no-compress is passed.
5b158ad3 166 --bzip2 Compress the generated initramfs using bzip2.
cc02093d
HH
167 Make sure your kernel has bzip2 decompression support
168 compiled in, otherwise you will not be able to boot.
169 --lzma Compress the generated initramfs using lzma.
3b403b32 170 Make sure your kernel has lzma support compiled in,
cc02093d 171 otherwise you will not be able to boot.
5e6c3b03
VL
172 --xz Compress the generated initramfs using xz.
173 Make sure that your kernel has xz support compiled
174 in, otherwise you will not be able to boot.
871c8e40 175 --lzo Compress the generated initramfs using lzop.
176 Make sure that your kernel has lzo support compiled
177 in, otherwise you will not be able to boot.
178 --lz4 Compress the generated initramfs using lz4.
179 Make sure that your kernel has lz4 support compiled
180 in, otherwise you will not be able to boot.
5e6c3b03
VL
181 --compress [COMPRESSION] Compress the generated initramfs with the
182 passed compression program. Make sure your kernel
3b403b32 183 knows how to decompress the generated initramfs,
5e6c3b03 184 otherwise you will not be able to boot.
5b158ad3 185 --no-compress Do not compress the generated initramfs. This will
cc02093d 186 override any other compression options.
5b11bb73 187 --list-modules List all available dracut modules.
956af8f2
188 -M, --show-modules Print included module's name to standard output during
189 build.
5fe5c7d0 190 --keep Keep the temporary initramfs for debugging purposes
ec3c5951 191 --printsize Print out the module install size
cdfeb278 192 --sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module)
ee54b840 193 --logfile [FILE] Logfile to use (overrides configuration setting)
80626ded 194 --reproducible Create reproducible images
ccaa9bee
HH
195
196If [LIST] has multiple arguments, then you have to put these in quotes.
ffa71b4a 197
ccaa9bee 198For example:
ffa71b4a
HH
199
200 # dracut --add-drivers "module1 module2" ...
201
cc02093d 202EOF
5616feb0
AT
203}
204
8466db96
HH
205# function push()
206# push values to a stack
207# $1 = stack variable
208# $2.. values
209# example:
210# push stack 1 2 "3 4"
211push() {
ffa71b4a 212 local _i
8466db96 213 local __stack=$1; shift
ffa71b4a
HH
214 for _i in "$@"; do
215 eval ${__stack}'[${#'${__stack}'[@]}]="$_i"'
8466db96
HH
216 done
217}
218
219# function pop()
220# pops the last value from a stack
221# assigns value to second argument variable
222# or echo to stdout, if no second argument
223# $1 = stack variable
224# $2 = optional variable to store the value
225# example:
226# pop stack val
227# val=$(pop stack)
228pop() {
229 local __stack=$1; shift
3b403b32 230 local __resultvar=$1
ffa71b4a 231 local _value;
8466db96
HH
232 # check for empty stack
233 eval '[[ ${#'${__stack}'[@]} -eq 0 ]] && return 1'
234
ffa71b4a 235 eval _value='${'${__stack}'[${#'${__stack}'[@]}-1]}'
8466db96
HH
236
237 if [[ "$__resultvar" ]]; then
ffa71b4a 238 eval $__resultvar="'$_value'"
8466db96 239 else
b093aa2d 240 printf "%s" "$_value"
8466db96
HH
241 fi
242 eval unset ${__stack}'[${#'${__stack}'[@]}-1]'
243 return 0
244}
245
5bc545ed
VL
246# Little helper function for reading args from the commandline.
247# it automatically handles -a b and -a=b variants, and returns 1 if
248# we need to shift $3.
249read_arg() {
250 # $1 = arg name
251 # $2 = arg value
252 # $3 = arg parameter
253 local rematch='^[^=]*=(.*)$'
254 if [[ $2 =~ $rematch ]]; then
cc02093d 255 read "$1" <<< "${BASH_REMATCH[1]}"
5bc545ed 256 else
cc02093d
HH
257 read "$1" <<< "$3"
258 # There is no way to shift our callers args, so
259 # return 1 to indicate they should do it instead.
260 return 1
5bc545ed
VL
261 fi
262}
263
335bc217 264dropindirs_sort()
a42b2b81 265{
b093aa2d
HH
266 local suffix=$1; shift
267 local -a files
268 local f d
269
dba20559
HH
270 for d in "$@"; do
271 for i in "$d/"*"$suffix"; do
272 if [[ -e "$i" ]]; then
273 printf "%s\n" "${i##*/}"
274 fi
275 done
276 done | sort -Vu | {
277 readarray -t files
278
279 for f in "${files[@]}"; do
280 for d in "$@"; do
281 if [[ -e "$d/$f" ]]; then
282 printf "%s\n" "$d/$f"
283 continue 2
b093aa2d 284 fi
a42b2b81 285 done
a42b2b81 286 done
dba20559 287 }
a42b2b81
HH
288}
289
659dc319
HB
290rearrange_params()
291{
292 # Workaround -i, --include taking 2 arguments
293 set -- "${@/--include/++include}"
294
295 # This prevents any long argument ending with "-i"
296 # -i, like --opt-i but I think we can just prevent that
297 set -- "${@/%-i/++include}"
298
299 TEMP=$(unset POSIXLY_CORRECT; getopt \
300 -o "a:m:o:d:I:k:c:L:fvqlHhMN" \
301 --long kver: \
302 --long add: \
303 --long force-add: \
304 --long add-drivers: \
305 --long omit-drivers: \
306 --long modules: \
307 --long omit: \
308 --long drivers: \
309 --long filesystems: \
310 --long install: \
54b68829 311 --long install-optional: \
659dc319
HB
312 --long fwdir: \
313 --long libdirs: \
314 --long fscks: \
315 --long add-fstab: \
316 --long mount: \
317 --long device: \
318 --long add-device: \
319 --long nofscks: \
320 --long ro-mnt \
321 --long kmoddir: \
322 --long conf: \
323 --long confdir: \
324 --long tmpdir: \
325 --long stdlog: \
326 --long compress: \
327 --long prefix: \
328 --long rebuild: \
329 --long force \
330 --long kernel-only \
331 --long no-kernel \
332 --long print-cmdline \
333 --long kernel-cmdline: \
334 --long strip \
335 --long nostrip \
336 --long prelink \
337 --long noprelink \
338 --long hardlink \
339 --long nohardlink \
340 --long noprefix \
341 --long mdadmconf \
342 --long nomdadmconf \
343 --long lvmconf \
344 --long nolvmconf \
345 --long debug \
346 --long profile \
347 --long sshkey: \
348 --long logfile: \
349 --long verbose \
350 --long quiet \
351 --long local \
352 --long hostonly \
353 --long host-only \
354 --long no-hostonly \
355 --long no-host-only \
646e0506
WC
356 --long hostonly-cmdline \
357 --long no-hostonly-cmdline \
659dc319
HB
358 --long persistent-policy: \
359 --long fstab \
360 --long help \
361 --long bzip2 \
362 --long lzma \
363 --long xz \
364 --long lzo \
365 --long lz4 \
366 --long no-compress \
367 --long gzip \
368 --long list-modules \
369 --long show-modules \
370 --long keep \
371 --long printsize \
372 --long regenerate-all \
373 --long noimageifnotneeded \
374 --long early-microcode \
375 --long no-early-microcode \
80626ded 376 --long reproducible \
659dc319
HB
377 -- "$@")
378
379 if (( $? != 0 )); then
380 usage
381 exit 1
382 fi
383}
384
432196ae 385verbosity_mod_l=0
f79e587c
HH
386unset kernel
387unset outfile
486a1b93 388
659dc319
HB
389rearrange_params "$@"
390eval set -- "$TEMP"
391
392# parse command line args to check if '--rebuild' option is present
393unset append_args_l
394unset rebuild_file
395while :
396do
397 if [ "$1" == "--" ]; then
398 shift; break
399 fi
400 if [ "$1" == "--rebuild" ]; then
401 append_args_l="yes"
402 rebuild_file=$2
403 if [ ! -e $rebuild_file ]; then
404 echo "Image file '$rebuild_file', for rebuild, does not exist!"
405 exit 1
406 fi
407 abs_rebuild_file=$(readlink -f "$rebuild_file") && rebuild_file="$abs_rebuild_file"
408 shift; continue
409 fi
410 shift
411done
412
413# get output file name and kernel version from command line arguments
414while (($# > 0)); do
415 case ${1%%=*} in
416 ++include)
417 shift 2;;
418 *)
419 if ! [[ ${outfile+x} ]]; then
420 outfile=$1
421 elif ! [[ ${kernel+x} ]]; then
422 kernel=$1
423 else
424 printf "\nUnknown arguments: %s\n\n" "$*" >&2
425 usage; exit 1;
426 fi
427 ;;
428 esac
429 shift
430done
431
432# extract input image file provided with rebuild option to get previous parameters, if any
433if [[ $append_args_l == "yes" ]]; then
434 unset rebuild_param
435
436 # determine resultant file
437 if ! [[ $outfile ]]; then
438 outfile=$rebuild_file
439 fi
440
441 if ! rebuild_param=$(lsinitrd $rebuild_file '*lib/dracut/build-parameter.txt'); then
442 echo "Image '$rebuild_file' has no rebuild information stored"
443 exit 1
444 fi
445
446 # prepend previous parameters to current command line args
447 if [[ $rebuild_param ]]; then
448 TEMP="$rebuild_param $TEMP"
449 eval set -- "$TEMP"
450 rearrange_params "$@"
451 fi
452
453 # clean the temporarily used scratch-pad directory
454 rm -rf $scratch_dir
ffa71b4a
HH
455fi
456
659dc319
HB
457unset PARMS_TO_STORE
458PARMS_TO_STORE=""
459
ffa71b4a
HH
460eval set -- "$TEMP"
461
462while :; do
659dc319
HB
463 if [ $1 != "--" ] && [ $1 != "--rebuild" ]; then
464 PARMS_TO_STORE+=" $1";
465 fi
ffa71b4a 466 case $1 in
659dc319
HB
467 --kver) kernel="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
468 -a|--add) push add_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
469 --force-add) push force_add_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
470 --add-drivers) push add_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
471 --omit-drivers) push omit_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
472 -m|--modules) push dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
473 -o|--omit) push omit_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
474 -d|--drivers) push drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
475 --filesystems) push filesystems_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
476 -I|--install) push install_items_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
54b68829
HH
477 --install-optional)
478 push install_optional_items_l \
479 "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
659dc319
HB
480 --fwdir) push fw_dir_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
481 --libdirs) push libdirs_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
482 --fscks) push fscks_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
483 --add-fstab) push add_fstab_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
484 --mount) push fstab_lines "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
c586b033 485 --add-device|--device)
659dc319
HB
486 push add_device_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
487 --kernel-cmdline) push kernel_cmdline_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
25b45979 488 --nofscks) nofscks_l="yes";;
ff3953ef 489 --ro-mnt) ro_mnt_l="yes";;
659dc319
HB
490 -k|--kmoddir) drivers_dir_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
491 -c|--conf) conffile="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
492 --confdir) confdir="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
493 --tmpdir) tmpdir_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
494 -L|--stdlog) stdloglvl_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
495 --compress) compress_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
496 --prefix) prefix_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
497 --rebuild) if [ $rebuild_file == $outfile ]; then
498 force=yes
499 fi
500 shift
501 ;;
cc02093d
HH
502 -f|--force) force=yes;;
503 --kernel-only) kernel_only="yes"; no_kernel="no";;
504 --no-kernel) kernel_only="no"; no_kernel="yes";;
ab9457ef
HH
505 --print-cmdline)
506 print_cmdline="yes"; hostonly_l="yes"; kernel_only="yes"; no_kernel="yes";;
507 --early-microcode)
508 early_microcode_l="yes";;
509 --no-early-microcode)
510 early_microcode_l="no";;
cc02093d
HH
511 --strip) do_strip_l="yes";;
512 --nostrip) do_strip_l="no";;
f4a94278
HH
513 --prelink) do_prelink_l="yes";;
514 --noprelink) do_prelink_l="no";;
04d18f55
HH
515 --hardlink) do_hardlink_l="yes";;
516 --nohardlink) do_hardlink_l="no";;
fd786adc 517 --noprefix) prefix_l="/";;
690396a5
VL
518 --mdadmconf) mdadmconf_l="yes";;
519 --nomdadmconf) mdadmconf_l="no";;
520 --lvmconf) lvmconf_l="yes";;
521 --nolvmconf) lvmconf_l="no";;
cc02093d 522 --debug) debug="yes";;
57258a2c 523 --profile) profile="yes";;
659dc319 524 --sshkey) sshkey="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
ee54b840 525 --logfile) logfile_l="$2"; shift;;
432196ae
526 -v|--verbose) ((verbosity_mod_l++));;
527 -q|--quiet) ((verbosity_mod_l--));;
dbf8f6ba
HH
528 -l|--local)
529 allowlocal="yes"
b093aa2d
HH
530 [[ -f "$(readlink -f "${0%/*}")/dracut-functions.sh" ]] \
531 && dracutbasedir="$(readlink -f "${0%/*}")"
dbf8f6ba 532 ;;
ea3c4e82
HH
533 -H|--hostonly|--host-only)
534 hostonly_l="yes" ;;
535 -N|--no-hostonly|--no-host-only)
536 hostonly_l="no" ;;
ab9457ef
HH
537 --hostonly-cmdline)
538 hostonly_cmdline_l="yes" ;;
539 --no-hostonly-cmdline)
540 hostonly_cmdline_l="no" ;;
324ea606 541 --persistent-policy)
659dc319 542 persistent_policy_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
cc02093d 543 --fstab) use_fstab_l="yes" ;;
ffa71b4a 544 -h|--help) long_usage; exit 1 ;;
659dc319 545 -i|--include) push include_src "$2"; PARMS_TO_STORE+=" '$2'";
ffa71b4a 546 shift;;
3a714439
VL
547 --bzip2) compress_l="bzip2";;
548 --lzma) compress_l="lzma";;
549 --xz) compress_l="xz";;
871c8e40 550 --lzo) compress_l="lzo";;
551 --lz4) compress_l="lz4";;
3a714439
VL
552 --no-compress) _no_compress_l="cat";;
553 --gzip) compress_l="gzip";;
ffa71b4a 554 --list-modules) do_list="yes";;
956af8f2
555 -M|--show-modules)
556 show_modules_l="yes"
557 ;;
5fe5c7d0 558 --keep) keep="yes";;
ec3c5951 559 --printsize) printsize="yes";;
7d848c55 560 --regenerate-all) regenerate_all="yes";;
83bb0893 561 --noimageifnotneeded) noimageifnotneeded="yes";;
80626ded 562 --reproducible) reproducible_l="yes";;
ffa71b4a
HH
563 --) shift; break;;
564
565 *) # should not even reach this point
566 printf "\n!Unknown option: '%s'\n\n" "$1" >&2; usage; exit 1;;
567 esac
568 shift
569done
570
571# getopt cannot handle multiple arguments, so just handle "-I,--include"
572# the old fashioned way
573
574while (($# > 0)); do
4eec1a22 575 if [ "${1%%=*}" == "++include" ]; then
659dc319
HB
576 push include_src "$2"
577 push include_target "$3"
578 PARMS_TO_STORE+=" --include '$2' '$3'"
579 shift 2
580 fi
b368a5f3 581 shift
641cc356 582done
ffa71b4a 583
7d848c55
HH
584if [[ $regenerate_all == "yes" ]]; then
585 ret=0
586 if [[ $kernel ]]; then
b093aa2d 587 printf -- "--regenerate-all cannot be called with a kernel version\n" >&2
7d848c55
HH
588 exit 1
589 fi
590
591 if [[ $outfile ]]; then
b093aa2d 592 printf -- "--regenerate-all cannot be called with a image file\n" >&2
7d848c55
HH
593 exit 1
594 fi
595
596 ((len=${#dracut_args[@]}))
597 for ((i=0; i < len; i++)); do
598 [[ ${dracut_args[$i]} == "--regenerate-all" ]] && \
599 unset dracut_args[$i]
600 done
601
602 cd /lib/modules
603 for i in *; do
b29cb516 604 [[ -f $i/modules.dep ]] || [[ -f $i/modules.dep.bin ]] || continue
b093aa2d 605 dracut --kver="$i" "${dracut_args[@]}"
7d848c55
HH
606 ((ret+=$?))
607 done
608 exit $ret
609fi
610
8a5354a9 611if ! [[ $kernel ]]; then
486a1b93
HH
612 kernel=$(uname -r)
613fi
ffa71b4a 614
05214a0b
HH
615if [[ $kernel ]]; then
616 if ! [[ -d /lib/modules/$kernel ]] && [[ $no_kernel != yes ]]; then
617 printf -- "Kernel version $kernel has no module directory /lib/modules/$kernel\n" >&2
618 fi
619fi
620
ffa71b4a 621if ! [[ $outfile ]]; then
cc230300
HH
622 [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
623
624 if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
625 outfile="/boot/${MACHINE_ID}/$kernel/initrd"
626 else
627 outfile="/boot/initramfs-$kernel.img"
628 fi
ffa71b4a 629fi
4cba351e 630
02b5c8e3
HH
631unset LC_MESSAGES
632unset LC_CTYPE
633export LC_ALL=C
634export LANG=C
d619fb5e 635unset LD_LIBRARY_PATH
45404a2a 636unset LD_PRELOAD
1fcf2d2f 637unset GREP_OPTIONS
a55711cd 638
89d44e72 639export DRACUT_LOG_LEVEL=warning
3b403b32 640[[ $debug ]] && {
89d44e72 641 export DRACUT_LOG_LEVEL=debug
c36ce334
VL
642 export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
643 set -x
644}
645
57258a2c
HH
646[[ $profile ]] && {
647 export PS4='+ $(date "+%s.%N") ${BASH_SOURCE}@${LINENO}: ';
648 set -x
649 debug=yes
650}
651
c5a65990 652[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
5d791c0e 653
f1336ac7 654# if we were not passed a config file, try the default one
42c71947 655if [[ ! -f $conffile ]]; then
b093aa2d
HH
656 if [[ $allowlocal ]]; then
657 conffile="$dracutbasedir/dracut.conf"
658 else
eebc929a 659 conffile="/etc/dracut.conf"
b093aa2d 660 fi
42c71947 661fi
f1336ac7 662
2c2c4580 663if [[ ! -d $confdir ]]; then
b093aa2d
HH
664 if [[ $allowlocal ]]; then
665 confdir="$dracutbasedir/dracut.conf.d"
666 else
eebc929a 667 confdir="/etc/dracut.conf.d"
b093aa2d 668 fi
2c2c4580
HH
669fi
670
2245f372
AB
671# source our config file
672[[ -f $conffile ]] && . "$conffile"
673
2c2c4580 674# source our config dir
335bc217 675for f in $(dropindirs_sort ".conf" "$confdir" "$dracutbasedir/dracut.conf.d"); do
a42b2b81
HH
676 [[ -e $f ]] && . "$f"
677done
2c2c4580 678
eab9b75c
HH
679DRACUT_PATH=${DRACUT_PATH:-/usr/sbin /sbin /usr/bin /bin}
680
681for i in $DRACUT_PATH; do
682 rl=$i
683 if [ -L "$i" ]; then
684 rl=$(readlink -f $i)
685 fi
686 if [[ "$NPATH" != *:$rl* ]] ; then
687 NPATH+=":$rl"
688 fi
689done
690export PATH="${NPATH#:}"
691unset NPATH
692
d87c2708 693# these optins add to the stuff in the config file
e5e5c895 694if (( ${#add_dracutmodules_l[@]} )); then
661f9a34
HH
695 while pop add_dracutmodules_l val; do
696 add_dracutmodules+=" $val "
697 done
698fi
699
31f1c02d
AW
700if (( ${#force_add_dracutmodules_l[@]} )); then
701 while pop force_add_dracutmodules_l val; do
702 force_add_dracutmodules+=" $val "
703 done
704fi
705
25b45979
MS
706if (( ${#fscks_l[@]} )); then
707 while pop fscks_l val; do
708 fscks+=" $val "
709 done
710fi
711
70cb8a68
HH
712if (( ${#add_fstab_l[@]} )); then
713 while pop add_fstab_l val; do
714 add_fstab+=" $val "
715 done
716fi
717
718if (( ${#fstab_lines_l[@]} )); then
719 while pop fstab_lines_l val; do
720 push fstab_lines $val
721 done
722fi
723
0ec40e08
HH
724if (( ${#install_items_l[@]} )); then
725 while pop install_items_l val; do
c6c6a088 726 install_items+=" $val "
0ec40e08
HH
727 done
728fi
729
54b68829
HH
730if (( ${#install_optional_items_l[@]} )); then
731 while pop install_optional_items_l val; do
732 install_optional_items+=" $val "
733 done
734fi
735
f1336ac7 736# these options override the stuff in the config file
e5e5c895 737if (( ${#dracutmodules_l[@]} )); then
661f9a34
HH
738 dracutmodules=''
739 while pop dracutmodules_l val; do
740 dracutmodules+="$val "
741 done
742fi
743
e5e5c895 744if (( ${#omit_dracutmodules_l[@]} )); then
661f9a34
HH
745 omit_dracutmodules=''
746 while pop omit_dracutmodules_l val; do
747 omit_dracutmodules+="$val "
748 done
749fi
750
e5e5c895 751if (( ${#filesystems_l[@]} )); then
661f9a34
HH
752 filesystems=''
753 while pop filesystems_l val; do
754 filesystems+="$val "
755 done
756fi
757
e5e5c895 758if (( ${#fw_dir_l[@]} )); then
661f9a34
HH
759 fw_dir=''
760 while pop fw_dir_l val; do
761 fw_dir+="$val "
762 done
763fi
764
c9143a63
JAH
765if (( ${#libdirs_l[@]} )); then
766 libdirs=''
767 while pop libdirs_l val; do
768 libdirs+="$val "
769 done
770fi
771
e103615b 772[[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l
b991617f 773[[ ! $stdloglvl ]] && stdloglvl=4
432196ae
774stdloglvl=$((stdloglvl + verbosity_mod_l))
775((stdloglvl > 6)) && stdloglvl=6
776((stdloglvl < 0)) && stdloglvl=0
777
26537a5b 778[[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
31f7db66 779[[ $do_strip_l ]] && do_strip=$do_strip_l
6c128565 780[[ $do_strip ]] || do_strip=yes
f4a94278
HH
781[[ $do_prelink_l ]] && do_prelink=$do_prelink_l
782[[ $do_prelink ]] || do_prelink=yes
04d18f55
HH
783[[ $do_hardlink_l ]] && do_hardlink=$do_hardlink_l
784[[ $do_hardlink ]] || do_hardlink=yes
fd786adc
HH
785[[ $prefix_l ]] && prefix=$prefix_l
786[[ $prefix = "/" ]] && unset prefix
ba726310 787[[ $hostonly_l ]] && hostonly=$hostonly_l
ab9457ef 788[[ $hostonly_cmdline_l ]] && hostonly_cmdline=$hostonly_cmdline_l
30f6c80d 789[[ "$hostonly" == "yes" ]] && ! [[ $hostonly_cmdline ]] && hostonly_cmdline="yes"
3411ad66 790[[ $persistent_policy_l ]] && persistent_policy=$persistent_policy_l
7c179686 791[[ $use_fstab_l ]] && use_fstab=$use_fstab_l
2f02ae9d 792[[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l
7a34efa5 793[[ $lvmconf_l ]] && lvmconf=$lvmconf_l
c5a65990 794[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
8bc650d9 795[[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware"
882c4c5a
796[[ $tmpdir_l ]] && tmpdir="$tmpdir_l"
797[[ $tmpdir ]] || tmpdir=/var/tmp
871c8e40 798[[ $INITRD_COMPRESS ]] && compress=$INITRD_COMPRESS
3a714439 799[[ $compress_l ]] && compress=$compress_l
956af8f2 800[[ $show_modules_l ]] && show_modules=$show_modules_l
25b45979 801[[ $nofscks_l ]] && nofscks="yes"
ff3953ef 802[[ $ro_mnt_l ]] && ro_mnt="yes"
b7c770e1
DS
803[[ $early_microcode_l ]] && early_microcode=$early_microcode_l
804[[ $early_microcode ]] || early_microcode=no
ee54b840 805[[ $logfile_l ]] && logfile="$logfile_l"
80626ded
HH
806[[ $reproducible_l ]] && reproducible="$reproducible_l"
807
ddfd1d10
VL
808# eliminate IFS hackery when messing with fw_dir
809fw_dir=${fw_dir//:/ }
9a8a00cf 810
3a714439 811# handle compression options.
55468fb9 812[[ $compress ]] || compress="gzip"
3a714439 813case $compress in
6f223367 814 bzip2) compress="bzip2 -9";;
a76a22b7
KK
815 lzma) compress="lzma -9 -T0";;
816 xz) compress="xz --check=crc32 --lzma2=dict=1MiB -T0";;
80626ded 817 gzip) compress="gzip -n -9 --rsyncable"; command -v pigz > /dev/null 2>&1 && compress="pigz -9 -n -T -R";;
871c8e40 818 lzo) compress="lzop -9";;
8a2db478 819 lz4) compress="lz4 -l -9";;
3a714439
VL
820esac
821if [[ $_no_compress_l = "cat" ]]; then
822 compress="cat"
823fi
824
ba726310 825[[ $hostonly = yes ]] && hostonly="-h"
ba67b923 826[[ $hostonly != "-h" ]] && unset hostonly
ba726310 827
80626ded
HH
828[[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1
829
26c231f1 830readonly TMPDIR="$tmpdir"
b093aa2d 831readonly initdir="$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)"
26c231f1 832[ -d "$initdir" ] || {
f49ec88a 833 printf "%s\n" "dracut: mktemp --tmpdir='$TMPDIR/' -d -t initramfs.XXXXXX failed." >&2
26c231f1
HH
834 exit 1
835}
836
cd08059f 837if [[ $early_microcode = yes ]] || ( [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]] ); then
b5b608e4
TR
838 readonly early_cpio_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_cpio.XXXXXX)"
839 [ -d "$early_cpio_dir" ] || {
f49ec88a 840 printf "%s\n" "dracut: mktemp --tmpdir='$TMPDIR/' -d -t early_cpio.XXXXXX failed." >&2
5f2c30d9
KRW
841 exit 1
842 }
843fi
d008b6b8 844# clean up after ourselves no matter how we die.
bbaa0d59
HH
845trap '
846 ret=$?;
bbaa0d59 847 [[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; };
b5b608e4 848 [[ $keep ]] && echo "Not removing $early_cpio_dir." >&2 || { [[ $early_cpio_dir ]] && rm -Rf -- "$early_cpio_dir"; };
bbaa0d59
HH
849 [[ $_dlogdir ]] && rm -Rf -- "$_dlogdir";
850 exit $ret;
851 ' EXIT
852
d008b6b8
HH
853# clean up after ourselves no matter how we die.
854trap 'exit 1;' SIGINT
855
89d44e72
HH
856export DRACUT_KERNEL_LAZY="1"
857export DRACUT_RESOLVE_LAZY="1"
858
535f61ca
HH
859if [[ $print_cmdline ]]; then
860 stdloglvl=0
861 sysloglvl=0
862 fileloglvl=0
863 kmsgloglvl=0
864fi
865
552ecca6
HH
866if [[ -f $dracutbasedir/dracut-functions.sh ]]; then
867 . $dracutbasedir/dracut-functions.sh
adbc8a42 868else
b093aa2d
HH
869 printf "%s\n" "dracut: Cannot find $dracutbasedir/dracut-functions.sh." >&2
870 printf "%s\n" "dracut: Are you running from a git checkout?" >&2
871 printf "%s\n" "dracut: Try passing -l as an argument to $0" >&2
cc02093d 872 exit 1
adbc8a42 873fi
22fd1627 874
1743473b
HH
875if ! [[ $print_cmdline ]]; then
876 inst /bin/sh
ffc68f35 877 if ! $DRACUT_INSTALL ${initdir:+-D "$initdir"} -R "$initdir/bin/sh" &>/dev/null; then
1743473b
HH
878 unset DRACUT_RESOLVE_LAZY
879 export DRACUT_RESOLVE_DEPS=1
880 fi
881 rm -fr -- ${initdir}/*
bfd2e8c2 882fi
bfd2e8c2 883
dbf8f6ba
HH
884if [[ -f $dracutbasedir/dracut-version.sh ]]; then
885 . $dracutbasedir/dracut-version.sh
886fi
887
bfd2e8c2 888# Verify bash version, current minimum is 3.1
b093aa2d
HH
889if (( BASH_VERSINFO[0] < 4 )); then
890 dfatal 'You need at least Bash 4 to use dracut, sorry.'
d239b550
MS
891 exit 1
892fi
893
552ecca6 894dracutfunctions=$dracutbasedir/dracut-functions.sh
5cad5bb5 895export dracutfunctions
9a8a00cf 896
fcbcb252
HH
897if (( ${#drivers_l[@]} )); then
898 drivers=''
899 while pop drivers_l val; do
900 drivers+="$val "
901 done
902fi
903drivers=${drivers/-/_}
904
905if (( ${#add_drivers_l[@]} )); then
906 while pop add_drivers_l val; do
907 add_drivers+=" $val "
908 done
909fi
910add_drivers=${add_drivers/-/_}
911
912if (( ${#omit_drivers_l[@]} )); then
913 while pop omit_drivers_l val; do
914 omit_drivers+=" $val "
915 done
916fi
917omit_drivers=${omit_drivers/-/_}
918
d20fb951
HH
919if (( ${#kernel_cmdline_l[@]} )); then
920 while pop kernel_cmdline_l val; do
921 kernel_cmdline+=" $val "
922 done
923fi
924
34248c92 925omit_drivers_corrected=""
fcbcb252 926for d in $omit_drivers; do
b093aa2d 927 [[ " $drivers $add_drivers " == *\ $d\ * ]] && continue
34248c92 928 omit_drivers_corrected+="$d|"
fcbcb252 929done
34248c92 930omit_drivers="${omit_drivers_corrected%|}"
fcbcb252
HH
931unset omit_drivers_corrected
932
ffa71b4a
HH
933# prepare args for logging
934for ((i=0; i < ${#dracut_args[@]}; i++)); do
b093aa2d 935 [[ "${dracut_args[$i]}" == *\ * ]] && \
ffa71b4a 936 dracut_args[$i]="\"${dracut_args[$i]}\""
a4210166 937 #" keep vim happy
ffa71b4a 938done
535f61ca 939
bbaa0d59 940dinfo "Executing: $0 ${dracut_args[@]}"
58dad702 941
5b11bb73
HH
942[[ $do_list = yes ]] && {
943 for mod in $dracutbasedir/modules.d/*; do
944 [[ -d $mod ]] || continue;
d8e8e14e
945 [[ -e $mod/install || -e $mod/installkernel || \
946 -e $mod/module-setup.sh ]] || continue
b093aa2d 947 printf "%s\n" "${mod##*/??}"
5b11bb73
HH
948 done
949 exit 0
950}
951
66ac3cd1 952# This is kinda legacy -- eventually it should go away.
f1336ac7 953case $dracutmodules in
66ac3cd1 954 ""|auto) dracutmodules="all" ;;
f1336ac7 955esac
e12aac5e 956
454771cd 957abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
ec9315e5 958
5db6ca5a
HH
959if [[ -d $srcmods ]]; then
960 [[ -f $srcmods/modules.dep ]] || {
961 dwarn "$srcmods/modules.dep is missing. Did you run depmod?"
962 }
963fi
fe1484f3 964
96cf7270
HH
965if [[ ! $print_cmdline ]]; then
966 if [[ -f $outfile && ! $force ]]; then
967 dfatal "Will not override existing initramfs ($outfile) without --force"
968 exit 1
969 fi
970
971 outdir=${outfile%/*}
972 [[ $outdir ]] || outdir="/"
973
974 if [[ ! -d "$outdir" ]]; then
975 dfatal "Can't write to $outdir: Directory $outdir does not exist or is not accessible."
976 exit 1
977 elif [[ ! -w "$outdir" ]]; then
978 dfatal "No permission to write to $outdir."
979 exit 1
980 elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
981 dfatal "No permission to write $outfile."
982 exit 1
983 fi
ec9315e5
JK
984fi
985
8e3f6537
HH
986if [[ $acpi_override = yes ]] && ! check_kernel_config CONFIG_ACPI_INITRD_TABLE_OVERRIDE; then
987 dwarn "Disabling ACPI override, because kernel does not support it. CONFIG_ACPI_INITRD_TABLE_OVERRIDE!=y"
988 unset acpi_override
989fi
990
991if [[ $early_microcode = yes ]]; then
992 if [[ $hostonly ]]; then
993 [[ $(get_cpu_vendor) == "AMD" ]] \
994 && ! check_kernel_config CONFIG_MICROCODE_AMD_EARLY \
995 && unset early_microcode
996 [[ $(get_cpu_vendor) == "Intel" ]] \
997 && ! check_kernel_config CONFIG_MICROCODE_INTEL_EARLY \
998 && unset early_microcode
999 else
1000 ! check_kernel_config CONFIG_MICROCODE_AMD_EARLY \
1001 && ! check_kernel_config CONFIG_MICROCODE_INTEL_EARLY \
1002 && unset early_microcode
1003 fi
1004 [[ $early_microcode != yes ]] \
1005 && dwarn "Disabling early microcode, because kernel does not support it. CONFIG_MICROCODE_[AMD|INTEL]_EARLY!=y"
1006fi
1007
f6f74096
DD
1008# Need to be able to have non-root users read stuff (rpcbind etc)
1009chmod 755 "$initdir"
1010
5bfa3b36
HH
1011if [[ $hostonly ]]; then
1012 for i in /sys /proc /run /dev; do
5e601454 1013 if ! findmnt --target "$i" &>/dev/null; then
5bfa3b36
HH
1014 dwarning "Turning off host-only mode: '$i' is not mounted!"
1015 unset hostonly
1016 fi
1017 done
1018fi
1019
d351541e
HH
1020declare -A host_fs_types
1021
cd7ff122
AW
1022for line in "${fstab_lines[@]}"; do
1023 set -- $line
1024 #dev mp fs fsopts
d0096de7 1025 push host_devs "$1"
d351541e 1026 host_fs_types["$1"]="$3"
cd7ff122
AW
1027done
1028
1029for f in $add_fstab; do
b093aa2d 1030 [[ -e $f ]] || continue
cd7ff122 1031 while read dev rest; do
b093aa2d
HH
1032 push host_devs "$dev"
1033 done < "$f"
1034done
1035
1036for dev in $add_device; do
1037 push host_devs "$dev"
cd7ff122
AW
1038done
1039
c586b033
CG
1040if (( ${#add_device_l[@]} )); then
1041 while pop add_device_l val; do
1042 add_device+=" $val "
b093aa2d 1043 push host_devs "$val"
c586b033
CG
1044 done
1045fi
1046
7ae5d9d1 1047if [[ $hostonly ]]; then
480d772f
HH
1048 # in hostonly mode, determine all devices, which have to be accessed
1049 # and examine them for filesystem types
1050
bcfbddef 1051 for mp in \
7ae5d9d1
HH
1052 "/" \
1053 "/etc" \
d624f606
HH
1054 "/bin" \
1055 "/sbin" \
1056 "/lib" \
1057 "/lib64" \
af75a298 1058 "/usr" \
9fc14445
HH
1059 "/usr/bin" \
1060 "/usr/sbin" \
1061 "/usr/lib" \
1062 "/usr/lib64" \
a956a464
HH
1063 "/boot" \
1064 "/boot/efi" \
1065 ;
bcfbddef 1066 do
d624f606 1067 mp=$(readlink -f "$mp")
7ae5d9d1 1068 mountpoint "$mp" >/dev/null 2>&1 || continue
a4f7b504 1069 _dev=$(find_block_device "$mp")
e95b6723 1070 _bdev=$(readlink -f "/dev/block/$_dev")
a4f7b504
HH
1071 [[ -b $_bdev ]] && _dev=$_bdev
1072 push host_devs $_dev
8da51857 1073 [[ "$mp" == "/" ]] && root_dev="$_dev"
5a6a98f8 1074 push host_devs "$_dev"
7ae5d9d1 1075 done
dd587549 1076
7fd850d5
HH
1077 if [[ -f /proc/swaps ]] && [[ -f /etc/fstab ]]; then
1078 while read dev type rest; do
1079 [[ -b $dev ]] || continue
1080 [[ "$type" == "partition" ]] || continue
1081
1082 while read _d _m _t _o _r; do
1083 [[ "$_d" == \#* ]] && continue
1084 [[ $_d ]] || continue
546d5dac
HH
1085 [[ $_t != "swap" ]] && continue
1086 [[ $_m != "swap" ]] && [[ $_m != "none" ]] && continue
7fd850d5 1087 [[ "$_o" == *noauto* ]] && continue
c82a1133 1088 _d=$(expand_persistent_dev "$_d")
7fd850d5
HH
1089 [[ "$_d" -ef "$dev" ]] || continue
1090
1091 if [[ -f /etc/crypttab ]]; then
1092 while read _mapper _a _p _o; do
1093 [[ $_mapper = \#* ]] && continue
1094 [[ "$_d" -ef /dev/mapper/"$_mapper" ]] || continue
1095 [[ "$_o" ]] || _o="$_p"
64ae4e07
HH
1096 # skip entries with password files
1097 [[ "$_p" == /* ]] && [[ -f $_p ]] && continue 2
1743473b 1098 # skip mkswap swap
7fd850d5
HH
1099 [[ $_o == *swap* ]] && continue 2
1100 done < /etc/crypttab
1101 fi
bcfbddef 1102
7fd850d5
HH
1103 push host_devs "$(readlink -f "$dev")"
1104 break
1105 done < /etc/fstab
1106 done < /proc/swaps
1107 fi
36b2e5e2
CW
1108 # record all host modaliases
1109 declare -A host_modalias
fc68c87a
HH
1110 find /sys/devices/ -name uevent -print > "$initdir/.modalias"
1111 while read m; do
1112 while read line; do
1113 [[ "$line" != MODALIAS\=* ]] && continue
1114 modalias="${line##MODALIAS=}" && [[ $modalias ]] && host_modalias["$modalias"]=1
3b9aaaab 1115 break
fc68c87a
HH
1116 done < "$m"
1117 done < "$initdir/.modalias"
1118
36b2e5e2
CW
1119 rm -f -- "$initdir/.modalias"
1120
4d7c18c7
HH
1121 while read _k _s _v; do
1122 [ "$_k" != "name" -a "$_k" != "driver" ] && continue
1123 host_modalias["$_v"]=1
1124 done </proc/crypto
1125
36b2e5e2
CW
1126 # check /proc/modules
1127 declare -A host_modules
1128 while read m rest; do
1129 host_modules["$m"]=1
1130 done </proc/modules
7ae5d9d1 1131fi
7ae5d9d1 1132
3c4315fa
HH
1133unset m
1134unset rest
1135
dba20559 1136_get_fs_type() {
19bab59c 1137 [[ $1 ]] || return
e41f3f90
HH
1138 if [[ -b /dev/block/$1 ]]; then
1139 ID_FS_TYPE=$(get_fs_env "/dev/block/$1") && host_fs_types["$(readlink -f "/dev/block/$1")"]="$ID_FS_TYPE"
19bab59c 1140 return 1
cd7ff122 1141 fi
e41f3f90
HH
1142 if [[ -b $1 ]]; then
1143 ID_FS_TYPE=$(get_fs_env "$1") && host_fs_types["$(readlink -f "$1")"]="$ID_FS_TYPE"
19bab59c 1144 return 1
4f10ae2b 1145 fi
b093aa2d 1146 if fstype=$(find_dev_fstype "$1"); then
dba20559 1147 host_fs_types["$1"]="$fstype"
19bab59c 1148 return 1
cd7ff122
AW
1149 fi
1150 return 1
dba20559
HH
1151}
1152
1153for dev in ${host_devs[@]}; do
1154 _get_fs_type "$dev"
1155 check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
cd7ff122
AW
1156done
1157
8df0b654
HH
1158for dev in "${!host_fs_types[@]}"; do
1159 [[ ${host_fs_types[$dev]} = "reiserfs" ]] || [[ ${host_fs_types[$dev]} = "xfs" ]] || continue
1160 rootopts=$(find_dev_fsopts "$dev")
1161 if [[ ${host_fs_types[$dev]} = "reiserfs" ]]; then
1162 journaldev=$(fs_get_option $rootopts "jdev")
1163 elif [[ ${host_fs_types[$dev]} = "xfs" ]]; then
1164 journaldev=$(fs_get_option $rootopts "logdev")
1165 fi
1166 if [[ $journaldev ]]; then
1167 dev="$(readlink -f "$dev")"
1168 push host_devs "$dev"
1169 _get_fs_type "$dev"
1170 check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
1171 fi
1172done
1173
d1615612 1174[[ -d $udevdir ]] \
b093aa2d 1175 || udevdir="$(pkg-config udev --variable=udevdir 2>/dev/null)"
d1615612
HH
1176if ! [[ -d "$udevdir" ]]; then
1177 [[ -d /lib/udev ]] && udevdir=/lib/udev
1178 [[ -d /usr/lib/udev ]] && udevdir=/usr/lib/udev
1179fi
1180
1181[[ -d $systemdutildir ]] \
1182 || systemdutildir=$(pkg-config systemd --variable=systemdutildir 2>/dev/null)
d1615612
HH
1183
1184if ! [[ -d "$systemdutildir" ]]; then
1185 [[ -d /lib/systemd ]] && systemdutildir=/lib/systemd
1186 [[ -d /usr/lib/systemd ]] && systemdutildir=/usr/lib/systemd
1187fi
cb8def95
HH
1188
1189[[ -d $systemdsystemunitdir ]] \
1190 || systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null)
1191
d1615612
HH
1192[[ -d "$systemdsystemunitdir" ]] || systemdsystemunitdir=${systemdutildir}/system
1193
cb8def95
HH
1194[[ -d $systemdsystemconfdir ]] \
1195 || systemdsystemconfdir=$(pkg-config systemd --variable=systemdsystemconfdir 2>/dev/null)
1196
1197[[ -d "$systemdsystemconfdir" ]] || systemdsystemconfdir=/etc/systemd/system
1198
aec9f902 1199export initdir dracutbasedir dracutmodules \
e103615b 1200 fw_dir drivers_dir debug no_kernel kernel_only \
5a6a98f8 1201 omit_drivers mdadmconf lvmconf root_dev \
ff3953ef 1202 use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
1e64e493 1203 stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
dbf8f6ba 1204 debug host_fs_types host_devs sshkey add_fstab \
cb8def95 1205 DRACUT_VERSION udevdir prefix filesystems drivers \
3c4315fa 1206 systemdutildir systemdsystemunitdir systemdsystemconfdir \
ee4b74fb 1207 host_modalias host_modules hostonly_cmdline
f4fff04e 1208
1743473b
HH
1209mods_to_load=""
1210# check all our modules to see if they should be sourced.
1211# This builds a list of modules that we will install next.
1212for_each_module_dir check_module
1213for_each_module_dir check_mount
1214
88c86ac7 1215dracut_module_included "fips" && export DRACUT_FIPS_MODE=1
1743473b
HH
1216
1217if [[ $print_cmdline ]]; then
1218 modules_loaded=" "
1219 # source our modules.
1220 for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
1221 _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
1222 module_cmdline "$_d_mod"
1223 done
1224 unset moddir
1225 printf "\n"
1226 exit 0
1227fi
1228
dbad9f46 1229# Create some directory structure first
fd786adc 1230[[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
dbad9f46 1231
785a6cd2 1232[[ -h /lib ]] || mkdir -m 0755 -p "${initdir}${prefix}/lib"
fd786adc 1233[[ $prefix ]] && ln -sfn "${prefix#/}/lib" "$initdir/lib"
dbad9f46 1234
785a6cd2 1235if [[ $prefix ]]; then
d2a9c4a8 1236 for d in bin etc lib sbin tmp usr var $libdirs; do
b093aa2d 1237 [[ "$d" == */* ]] && continue
785a6cd2
HH
1238 ln -sfn "${prefix#/}/${d#/}" "$initdir/$d"
1239 done
1240fi
1241
1242if [[ $kernel_only != yes ]]; then
3f54a83c 1243 for d in usr/bin usr/sbin bin etc lib sbin tmp usr var $libdirs; do
fd786adc 1244 [[ -e "${initdir}${prefix}/$d" ]] && continue
d433da44
HH
1245 if [ -L "/$d" ]; then
1246 inst_symlink "/$d" "${prefix}/$d"
785a6cd2
HH
1247 else
1248 mkdir -m 0755 -p "${initdir}${prefix}/$d"
1249 fi
3b403b32 1250 done
dbad9f46 1251
8d89fc6b 1252 for d in dev proc sys sysroot root run; do
d433da44
HH
1253 if [ -L "/$d" ]; then
1254 inst_symlink "/$d"
785a6cd2
HH
1255 else
1256 mkdir -m 0755 -p "$initdir/$d"
1257 fi
33ee031c 1258 done
dbad9f46 1259
506b2192
HH
1260 ln -sfn ../run "$initdir/var/run"
1261 ln -sfn ../run/lock "$initdir/var/lock"
3f54a83c 1262 ln -sfn ../run/log "$initdir/var/log"
6f09acf8
HH
1263else
1264 for d in lib "$libdir"; do
1265 [[ -e "${initdir}${prefix}/$d" ]] && continue
1266 if [ -h "/$d" ]; then
1267 inst "/$d" "${prefix}/$d"
1268 else
1269 mkdir -m 0755 -p "${initdir}${prefix}/$d"
1270 fi
1271 done
33ee031c 1272fi
0f86847d 1273
14c47b0e
HH
1274if [[ $kernel_only != yes ]]; then
1275 mkdir -p "${initdir}/etc/cmdline.d"
4fed3ddf
HH
1276 for _d in $hookdirs; do
1277 mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
1278 done
26144216 1279 if [[ "$UID" = "0" ]]; then
ad200fbc
HH
1280 [ -c ${initdir}/dev/null ] || mknod ${initdir}/dev/null c 1 3
1281 [ -c ${initdir}/dev/kmsg ] || mknod ${initdir}/dev/kmsg c 1 11
1282 [ -c ${initdir}/dev/console ] || mknod ${initdir}/dev/console c 5 1
26144216 1283 fi
14c47b0e 1284fi
96b8d60a 1285
ec3c5951 1286_isize=0 #initramfs size
979c4a93 1287modules_loaded=" "
95bde758 1288# source our modules.
5d791c0e 1289for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
979c4a93 1290 _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
b093aa2d
HH
1291 if [[ "$mods_to_load" == *\ $_d_mod\ * ]]; then
1292 if [[ $show_modules = yes ]]; then
1293 printf "%s\n" "$_d_mod"
1294 else
979c4a93 1295 dinfo "*** Including module: $_d_mod ***"
b093aa2d
HH
1296 fi
1297 if [[ $kernel_only == yes ]]; then
1298 module_installkernel "$_d_mod" || {
a6d3be9d
AW
1299 dfatal "installkernel failed in module $_d_mod"
1300 exit 1
1301 }
cc02093d 1302 else
b093aa2d 1303 module_install "$_d_mod"
95d2dabc 1304 if [[ $no_kernel != yes ]]; then
b093aa2d 1305 module_installkernel "$_d_mod" || {
a6d3be9d
AW
1306 dfatal "installkernel failed in module $_d_mod"
1307 exit 1
1308 }
cc02093d
HH
1309 fi
1310 fi
979c4a93
HH
1311 mods_to_load=${mods_to_load// $_d_mod /}
1312 modules_loaded+="$_d_mod "
ec3c5951
DY
1313
1314 #print the module install size
1315 if [ -n "$printsize" ]; then
1316 _isize_new=$(du -sk ${initdir}|cut -f1)
b093aa2d
HH
1317 _isize_delta=$((_isize_new - _isize))
1318 printf "%s\n" "$_d_mod install size: ${_isize_delta}k"
ec3c5951
DY
1319 _isize=$_isize_new
1320 fi
66ac3cd1 1321 fi
15136762 1322done
20abd914 1323unset moddir
0a35a80b
HH
1324
1325for i in $modules_loaded; do
43fed151 1326 mkdir -p $initdir/lib/dracut
b093aa2d 1327 printf "%s\n" "$i" >> $initdir/lib/dracut/modules.txt
0a35a80b
HH
1328done
1329
ea216a65 1330dinfo "*** Including modules done ***"
aabc0553 1331
0f86847d 1332## final stuff that has to happen
89d44e72 1333if [[ $no_kernel != yes ]]; then
aec9f902
HH
1334
1335 if [[ $drivers ]]; then
1336 hostonly='' instmods $drivers
1337 fi
1338
1339 if [[ $add_drivers ]]; then
1340 hostonly='' instmods -c $add_drivers
1341 fi
1342 if [[ $filesystems ]]; then
1343 hostonly='' instmods -c $filesystems
1344 fi
1345
89d44e72
HH
1346 dinfo "*** Installing kernel module dependencies and firmware ***"
1347 dracut_kernel_post
1348 dinfo "*** Installing kernel module dependencies and firmware done ***"
83bb0893
HH
1349
1350 if [[ $noimageifnotneeded == yes ]] && [[ $hostonly ]]; then
1351 if [[ ! -f "$initdir/lib/dracut/need-initqueue" ]] && \
1352 [[ -f ${initdir}/lib/modules/$kernel/modules.dep && ! -s ${initdir}/lib/modules/$kernel/modules.dep ]]; then
1353 for i in ${initdir}/etc/cmdline.d/*.conf; do
1354 # We need no initramfs image and do not generate one.
1355 [[ $i == "${initdir}/etc/cmdline.d/*.conf" ]] && exit 0
1356 done
1357 fi
1358 fi
89d44e72 1359fi
d8aeb3a7 1360
998bf6e0 1361if [[ $kernel_only != yes ]]; then
af119460 1362 (( ${#install_items[@]} > 0 )) && inst_multiple ${install_items[@]}
54b68829 1363 (( ${#install_optional_items[@]} > 0 )) && inst_multiple -o ${install_optional_items[@]}
998bf6e0 1364
b093aa2d 1365 [[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
d20fb951 1366
998bf6e0 1367 while pop fstab_lines line; do
5f6a495b
DY
1368 line=($line)
1369 [ -z "${line[3]}" ] && line[3]="defaults"
1370 [ -z "${line[4]}" ] && line[4]="0"
1371 [ -z "${line[5]}" ] && line[5]="2"
1372 echo "${line[@]}" >> "${initdir}/etc/fstab"
998bf6e0
HH
1373 done
1374
1375 for f in $add_fstab; do
b093aa2d 1376 cat "$f" >> "${initdir}/etc/fstab"
998bf6e0
HH
1377 done
1378
6c6d8057
HH
1379 if [ -d ${initdir}/$systemdutildir ]; then
1380 mkdir -p ${initdir}/etc/conf.d
1381 {
b093aa2d
HH
1382 printf "%s\n" "systemdutildir=\"$systemdutildir\""
1383 printf "%s\n" "systemdsystemunitdir=\"$systemdsystemunitdir\""
1384 printf "%s\n" "systemdsystemconfdir=\"$systemdsystemconfdir\""
6c6d8057
HH
1385 } > ${initdir}/etc/conf.d/systemd.conf
1386 fi
1387
998bf6e0
HH
1388 if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then
1389 dinfo "*** Resolving executable dependencies ***"
1390 find "$initdir" -type f \
1391 '(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \
1392 -not -path '*.ko' -print0 \
ffc68f35 1393 | xargs -r -0 $DRACUT_INSTALL ${initdir:+-D "$initdir"} -R ${DRACUT_FIPS_MODE:+-H} --
998bf6e0
HH
1394 dinfo "*** Resolving executable dependencies done***"
1395 fi
8dcc4830
HH
1396
1397 # libpthread workaround: pthread_cancel wants to dlopen libgcc_s.so
1398 for _dir in $libdirs; do
1399 for _f in "$_dir/libpthread.so"*; do
1400 [[ -e "$_f" ]] || continue
1401 inst_libdir_file "libgcc_s.so*"
1402 break 2
1403 done
1404 done
998bf6e0
HH
1405fi
1406
661f9a34
HH
1407while pop include_src src && pop include_target tgt; do
1408 if [[ $src && $tgt ]]; then
1409 if [[ -f $src ]]; then
1410 inst $src $tgt
1411 else
3b403b32 1412 ddebug "Including directory: $src"
661f9a34 1413 mkdir -p "${initdir}/${tgt}"
dbad9f46 1414 # check for preexisting symlinks, so we can cope with the
fd786adc 1415 # symlinks to $prefix
dbad9f46
HH
1416 for i in "$src"/*; do
1417 [[ -e "$i" || -h "$i" ]] || continue
1418 s=${initdir}/${tgt}/${i#$src/}
1419 if [[ -d "$i" ]]; then
1420 if ! [[ -e "$s" ]]; then
1421 mkdir -m 0755 -p "$s"
1422 chmod --reference="$i" "$s"
1423 fi
98eb6d57 1424 cp --reflink=auto --sparse=auto -fa -t "$s" "$i"/*
dbad9f46 1425 else
98eb6d57 1426 cp --reflink=auto --sparse=auto -fa -t "$s" "$i"
3b403b32 1427 fi
dbad9f46 1428 done
661f9a34 1429 fi
4fea3ea6 1430 fi
661f9a34 1431done
88ffd2df 1432
14c47b0e 1433if [[ $kernel_only != yes ]]; then
1254925f
HH
1434 # make sure that library links are correct and up to date
1435 for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do
482c573d 1436 [[ -f $f ]] && inst_simple "$f"
1254925f
HH
1437 done
1438 if ! ldconfig -r "$initdir"; then
1439 if [[ $UID = 0 ]]; then
1440 derror "ldconfig exited ungracefully"
1441 else
1442 derror "ldconfig might need uid=0 (root) for chroot()"
1443 fi
432196ae
1444 fi
1445fi
fdc421db 1446
6cd7001b
HH
1447PRELINK_BIN="$(command -v prelink)"
1448if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then
1449 if [[ $DRACUT_FIPS_MODE ]]; then
1450 dinfo "*** Installing prelink files ***"
1451 inst_multiple -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf /etc/prelink.cache
1452 elif [[ $do_prelink == yes ]]; then
1453 dinfo "*** Pre-linking files ***"
1454 inst_multiple -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf
1455 chroot "$initdir" "$PRELINK_BIN" -a
1456 rm -f -- "$initdir/$PRELINK_BIN"
1457 rm -fr -- "$initdir"/etc/prelink.*
1458 dinfo "*** Pre-linking files done ***"
404815ea
HH
1459 fi
1460fi
1461
1462if [[ $do_hardlink = yes ]] && command -v hardlink >/dev/null; then
1463 dinfo "*** Hardlinking files ***"
1464 hardlink "$initdir" 2>&1
1465 dinfo "*** Hardlinking files done ***"
1466fi
1467
3b403b32 1468# strip binaries
98adb06e 1469if [[ $do_strip = yes ]] ; then
69b35075 1470 for p in strip xargs find; do
cc02093d 1471 if ! type -P $p >/dev/null; then
fefd3f66 1472 dinfo "Could not find '$p'. Not stripping the initramfs."
cc02093d
HH
1473 do_strip=no
1474 fi
31f7db66
HH
1475 done
1476fi
1477
5ae33613 1478if [[ $do_strip = yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then
89d44e72 1479 dinfo "*** Stripping files ***"
5ae33613
HH
1480 find "$initdir" -type f \
1481 -executable -not -path '*/lib/modules/*.ko' -print0 \
1482 | xargs -r -0 strip -g 2>/dev/null
2d9b156e
HH
1483
1484 # strip kernel modules, but do not touch signed modules
1485 find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
1486 | while read -r -d $'\0' f; do
1487 SIG=$(tail -c 28 "$f")
b093aa2d 1488 [[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; }
2d9b156e
HH
1489 done | xargs -r -0 strip -g
1490
89d44e72 1491 dinfo "*** Stripping files done ***"
979c4a93 1492fi
5f2c30d9
KRW
1493if [[ $early_microcode = yes ]]; then
1494 dinfo "*** Generating early-microcode cpio image ***"
1495 ucode_dir=(amd-ucode intel-ucode)
1496 ucode_dest=(AuthenticAMD.bin GenuineIntel.bin)
b5b608e4 1497 _dest_dir="$early_cpio_dir/d/kernel/x86/microcode"
5f2c30d9
KRW
1498 _dest_idx="0 1"
1499 mkdir -p $_dest_dir
1500 if [[ $hostonly ]]; then
1501 [[ $(get_cpu_vendor) == "AMD" ]] && _dest_idx="0"
1502 [[ $(get_cpu_vendor) == "Intel" ]] && _dest_idx="1"
1503 fi
1504 for idx in $_dest_idx; do
1505 _fw=${ucode_dir[$idx]}
1506 for _fwdir in $fw_dir; do
1507 if [[ -d $_fwdir && -d $_fwdir/$_fw ]]; then
1508 _src="*"
1509 dinfo "*** Constructing ${ucode_dest[$idx]} ****"
1510 if [[ $hostonly ]]; then
1511 _src=$(get_ucode_file)
d8b04dc1
TR
1512 if ! [[ -r $_fwdir/$_fw/$_src ]];then
1513 break;
1514 fi
5f2c30d9
KRW
1515 fi
1516 cat $_fwdir/$_fw/$_src > $_dest_dir/${ucode_dest[$idx]}
d8b04dc1 1517 create_early_cpio="yes"
5f2c30d9
KRW
1518 fi
1519 done
1520 done
5f2c30d9 1521fi
bbaa0d59 1522
f3b14c2b
TR
1523if [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]]; then
1524 dinfo "*** Packaging ACPI tables to override BIOS provided ones ***"
1525 _dest_dir="$early_cpio_dir/d/kernel/firmware/acpi"
1526 mkdir -p $_dest_dir
1527 for table in $acpi_table_dir/*.aml; do
1528 dinfo " Adding ACPI table: $table"
80626ded 1529 cp -a $table $_dest_dir
f3b14c2b
TR
1530 create_early_cpio="yes"
1531 done
1532fi
1533
659dc319
HB
1534dinfo "*** Store current command line parameters ***"
1535if ! ( echo $PARMS_TO_STORE > $initdir/lib/dracut/build-parameter.txt ); then
1536 dfatal "Could not store the current command line parameters"
1537 exit 1
1538fi
1539
32bd2fbb 1540rm -f -- "$outfile"
89d44e72 1541dinfo "*** Creating image file ***"
c8a9a6b4 1542
80626ded
HH
1543if [[ $DRACUT_REPRODUCIBLE ]]; then
1544 find "$initdir" -newer "$dracutbasedir/dracut-functions.sh" -print0 \
1545 | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh"
1546
1547 [[ "$(cpio --help)" == *--reproducible* ]] && CPIO_REPRODUCIBLE=1
1548fi
1549
c8a9a6b4
HH
1550[[ "$UID" != 0 ]] && cpio_owner_root="-R 0:0"
1551
b5b608e4 1552if [[ $create_early_cpio = yes ]]; then
b9909e33 1553 echo 1 > "$early_cpio_dir/d/early_cpio"
80626ded
HH
1554
1555 if [[ $DRACUT_REPRODUCIBLE ]]; then
1556 find "$early_cpio_dir/d" -newer "$dracutbasedir/dracut-functions.sh" -print0 \
1557 | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh"
1558 fi
1559
5f2c30d9 1560 # The microcode blob is _before_ the initramfs blob, not after
80626ded
HH
1561 (
1562 cd "$early_cpio_dir/d"
1563 find . -print0 | sort -z \
1564 | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null $cpio_owner_root -H newc -o --quiet > $outfile
1565 )
5f2c30d9 1566fi
80626ded
HH
1567
1568if ! (
1569 umask 077; cd "$initdir"
1570 find . -print0 | sort -z \
1571 | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null $cpio_owner_root -H newc -o --quiet \
1572 | $compress >> "$outfile"
1573 ); then
dc4c1ee3 1574 dfatal "dracut: creation of $outfile failed"
734a0d9e 1575 exit 1
3b403b32 1576fi
89d44e72 1577dinfo "*** Creating image file done ***"
432196ae 1578
bbaa0d59 1579if (( maxloglvl >= 5 )); then
dadd2b69
HH
1580 if [[ $allowlocal ]]; then
1581 "$dracutbasedir/lsinitrd.sh" "$outfile"| ddebug
1582 else
1583 lsinitrd "$outfile"| ddebug
1584 fi
bbaa0d59 1585fi
1faecdc1 1586
3da58569 1587exit 0