]> git.ipfire.org Git - thirdparty/dracut.git/blob - dracut.sh
do not wait_for_dev for the root device
[thirdparty/dracut.git] / dracut.sh
1 #!/bin/bash
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 #
5 # Generator script for a dracut initramfs
6 # Tries to retain some degree of compatibility with the command line
7 # of the various mkinitrd implementations out there
8 #
9
10 # Copyright 2005-2013 Red Hat, Inc. All rights reserved.
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #
25
26 # store for logging
27 dracut_args=( "$@" )
28
29 set -o pipefail
30
31 usage() {
32 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
33 if [[ -f $dracutbasedir/dracut-version.sh ]]; then
34 . $dracutbasedir/dracut-version.sh
35 fi
36
37 # 80x25 linebreak here ^
38 cat << EOF
39 Usage: $0 [OPTION]... [<initramfs> [<kernel-version>]]
40
41 Version: $DRACUT_VERSION
42
43 Creates initial ramdisk images for preloading modules
44
45 -h, --help Display all options
46
47 If a [LIST] has multiple arguments, then you have to put these in quotes.
48
49 For example:
50
51 # dracut --add-drivers "module1 module2" ...
52
53 EOF
54 }
55
56 long_usage() {
57 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
58 if [[ -f $dracutbasedir/dracut-version.sh ]]; then
59 . $dracutbasedir/dracut-version.sh
60 fi
61
62 # 80x25 linebreak here ^
63 cat << EOF
64 Usage: $0 [OPTION]... [<initramfs> [<kernel-version>]]
65
66 Version: $DRACUT_VERSION
67
68 Creates initial ramdisk images for preloading modules
69
70 --kver [VERSION] Set kernel version to [VERSION].
71 -f, --force Overwrite existing initramfs file.
72 -a, --add [LIST] Add a space-separated list of dracut modules.
73 -m, --modules [LIST] Specify a space-separated list of dracut modules to
74 call when building the initramfs. Modules are located
75 in /usr/lib/dracut/modules.d.
76 -o, --omit [LIST] Omit a space-separated list of dracut modules.
77 --force-add [LIST] Force to add a space-separated list of dracut modules
78 to the default set of modules, when -H is specified.
79 -d, --drivers [LIST] Specify a space-separated list of kernel modules to
80 exclusively include in the initramfs.
81 --add-drivers [LIST] Specify a space-separated list of kernel
82 modules to add to the initramfs.
83 --omit-drivers [LIST] Specify a space-separated list of kernel
84 modules not to add to the initramfs.
85 --filesystems [LIST] Specify a space-separated list of kernel filesystem
86 modules to exclusively include in the generic
87 initramfs.
88 -k, --kmoddir [DIR] Specify the directory, where to look for kernel
89 modules
90 --fwdir [DIR] Specify additional directories, where to look for
91 firmwares, separated by :
92 --kernel-only Only install kernel drivers and firmware files
93 --no-kernel Do not install kernel drivers and firmware files
94 --no-early-microcode Do not combine early microcode with ramdisk
95 --kernel-cmdline [PARAMETERS] Specify default kernel command line parameters
96 --strip Strip binaries in the initramfs
97 --nostrip Do not strip binaries in the initramfs
98 --hardlink Hardlink files in the initramfs
99 --nohardlink Do not hardlink files in the initramfs
100 --prefix [DIR] Prefix initramfs files with [DIR]
101 --noprefix Do not prefix initramfs files
102 --mdadmconf Include local /etc/mdadm.conf
103 --nomdadmconf Do not include local /etc/mdadm.conf
104 --lvmconf Include local /etc/lvm/lvm.conf
105 --nolvmconf Do not include local /etc/lvm/lvm.conf
106 --fscks [LIST] Add a space-separated list of fsck helpers.
107 --nofscks Inhibit installation of any fsck helpers.
108 --ro-mnt Mount / and /usr read-only by default.
109 -h, --help This message
110 --debug Output debug information of the build process
111 --profile Output profile information of the build process
112 -L, --stdlog [0-6] Specify logging level (to standard error)
113 0 - suppress any messages
114 1 - only fatal errors
115 2 - all errors
116 3 - warnings
117 4 - info
118 5 - debug info (here starts lots of output)
119 6 - trace info (and even more)
120 -v, --verbose Increase verbosity level
121 -q, --quiet Decrease verbosity level
122 -c, --conf [FILE] Specify configuration file to use.
123 Default: /etc/dracut.conf
124 --confdir [DIR] Specify configuration directory to use *.conf files
125 from. Default: /etc/dracut.conf.d
126 --tmpdir [DIR] Temporary directory to be used instead of default
127 /var/tmp.
128 -l, --local Local mode. Use modules from the current working
129 directory instead of the system-wide installed in
130 /usr/lib/dracut/modules.d.
131 Useful when running dracut from a git checkout.
132 -H, --hostonly Host-Only mode: Install only what is needed for
133 booting the local host instead of a generic host.
134 -N, --no-hostonly Disables Host-Only mode
135 --fstab Use /etc/fstab to determine the root device.
136 --add-fstab [FILE] Add file to the initramfs fstab
137 --mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
138 Mount device [DEV] on mountpoint [MP] with filesystem
139 [FSTYPE] and options [FSOPTS] in the initramfs
140 --add-device "[DEV]" Bring up [DEV] in initramfs
141 -i, --include [SOURCE] [TARGET]
142 Include the files in the SOURCE directory into the
143 Target directory in the final initramfs.
144 If SOURCE is a file, it will be installed to TARGET
145 in the final initramfs.
146 -I, --install [LIST] Install the space separated list of files into the
147 initramfs.
148 --gzip Compress the generated initramfs using gzip.
149 This will be done by default, unless another
150 compression option or --no-compress is passed.
151 --bzip2 Compress the generated initramfs using bzip2.
152 Make sure your kernel has bzip2 decompression support
153 compiled in, otherwise you will not be able to boot.
154 --lzma Compress the generated initramfs using lzma.
155 Make sure your kernel has lzma support compiled in,
156 otherwise you will not be able to boot.
157 --xz Compress the generated initramfs using xz.
158 Make sure that your kernel has xz support compiled
159 in, otherwise you will not be able to boot.
160 --compress [COMPRESSION] Compress the generated initramfs with the
161 passed compression program. Make sure your kernel
162 knows how to decompress the generated initramfs,
163 otherwise you will not be able to boot.
164 --no-compress Do not compress the generated initramfs. This will
165 override any other compression options.
166 --list-modules List all available dracut modules.
167 -M, --show-modules Print included module's name to standard output during
168 build.
169 --keep Keep the temporary initramfs for debugging purposes
170 --printsize Print out the module install size
171 --sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module)
172
173 If [LIST] has multiple arguments, then you have to put these in quotes.
174
175 For example:
176
177 # dracut --add-drivers "module1 module2" ...
178
179 EOF
180 }
181
182 # function push()
183 # push values to a stack
184 # $1 = stack variable
185 # $2.. values
186 # example:
187 # push stack 1 2 "3 4"
188 push() {
189 local _i
190 local __stack=$1; shift
191 for _i in "$@"; do
192 eval ${__stack}'[${#'${__stack}'[@]}]="$_i"'
193 done
194 }
195
196 # function pop()
197 # pops the last value from a stack
198 # assigns value to second argument variable
199 # or echo to stdout, if no second argument
200 # $1 = stack variable
201 # $2 = optional variable to store the value
202 # example:
203 # pop stack val
204 # val=$(pop stack)
205 pop() {
206 local __stack=$1; shift
207 local __resultvar=$1
208 local _value;
209 # check for empty stack
210 eval '[[ ${#'${__stack}'[@]} -eq 0 ]] && return 1'
211
212 eval _value='${'${__stack}'[${#'${__stack}'[@]}-1]}'
213
214 if [[ "$__resultvar" ]]; then
215 eval $__resultvar="'$_value'"
216 else
217 printf "%s" "$_value"
218 fi
219 eval unset ${__stack}'[${#'${__stack}'[@]}-1]'
220 return 0
221 }
222
223 # Little helper function for reading args from the commandline.
224 # it automatically handles -a b and -a=b variants, and returns 1 if
225 # we need to shift $3.
226 read_arg() {
227 # $1 = arg name
228 # $2 = arg value
229 # $3 = arg parameter
230 local rematch='^[^=]*=(.*)$'
231 if [[ $2 =~ $rematch ]]; then
232 read "$1" <<< "${BASH_REMATCH[1]}"
233 else
234 read "$1" <<< "$3"
235 # There is no way to shift our callers args, so
236 # return 1 to indicate they should do it instead.
237 return 1
238 fi
239 }
240
241 dropindirs_sort()
242 {
243 local suffix=$1; shift
244 local -a files
245 local f d
246
247 readarray -t files < <(
248 for d in "$@"; do
249 for i in "$d/"*"$suffix"; do
250 if [[ -e "$i" ]]; then
251 printf "%s\n" "${i##*/}"
252 fi
253 done
254 done | sort -Vu
255 )
256
257 for f in "${files[@]}"; do
258 for d in "$@"; do
259 if [[ -e "$d/$f" ]]; then
260 printf "%s\n" "$d/$f"
261 continue 2
262 fi
263 done
264 done
265 }
266
267 verbosity_mod_l=0
268 unset kernel
269 unset outfile
270
271 # Workaround -i, --include taking 2 arguments
272 set -- "${@/--include/++include}"
273
274 # This prevents any long argument ending with "-i"
275 # -i, like --opt-i but I think we can just prevent that
276 set -- "${@/%-i/++include}"
277
278 TEMP=$(unset POSIXLY_CORRECT; getopt \
279 -o "a:m:o:d:I:k:c:L:fvqlHhMN" \
280 --long kver: \
281 --long add: \
282 --long force-add: \
283 --long add-drivers: \
284 --long omit-drivers: \
285 --long modules: \
286 --long omit: \
287 --long drivers: \
288 --long filesystems: \
289 --long install: \
290 --long fwdir: \
291 --long libdirs: \
292 --long fscks: \
293 --long add-fstab: \
294 --long mount: \
295 --long device: \
296 --long nofscks: \
297 --long ro-mnt \
298 --long kmoddir: \
299 --long conf: \
300 --long confdir: \
301 --long tmpdir: \
302 --long stdlog: \
303 --long compress: \
304 --long prefix: \
305 --long force \
306 --long kernel-only \
307 --long no-kernel \
308 --long kernel-cmdline: \
309 --long strip \
310 --long nostrip \
311 --long hardlink \
312 --long nohardlink \
313 --long noprefix \
314 --long mdadmconf \
315 --long nomdadmconf \
316 --long lvmconf \
317 --long nolvmconf \
318 --long debug \
319 --long profile \
320 --long sshkey: \
321 --long verbose \
322 --long quiet \
323 --long local \
324 --long hostonly \
325 --long host-only \
326 --long no-hostonly \
327 --long no-host-only \
328 --long fstab \
329 --long help \
330 --long bzip2 \
331 --long lzma \
332 --long xz \
333 --long no-compress \
334 --long gzip \
335 --long list-modules \
336 --long show-modules \
337 --long keep \
338 --long printsize \
339 --long regenerate-all \
340 --long noimageifnotneeded \
341 -- "$@")
342
343 if (( $? != 0 )); then
344 usage
345 exit 1
346 fi
347
348 eval set -- "$TEMP"
349
350 while :; do
351 case $1 in
352 --kver) kernel="$2"; shift;;
353 -a|--add) push add_dracutmodules_l "$2"; shift;;
354 --force-add) push force_add_dracutmodules_l "$2"; shift;;
355 --add-drivers) push add_drivers_l "$2"; shift;;
356 --omit-drivers) push omit_drivers_l "$2"; shift;;
357 -m|--modules) push dracutmodules_l "$2"; shift;;
358 -o|--omit) push omit_dracutmodules_l "$2"; shift;;
359 -d|--drivers) push drivers_l "$2"; shift;;
360 --filesystems) push filesystems_l "$2"; shift;;
361 -I|--install) push install_items_l "$2"; shift;;
362 --fwdir) push fw_dir_l "$2"; shift;;
363 --libdirs) push libdirs_l "$2"; shift;;
364 --fscks) push fscks_l "$2"; shift;;
365 --add-fstab) push add_fstab_l "$2"; shift;;
366 --mount) push fstab_lines "$2"; shift;;
367 --add-device|--device)
368 push add_device_l "$2"; shift;;
369 --kernel-cmdline) push kernel_cmdline_l "$2"; shift;;
370 --nofscks) nofscks_l="yes";;
371 --ro-mnt) ro_mnt_l="yes";;
372 -k|--kmoddir) drivers_dir_l="$2"; shift;;
373 -c|--conf) conffile="$2"; shift;;
374 --confdir) confdir="$2"; shift;;
375 --tmpdir) tmpdir_l="$2"; shift;;
376 -L|--stdlog) stdloglvl_l="$2"; shift;;
377 --compress) compress_l="$2"; shift;;
378 --prefix) prefix_l="$2"; shift;;
379 -f|--force) force=yes;;
380 --kernel-only) kernel_only="yes"; no_kernel="no";;
381 --no-kernel) kernel_only="no"; no_kernel="yes";;
382 --no-early-microcode) early_microcode="no";;
383 --strip) do_strip_l="yes";;
384 --nostrip) do_strip_l="no";;
385 --hardlink) do_hardlink_l="yes";;
386 --nohardlink) do_hardlink_l="no";;
387 --noprefix) prefix_l="/";;
388 --mdadmconf) mdadmconf_l="yes";;
389 --nomdadmconf) mdadmconf_l="no";;
390 --lvmconf) lvmconf_l="yes";;
391 --nolvmconf) lvmconf_l="no";;
392 --debug) debug="yes";;
393 --profile) profile="yes";;
394 --sshkey) sshkey="$2"; shift;;
395 -v|--verbose) ((verbosity_mod_l++));;
396 -q|--quiet) ((verbosity_mod_l--));;
397 -l|--local)
398 allowlocal="yes"
399 [[ -f "$(readlink -f "${0%/*}")/dracut-functions.sh" ]] \
400 && dracutbasedir="$(readlink -f "${0%/*}")"
401 ;;
402 -H|--hostonly|--host-only)
403 hostonly_l="yes" ;;
404 -N|--no-hostonly|--no-host-only)
405 hostonly_l="no" ;;
406 --fstab) use_fstab_l="yes" ;;
407 -h|--help) long_usage; exit 1 ;;
408 -i|--include) push include_src "$2"
409 shift;;
410 --bzip2) compress_l="bzip2";;
411 --lzma) compress_l="lzma";;
412 --xz) compress_l="xz";;
413 --no-compress) _no_compress_l="cat";;
414 --gzip) compress_l="gzip";;
415 --list-modules) do_list="yes";;
416 -M|--show-modules)
417 show_modules_l="yes"
418 ;;
419 --keep) keep="yes";;
420 --printsize) printsize="yes";;
421 --regenerate-all) regenerate_all="yes";;
422 --noimageifnotneeded) noimageifnotneeded="yes";;
423
424 --) shift; break;;
425
426 *) # should not even reach this point
427 printf "\n!Unknown option: '%s'\n\n" "$1" >&2; usage; exit 1;;
428 esac
429 shift
430 done
431
432 # getopt cannot handle multiple arguments, so just handle "-I,--include"
433 # the old fashioned way
434
435 while (($# > 0)); do
436 case ${1%%=*} in
437 ++include) push include_src "$2"
438 push include_target "$3"
439 shift 2;;
440 *)
441 if ! [[ ${outfile+x} ]]; then
442 outfile=$1
443 elif ! [[ ${kernel+x} ]]; then
444 kernel=$1
445 else
446 printf "\nUnknown arguments: %s\n\n" "$*" >&2
447 usage; exit 1;
448 fi
449 ;;
450 esac
451 shift
452 done
453
454 if [[ $regenerate_all == "yes" ]]; then
455 ret=0
456 if [[ $kernel ]]; then
457 printf -- "--regenerate-all cannot be called with a kernel version\n" >&2
458 exit 1
459 fi
460
461 if [[ $outfile ]]; then
462 printf -- "--regenerate-all cannot be called with a image file\n" >&2
463 exit 1
464 fi
465
466 ((len=${#dracut_args[@]}))
467 for ((i=0; i < len; i++)); do
468 [[ ${dracut_args[$i]} == "--regenerate-all" ]] && \
469 unset dracut_args[$i]
470 done
471
472 cd /lib/modules
473 for i in *; do
474 [[ -f $i/modules.builtin ]] || continue
475 dracut --kver="$i" "${dracut_args[@]}"
476 ((ret+=$?))
477 done
478 exit $ret
479 fi
480
481 if ! [[ $kernel ]]; then
482 kernel=$(uname -r)
483 fi
484
485 if ! [[ $outfile ]]; then
486 [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
487
488 if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
489 outfile="/boot/${MACHINE_ID}/$kernel/initrd"
490 else
491 outfile="/boot/initramfs-$kernel.img"
492 fi
493 fi
494
495 for i in /usr/sbin /sbin /usr/bin /bin; do
496 rl=$i
497 if [ -L "$i" ]; then
498 rl=$(readlink -f $i)
499 fi
500 if [[ "$NPATH" != "*:$rl*" ]] ; then
501 NPATH+=":$rl"
502 fi
503 done
504 export PATH="${NPATH#:}"
505 unset LC_MESSAGES
506 unset LC_CTYPE
507 export LC_ALL=C
508 export LANG=C
509 unset NPATH
510 unset LD_LIBRARY_PATH
511 unset GREP_OPTIONS
512
513 export DRACUT_LOG_LEVEL=warning
514 [[ $debug ]] && {
515 export DRACUT_LOG_LEVEL=debug
516 export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
517 set -x
518 }
519
520 [[ $profile ]] && {
521 export PS4='+ $(date "+%s.%N") ${BASH_SOURCE}@${LINENO}: ';
522 set -x
523 debug=yes
524 }
525
526 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
527
528 # if we were not passed a config file, try the default one
529 if [[ ! -f $conffile ]]; then
530 if [[ $allowlocal ]]; then
531 conffile="$dracutbasedir/dracut.conf"
532 else
533 conffile="/etc/dracut.conf"
534 fi
535 fi
536
537 if [[ ! -d $confdir ]]; then
538 if [[ $allowlocal ]]; then
539 confdir="$dracutbasedir/dracut.conf.d"
540 else
541 confdir="/etc/dracut.conf.d"
542 fi
543 fi
544
545 # source our config file
546 [[ -f $conffile ]] && . "$conffile"
547
548 # source our config dir
549 for f in $(dropindirs_sort ".conf" "$confdir" "$dracutbasedir/dracut.conf.d"); do
550 [[ -e $f ]] && . "$f"
551 done
552
553 # these optins add to the stuff in the config file
554 if (( ${#add_dracutmodules_l[@]} )); then
555 while pop add_dracutmodules_l val; do
556 add_dracutmodules+=" $val "
557 done
558 fi
559
560 if (( ${#force_add_dracutmodules_l[@]} )); then
561 while pop force_add_dracutmodules_l val; do
562 force_add_dracutmodules+=" $val "
563 done
564 fi
565
566 if (( ${#fscks_l[@]} )); then
567 while pop fscks_l val; do
568 fscks+=" $val "
569 done
570 fi
571
572 if (( ${#add_fstab_l[@]} )); then
573 while pop add_fstab_l val; do
574 add_fstab+=" $val "
575 done
576 fi
577
578 if (( ${#fstab_lines_l[@]} )); then
579 while pop fstab_lines_l val; do
580 push fstab_lines $val
581 done
582 fi
583
584 if (( ${#install_items_l[@]} )); then
585 while pop install_items_l val; do
586 install_items+=" $val "
587 done
588 fi
589
590 # these options override the stuff in the config file
591 if (( ${#dracutmodules_l[@]} )); then
592 dracutmodules=''
593 while pop dracutmodules_l val; do
594 dracutmodules+="$val "
595 done
596 fi
597
598 if (( ${#omit_dracutmodules_l[@]} )); then
599 omit_dracutmodules=''
600 while pop omit_dracutmodules_l val; do
601 omit_dracutmodules+="$val "
602 done
603 fi
604
605 if (( ${#filesystems_l[@]} )); then
606 filesystems=''
607 while pop filesystems_l val; do
608 filesystems+="$val "
609 done
610 fi
611
612 if (( ${#fw_dir_l[@]} )); then
613 fw_dir=''
614 while pop fw_dir_l val; do
615 fw_dir+="$val "
616 done
617 fi
618
619 if (( ${#libdirs_l[@]} )); then
620 libdirs=''
621 while pop libdirs_l val; do
622 libdirs+="$val "
623 done
624 fi
625
626 [[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l
627 [[ ! $stdloglvl ]] && stdloglvl=4
628 stdloglvl=$((stdloglvl + verbosity_mod_l))
629 ((stdloglvl > 6)) && stdloglvl=6
630 ((stdloglvl < 0)) && stdloglvl=0
631
632 [[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
633 [[ $do_strip_l ]] && do_strip=$do_strip_l
634 [[ $do_strip ]] || do_strip=yes
635 [[ $do_hardlink_l ]] && do_hardlink=$do_hardlink_l
636 [[ $do_hardlink ]] || do_hardlink=yes
637 [[ $prefix_l ]] && prefix=$prefix_l
638 [[ $prefix = "/" ]] && unset prefix
639 [[ $hostonly_l ]] && hostonly=$hostonly_l
640 [[ $use_fstab_l ]] && use_fstab=$use_fstab_l
641 [[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l
642 [[ $lvmconf_l ]] && lvmconf=$lvmconf_l
643 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
644 [[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware"
645 [[ $tmpdir_l ]] && tmpdir="$tmpdir_l"
646 [[ $tmpdir ]] || tmpdir=/var/tmp
647 [[ $compress_l ]] && compress=$compress_l
648 [[ $show_modules_l ]] && show_modules=$show_modules_l
649 [[ $nofscks_l ]] && nofscks="yes"
650 [[ $ro_mnt_l ]] && ro_mnt="yes"
651 [[ ! $early_microcode ]] && early_microcode="yes"
652 # eliminate IFS hackery when messing with fw_dir
653 fw_dir=${fw_dir//:/ }
654
655 # handle compression options.
656 [[ $compress ]] || compress="gzip"
657 case $compress in
658 bzip2) compress="bzip2 -9";;
659 lzma) compress="lzma -9";;
660 xz) compress="xz --check=crc32 --lzma2=dict=1MiB";;
661 gzip) compress="gzip -9"; command -v pigz > /dev/null 2>&1 && compress="pigz -9";;
662 esac
663 if [[ $_no_compress_l = "cat" ]]; then
664 compress="cat"
665 fi
666
667 [[ $hostonly = yes ]] && hostonly="-h"
668 [[ $hostonly != "-h" ]] && unset hostonly
669
670 readonly TMPDIR="$tmpdir"
671 readonly initdir="$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)"
672 [ -d "$initdir" ] || {
673 printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t initramfs.XXXXXX failed." >&2
674 exit 1
675 }
676
677 if [[ $early_microcode = yes ]]; then
678 readonly microcode_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_microcode.XXXXXX)"
679 [ -d "$microcode_dir" ] || {
680 printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t early_microcode.XXXXXX failed." >&2
681 exit 1
682 }
683 fi
684 # clean up after ourselves no matter how we die.
685 trap 'ret=$?;[[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";[[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; [[ $microcode_dir ]] && rm -Rf -- "$microcode_dir"; exit $ret; };' EXIT
686 # clean up after ourselves no matter how we die.
687 trap 'exit 1;' SIGINT
688
689 export DRACUT_KERNEL_LAZY="1"
690 export DRACUT_RESOLVE_LAZY="1"
691
692 if [[ -f $dracutbasedir/dracut-functions.sh ]]; then
693 . $dracutbasedir/dracut-functions.sh
694 else
695 printf "%s\n" "dracut: Cannot find $dracutbasedir/dracut-functions.sh." >&2
696 printf "%s\n" "dracut: Are you running from a git checkout?" >&2
697 printf "%s\n" "dracut: Try passing -l as an argument to $0" >&2
698 exit 1
699 fi
700
701 inst /bin/sh
702 if ! $DRACUT_INSTALL ${initdir+-D "$initdir"} -R "$initdir/bin/sh" &>/dev/null; then
703 unset DRACUT_RESOLVE_LAZY
704 export DRACUT_RESOLVE_DEPS=1
705 fi
706 rm -fr -- ${initdir}/*
707
708 if [[ -f $dracutbasedir/dracut-version.sh ]]; then
709 . $dracutbasedir/dracut-version.sh
710 fi
711
712 # Verify bash version, current minimum is 3.1
713 if (( BASH_VERSINFO[0] < 4 )); then
714 dfatal 'You need at least Bash 4 to use dracut, sorry.'
715 exit 1
716 fi
717
718 dracutfunctions=$dracutbasedir/dracut-functions.sh
719 export dracutfunctions
720
721 if (( ${#drivers_l[@]} )); then
722 drivers=''
723 while pop drivers_l val; do
724 drivers+="$val "
725 done
726 fi
727 drivers=${drivers/-/_}
728
729 if (( ${#add_drivers_l[@]} )); then
730 while pop add_drivers_l val; do
731 add_drivers+=" $val "
732 done
733 fi
734 add_drivers=${add_drivers/-/_}
735
736 if (( ${#omit_drivers_l[@]} )); then
737 while pop omit_drivers_l val; do
738 omit_drivers+=" $val "
739 done
740 fi
741 omit_drivers=${omit_drivers/-/_}
742
743 if (( ${#kernel_cmdline_l[@]} )); then
744 while pop kernel_cmdline_l val; do
745 kernel_cmdline+=" $val "
746 done
747 fi
748
749 omit_drivers_corrected=""
750 for d in $omit_drivers; do
751 [[ " $drivers $add_drivers " == *\ $d\ * ]] && continue
752 omit_drivers_corrected+="$d|"
753 done
754 omit_drivers="${omit_drivers_corrected%|}"
755 unset omit_drivers_corrected
756
757 # prepare args for logging
758 for ((i=0; i < ${#dracut_args[@]}; i++)); do
759 [[ "${dracut_args[$i]}" == *\ * ]] && \
760 dracut_args[$i]="\"${dracut_args[$i]}\""
761 #" keep vim happy
762 done
763 ddebug "Executing: $0 ${dracut_args[@]}"
764
765 [[ $do_list = yes ]] && {
766 for mod in $dracutbasedir/modules.d/*; do
767 [[ -d $mod ]] || continue;
768 [[ -e $mod/install || -e $mod/installkernel || \
769 -e $mod/module-setup.sh ]] || continue
770 printf "%s\n" "${mod##*/??}"
771 done
772 exit 0
773 }
774
775 # This is kinda legacy -- eventually it should go away.
776 case $dracutmodules in
777 ""|auto) dracutmodules="all" ;;
778 esac
779
780 abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
781
782 if [[ -d $srcmods ]]; then
783 [[ -f $srcmods/modules.dep ]] || {
784 dwarn "$srcmods/modules.dep is missing. Did you run depmod?"
785 }
786 fi
787
788 if [[ -f $outfile && ! $force ]]; then
789 dfatal "Will not override existing initramfs ($outfile) without --force"
790 exit 1
791 fi
792
793 outdir=${outfile%/*}
794 [[ $outdir ]] || outdir="/"
795
796 if [[ ! -d "$outdir" ]]; then
797 dfatal "Can't write to $outdir: Directory $outdir does not exist or is not accessible."
798 exit 1
799 elif [[ ! -w "$outdir" ]]; then
800 dfatal "No permission to write to $outdir."
801 exit 1
802 elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
803 dfatal "No permission to write $outfile."
804 exit 1
805 fi
806
807 # Need to be able to have non-root users read stuff (rpcbind etc)
808 chmod 755 "$initdir"
809
810 if [[ $hostonly ]]; then
811 for i in /sys /proc /run /dev; do
812 if ! findmnt --target "$i" &>/dev/null; then
813 dwarning "Turning off host-only mode: '$i' is not mounted!"
814 unset hostonly
815 fi
816 done
817 if ! [[ -d /run/udev/data ]]; then
818 dwarning "Turning off host-only mode: udev database not found!"
819 unset hostonly
820 fi
821 fi
822
823 declare -A host_fs_types
824
825 for line in "${fstab_lines[@]}"; do
826 set -- $line
827 #dev mp fs fsopts
828 push host_devs "$1"
829 host_fs_types["$1"]="$3"
830 done
831
832 for f in $add_fstab; do
833 [[ -e $f ]] || continue
834 while read dev rest; do
835 push host_devs "$dev"
836 done < "$f"
837 done
838
839 for dev in $add_device; do
840 push host_devs "$dev"
841 done
842
843 if (( ${#add_device_l[@]} )); then
844 while pop add_device_l val; do
845 add_device+=" $val "
846 push host_devs "$val"
847 done
848 fi
849
850 if [[ $hostonly ]]; then
851 # in hostonly mode, determine all devices, which have to be accessed
852 # and examine them for filesystem types
853
854 for mp in \
855 "/" \
856 "/etc" \
857 "/usr" \
858 "/usr/bin" \
859 "/usr/sbin" \
860 "/usr/lib" \
861 "/usr/lib64" \
862 "/boot";
863 do
864 mountpoint "$mp" >/dev/null 2>&1 || continue
865 _dev="$(readlink -f "/dev/block/$(find_block_device "$mp")")"
866 [[ "$_mp" == "/" ]] && root_dev="$_dev"
867 push host_devs "$_dev"
868 done
869
870 while read dev type rest; do
871 [[ -b $dev ]] || continue
872 [[ "$type" == "partition" ]] || continue
873 while read _d _m _t _o _r; do
874 [[ "$_d" == \#* ]] && continue
875 [[ $_d ]] || continue
876 [[ $_t != "swap" ]] || [[ $_m != "swap" ]] && continue
877 [[ "$_o" == *noauto* ]] && continue
878 [[ "$_d" == UUID\=* ]] && _d="/dev/disk/by-uuid/${_d#UUID=}"
879 [[ "$_d" == LABEL\=* ]] && _d="/dev/disk/by-label/$_d#LABEL=}"
880 [[ "$_d" -ef "$dev" ]] || continue
881
882 while read _mapper _a _p _o; do
883 [[ $_mapper = \#* ]] && continue
884 [[ "$_d" -ef /dev/mapper/"$_mapper" ]] || continue
885 [[ "$_o" ]] || _o="$_p"
886 # skip mkswap swap
887 [[ $_o == *swap* ]] && continue 2
888 done < /etc/crypttab
889
890 push host_devs "$(readlink -f "$dev")"
891 break
892 done < /etc/fstab
893 done < /proc/swaps
894 fi
895
896 _get_fs_type() { (
897 [[ $1 ]] || return
898 if [[ -b /dev/block/$1 ]] && ID_FS_TYPE=$(get_fs_env "/dev/block/$1"); then
899 printf "%s\n" "$(readlink -f "/dev/block/$1")" "$ID_FS_TYPE"
900 return 1
901 fi
902 if [[ -b $1 ]] && ID_FS_TYPE=$(get_fs_env "$1"); then
903 printf "%s\n" "$(readlink -f "$1")" "$ID_FS_TYPE"
904 return 1
905 fi
906 if fstype=$(find_dev_fstype "$1"); then
907 printf "%s\n" "$1" "$fstype"
908 return 1
909 fi
910 return 1
911 ) }
912
913 for dev in "${host_devs[@]}"; do
914 while read key; do
915 read val
916 host_fs_types["$key"]="$val"
917 done < <(
918 _get_fs_type "$dev"
919 check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
920 )
921 done
922
923 [[ -d $udevdir ]] \
924 || udevdir="$(pkg-config udev --variable=udevdir 2>/dev/null)"
925 if ! [[ -d "$udevdir" ]]; then
926 [[ -d /lib/udev ]] && udevdir=/lib/udev
927 [[ -d /usr/lib/udev ]] && udevdir=/usr/lib/udev
928 fi
929
930 [[ -d $systemdutildir ]] \
931 || systemdutildir=$(pkg-config systemd --variable=systemdutildir 2>/dev/null)
932
933 if ! [[ -d "$systemdutildir" ]]; then
934 [[ -d /lib/systemd ]] && systemdutildir=/lib/systemd
935 [[ -d /usr/lib/systemd ]] && systemdutildir=/usr/lib/systemd
936 fi
937
938 [[ -d $systemdsystemunitdir ]] \
939 || systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null)
940
941 [[ -d "$systemdsystemunitdir" ]] || systemdsystemunitdir=${systemdutildir}/system
942
943 [[ -d $systemdsystemconfdir ]] \
944 || systemdsystemconfdir=$(pkg-config systemd --variable=systemdsystemconfdir 2>/dev/null)
945
946 [[ -d "$systemdsystemconfdir" ]] || systemdsystemconfdir=/etc/systemd/system
947
948 export initdir dracutbasedir dracutmodules \
949 fw_dir drivers_dir debug no_kernel kernel_only \
950 omit_drivers mdadmconf lvmconf root_dev \
951 use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
952 stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
953 debug host_fs_types host_devs sshkey add_fstab \
954 DRACUT_VERSION udevdir prefix filesystems drivers \
955 systemdutildir systemdsystemunitdir systemdsystemconfdir
956
957 # Create some directory structure first
958 [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
959
960 [[ -h /lib ]] || mkdir -m 0755 -p "${initdir}${prefix}/lib"
961 [[ $prefix ]] && ln -sfn "${prefix#/}/lib" "$initdir/lib"
962
963 if [[ $prefix ]]; then
964 for d in bin etc lib sbin tmp usr var $libdirs; do
965 [[ "$d" == */* ]] && continue
966 ln -sfn "${prefix#/}/${d#/}" "$initdir/$d"
967 done
968 fi
969
970 if [[ $kernel_only != yes ]]; then
971 for d in usr/bin usr/sbin bin etc lib sbin tmp usr var $libdirs; do
972 [[ -e "${initdir}${prefix}/$d" ]] && continue
973 if [ -L "/$d" ]; then
974 inst_symlink "/$d" "${prefix}/$d"
975 else
976 mkdir -m 0755 -p "${initdir}${prefix}/$d"
977 fi
978 done
979
980 for d in dev proc sys sysroot root run run/lock run/initramfs; do
981 if [ -L "/$d" ]; then
982 inst_symlink "/$d"
983 else
984 mkdir -m 0755 -p "$initdir/$d"
985 fi
986 done
987
988 ln -sfn ../run "$initdir/var/run"
989 ln -sfn ../run/lock "$initdir/var/lock"
990 ln -sfn ../run/log "$initdir/var/log"
991 else
992 for d in lib "$libdir"; do
993 [[ -e "${initdir}${prefix}/$d" ]] && continue
994 if [ -h "/$d" ]; then
995 inst "/$d" "${prefix}/$d"
996 else
997 mkdir -m 0755 -p "${initdir}${prefix}/$d"
998 fi
999 done
1000 fi
1001
1002 if [[ $kernel_only != yes ]]; then
1003 mkdir -p "${initdir}/etc/cmdline.d"
1004 for _d in $hookdirs; do
1005 mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
1006 done
1007 if [[ "$UID" = "0" ]]; then
1008 [ -c ${initdir}/dev/null ] || mknod ${initdir}/dev/null c 1 3
1009 [ -c ${initdir}/dev/kmsg ] || mknod ${initdir}/dev/kmsg c 1 11
1010 [ -c ${initdir}/dev/console ] || mknod ${initdir}/dev/console c 5 1
1011 fi
1012 fi
1013
1014 mods_to_load=""
1015 # check all our modules to see if they should be sourced.
1016 # This builds a list of modules that we will install next.
1017 for_each_module_dir check_module
1018 for_each_module_dir check_mount
1019
1020 [[ "$mods_to_load " == *01fips\ * ]] && export DRACUT_FIPS_MODE=1
1021
1022 _isize=0 #initramfs size
1023 modules_loaded=" "
1024 # source our modules.
1025 for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
1026 _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
1027 if [[ "$mods_to_load" == *\ $_d_mod\ * ]]; then
1028 if [[ $show_modules = yes ]]; then
1029 printf "%s\n" "$_d_mod"
1030 else
1031 dinfo "*** Including module: $_d_mod ***"
1032 fi
1033 if [[ $kernel_only == yes ]]; then
1034 module_installkernel "$_d_mod" || {
1035 dfatal "installkernel failed in module $_d_mod"
1036 exit 1
1037 }
1038 else
1039 module_install "$_d_mod"
1040 if [[ $no_kernel != yes ]]; then
1041 module_installkernel "$_d_mod" || {
1042 dfatal "installkernel failed in module $_d_mod"
1043 exit 1
1044 }
1045 fi
1046 fi
1047 mods_to_load=${mods_to_load// $_d_mod /}
1048 modules_loaded+="$_d_mod "
1049
1050 #print the module install size
1051 if [ -n "$printsize" ]; then
1052 _isize_new=$(du -sk ${initdir}|cut -f1)
1053 _isize_delta=$((_isize_new - _isize))
1054 printf "%s\n" "$_d_mod install size: ${_isize_delta}k"
1055 _isize=$_isize_new
1056 fi
1057 fi
1058 done
1059 unset moddir
1060
1061 for i in $modules_loaded; do
1062 mkdir -p $initdir/lib/dracut
1063 printf "%s\n" "$i" >> $initdir/lib/dracut/modules.txt
1064 done
1065
1066 dinfo "*** Including modules done ***"
1067
1068 ## final stuff that has to happen
1069 if [[ $no_kernel != yes ]]; then
1070
1071 if [[ $drivers ]]; then
1072 hostonly='' instmods $drivers
1073 fi
1074
1075 if [[ $add_drivers ]]; then
1076 hostonly='' instmods -c $add_drivers
1077 fi
1078 if [[ $filesystems ]]; then
1079 hostonly='' instmods -c $filesystems
1080 fi
1081
1082 dinfo "*** Installing kernel module dependencies and firmware ***"
1083 dracut_kernel_post
1084 dinfo "*** Installing kernel module dependencies and firmware done ***"
1085
1086 if [[ $noimageifnotneeded == yes ]] && [[ $hostonly ]]; then
1087 if [[ ! -f "$initdir/lib/dracut/need-initqueue" ]] && \
1088 [[ -f ${initdir}/lib/modules/$kernel/modules.dep && ! -s ${initdir}/lib/modules/$kernel/modules.dep ]]; then
1089 for i in ${initdir}/etc/cmdline.d/*.conf; do
1090 # We need no initramfs image and do not generate one.
1091 [[ $i == "${initdir}/etc/cmdline.d/*.conf" ]] && exit 0
1092 done
1093 fi
1094 fi
1095 fi
1096
1097 if [[ $kernel_only != yes ]]; then
1098 (( ${#install_items[@]} > 0 )) && dracut_install ${install_items[@]}
1099
1100 [[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
1101
1102 while pop fstab_lines line; do
1103 printf "%s\n" "$line 0 0" >> "${initdir}/etc/fstab"
1104 done
1105
1106 for f in $add_fstab; do
1107 cat "$f" >> "${initdir}/etc/fstab"
1108 done
1109
1110 if [ -d ${initdir}/$systemdutildir ]; then
1111 mkdir -p ${initdir}/etc/conf.d
1112 {
1113 printf "%s\n" "systemdutildir=\"$systemdutildir\""
1114 printf "%s\n" "systemdsystemunitdir=\"$systemdsystemunitdir\""
1115 printf "%s\n" "systemdsystemconfdir=\"$systemdsystemconfdir\""
1116 } > ${initdir}/etc/conf.d/systemd.conf
1117 fi
1118
1119 if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then
1120 dinfo "*** Resolving executable dependencies ***"
1121 find "$initdir" -type f \
1122 '(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \
1123 -not -path '*.ko' -print0 \
1124 | xargs -r -0 $DRACUT_INSTALL ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H} --
1125 dinfo "*** Resolving executable dependencies done***"
1126 fi
1127 fi
1128
1129 while pop include_src src && pop include_target tgt; do
1130 if [[ $src && $tgt ]]; then
1131 if [[ -f $src ]]; then
1132 inst $src $tgt
1133 else
1134 ddebug "Including directory: $src"
1135 mkdir -p "${initdir}/${tgt}"
1136 # check for preexisting symlinks, so we can cope with the
1137 # symlinks to $prefix
1138 for i in "$src"/*; do
1139 [[ -e "$i" || -h "$i" ]] || continue
1140 s=${initdir}/${tgt}/${i#$src/}
1141 if [[ -d "$i" ]]; then
1142 if ! [[ -e "$s" ]]; then
1143 mkdir -m 0755 -p "$s"
1144 chmod --reference="$i" "$s"
1145 fi
1146 cp --reflink=auto --sparse=auto -fa -t "$s" "$i"/*
1147 else
1148 cp --reflink=auto --sparse=auto -fa -t "$s" "$i"
1149 fi
1150 done
1151 fi
1152 fi
1153 done
1154
1155 if [[ $kernel_only != yes ]]; then
1156 # make sure that library links are correct and up to date
1157 for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do
1158 [[ -f $f ]] && inst_simple "$f"
1159 done
1160 if ! ldconfig -r "$initdir"; then
1161 if [[ $UID = 0 ]]; then
1162 derror "ldconfig exited ungracefully"
1163 else
1164 derror "ldconfig might need uid=0 (root) for chroot()"
1165 fi
1166 fi
1167 fi
1168
1169 if (( maxloglvl >= 5 )); then
1170 ddebug "Listing sizes of included files:"
1171 du -c "$initdir" | sort -n | ddebug
1172 fi
1173
1174 PRELINK_BIN="$(command -v prelink)"
1175 if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then
1176 if [[ $DRACUT_FIPS_MODE ]]; then
1177 dinfo "*** Installing prelink files ***"
1178 dracut_install -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf /etc/prelink.cache
1179 else
1180 dinfo "*** Pre-linking files ***"
1181 dracut_install -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf
1182 chroot "$initdir" "$PRELINK_BIN" -a
1183 rm -f -- "$initdir/$PRELINK_BIN"
1184 rm -fr -- "$initdir"/etc/prelink.*
1185 dinfo "*** Pre-linking files done ***"
1186 fi
1187 fi
1188
1189 if [[ $do_hardlink = yes ]] && command -v hardlink >/dev/null; then
1190 dinfo "*** Hardlinking files ***"
1191 hardlink "$initdir" 2>&1
1192 dinfo "*** Hardlinking files done ***"
1193 fi
1194
1195 # strip binaries
1196 if [[ $do_strip = yes ]] ; then
1197 for p in strip xargs find; do
1198 if ! type -P $p >/dev/null; then
1199 dinfo "Could not find '$p'. Not stripping the initramfs."
1200 do_strip=no
1201 fi
1202 done
1203 fi
1204
1205 if [[ $do_strip = yes ]] ; then
1206 dinfo "*** Stripping files ***"
1207 if [[ $DRACUT_FIPS_MODE ]]; then
1208 find "$initdir" -type f \
1209 -executable -not -path '*/lib/modules/*.ko' -print0 \
1210 | while read -r -d $'\0' f; do
1211 if ! [[ -e "${f%/*}/.${f##*/}.hmac" ]] \
1212 && ! [[ -e "/lib/hmaccalc/${f##*/}.hmac" ]] \
1213 && ! [[ -e "/lib64/hmaccalc/${f##*/}.hmac" ]] \
1214 && ! [[ -e "/lib/fipscheck/${f##*/}.hmac" ]] \
1215 && ! [[ -e "/lib64/fipscheck/${f##*/}.hmac" ]]; then
1216 printf "%s\000" "$f";
1217 fi
1218 done | xargs -r -0 strip -g 2>/dev/null
1219 else
1220 find "$initdir" -type f \
1221 -executable -not -path '*/lib/modules/*.ko' -print0 \
1222 | xargs -r -0 strip -g 2>/dev/null
1223 fi
1224
1225 # strip kernel modules, but do not touch signed modules
1226 find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
1227 | while read -r -d $'\0' f; do
1228 SIG=$(tail -c 28 "$f")
1229 [[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; }
1230 done | xargs -r -0 strip -g
1231
1232 dinfo "*** Stripping files done ***"
1233 fi
1234 if [[ $early_microcode = yes ]]; then
1235 dinfo "*** Generating early-microcode cpio image ***"
1236 ucode_dir=(amd-ucode intel-ucode)
1237 ucode_dest=(AuthenticAMD.bin GenuineIntel.bin)
1238 _dest_dir="$microcode_dir/d/kernel/x86/microcode"
1239 _dest_idx="0 1"
1240 mkdir -p $_dest_dir
1241 if [[ $hostonly ]]; then
1242 [[ $(get_cpu_vendor) == "AMD" ]] && _dest_idx="0"
1243 [[ $(get_cpu_vendor) == "Intel" ]] && _dest_idx="1"
1244 fi
1245 for idx in $_dest_idx; do
1246 _fw=${ucode_dir[$idx]}
1247 for _fwdir in $fw_dir; do
1248 if [[ -d $_fwdir && -d $_fwdir/$_fw ]]; then
1249 _src="*"
1250 dinfo "*** Constructing ${ucode_dest[$idx]} ****"
1251 if [[ $hostonly ]]; then
1252 _src=$(get_ucode_file)
1253 fi
1254 cat $_fwdir/$_fw/$_src > $_dest_dir/${ucode_dest[$idx]}
1255 fi
1256 done
1257 done
1258 (cd "$microcode_dir/d"; find . | cpio -o -H newc --quiet >../ucode.cpio)
1259 fi
1260 rm -f -- "$outfile"
1261 dinfo "*** Creating image file ***"
1262 if [[ $early_microcode = yes ]]; then
1263 # The microcode blob is _before_ the initramfs blob, not after
1264 mv $microcode_dir/ucode.cpio $outfile.$$
1265 fi
1266 if ! ( umask 077; cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \
1267 $compress >> "$outfile.$$"; ); then
1268 dfatal "dracut: creation of $outfile.$$ failed"
1269 exit 1
1270 fi
1271 mv -- "$outfile.$$" "$outfile"
1272 dinfo "*** Creating image file done ***"
1273
1274 dinfo "Wrote $outfile:"
1275 dinfo "$(ls -l "$outfile")"
1276
1277 exit 0