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