dracut.sh: Add --noimageifnotneeded parameter
Do not create an image in host-only mode, if no kernel driver is needed and no $initdir/etc/cmdline/*.conf is generated.master
parent
8fdcc1a9b1
commit
83bb0893ed
|
|
@ -2,10 +2,27 @@
|
|||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
if [[ -f /etc/kernel/cmdline ]]; then
|
||||
readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
|
||||
fi
|
||||
|
||||
if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
|
||||
readarray -t BOOT_OPTIONS < /proc/cmdline
|
||||
fi
|
||||
|
||||
unset noimageifnotneeded
|
||||
|
||||
for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
|
||||
if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
|
||||
noimageifnotneeded="yes"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
ret=0
|
||||
case "$1" in
|
||||
add)
|
||||
dracut "$3"/initrd "$2"
|
||||
dracut ${noimageifnotneeded+--noimageifnotneeded} "$3"/initrd "$2"
|
||||
ret=$?
|
||||
;;
|
||||
remove)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ _dracut() {
|
|||
--lvmconf --nolvmconf --debug --profile --verbose --quiet
|
||||
--local --hostonly --no-hostonly --fstab --help --bzip2 --lzma
|
||||
--xz --no-compress --gzip --list-modules --show-modules --keep
|
||||
--printsize --regenerate-all'
|
||||
--printsize --regenerate-all --noimageifnotneeded'
|
||||
|
||||
[ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers
|
||||
--omit-drivers --modules --omit --drivers --filesystems --install
|
||||
|
|
|
|||
12
dracut.sh
12
dracut.sh
|
|
@ -330,6 +330,7 @@ TEMP=$(unset POSIXLY_CORRECT; getopt \
|
|||
--long keep \
|
||||
--long printsize \
|
||||
--long regenerate-all \
|
||||
--long noimageifnotneeded \
|
||||
-- "$@")
|
||||
|
||||
if (( $? != 0 )); then
|
||||
|
|
@ -408,6 +409,7 @@ while :; do
|
|||
--keep) keep="yes";;
|
||||
--printsize) printsize="yes";;
|
||||
--regenerate-all) regenerate_all="yes";;
|
||||
--noimageifnotneeded) noimageifnotneeded="yes";;
|
||||
|
||||
--) shift; break;;
|
||||
|
||||
|
|
@ -1020,6 +1022,16 @@ if [[ $no_kernel != yes ]]; then
|
|||
dinfo "*** Installing kernel module dependencies and firmware ***"
|
||||
dracut_kernel_post
|
||||
dinfo "*** Installing kernel module dependencies and firmware done ***"
|
||||
|
||||
if [[ $noimageifnotneeded == yes ]] && [[ $hostonly ]]; then
|
||||
if [[ ! -f "$initdir/lib/dracut/need-initqueue" ]] && \
|
||||
[[ -f ${initdir}/lib/modules/$kernel/modules.dep && ! -s ${initdir}/lib/modules/$kernel/modules.dep ]]; then
|
||||
for i in ${initdir}/etc/cmdline.d/*.conf; do
|
||||
# We need no initramfs image and do not generate one.
|
||||
[[ $i == "${initdir}/etc/cmdline.d/*.conf" ]] && exit 0
|
||||
done
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $kernel_only != yes ]]; then
|
||||
|
|
|
|||
Loading…
Reference in New Issue