dracut: add "--omit-driver"

master
Harald Hoyer 2012-02-15 14:53:18 +01:00
parent 28f0b27fb9
commit fcbcb2521c
4 changed files with 71 additions and 16 deletions

52
dracut
View File

@ -40,8 +40,10 @@ Creates initial ramdisk images for preloading modules
-a, --add [LIST] Add a space-separated list of dracut modules. -a, --add [LIST] Add a space-separated list of dracut modules.
-d, --drivers [LIST] Specify a space-separated list of kernel modules to -d, --drivers [LIST] Specify a space-separated list of kernel modules to
exclusively include in the initramfs. exclusively include in the initramfs.
--add-drivers [LIST] Specify a space-separated list of kernel --add-drivers [LIST] Specify a space-separated list of kernel
modules to add to the initramfs. modules to add to the initramfs.
--omit-drivers [LIST] Specify a space-separated list of kernel
modules not to add to the initramfs.
--filesystems [LIST] Specify a space-separated list of kernel filesystem --filesystems [LIST] Specify a space-separated list of kernel filesystem
modules to exclusively include in the generic modules to exclusively include in the generic
initramfs. initramfs.
@ -210,6 +212,7 @@ while (($# > 0)); do
-a|--add) push_arg add_dracutmodules_l "$@" || shift;; -a|--add) push_arg add_dracutmodules_l "$@" || shift;;
--force-add) push_arg force_add_dracutmodules_l "$@" || shift;; --force-add) push_arg force_add_dracutmodules_l "$@" || shift;;
--add-drivers) push_arg add_drivers_l "$@" || shift;; --add-drivers) push_arg add_drivers_l "$@" || shift;;
--omit-drivers) push_arg omit_drivers_l "$@" || shift;;
-m|--modules) push_arg dracutmodules_l "$@" || shift;; -m|--modules) push_arg dracutmodules_l "$@" || shift;;
-o|--omit) push_arg omit_dracutmodules_l "$@" || shift;; -o|--omit) push_arg omit_dracutmodules_l "$@" || shift;;
-d|--drivers) push_arg drivers_l "$@" || shift;; -d|--drivers) push_arg drivers_l "$@" || shift;;
@ -341,13 +344,6 @@ if (( ${#force_add_dracutmodules_l[@]} )); then
done done
fi fi



if (( ${#add_drivers_l[@]} )); then
while pop add_drivers_l val; do
add_drivers+=" $val "
done
fi

if (( ${#fscks_l[@]} )); then if (( ${#fscks_l[@]} )); then
while pop fscks_l val; do while pop fscks_l val; do
fscks+=" $val " fscks+=" $val "
@ -387,13 +383,6 @@ if (( ${#omit_dracutmodules_l[@]} )); then
done done
fi fi


if (( ${#drivers_l[@]} )); then
drivers=''
while pop drivers_l val; do
drivers+="$val "
done
fi

if (( ${#filesystems_l[@]} )); then if (( ${#filesystems_l[@]} )); then
filesystems='' filesystems=''
while pop filesystems_l val; do while pop filesystems_l val; do
@ -466,6 +455,37 @@ fi
dracutfunctions=$dracutbasedir/dracut-functions dracutfunctions=$dracutbasedir/dracut-functions
export dracutfunctions export dracutfunctions


if (( ${#drivers_l[@]} )); then
drivers=''
while pop drivers_l val; do
drivers+="$val "
done
fi
drivers=${drivers/-/_}

if (( ${#add_drivers_l[@]} )); then
while pop add_drivers_l val; do
add_drivers+=" $val "
done
fi
add_drivers=${add_drivers/-/_}

if (( ${#omit_drivers_l[@]} )); then
while pop omit_drivers_l val; do
omit_drivers+=" $val "
done
fi
omit_drivers=${omit_drivers/-/_}

unset omit_drivers_corrected
for d in $omit_drivers; do
strstr " $drivers $add_drivers " " $d " && continue
omit_drivers_corrected+=" $d "
done
omit_drivers=$omit_drivers_corrected
unset omit_drivers_corrected


ddebug "Executing $0 $dracut_args" ddebug "Executing $0 $dracut_args"


[[ $do_list = yes ]] && { [[ $do_list = yes ]] && {
@ -604,7 +624,7 @@ done


export initdir dracutbasedir dracutmodules drivers \ export initdir dracutbasedir dracutmodules drivers \
fw_dir drivers_dir debug no_kernel kernel_only \ fw_dir drivers_dir debug no_kernel kernel_only \
add_drivers mdadmconf lvmconf filesystems \ add_drivers omit_drivers mdadmconf lvmconf filesystems \
use_fstab fstab_lines libdir usrlibdir fscks nofscks cttyhack \ use_fstab fstab_lines libdir usrlibdir fscks nofscks cttyhack \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \ stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug host_fs_types host_devs sshkey debug host_fs_types host_devs sshkey

View File

@ -927,6 +927,17 @@ install_kmod_with_fw() {
# no need to go further if the module is already installed # no need to go further if the module is already installed
[[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] \ [[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] \
&& return 0 && return 0

if [[ $omit_drivers ]]; then
local _kmod=${1##*/}
_kmod=${_kmod%.ko}
_kmod=${_kmod/-/_}
if strstr " $omit_drivers " " $_kmod " ; then
dinfo "Omitting driver $_kmod"
return 1
fi
fi

inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" \ inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" \
|| return $? || return $?



View File

@ -196,6 +196,20 @@ The kernel modules have to be specified without the ".ko" suffix. This
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<option>--omit-drivers&nbsp;<replaceable>&lt;list of kernel modules&gt;</replaceable></option>
</term>
<listitem>
<para>specify a space-separated list of kernel modules not to add to the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix. This parameter can be specified multiple times.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --omit-drivers "kmodule1 kmodule2" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<option>--filesystems&nbsp;<replaceable>&lt;list of filesystems&gt;</replaceable></option> <option>--filesystems&nbsp;<replaceable>&lt;list of filesystems&gt;</replaceable></option>

View File

@ -82,6 +82,16 @@ The kernel modules have to be specified without the &quot;.ko&quot; suffix.</par
<listitem> <listitem>
<para>Specify a space-separated list of kernel <para>Specify a space-separated list of kernel
modules to add to the initramfs. modules to add to the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>omit_drivers+=&quot;&nbsp;<replaceable>&lt;kernel modules&gt;</replaceable>&nbsp;&quot;</envar>
</term>
<listitem>
<para>Specify a space-separated list of kernel
modules not to add to the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix.</para> The kernel modules have to be specified without the &quot;.ko&quot; suffix.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>