]> git.ipfire.org Git - thirdparty/dracut.git/blob - dracut.sh
dracut.sh: remove push()
[thirdparty/dracut.git] / dracut.sh
1 #!/bin/bash --norc
2 #
3 # Generator script for a dracut initramfs
4 # Tries to retain some degree of compatibility with the command line
5 # of the various mkinitrd implementations out there
6 #
7
8 # Copyright 2005-2013 Red Hat, Inc. All rights reserved.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #
23
24 # store for logging
25 dracut_args=( "$@" )
26
27 set -o pipefail
28
29 usage() {
30 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
31 if [[ -f $dracutbasedir/dracut-version.sh ]]; then
32 . $dracutbasedir/dracut-version.sh
33 fi
34
35 # 80x25 linebreak here ^
36 cat << EOF
37 Usage: $0 [OPTION]... [<initramfs> [<kernel-version>]]
38
39 Version: $DRACUT_VERSION
40
41 Creates initial ramdisk images for preloading modules
42
43 -h, --help Display all options
44
45 If a [LIST] has multiple arguments, then you have to put these in quotes.
46
47 For example:
48
49 # dracut --add-drivers "module1 module2" ...
50
51 EOF
52 }
53
54 long_usage() {
55 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
56 if [[ -f $dracutbasedir/dracut-version.sh ]]; then
57 . $dracutbasedir/dracut-version.sh
58 fi
59
60 # 80x25 linebreak here ^
61 cat << EOF
62 Usage: $0 [OPTION]... [<initramfs> [<kernel-version>]]
63
64 Version: $DRACUT_VERSION
65
66 Creates initial ramdisk images for preloading modules
67
68 --kver [VERSION] Set kernel version to [VERSION].
69 -f, --force Overwrite existing initramfs file.
70 -a, --add [LIST] Add a space-separated list of dracut modules.
71 --rebuild Append arguments to those of existing image and rebuild
72 -m, --modules [LIST] Specify a space-separated list of dracut modules to
73 call when building the initramfs. Modules are located
74 in /usr/lib/dracut/modules.d.
75 -o, --omit [LIST] Omit a space-separated list of dracut modules.
76 --force-add [LIST] Force to add a space-separated list of dracut modules
77 to the default set of modules, when -H is specified.
78 -d, --drivers [LIST] Specify a space-separated list of kernel modules to
79 exclusively include in the initramfs.
80 --add-drivers [LIST] Specify a space-separated list of kernel
81 modules to add to the initramfs.
82 --force-drivers [LIST] Specify a space-separated list of kernel
83 modules to add to the initramfs and make sure they
84 are tried to be loaded via modprobe same as passing
85 rd.driver.pre=DRIVER kernel parameter.
86 --omit-drivers [LIST] Specify a space-separated list of kernel
87 modules not to add to the initramfs.
88 --filesystems [LIST] Specify a space-separated list of kernel filesystem
89 modules to exclusively include in the generic
90 initramfs.
91 -k, --kmoddir [DIR] Specify the directory, where to look for kernel
92 modules
93 --fwdir [DIR] Specify additional directories, where to look for
94 firmwares, separated by :
95 --kernel-only Only install kernel drivers and firmware files
96 --no-kernel Do not install kernel drivers and firmware files
97 --print-cmdline Print the kernel command line for the given disk layout
98 --early-microcode Combine early microcode with ramdisk
99 --no-early-microcode Do not combine early microcode with ramdisk
100 --kernel-cmdline [PARAMETERS] Specify default kernel command line parameters
101 --strip Strip binaries in the initramfs
102 --nostrip Do not strip binaries in the initramfs
103 --prelink Prelink binaries in the initramfs
104 --noprelink Do not prelink binaries in the initramfs
105 --hardlink Hardlink files in the initramfs
106 --nohardlink Do not hardlink files in the initramfs
107 --prefix [DIR] Prefix initramfs files with [DIR]
108 --noprefix Do not prefix initramfs files
109 --mdadmconf Include local /etc/mdadm.conf
110 --nomdadmconf Do not include local /etc/mdadm.conf
111 --lvmconf Include local /etc/lvm/lvm.conf
112 --nolvmconf Do not include local /etc/lvm/lvm.conf
113 --fscks [LIST] Add a space-separated list of fsck helpers.
114 --nofscks Inhibit installation of any fsck helpers.
115 --ro-mnt Mount / and /usr read-only by default.
116 -h, --help This message
117 --debug Output debug information of the build process
118 --profile Output profile information of the build process
119 -L, --stdlog [0-6] Specify logging level (to standard error)
120 0 - suppress any messages
121 1 - only fatal errors
122 2 - all errors
123 3 - warnings
124 4 - info
125 5 - debug info (here starts lots of output)
126 6 - trace info (and even more)
127 -v, --verbose Increase verbosity level
128 -q, --quiet Decrease verbosity level
129 -c, --conf [FILE] Specify configuration file to use.
130 Default: /etc/dracut.conf
131 --confdir [DIR] Specify configuration directory to use *.conf files
132 from. Default: /etc/dracut.conf.d
133 --tmpdir [DIR] Temporary directory to be used instead of default
134 /var/tmp.
135 -l, --local Local mode. Use modules from the current working
136 directory instead of the system-wide installed in
137 /usr/lib/dracut/modules.d.
138 Useful when running dracut from a git checkout.
139 -H, --hostonly Host-Only mode: Install only what is needed for
140 booting the local host instead of a generic host.
141 -N, --no-hostonly Disables Host-Only mode
142 --hostonly-cmdline Store kernel command line arguments needed
143 in the initramfs
144 --no-hostonly-cmdline Do not store kernel command line arguments needed
145 in the initramfs
146 --persistent-policy [POLICY]
147 Use [POLICY] to address disks and partitions.
148 POLICY can be any directory name found in /dev/disk.
149 E.g. "by-uuid", "by-label"
150 --fstab Use /etc/fstab to determine the root device.
151 --add-fstab [FILE] Add file to the initramfs fstab
152 --mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
153 Mount device [DEV] on mountpoint [MP] with filesystem
154 [FSTYPE] and options [FSOPTS] in the initramfs
155 --add-device "[DEV]" Bring up [DEV] in initramfs
156 -i, --include [SOURCE] [TARGET]
157 Include the files in the SOURCE directory into the
158 Target directory in the final initramfs.
159 If SOURCE is a file, it will be installed to TARGET
160 in the final initramfs.
161 -I, --install [LIST] Install the space separated list of files into the
162 initramfs.
163 --install-optional [LIST] Install the space separated list of files into the
164 initramfs, if they exist.
165 --gzip Compress the generated initramfs using gzip.
166 This will be done by default, unless another
167 compression option or --no-compress is passed.
168 --bzip2 Compress the generated initramfs using bzip2.
169 Make sure your kernel has bzip2 decompression support
170 compiled in, otherwise you will not be able to boot.
171 --lzma Compress the generated initramfs using lzma.
172 Make sure your kernel has lzma support compiled in,
173 otherwise you will not be able to boot.
174 --xz Compress the generated initramfs using xz.
175 Make sure that your kernel has xz support compiled
176 in, otherwise you will not be able to boot.
177 --lzo Compress the generated initramfs using lzop.
178 Make sure that your kernel has lzo support compiled
179 in, otherwise you will not be able to boot.
180 --lz4 Compress the generated initramfs using lz4.
181 Make sure that your kernel has lz4 support compiled
182 in, otherwise you will not be able to boot.
183 --compress [COMPRESSION] Compress the generated initramfs with the
184 passed compression program. Make sure your kernel
185 knows how to decompress the generated initramfs,
186 otherwise you will not be able to boot.
187 --no-compress Do not compress the generated initramfs. This will
188 override any other compression options.
189 --list-modules List all available dracut modules.
190 -M, --show-modules Print included module's name to standard output during
191 build.
192 --keep Keep the temporary initramfs for debugging purposes
193 --printsize Print out the module install size
194 --sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module)
195 --logfile [FILE] Logfile to use (overrides configuration setting)
196 --reproducible Create reproducible images
197 --loginstall [DIR] Log all files installed from the host to [DIR]
198 --uefi Create an UEFI executable with the kernel cmdline and
199 kernel combined
200 --uefi-stub [FILE] Use the UEFI stub [FILE] to create an UEFI executable
201 --kernel-image [FILE] location of the kernel image
202
203 If [LIST] has multiple arguments, then you have to put these in quotes.
204
205 For example:
206
207 # dracut --add-drivers "module1 module2" ...
208
209 EOF
210 }
211
212 # Fills up host_devs stack variable and makes sure there are no duplicates
213 push_host_devs() {
214 local _dev
215 [[ " ${host_devs[@]} " == *" $1 "* ]] && return
216 host_devs+=( "$1" )
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)
228 pop() {
229 local __stack=$1; shift
230 local __resultvar=$1
231 local _value;
232 # check for empty stack
233 eval '[[ ${#'${__stack}'[@]} -eq 0 ]] && return 1'
234
235 eval _value='${'${__stack}'[${#'${__stack}'[@]}-1]}'
236
237 if [[ "$__resultvar" ]]; then
238 eval $__resultvar="'$_value'"
239 else
240 printf "%s" "$_value"
241 fi
242 eval unset ${__stack}'[${#'${__stack}'[@]}-1]'
243 return 0
244 }
245
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.
249 read_arg() {
250 # $1 = arg name
251 # $2 = arg value
252 # $3 = arg parameter
253 local rematch='^[^=]*=(.*)$'
254 if [[ $2 =~ $rematch ]]; then
255 read "$1" <<< "${BASH_REMATCH[1]}"
256 else
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
261 fi
262 }
263
264 dropindirs_sort()
265 {
266 local suffix=$1; shift
267 local -a files
268 local f d
269
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
284 fi
285 done
286 done
287 }
288 }
289
290 rearrange_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 force-drivers: \
306 --long omit-drivers: \
307 --long modules: \
308 --long omit: \
309 --long drivers: \
310 --long filesystems: \
311 --long install: \
312 --long install-optional: \
313 --long fwdir: \
314 --long libdirs: \
315 --long fscks: \
316 --long add-fstab: \
317 --long mount: \
318 --long device: \
319 --long add-device: \
320 --long nofscks: \
321 --long ro-mnt \
322 --long kmoddir: \
323 --long conf: \
324 --long confdir: \
325 --long tmpdir: \
326 --long stdlog: \
327 --long compress: \
328 --long prefix: \
329 --long rebuild: \
330 --long force \
331 --long kernel-only \
332 --long no-kernel \
333 --long print-cmdline \
334 --long kernel-cmdline: \
335 --long strip \
336 --long nostrip \
337 --long prelink \
338 --long noprelink \
339 --long hardlink \
340 --long nohardlink \
341 --long noprefix \
342 --long mdadmconf \
343 --long nomdadmconf \
344 --long lvmconf \
345 --long nolvmconf \
346 --long debug \
347 --long profile \
348 --long sshkey: \
349 --long logfile: \
350 --long verbose \
351 --long quiet \
352 --long local \
353 --long hostonly \
354 --long host-only \
355 --long no-hostonly \
356 --long no-host-only \
357 --long hostonly-cmdline \
358 --long no-hostonly-cmdline \
359 --long persistent-policy: \
360 --long fstab \
361 --long help \
362 --long bzip2 \
363 --long lzma \
364 --long xz \
365 --long lzo \
366 --long lz4 \
367 --long no-compress \
368 --long gzip \
369 --long list-modules \
370 --long show-modules \
371 --long keep \
372 --long printsize \
373 --long regenerate-all \
374 --long noimageifnotneeded \
375 --long early-microcode \
376 --long no-early-microcode \
377 --long reproducible \
378 --long loginstall: \
379 --long uefi \
380 --long uefi-stub: \
381 --long kernel-image: \
382 -- "$@")
383
384 if (( $? != 0 )); then
385 usage
386 exit 1
387 fi
388 }
389
390 verbosity_mod_l=0
391 unset kernel
392 unset outfile
393
394 rearrange_params "$@"
395 eval set -- "$TEMP"
396
397 # parse command line args to check if '--rebuild' option is present
398 unset append_args_l
399 unset rebuild_file
400 while :
401 do
402 if [ "$1" == "--" ]; then
403 shift; break
404 fi
405 if [ "$1" == "--rebuild" ]; then
406 append_args_l="yes"
407 rebuild_file=$2
408 if [ ! -e $rebuild_file ]; then
409 echo "Image file '$rebuild_file', for rebuild, does not exist!"
410 exit 1
411 fi
412 abs_rebuild_file=$(readlink -f "$rebuild_file") && rebuild_file="$abs_rebuild_file"
413 shift; continue
414 fi
415 shift
416 done
417
418 # get output file name and kernel version from command line arguments
419 while (($# > 0)); do
420 case ${1%%=*} in
421 ++include)
422 shift 2;;
423 *)
424 if ! [[ ${outfile+x} ]]; then
425 outfile=$1
426 elif ! [[ ${kernel+x} ]]; then
427 kernel=$1
428 else
429 printf "\nUnknown arguments: %s\n\n" "$*" >&2
430 usage; exit 1;
431 fi
432 ;;
433 esac
434 shift
435 done
436
437 # extract input image file provided with rebuild option to get previous parameters, if any
438 if [[ $append_args_l == "yes" ]]; then
439 unset rebuild_param
440
441 # determine resultant file
442 if ! [[ $outfile ]]; then
443 outfile=$rebuild_file
444 fi
445
446 if ! rebuild_param=$(lsinitrd $rebuild_file '*lib/dracut/build-parameter.txt'); then
447 echo "Image '$rebuild_file' has no rebuild information stored"
448 exit 1
449 fi
450
451 # prepend previous parameters to current command line args
452 if [[ $rebuild_param ]]; then
453 TEMP="$rebuild_param $TEMP"
454 eval set -- "$TEMP"
455 rearrange_params "$@"
456 fi
457
458 # clean the temporarily used scratch-pad directory
459 rm -rf $scratch_dir
460 fi
461
462 unset PARMS_TO_STORE
463 PARMS_TO_STORE=""
464
465 eval set -- "$TEMP"
466
467 while :; do
468 if [ $1 != "--" ] && [ $1 != "--rebuild" ]; then
469 PARMS_TO_STORE+=" $1";
470 fi
471 case $1 in
472 --kver) kernel="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
473 -a|--add) add_dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
474 --force-add) force_add_dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
475 --add-drivers) add_drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
476 --force-drivers) force_drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
477 --omit-drivers) omit_drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
478 -m|--modules) dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
479 -o|--omit) omit_dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
480 -d|--drivers) drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
481 --filesystems) filesystems_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
482 -I|--install) install_items_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
483 --install-optional) install_optional_items_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
484 --fwdir) fw_dir_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
485 --libdirs) libdirs_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
486 --fscks) fscks_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
487 --add-fstab) add_fstab_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
488 --mount) fstab_lines+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
489 --add-device|--device) add_device_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
490 --kernel-cmdline) kernel_cmdline_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
491 --nofscks) nofscks_l="yes";;
492 --ro-mnt) ro_mnt_l="yes";;
493 -k|--kmoddir) drivers_dir_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
494 -c|--conf) conffile="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
495 --confdir) confdir="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
496 --tmpdir) tmpdir_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
497 -L|--stdlog) stdloglvl_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
498 --compress) compress_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
499 --prefix) prefix_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
500 --loginstall) loginstall_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
501 --rebuild) if [ $rebuild_file == $outfile ]; then
502 force=yes
503 fi
504 shift
505 ;;
506 -f|--force) force=yes;;
507 --kernel-only) kernel_only="yes"; no_kernel="no";;
508 --no-kernel) kernel_only="no"; no_kernel="yes";;
509 --print-cmdline)
510 print_cmdline="yes"; hostonly_l="yes"; kernel_only="yes"; no_kernel="yes";;
511 --early-microcode)
512 early_microcode_l="yes";;
513 --no-early-microcode)
514 early_microcode_l="no";;
515 --strip) do_strip_l="yes";;
516 --nostrip) do_strip_l="no";;
517 --prelink) do_prelink_l="yes";;
518 --noprelink) do_prelink_l="no";;
519 --hardlink) do_hardlink_l="yes";;
520 --nohardlink) do_hardlink_l="no";;
521 --noprefix) prefix_l="/";;
522 --mdadmconf) mdadmconf_l="yes";;
523 --nomdadmconf) mdadmconf_l="no";;
524 --lvmconf) lvmconf_l="yes";;
525 --nolvmconf) lvmconf_l="no";;
526 --debug) debug="yes";;
527 --profile) profile="yes";;
528 --sshkey) sshkey="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
529 --logfile) logfile_l="$2"; shift;;
530 -v|--verbose) ((verbosity_mod_l++));;
531 -q|--quiet) ((verbosity_mod_l--));;
532 -l|--local)
533 allowlocal="yes"
534 [[ -f "$(readlink -f "${0%/*}")/dracut-init.sh" ]] \
535 && dracutbasedir="$(readlink -f "${0%/*}")"
536 ;;
537 -H|--hostonly|--host-only)
538 hostonly_l="yes" ;;
539 -N|--no-hostonly|--no-host-only)
540 hostonly_l="no" ;;
541 --hostonly-cmdline)
542 hostonly_cmdline_l="yes" ;;
543 --no-hostonly-cmdline)
544 hostonly_cmdline_l="no" ;;
545 --persistent-policy)
546 persistent_policy_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
547 --fstab) use_fstab_l="yes" ;;
548 -h|--help) long_usage; exit 1 ;;
549 -i|--include) include_src+=("$2"); PARMS_TO_STORE+=" '$2'";
550 shift;;
551 --bzip2) compress_l="bzip2";;
552 --lzma) compress_l="lzma";;
553 --xz) compress_l="xz";;
554 --lzo) compress_l="lzo";;
555 --lz4) compress_l="lz4";;
556 --no-compress) _no_compress_l="cat";;
557 --gzip) compress_l="gzip";;
558 --list-modules) do_list="yes";;
559 -M|--show-modules)
560 show_modules_l="yes"
561 ;;
562 --keep) keep="yes";;
563 --printsize) printsize="yes";;
564 --regenerate-all) regenerate_all="yes";;
565 --noimageifnotneeded) noimageifnotneeded="yes";;
566 --reproducible) reproducible_l="yes";;
567 --uefi) uefi="yes";;
568 --uefi-stub)
569 uefi_stub_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
570 --kernel-image)
571 kernel_image_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
572 --) shift; break;;
573
574 *) # should not even reach this point
575 printf "\n!Unknown option: '%s'\n\n" "$1" >&2; usage; exit 1;;
576 esac
577 shift
578 done
579
580 # getopt cannot handle multiple arguments, so just handle "-I,--include"
581 # the old fashioned way
582
583 while (($# > 0)); do
584 if [ "${1%%=*}" == "++include" ]; then
585 include_src+=("$2")
586 include_target+=("$3")
587 PARMS_TO_STORE+=" --include '$2' '$3'"
588 shift 2
589 fi
590 shift
591 done
592
593 if [[ $regenerate_all == "yes" ]]; then
594 ret=0
595 if [[ $kernel ]]; then
596 printf -- "--regenerate-all cannot be called with a kernel version\n" >&2
597 exit 1
598 fi
599
600 if [[ $outfile ]]; then
601 printf -- "--regenerate-all cannot be called with a image file\n" >&2
602 exit 1
603 fi
604
605 ((len=${#dracut_args[@]}))
606 for ((i=0; i < len; i++)); do
607 [[ ${dracut_args[$i]} == "--regenerate-all" ]] && \
608 unset dracut_args[$i]
609 done
610
611 cd /lib/modules
612 for i in *; do
613 [[ -f $i/modules.dep ]] || [[ -f $i/modules.dep.bin ]] || continue
614 dracut --kver="$i" "${dracut_args[@]}"
615 ((ret+=$?))
616 done
617 exit $ret
618 fi
619
620 if ! [[ $kernel ]]; then
621 kernel=$(uname -r)
622 fi
623
624 if [[ $kernel ]]; then
625 if ! [[ -d /lib/modules/$kernel ]] && [[ $no_kernel != yes ]]; then
626 printf -- "Kernel version $kernel has no module directory /lib/modules/$kernel\n" >&2
627 fi
628 fi
629
630 if ! [[ $outfile ]]; then
631 [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
632
633 if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
634 outfile="/boot/${MACHINE_ID}/$kernel/initrd"
635 else
636 outfile="/boot/initramfs-$kernel.img"
637 fi
638 fi
639
640 unset LC_MESSAGES
641 unset LC_CTYPE
642 export LC_ALL=C
643 export LANG=C
644 unset LD_LIBRARY_PATH
645 unset LD_PRELOAD
646 unset GREP_OPTIONS
647
648 export DRACUT_LOG_LEVEL=warning
649 [[ $debug ]] && {
650 export DRACUT_LOG_LEVEL=debug
651 export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
652 set -x
653 }
654
655 [[ $profile ]] && {
656 export PS4='+ $(date "+%s.%N") ${BASH_SOURCE}@${LINENO}: ';
657 set -x
658 debug=yes
659 }
660
661 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
662
663 # if we were not passed a config file, try the default one
664 if [[ ! -f $conffile ]]; then
665 if [[ $allowlocal ]]; then
666 conffile="$dracutbasedir/dracut.conf"
667 else
668 conffile="/etc/dracut.conf"
669 fi
670 fi
671
672 if [[ ! -d $confdir ]]; then
673 if [[ $allowlocal ]]; then
674 confdir="$dracutbasedir/dracut.conf.d"
675 else
676 confdir="/etc/dracut.conf.d"
677 fi
678 fi
679
680 # source our config file
681 [[ -f $conffile ]] && . "$conffile"
682
683 # source our config dir
684 for f in $(dropindirs_sort ".conf" "$confdir" "$dracutbasedir/dracut.conf.d"); do
685 [[ -e $f ]] && . "$f"
686 done
687
688 DRACUT_PATH=${DRACUT_PATH:-/sbin /bin /usr/sbin /usr/bin}
689
690 for i in $DRACUT_PATH; do
691 rl=$i
692 if [ -L "$i" ]; then
693 rl=$(readlink -f $i)
694 fi
695 if [[ "$NPATH" != *:$rl* ]] ; then
696 NPATH+=":$rl"
697 fi
698 done
699 export PATH="${NPATH#:}"
700 unset NPATH
701
702 # these optins add to the stuff in the config file
703 if (( ${#add_dracutmodules_l[@]} )); then
704 while pop add_dracutmodules_l val; do
705 add_dracutmodules+=" $val "
706 done
707 fi
708
709 if (( ${#force_add_dracutmodules_l[@]} )); then
710 while pop force_add_dracutmodules_l val; do
711 force_add_dracutmodules+=" $val "
712 done
713 fi
714
715 if (( ${#fscks_l[@]} )); then
716 while pop fscks_l val; do
717 fscks+=" $val "
718 done
719 fi
720
721 if (( ${#add_fstab_l[@]} )); then
722 while pop add_fstab_l val; do
723 add_fstab+=" $val "
724 done
725 fi
726
727 if (( ${#fstab_lines_l[@]} )); then
728 while pop fstab_lines_l val; do
729 fstab_lines+=($val)
730 done
731 fi
732
733 if (( ${#install_items_l[@]} )); then
734 while pop install_items_l val; do
735 install_items+=" $val "
736 done
737 fi
738
739 if (( ${#install_optional_items_l[@]} )); then
740 while pop install_optional_items_l val; do
741 install_optional_items+=" $val "
742 done
743 fi
744
745 # these options override the stuff in the config file
746 if (( ${#dracutmodules_l[@]} )); then
747 dracutmodules=''
748 while pop dracutmodules_l val; do
749 dracutmodules+="$val "
750 done
751 fi
752
753 if (( ${#omit_dracutmodules_l[@]} )); then
754 omit_dracutmodules=''
755 while pop omit_dracutmodules_l val; do
756 omit_dracutmodules+="$val "
757 done
758 fi
759
760 if (( ${#filesystems_l[@]} )); then
761 filesystems=''
762 while pop filesystems_l val; do
763 filesystems+="$val "
764 done
765 fi
766
767 if (( ${#fw_dir_l[@]} )); then
768 fw_dir=''
769 while pop fw_dir_l val; do
770 fw_dir+="$val "
771 done
772 fi
773
774 if (( ${#libdirs_l[@]} )); then
775 libdirs=''
776 while pop libdirs_l val; do
777 libdirs+="$val "
778 done
779 fi
780
781 [[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l
782 [[ ! $stdloglvl ]] && stdloglvl=4
783 stdloglvl=$((stdloglvl + verbosity_mod_l))
784 ((stdloglvl > 6)) && stdloglvl=6
785 ((stdloglvl < 0)) && stdloglvl=0
786
787 [[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
788 [[ $do_strip_l ]] && do_strip=$do_strip_l
789 [[ $do_strip ]] || do_strip=yes
790 [[ $do_prelink_l ]] && do_prelink=$do_prelink_l
791 [[ $do_prelink ]] || do_prelink=yes
792 [[ $do_hardlink_l ]] && do_hardlink=$do_hardlink_l
793 [[ $do_hardlink ]] || do_hardlink=yes
794 [[ $prefix_l ]] && prefix=$prefix_l
795 [[ $prefix = "/" ]] && unset prefix
796 [[ $hostonly_l ]] && hostonly=$hostonly_l
797 [[ $hostonly_cmdline_l ]] && hostonly_cmdline=$hostonly_cmdline_l
798 [[ "$hostonly" == "yes" ]] && ! [[ $hostonly_cmdline ]] && hostonly_cmdline="yes"
799 [[ $persistent_policy_l ]] && persistent_policy=$persistent_policy_l
800 [[ $use_fstab_l ]] && use_fstab=$use_fstab_l
801 [[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l
802 [[ $lvmconf_l ]] && lvmconf=$lvmconf_l
803 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
804 [[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware /lib/firmware/$kernel"
805 [[ $tmpdir_l ]] && tmpdir="$tmpdir_l"
806 [[ $tmpdir ]] || tmpdir=/var/tmp
807 [[ $INITRD_COMPRESS ]] && compress=$INITRD_COMPRESS
808 [[ $compress_l ]] && compress=$compress_l
809 [[ $show_modules_l ]] && show_modules=$show_modules_l
810 [[ $nofscks_l ]] && nofscks="yes"
811 [[ $ro_mnt_l ]] && ro_mnt="yes"
812 [[ $early_microcode_l ]] && early_microcode=$early_microcode_l
813 [[ $early_microcode ]] || early_microcode=no
814 [[ $logfile_l ]] && logfile="$logfile_l"
815 [[ $reproducible_l ]] && reproducible="$reproducible_l"
816 [[ $loginstall_l ]] && loginstall="$loginstall_l"
817 [[ $uefi_stub_l ]] && uefi_stub="$uefi_stub_l"
818 [[ $kernel_image_l ]] && kernel_image="$kernel_image_l"
819
820 # eliminate IFS hackery when messing with fw_dir
821 fw_dir=${fw_dir//:/ }
822
823 # check for logfile and try to create one if it doesn't exist
824 if [[ -n "$logfile" ]];then
825 if [[ ! -f "$logfile" ]];then
826 touch "$logfile"
827 if [ ! $? -eq 0 ] ;then
828 printf "%s\n" "dracut: touch $logfile failed." >&2
829 fi
830 fi
831 fi
832
833 # handle compression options.
834 [[ $compress ]] || compress="gzip"
835 case $compress in
836 bzip2) compress="bzip2 -9";
837 command -v lbzip2 > /dev/null 2>&1 && compress="lbzip2 -9";;
838 lzma) compress="lzma -9 -T0";;
839 xz) compress="xz --check=crc32 --lzma2=dict=1MiB -T0";;
840 gzip) compress="gzip -n -9";
841 if command -v pigz > /dev/null 2>&1; then
842 compress="pigz -9 -n -T -R"
843 elif command -v gzip --help 2>&1 | grep -q rsyncable; then
844 compress="gzip -n -9 --rsyncable"
845 fi
846 ;;
847 lzo) compress="lzop -9";;
848 lz4) compress="lz4 -l -9";;
849 esac
850 if [[ $_no_compress_l = "cat" ]]; then
851 compress="cat"
852 fi
853
854 [[ $hostonly = yes ]] && hostonly="-h"
855 [[ $hostonly != "-h" ]] && unset hostonly
856
857 [[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1
858
859 readonly TMPDIR="$tmpdir"
860 readonly initdir="$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)"
861 [ -d "$initdir" ] || {
862 printf "%s\n" "dracut: mktemp --tmpdir='$TMPDIR/' -d -t initramfs.XXXXXX failed." >&2
863 exit 1
864 }
865
866 if [[ $early_microcode = yes ]] || ( [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]] ); then
867 readonly early_cpio_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_cpio.XXXXXX)"
868 [ -d "$early_cpio_dir" ] || {
869 printf "%s\n" "dracut: mktemp --tmpdir='$TMPDIR/' -d -t early_cpio.XXXXXX failed." >&2
870 exit 1
871 }
872 fi
873 # clean up after ourselves no matter how we die.
874 trap '
875 ret=$?;
876 [[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; };
877 [[ $keep ]] && echo "Not removing $early_cpio_dir." >&2 || { [[ $early_cpio_dir ]] && rm -Rf -- "$early_cpio_dir"; };
878 [[ $keep ]] && echo "Not removing $uefi_outdir." >&2 || { [[ $uefi_outdir ]] && rm -Rf -- "$uefi_outdir"; };
879 [[ $_dlogdir ]] && rm -Rf -- "$_dlogdir";
880 exit $ret;
881 ' EXIT
882
883 # clean up after ourselves no matter how we die.
884 trap 'exit 1;' SIGINT
885
886 export DRACUT_KERNEL_LAZY="1"
887 export DRACUT_RESOLVE_LAZY="1"
888
889 if [[ $print_cmdline ]]; then
890 stdloglvl=0
891 sysloglvl=0
892 fileloglvl=0
893 kmsgloglvl=0
894 fi
895
896 if [[ -f $dracutbasedir/dracut-version.sh ]]; then
897 . $dracutbasedir/dracut-version.sh
898 fi
899
900 if [[ -f $dracutbasedir/dracut-init.sh ]]; then
901 . $dracutbasedir/dracut-init.sh
902 else
903 printf "%s\n" "dracut: Cannot find $dracutbasedir/dracut-init.sh." >&2
904 printf "%s\n" "dracut: Are you running from a git checkout?" >&2
905 printf "%s\n" "dracut: Try passing -l as an argument to $0" >&2
906 exit 1
907 fi
908
909 if ! [[ $print_cmdline ]]; then
910 inst /bin/sh
911 if ! $DRACUT_INSTALL ${initdir:+-D "$initdir"} -R "$initdir/bin/sh" &>/dev/null; then
912 unset DRACUT_RESOLVE_LAZY
913 export DRACUT_RESOLVE_DEPS=1
914 fi
915 rm -fr -- ${initdir}/*
916 fi
917
918 # Verify bash version, current minimum is 4
919 if (( BASH_VERSINFO[0] < 4 )); then
920 dfatal 'You need at least Bash 4 to use dracut, sorry.'
921 exit 1
922 fi
923
924 dracutfunctions=$dracutbasedir/dracut-functions.sh
925 export dracutfunctions
926
927 if (( ${#drivers_l[@]} )); then
928 drivers=''
929 while pop drivers_l val; do
930 drivers+="$val "
931 done
932 fi
933 drivers=${drivers/-/_}
934
935 if (( ${#add_drivers_l[@]} )); then
936 while pop add_drivers_l val; do
937 add_drivers+=" $val "
938 done
939 fi
940 add_drivers=${add_drivers/-/_}
941
942 if (( ${#force_drivers_l[@]} )); then
943 while pop force_drivers_l val; do
944 force_drivers+=" $val "
945 done
946 fi
947 force_drivers=${force_drivers/-/_}
948
949 if (( ${#omit_drivers_l[@]} )); then
950 while pop omit_drivers_l val; do
951 omit_drivers+=" $val "
952 done
953 fi
954 omit_drivers=${omit_drivers/-/_}
955
956 if (( ${#kernel_cmdline_l[@]} )); then
957 while pop kernel_cmdline_l val; do
958 kernel_cmdline+=" $val "
959 done
960 fi
961
962 omit_drivers_corrected=""
963 for d in $omit_drivers; do
964 [[ " $drivers $add_drivers " == *\ $d\ * ]] && continue
965 [[ " $drivers $force_drivers " == *\ $d\ * ]] && continue
966 omit_drivers_corrected+="$d|"
967 done
968 omit_drivers="${omit_drivers_corrected%|}"
969 unset omit_drivers_corrected
970
971 # prepare args for logging
972 for ((i=0; i < ${#dracut_args[@]}; i++)); do
973 [[ "${dracut_args[$i]}" == *\ * ]] && \
974 dracut_args[$i]="\"${dracut_args[$i]}\""
975 #" keep vim happy
976 done
977
978 dinfo "Executing: $0 ${dracut_args[@]}"
979
980 [[ $do_list = yes ]] && {
981 for mod in $dracutbasedir/modules.d/*; do
982 [[ -d $mod ]] || continue;
983 [[ -e $mod/install || -e $mod/installkernel || \
984 -e $mod/module-setup.sh ]] || continue
985 printf "%s\n" "${mod##*/??}"
986 done
987 exit 0
988 }
989
990 # This is kinda legacy -- eventually it should go away.
991 case $dracutmodules in
992 ""|auto) dracutmodules="all" ;;
993 esac
994
995 abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
996
997 if [[ -d $srcmods ]]; then
998 [[ -f $srcmods/modules.dep ]] || {
999 dwarn "$srcmods/modules.dep is missing. Did you run depmod?"
1000 }
1001 fi
1002
1003 if [[ ! $print_cmdline ]]; then
1004 if [[ -f $outfile && ! $force ]]; then
1005 dfatal "Will not override existing initramfs ($outfile) without --force"
1006 exit 1
1007 fi
1008
1009 outdir=${outfile%/*}
1010 [[ $outdir ]] || outdir="/"
1011
1012 if [[ ! -d "$outdir" ]]; then
1013 dfatal "Can't write to $outdir: Directory $outdir does not exist or is not accessible."
1014 exit 1
1015 elif [[ ! -w "$outdir" ]]; then
1016 dfatal "No permission to write to $outdir."
1017 exit 1
1018 elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
1019 dfatal "No permission to write $outfile."
1020 exit 1
1021 fi
1022
1023 if [[ $loginstall ]]; then
1024 if ! mkdir -p "$loginstall"; then
1025 dfatal "Could not create directory to log installed files to '$loginstall'."
1026 exit 1
1027 fi
1028 loginstall=$(readlink -f "$loginstall")
1029 fi
1030
1031 if [[ $uefi = yes ]]; then
1032 if ! command -v objcopy &>/dev/null; then
1033 dfatal "Need 'objcopy' to create a UEFI executable"
1034 exit 1
1035 fi
1036 unset EFI_MACHINE_TYPE_NAME
1037 case $(arch) in
1038 x86_64)
1039 EFI_MACHINE_TYPE_NAME=x64;;
1040 ia32)
1041 EFI_MACHINE_TYPE_NAME=ia32;;
1042 *)
1043 dfatal "Architecture '$(arch)' not supported to create a UEFI executable"
1044 exit 1
1045 ;;
1046 esac
1047
1048 if ! [[ -s $uefi_stub ]]; then
1049 for uefi_stub in \
1050 "/lib/systemd/boot/efi/linux${EFI_MACHINE_TYPE_NAME}.efi.stub" \
1051 "/usr/lib/gummiboot/linux${EFI_MACHINE_TYPE_NAME}.efi.stub"; do
1052 [[ -s $uefi_stub ]] || continue
1053 break
1054 done
1055 fi
1056 if ! [[ -s $uefi_stub ]]; then
1057 dfatal "Can't find a uefi stub '$uefi_stub' to create a UEFI executable"
1058 exit 1
1059 fi
1060
1061 if ! [[ $kernel_image ]]; then
1062 for kernel_image in "/lib/modules/$kernel/vmlinuz" "/boot/vmlinuz-$kernel"; do
1063 [[ -s "$kernel_image" ]] || continue
1064 break
1065 done
1066 fi
1067 if ! [[ -s $kernel_image ]]; then
1068 dfatal "Can't find a kernel image '$kernel_image' to create a UEFI executable"
1069 exit 1
1070 fi
1071 fi
1072 fi
1073
1074 if [[ $acpi_override = yes ]] && ! check_kernel_config CONFIG_ACPI_INITRD_TABLE_OVERRIDE; then
1075 dwarn "Disabling ACPI override, because kernel does not support it. CONFIG_ACPI_INITRD_TABLE_OVERRIDE!=y"
1076 unset acpi_override
1077 fi
1078
1079 if [[ $early_microcode = yes ]]; then
1080 if [[ $hostonly ]]; then
1081 [[ $(get_cpu_vendor) == "AMD" ]] \
1082 && ! check_kernel_config CONFIG_MICROCODE_AMD_EARLY \
1083 && unset early_microcode
1084 [[ $(get_cpu_vendor) == "Intel" ]] \
1085 && ! check_kernel_config CONFIG_MICROCODE_INTEL_EARLY \
1086 && unset early_microcode
1087 else
1088 ! check_kernel_config CONFIG_MICROCODE_AMD_EARLY \
1089 && ! check_kernel_config CONFIG_MICROCODE_INTEL_EARLY \
1090 && unset early_microcode
1091 fi
1092 [[ $early_microcode != yes ]] \
1093 && dwarn "Disabling early microcode, because kernel does not support it. CONFIG_MICROCODE_[AMD|INTEL]_EARLY!=y"
1094 fi
1095
1096 # Need to be able to have non-root users read stuff (rpcbind etc)
1097 chmod 755 "$initdir"
1098
1099 if [[ $hostonly ]]; then
1100 for i in /sys /proc /run /dev; do
1101 if ! findmnt --target "$i" &>/dev/null; then
1102 dwarning "Turning off host-only mode: '$i' is not mounted!"
1103 unset hostonly
1104 fi
1105 done
1106 fi
1107
1108 declare -A host_fs_types
1109
1110 for line in "${fstab_lines[@]}"; do
1111 set -- $line
1112 dev="$1"
1113 #dev mp fs fsopts
1114 case "$dev" in
1115 UUID=*)
1116 dev=$(blkid -l -t UUID=${dev#UUID=} -o device)
1117 ;;
1118 LABEL=*)
1119 dev=$(blkid -l -t LABEL=${dev#LABEL=} -o device)
1120 ;;
1121 PARTUUID=*)
1122 dev=$(blkid -l -t PARTUUID=${dev#PARTUUID=} -o device)
1123 ;;
1124 PARTLABEL=*)
1125 dev=$(blkid -l -t PARTLABEL=${dev#PARTLABEL=} -o device)
1126 ;;
1127 esac
1128 [ -z "$dev" ] && dwarn "Bad fstab entry $@" && continue
1129 if [[ "$3" == btrfs ]]; then
1130 for i in $(btrfs_devs "$2"); do
1131 push_host_devs "$i"
1132 done
1133 fi
1134 push_host_devs "$dev"
1135 host_fs_types["$dev"]="$3"
1136 done
1137
1138 for f in $add_fstab; do
1139 [[ -e $f ]] || continue
1140 while read dev rest || [ -n "$dev" ]; do
1141 push_host_devs "$dev"
1142 done < "$f"
1143 done
1144
1145 for dev in $add_device; do
1146 push_host_devs "$dev"
1147 done
1148
1149 if (( ${#add_device_l[@]} )); then
1150 while pop add_device_l val; do
1151 add_device+=" $val "
1152 push_host_devs "$val"
1153 done
1154 fi
1155
1156 if [[ $hostonly ]]; then
1157 # in hostonly mode, determine all devices, which have to be accessed
1158 # and examine them for filesystem types
1159
1160 for mp in \
1161 "/" \
1162 "/etc" \
1163 "/bin" \
1164 "/sbin" \
1165 "/lib" \
1166 "/lib64" \
1167 "/usr" \
1168 "/usr/bin" \
1169 "/usr/sbin" \
1170 "/usr/lib" \
1171 "/usr/lib64" \
1172 "/boot" \
1173 "/boot/efi" \
1174 ;
1175 do
1176 mp=$(readlink -f "$mp")
1177 mountpoint "$mp" >/dev/null 2>&1 || continue
1178 _dev=$(find_block_device "$mp")
1179 _bdev=$(readlink -f "/dev/block/$_dev")
1180 [[ -b $_bdev ]] && _dev=$_bdev
1181 push_host_devs $_dev
1182 [[ "$mp" == "/" ]] && root_devs+=("$_dev")
1183 push_host_devs "$_dev"
1184 if [[ $(find_mp_fstype "$mp") == btrfs ]]; then
1185 for i in $(btrfs_devs "$mp"); do
1186 [[ "$mp" == "/" ]] && root_devs+=("$i")
1187 push_host_devs "$i"
1188 done
1189 fi
1190 done
1191
1192 if [[ -f /proc/swaps ]] && [[ -f /etc/fstab ]]; then
1193 while read dev type rest || [ -n "$dev" ]; do
1194 [[ -b $dev ]] || continue
1195 [[ "$type" == "partition" ]] || continue
1196
1197 while read _d _m _t _o _r || [ -n "$_d" ]; do
1198 [[ "$_d" == \#* ]] && continue
1199 [[ $_d ]] || continue
1200 [[ $_t != "swap" ]] && continue
1201 [[ $_m != "swap" ]] && [[ $_m != "none" ]] && continue
1202 [[ "$_o" == *noauto* ]] && continue
1203 _d=$(expand_persistent_dev "$_d")
1204 [[ "$_d" -ef "$dev" ]] || continue
1205
1206 if [[ -f /etc/crypttab ]]; then
1207 while read _mapper _a _p _o || [ -n "$_mapper" ]; do
1208 [[ $_mapper = \#* ]] && continue
1209 [[ "$_d" -ef /dev/mapper/"$_mapper" ]] || continue
1210 [[ "$_o" ]] || _o="$_p"
1211 # skip entries with password files
1212 [[ "$_p" == /* ]] && [[ -f $_p ]] && continue 2
1213 # skip mkswap swap
1214 [[ $_o == *swap* ]] && continue 2
1215 done < /etc/crypttab
1216 fi
1217
1218 _dev="$(readlink -f "$dev")"
1219 push_host_devs "$_dev"
1220 swap_devs+=("$_dev")
1221 break
1222 done < /etc/fstab
1223 done < /proc/swaps
1224 fi
1225
1226 # collect all "x-initrd.mount" entries from /etc/fstab
1227 if [[ -f /etc/fstab ]]; then
1228 while read _d _m _t _o _r || [ -n "$_d" ]; do
1229 [[ "$_d" == \#* ]] && continue
1230 [[ $_d ]] || continue
1231 [[ "$_o" != *x-initrd.mount* ]] && continue
1232 _dev=$(expand_persistent_dev "$_d")
1233 _dev="$(readlink -f "$_dev")"
1234 [[ -b $_dev ]] || continue
1235
1236 push_host_devs "$_dev"
1237 if [[ "$_t" == btrfs ]]; then
1238 for i in $(find_btrfs_devs "$_m"); do
1239 push_host_devs "$i"
1240 done
1241 fi
1242 done < /etc/fstab
1243 fi
1244
1245 # record all host modaliases
1246 declare -A host_modalias
1247 find /sys/devices/ -name uevent -print > "$initdir/.modalias"
1248 while read m || [ -n "$m" ]; do
1249 while read line || [ -n "$line" ]; do
1250 [[ "$line" != MODALIAS\=* ]] && continue
1251 modalias="${line##MODALIAS=}" && [[ $modalias ]] && host_modalias["$modalias"]=1
1252 break
1253 done < "$m"
1254 done < "$initdir/.modalias"
1255
1256 rm -f -- "$initdir/.modalias"
1257
1258 while read _k _s _v || [ -n "$_k" ]; do
1259 [ "$_k" != "name" -a "$_k" != "driver" ] && continue
1260 host_modalias["$_v"]=1
1261 done </proc/crypto
1262
1263 # check /proc/modules
1264 declare -A host_modules
1265 while read m rest || [ -n "$m" ]; do
1266 host_modules["$m"]=1
1267 done </proc/modules
1268 fi
1269
1270 unset m
1271 unset rest
1272
1273 _get_fs_type() {
1274 [[ $1 ]] || return
1275 if [[ -b /dev/block/$1 ]]; then
1276 ID_FS_TYPE=$(get_fs_env "/dev/block/$1") && host_fs_types["$(readlink -f "/dev/block/$1")"]="$ID_FS_TYPE"
1277 return 1
1278 fi
1279 if [[ -b $1 ]]; then
1280 ID_FS_TYPE=$(get_fs_env "$1") && host_fs_types["$(readlink -f "$1")"]="$ID_FS_TYPE"
1281 return 1
1282 fi
1283 if fstype=$(find_dev_fstype "$1"); then
1284 host_fs_types["$1"]="$fstype"
1285 return 1
1286 fi
1287 return 1
1288 }
1289
1290 for dev in ${host_devs[@]}; do
1291 _get_fs_type "$dev"
1292 check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
1293 done
1294
1295 for dev in "${!host_fs_types[@]}"; do
1296 [[ ${host_fs_types[$dev]} = "reiserfs" ]] || [[ ${host_fs_types[$dev]} = "xfs" ]] || continue
1297 rootopts=$(find_dev_fsopts "$dev")
1298 if [[ ${host_fs_types[$dev]} = "reiserfs" ]]; then
1299 journaldev=$(fs_get_option $rootopts "jdev")
1300 elif [[ ${host_fs_types[$dev]} = "xfs" ]]; then
1301 journaldev=$(fs_get_option $rootopts "logdev")
1302 fi
1303 if [[ $journaldev ]]; then
1304 dev="$(readlink -f "$dev")"
1305 push_host_devs "$dev"
1306 _get_fs_type "$dev"
1307 check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
1308 fi
1309 done
1310
1311 [[ -d $udevdir ]] \
1312 || udevdir="$(pkg-config udev --variable=udevdir 2>/dev/null)"
1313 if ! [[ -d "$udevdir" ]]; then
1314 [[ ! -h /lib ]] && [[ -d /lib/udev ]] && udevdir=/lib/udev
1315 [[ -d /usr/lib/udev ]] && udevdir=/usr/lib/udev
1316 fi
1317
1318 [[ -d $systemdutildir ]] \
1319 || systemdutildir=$(pkg-config systemd --variable=systemdutildir 2>/dev/null)
1320
1321 if ! [[ -d "$systemdutildir" ]]; then
1322 [[ ! -h /lib ]] && [[ -d /lib/systemd ]] && systemdutildir=/lib/systemd
1323 [[ -d /usr/lib/systemd ]] && systemdutildir=/usr/lib/systemd
1324 fi
1325
1326 [[ -d $systemdsystemunitdir ]] \
1327 || systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null)
1328
1329 [[ -d "$systemdsystemunitdir" ]] || systemdsystemunitdir=${systemdutildir}/system
1330
1331 [[ -d $systemdsystemconfdir ]] \
1332 || systemdsystemconfdir=$(pkg-config systemd --variable=systemdsystemconfdir 2>/dev/null)
1333
1334 [[ -d "$systemdsystemconfdir" ]] || systemdsystemconfdir=/etc/systemd/system
1335
1336 [[ -d $tmpfilesdir ]] \
1337 || tmpfilesdir=$(pkg-config systemd --variable=tmpfilesdir 2>/dev/null)
1338
1339 if ! [[ -d "$tmpfilesdir" ]]; then
1340 [[ -f /lib/tmpfiles.d ]] && tmpfilesdir=/lib/tmpfiles.d
1341 [[ -f /usr/lib/tmpfiles.d ]] && tmpfilesdir=/usr/lib/tmpfiles.d
1342 fi
1343
1344 export initdir dracutbasedir \
1345 dracutmodules force_add_dracutmodules add_dracutmodules omit_dracutmodules \
1346 mods_to_load \
1347 fw_dir drivers_dir debug no_kernel kernel_only \
1348 omit_drivers mdadmconf lvmconf root_dev \
1349 use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
1350 stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
1351 debug host_fs_types host_devs swap_devs sshkey add_fstab \
1352 DRACUT_VERSION udevdir prefix filesystems drivers \
1353 systemdutildir systemdsystemunitdir systemdsystemconfdir \
1354 host_modalias host_modules hostonly_cmdline loginstall \
1355 tmpfilesdir
1356
1357 mods_to_load=""
1358 # check all our modules to see if they should be sourced.
1359 # This builds a list of modules that we will install next.
1360 for_each_module_dir check_module
1361 for_each_module_dir check_mount
1362
1363 dracut_module_included "fips" && export DRACUT_FIPS_MODE=1
1364
1365 do_print_cmdline()
1366 {
1367 local -A _mods_to_print
1368 for i in $modules_loaded $mods_to_load; do
1369 _mods_to_print[$i]=1
1370 done
1371
1372 # source our modules.
1373 for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
1374 _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
1375 [[ ${_mods_to_print[$_d_mod]} ]] || continue
1376 module_cmdline "$_d_mod"
1377 done
1378 unset moddir
1379 }
1380
1381 if [[ $print_cmdline ]]; then
1382 do_print_cmdline
1383 printf "\n"
1384 exit 0
1385 fi
1386
1387 # Create some directory structure first
1388 [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
1389
1390 [[ -h /lib ]] || mkdir -m 0755 -p "${initdir}${prefix}/lib"
1391 [[ $prefix ]] && ln -sfn "${prefix#/}/lib" "$initdir/lib"
1392
1393 if [[ $prefix ]]; then
1394 for d in bin etc lib sbin tmp usr var $libdirs; do
1395 [[ "$d" == */* ]] && continue
1396 ln -sfn "${prefix#/}/${d#/}" "$initdir/$d"
1397 done
1398 fi
1399
1400 if [[ $kernel_only != yes ]]; then
1401 for d in usr/bin usr/sbin bin etc lib sbin tmp usr var var/tmp $libdirs; do
1402 [[ -e "${initdir}${prefix}/$d" ]] && continue
1403 if [ -L "/$d" ]; then
1404 inst_symlink "/$d" "${prefix}/$d"
1405 else
1406 mkdir -m 0755 -p "${initdir}${prefix}/$d"
1407 fi
1408 done
1409
1410 for d in dev proc sys sysroot root run; do
1411 if [ -L "/$d" ]; then
1412 inst_symlink "/$d"
1413 else
1414 mkdir -m 0755 -p "$initdir/$d"
1415 fi
1416 done
1417
1418 ln -sfn ../run "$initdir/var/run"
1419 ln -sfn ../run/lock "$initdir/var/lock"
1420 else
1421 for d in lib "$libdir"; do
1422 [[ -e "${initdir}${prefix}/$d" ]] && continue
1423 if [ -h "/$d" ]; then
1424 inst "/$d" "${prefix}/$d"
1425 else
1426 mkdir -m 0755 -p "${initdir}${prefix}/$d"
1427 fi
1428 done
1429 fi
1430
1431 if [[ $kernel_only != yes ]]; then
1432 mkdir -p "${initdir}/etc/cmdline.d"
1433 for _d in $hookdirs; do
1434 mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
1435 done
1436 if [[ "$UID" = "0" ]]; then
1437 [ -c ${initdir}/dev/null ] || mknod ${initdir}/dev/null c 1 3
1438 [ -c ${initdir}/dev/kmsg ] || mknod ${initdir}/dev/kmsg c 1 11
1439 [ -c ${initdir}/dev/console ] || mknod ${initdir}/dev/console c 5 1
1440 fi
1441 fi
1442
1443 _isize=0 #initramfs size
1444 modules_loaded=" "
1445 # source our modules.
1446 for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
1447 _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
1448 [[ "$mods_to_load" == *\ $_d_mod\ * ]] || continue
1449 if [[ $show_modules = yes ]]; then
1450 printf "%s\n" "$_d_mod"
1451 else
1452 dinfo "*** Including module: $_d_mod ***"
1453 fi
1454 if [[ $kernel_only == yes ]]; then
1455 module_installkernel "$_d_mod" || {
1456 dfatal "installkernel failed in module $_d_mod"
1457 exit 1
1458 }
1459 else
1460 module_install "$_d_mod"
1461 if [[ $no_kernel != yes ]]; then
1462 module_installkernel "$_d_mod" || {
1463 dfatal "installkernel failed in module $_d_mod"
1464 exit 1
1465 }
1466 fi
1467 fi
1468 mods_to_load=${mods_to_load// $_d_mod /}
1469 modules_loaded+="$_d_mod "
1470
1471 #print the module install size
1472 if [ -n "$printsize" ]; then
1473 _isize_new=$(du -sk ${initdir}|cut -f1)
1474 _isize_delta=$((_isize_new - _isize))
1475 printf "%s\n" "$_d_mod install size: ${_isize_delta}k"
1476 _isize=$_isize_new
1477 fi
1478 done
1479 unset moddir
1480
1481 for i in $modules_loaded; do
1482 mkdir -p $initdir/lib/dracut
1483 printf "%s\n" "$i" >> $initdir/lib/dracut/modules.txt
1484 done
1485
1486 dinfo "*** Including modules done ***"
1487
1488 ## final stuff that has to happen
1489 if [[ $no_kernel != yes ]]; then
1490
1491 if [[ $drivers ]]; then
1492 hostonly='' instmods $drivers
1493 fi
1494
1495 if [[ $add_drivers ]]; then
1496 hostonly='' instmods -c $add_drivers
1497 fi
1498 if [[ $force_drivers ]]; then
1499 hostonly='' instmods -c $force_drivers
1500 rm -f $initdir/etc/cmdline.d/20-force_driver.conf
1501 for mod in $force_drivers; do
1502 echo "rd.driver.pre=$mod" >>$initdir/etc/cmdline.d/20-force_drivers.conf
1503 done
1504 fi
1505 if [[ $filesystems ]]; then
1506 hostonly='' instmods -c $filesystems
1507 fi
1508
1509 dinfo "*** Installing kernel module dependencies and firmware ***"
1510 dracut_kernel_post
1511 dinfo "*** Installing kernel module dependencies and firmware done ***"
1512
1513 if [[ $noimageifnotneeded == yes ]] && [[ $hostonly ]]; then
1514 if [[ ! -f "$initdir/lib/dracut/need-initqueue" ]] && \
1515 [[ -f ${initdir}/lib/modules/$kernel/modules.dep && ! -s ${initdir}/lib/modules/$kernel/modules.dep ]]; then
1516 for i in ${initdir}/etc/cmdline.d/*.conf; do
1517 # We need no initramfs image and do not generate one.
1518 [[ $i == "${initdir}/etc/cmdline.d/*.conf" ]] && exit 0
1519 done
1520 fi
1521 fi
1522 fi
1523
1524 if [[ $kernel_only != yes ]]; then
1525 (( ${#install_items[@]} > 0 )) && inst_multiple ${install_items[@]}
1526 (( ${#install_optional_items[@]} > 0 )) && inst_multiple -o ${install_optional_items[@]}
1527
1528 [[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
1529
1530 while pop fstab_lines line; do
1531 line=($line)
1532 [ -z "${line[3]}" ] && line[3]="defaults"
1533 [ -z "${line[4]}" ] && line[4]="0"
1534 [ -z "${line[5]}" ] && line[5]="2"
1535 strstr "${line[2]}" "nfs" && line[5]="0"
1536 echo "${line[@]}" >> "${initdir}/etc/fstab"
1537 done
1538
1539 for f in $add_fstab; do
1540 cat "$f" >> "${initdir}/etc/fstab"
1541 done
1542
1543 if [ -d ${initdir}/$systemdutildir ]; then
1544 mkdir -p ${initdir}/etc/conf.d
1545 {
1546 printf "%s\n" "systemdutildir=\"$systemdutildir\""
1547 printf "%s\n" "systemdsystemunitdir=\"$systemdsystemunitdir\""
1548 printf "%s\n" "systemdsystemconfdir=\"$systemdsystemconfdir\""
1549 } > ${initdir}/etc/conf.d/systemd.conf
1550 fi
1551
1552 if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then
1553 dinfo "*** Resolving executable dependencies ***"
1554 find "$initdir" -type f -perm /0111 -not -path '*.ko' -print0 \
1555 | xargs -r -0 $DRACUT_INSTALL ${initdir:+-D "$initdir"} -R ${DRACUT_FIPS_MODE:+-H} --
1556 dinfo "*** Resolving executable dependencies done***"
1557 fi
1558
1559 # libpthread workaround: pthread_cancel wants to dlopen libgcc_s.so
1560 for _dir in $libdirs; do
1561 for _f in "$_dir/libpthread.so"*; do
1562 [[ -e "$_f" ]] || continue
1563 inst_libdir_file "libgcc_s.so*"
1564 break 2
1565 done
1566 done
1567 fi
1568
1569 while pop include_src src && pop include_target target; do
1570 if [[ $src && $target ]]; then
1571 if [[ -f $src ]]; then
1572 inst $src $target
1573 else
1574 ddebug "Including directory: $src"
1575 destdir="${initdir}/${target}"
1576 mkdir -p "$destdir"
1577 # check for preexisting symlinks, so we can cope with the
1578 # symlinks to $prefix
1579 # Objectname is a file or a directory
1580 for objectname in "$src"/*; do
1581 [[ -e "$objectname" || -h "$objectname" ]] || continue
1582 if [[ -d "$objectname" ]]; then
1583 # objectname is a directory, let's compute the final directory name
1584 object_destdir=${destdir}/${objectname#$src/}
1585 if ! [[ -e "$object_destdir" ]]; then
1586 mkdir -m 0755 -p "$object_destdir"
1587 chmod --reference="$objectname" "$object_destdir"
1588 fi
1589 cp --reflink=auto --sparse=auto -fa -t "$object_destdir" "$objectname"/*
1590 else
1591 cp --reflink=auto --sparse=auto -fa -t "$destdir" "$objectname"
1592 fi
1593 done
1594 fi
1595 fi
1596 done
1597
1598 if [[ $kernel_only != yes ]]; then
1599 # make sure that library links are correct and up to date
1600 for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do
1601 [[ -f $f ]] && inst_simple "$f"
1602 done
1603 if ! ldconfig -r "$initdir"; then
1604 if [[ $UID = 0 ]]; then
1605 derror "ldconfig exited ungracefully"
1606 else
1607 derror "ldconfig might need uid=0 (root) for chroot()"
1608 fi
1609 fi
1610 fi
1611
1612 PRELINK_BIN="$(command -v prelink)"
1613 if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then
1614 if [[ $DRACUT_FIPS_MODE ]]; then
1615 dinfo "*** Installing prelink files ***"
1616 inst_multiple -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf /etc/prelink.cache
1617 elif [[ $do_prelink == yes ]]; then
1618 dinfo "*** Pre-linking files ***"
1619 inst_multiple -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf
1620 chroot "$initdir" "$PRELINK_BIN" -a
1621 rm -f -- "$initdir/$PRELINK_BIN"
1622 rm -fr -- "$initdir"/etc/prelink.*
1623 dinfo "*** Pre-linking files done ***"
1624 fi
1625 fi
1626
1627 if [[ $do_hardlink = yes ]] && command -v hardlink >/dev/null; then
1628 dinfo "*** Hardlinking files ***"
1629 hardlink "$initdir" 2>&1
1630 dinfo "*** Hardlinking files done ***"
1631 fi
1632
1633 # strip binaries
1634 if [[ $do_strip = yes ]] ; then
1635 for p in strip xargs find; do
1636 if ! type -P $p >/dev/null; then
1637 dinfo "Could not find '$p'. Not stripping the initramfs."
1638 do_strip=no
1639 fi
1640 done
1641 fi
1642
1643 if [[ $do_strip = yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then
1644 dinfo "*** Stripping files ***"
1645 find "$initdir" -type f \
1646 -executable -not -path '*/lib/modules/*.ko' -print0 \
1647 | xargs -r -0 strip -g 2>/dev/null
1648
1649 # strip kernel modules, but do not touch signed modules
1650 find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
1651 | while read -r -d $'\0' f || [ -n "$f" ]; do
1652 SIG=$(tail -c 28 "$f")
1653 [[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; }
1654 done | xargs -r -0 strip -g
1655
1656 dinfo "*** Stripping files done ***"
1657 fi
1658 if [[ $early_microcode = yes ]]; then
1659 dinfo "*** Generating early-microcode cpio image ***"
1660 ucode_dir=(amd-ucode intel-ucode)
1661 ucode_dest=(AuthenticAMD.bin GenuineIntel.bin)
1662 _dest_dir="$early_cpio_dir/d/kernel/x86/microcode"
1663 _dest_idx="0 1"
1664 mkdir -p $_dest_dir
1665 if [[ $hostonly ]]; then
1666 [[ $(get_cpu_vendor) == "AMD" ]] && _dest_idx="0"
1667 [[ $(get_cpu_vendor) == "Intel" ]] && _dest_idx="1"
1668 fi
1669 for idx in $_dest_idx; do
1670 _fw=${ucode_dir[$idx]}
1671 for _fwdir in $fw_dir; do
1672 if [[ -d $_fwdir && -d $_fwdir/$_fw ]]; then
1673 _src="*"
1674 dinfo "*** Constructing ${ucode_dest[$idx]} ****"
1675 if [[ $hostonly ]]; then
1676 _src=$(get_ucode_file)
1677 if ! [[ -r $_fwdir/$_fw/$_src ]];then
1678 break;
1679 fi
1680 fi
1681 cat $_fwdir/$_fw/$_src > $_dest_dir/${ucode_dest[$idx]}
1682 create_early_cpio="yes"
1683 fi
1684 done
1685 done
1686 fi
1687
1688 if [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]]; then
1689 dinfo "*** Packaging ACPI tables to override BIOS provided ones ***"
1690 _dest_dir="$early_cpio_dir/d/kernel/firmware/acpi"
1691 mkdir -p $_dest_dir
1692 for table in $acpi_table_dir/*.aml; do
1693 dinfo " Adding ACPI table: $table"
1694 cp -a $table $_dest_dir
1695 create_early_cpio="yes"
1696 done
1697 fi
1698
1699 dinfo "*** Store current command line parameters ***"
1700 if ! ( echo $PARMS_TO_STORE > $initdir/lib/dracut/build-parameter.txt ); then
1701 dfatal "Could not store the current command line parameters"
1702 exit 1
1703 fi
1704
1705 if [[ $hostonly_cmdline ]] ; then
1706 unset _stored_cmdline
1707 if [ -d $initdir/etc/cmdline.d ];then
1708 dinfo "Stored kernel commandline:"
1709 for conf in $initdir/etc/cmdline.d/*.conf ; do
1710 [ -e "$conf" ] || continue
1711 dinfo "$(< $conf)"
1712 _stored_cmdline=1
1713 done
1714 fi
1715 if ! [[ $_stored_cmdline ]]; then
1716 dinfo "No dracut internal kernel commandline stored in initrd"
1717 fi
1718 fi
1719 rm -f -- "$outfile"
1720 dinfo "*** Creating image file '$outfile' ***"
1721
1722 if [[ $uefi = yes ]]; then
1723 uefi_outfile="$outfile"
1724 readonly uefi_outdir="$(mktemp --tmpdir="$TMPDIR/" -d -t initrd.XXXXXX)"
1725 # redirect initrd output
1726 outfile="$uefi_outdir/initrd"
1727 fi
1728
1729 if [[ $DRACUT_REPRODUCIBLE ]]; then
1730 find "$initdir" -newer "$dracutbasedir/dracut-functions.sh" -print0 \
1731 | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh"
1732
1733 [[ "$(cpio --help)" == *--reproducible* ]] && CPIO_REPRODUCIBLE=1
1734 fi
1735
1736 [[ "$UID" != 0 ]] && cpio_owner_root="-R 0:0"
1737
1738 if [[ $create_early_cpio = yes ]]; then
1739 echo 1 > "$early_cpio_dir/d/early_cpio"
1740
1741 if [[ $DRACUT_REPRODUCIBLE ]]; then
1742 find "$early_cpio_dir/d" -newer "$dracutbasedir/dracut-functions.sh" -print0 \
1743 | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh"
1744 fi
1745
1746 # The microcode blob is _before_ the initramfs blob, not after
1747 (
1748 cd "$early_cpio_dir/d"
1749 find . -print0 | sort -z \
1750 | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null $cpio_owner_root -H newc -o --quiet > $outfile
1751 )
1752 fi
1753
1754 if ! (
1755 umask 077; cd "$initdir"
1756 find . -print0 | sort -z \
1757 | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null $cpio_owner_root -H newc -o --quiet \
1758 | $compress >> "$outfile"
1759 ); then
1760 dfatal "dracut: creation of $outfile failed"
1761 exit 1
1762 fi
1763 dinfo "*** Creating initrd image file '$outfile' done ***"
1764
1765 if (( maxloglvl >= 5 )); then
1766 if [[ $allowlocal ]]; then
1767 "$dracutbasedir/lsinitrd.sh" "$outfile"| ddebug
1768 else
1769 lsinitrd "$outfile"| ddebug
1770 fi
1771 fi
1772
1773 if [[ $uefi = yes ]]; then
1774 if [[ $kernel_cmdline ]]; then
1775 echo -n "$kernel_cmdline" > "$uefi_outdir/cmdline.txt"
1776 elif [[ $hostonly_cmdline = yes ]] && [ -d $initdir/etc/cmdline.d ];then
1777 for conf in $initdir/etc/cmdline.d/*.conf ; do
1778 [ -e "$conf" ] || continue
1779 printf "%s " "$(< $conf)" >> "$uefi_outdir/cmdline.txt"
1780 done
1781 else
1782 do_print_cmdline > "$uefi_outdir/cmdline.txt"
1783 fi
1784 echo -ne "\x00" >> "$uefi_outdir/cmdline.txt"
1785
1786 dinfo "Using UEFI kernel cmdline:"
1787 dinfo $(< "$uefi_outdir/cmdline.txt")
1788
1789 [[ -s /usr/lib/os-release ]] && uefi_osrelease="/usr/lib/os-release"
1790 [[ -s /etc/os-release ]] && uefi_osrelease="/etc/os-release"
1791
1792 objcopy \
1793 ${uefi_osrelease:+--add-section .osrel=$uefi_osrelease --change-section-vma .osrel=0x20000} \
1794 --add-section .cmdline="$uefi_outdir/cmdline.txt" --change-section-vma .cmdline=0x30000 \
1795 --add-section .linux="$kernel_image" --change-section-vma .linux=0x40000 \
1796 --add-section .initrd="$outfile" --change-section-vma .initrd=0x3000000 \
1797 "$uefi_stub" "$uefi_outfile"
1798 dinfo "*** Creating UEFI image file '$uefi_outfile' done ***"
1799 fi
1800
1801 exit 0