--kernel-only
only install kernel drivers and firmware files
--no-kernel
do not install kernel drivers and firmware files
All kernel module related install commands moved from "install"
to "installkernel".
For "--kernel-only" all installkernel scripts of the specified
modules are used, regardless of any checks, so that all modules
which might be needed by any dracut generic image are in.
The basic idea is to create two images. One image with the kernel
modules and one without. So if the kernel changes, you only have
to replace one image.
Grub and the kernel can handle multiple images, so grub entry can
look like this:
title Fedora (2.6.29.5-191.fc11.i586)
root (hd0,0)
kernel /vmlinuz-2.6.29.5-191.fc11.i586 ro rhgb quiet
initrd /initrd-
20090722.img
initrd /initrd-kernel-2.6.29.5-191.fc11.i586.img
initrd /initrd-config.img
initrd-
20090722.img
the image provided by the initrd rpm
one old backup version is kept like with the kernel
initrd-kernel-2.6.29.5-191.fc11.i586.img
the image provided by the kernel rpm
initrd-config.img
optional image with local configuration files
testimage: all
./dracut -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
@echo wrote test-$(shell uname -r).img
+
+testimages: all
+ ./dracut -l -a debug --kernel-only -f test-kernel-$(shell uname -r).img $(shell uname -r)
+ @echo wrote test-$(shell uname -r).img
+ ./dracut -l -a debug --no-kernel -f test-dracut.img $(shell uname -r)
+ @echo wrote test-dracut.img
+
+
+
--- /dev/null
+dracut-kernel is used to pull in all firmware files to build an initrd with
+only kernel modules and firmware files.
+
+dracut --kernel-only only executes "installkernel" in the modules
+subdirectories.
+
-d, --drivers [LIST] Specify a space-separated list of kernel modules to
include in the initramfs.
-k, --kmoddir [DIR] Specify the directory, where to look for kernel modules
- --fwdir [DIR] Specify additional directory, where to look for
- firmwares
+ --fwdir [DIR] Specify additional directories, where to look for
+ firmwares, separated by :
+ --kernel-only Only install kernel drivers and firmware files
+ --no-kernel Do not install kernel drivers and firmware files
-h, --help This message
--debug Output debug information of the build process
-v, --verbose Verbose output during the build process
-d|--drivers) drivers_l="$2"; shift;;
-k|--kmoddir) drivers_dir_l="$2"; shift;;
--fwdir) fw_dir_l="$2"; shift;;
+ --kernel-only) kernel_only="yes"; nokernel="no";;
+ --no-kernel) kernel_only="no"; no_kernel="yes";;
-h|--help) usage; exit 1 ;;
--debug) debug="yes";;
-v|--verbose) beverbose="yes";;
[[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
[[ $fw_dir_l ]] && fw_dir=$fw_dir_l
[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
+[[ $fw_dir ]] || fw_dir=/lib/firmware
[[ $allowlocal && -f "$(dirname $0)/dracut-functions" ]] && dsrc="$(dirname $0)" || dsrc=$dracutbasedir
chmod 755 "$initdir"
export initdir hookdirs dsrc dracutmodules drivers \
- fw_dir drivers_dir debug beverbose
+ fw_dir drivers_dir debug beverbose no_kernel kernel_only
-# Create some directory structure first
-for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot tmp dev/pts var/run; do
- mkdir -p "$initdir/$d";
-done
+if [[ "$kernel_only" != "yes" ]]; then
+ # Create some directory structure first
+ for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot tmp dev/pts var/run; do
+ mkdir -p "$initdir/$d";
+ done
+fi
# check all our modules to see if they should be sourced.
# This builds a list of modules that we will install next.
for moddir in "$dsrc/modules.d"/[0-9][0-9]*; do
mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
if strstr "$mods_to_load" " $mod "; then
- . "$moddir/install"
+ if [[ "$kernel_only" = "yes" ]]; then
+ [[ -x "$moddir/installkernel" ]] && . "$moddir/installkernel"
+ else
+ . "$moddir/install"
+ if [[ "$no_kernel" != "yes" && -x "$moddir/installkernel" ]]; then
+ . "$moddir/installkernel"
+ fi
+ fi
mods_to_load=${mods_to_load// $mod /}
fi
done
#!/bin/bash
#
-# functions used by mkinitrd and other tools.
+# functions used by dracut and other tools.
#
-# Copyright 2005-2008 Red Hat, Inc. All rights reserved.
+# Copyright 2005-2009 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-# Authors:
-# Peter Jones <pjones@redhat.com>
-# Jeremy Katz <katzj@redhat.com>
-# Jakub Jelinek <jakub@redhat.com>
IF_RTLD=""
IF_dynamic=""
should_source_module() {
local dep
[[ -x $1/install ]] || return 1
+ if [[ "$kernel_only" = "yes" ]]; then
+ [[ -x $1/installkernel ]] && return 0
+ return 1
+ fi
[[ -x $1/check ]] || return 0
"$1/check" $hostonly || return 1
for dep in $("$1/check" -d); do
# install kernel modules, and handle installing all their dependencies as well.
instmods() {
+ [[ "$no_kernel" = "yes" ]] && return
local mod mpargs modpath modname cmd
while (($# > 0)); do
mod=${1%.ko}
[[ $hostonly ]] && ! grep -q "$mod" /proc/modules && {
shift; continue;
}
- modprobe $mpargs --ignore-install --set-version $kernel \
+ modprobe $mpargs --ignore-install --set-version $kernel -d ${srcmods%%/lib/modules/*}/ \
--show-depends $mod 2>/dev/null | \
while read cmd modpath options; do
[[ $cmd = insmod ]] || continue
dinfo "Installing dependencies for $mod ($modpath)"
instmods $mpargs $modname
fi
- inst_simple "$modpath"
- done
- for fw in $(modinfo -F firmware $mod 2>/dev/null); do
- if [[ -n "$fw_dir" && -f $fw_dir/$fw ]]; then
- inst_simple "$fw_dir/$fw"
- elif [[ -f /lib/firmware/$fw ]]; then
- inst_simple "/lib/firmware/$fw"
- else
- dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
- fi
+ inst_simple "$modpath" "/lib/modules/$kernel/${modpath##*/lib/modules/$kernel/}"
+ for fw in $(modinfo -k $kernel -F firmware $modpath 2>/dev/null); do
+ unset found
+ IFS=:
+ for fwdir in $fw_dir; do
+ if [ -d "$fwdir" -a -f $fwdir/$fw ]; then
+ inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
+ found=yes
+ fi
+ done
+ if [ "$found" != "yes" ]; then
+ dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
+ fi
+ done
done
;;
esac
.BR " \-\-fwdir " \fI[DIR]\fR
specify additional directory, where to look for firmwares
.TP
+.BR \-\-kernel-only
+only install kernel drivers and firmware files
+.TP
+.BR \-\-no-kernel
+do not install kernel drivers and firmware files
+.TP
.BR \-h ", " \-\-help
display help text and exit.
.TP
%description
dracut is a new, event-driven initramfs infrastructure based around udev.
-
%package generic
Summary: Metapackage to build a generic initramfs
Requires: %{name} = %{version}-%{release}
Requires: nbd
Requires: bridge-utils
Requires: net-tools iproute
+Requires: plymouth-system-theme plymouth-theme-charge plymouth-theme-solar
+
+%description generic
+This package requires everything which is needed to build a generic
+all purpose initramfs.
+
+%package kernel
+Summary: Metapackage to build generic initramfs with only kernel modules
+Requires: %{name} = %{version}-%{release}
Requires: ql2100-firmware
Requires: ql2200-firmware
Requires: ql23xx-firmware
Requires: ql2400-firmware
Requires: ql2500-firmware
-Requires: plymouth-system-theme plymouth-theme-charge plymouth-theme-solar
-%description generic
-This package requires everything which is needed to build a generic
-all purpose initramfs.
+%description kernel
+This package requires everything which is needed to build a initramfs with all
+kernel modules and firmware files needed by dracut modules.
%prep
%setup -q -n %{name}-%{version}%{?dashgittag}
%defattr(-,root,root,0755)
%doc README.generic
+%files kernel
+%defattr(-,root,root,0755)
+%doc README.kernel
+
%changelog
* Fri Jul 17 2009 Harald Hoyer <harald@redhat.com> 0.5-1
- version 0.5
#!/bin/bash
dracut_install ip dhclient hostname brctl
-# Include wired net drivers, excluding wireless
-for modname in $(find "$srcmods/kernel/drivers" -name '*.ko'); do
- if nm -uPA $modname | grep -q eth_type_trans; then
- if echo "$modname" | grep -q wireless; then
- continue
- else
- instmods $modname
- fi
- fi
-done
inst "$moddir/ifup" "/sbin/ifup"
inst "$moddir/netroot" "/sbin/netroot"
inst "$moddir/dhclient-script" "/sbin/dhclient-script"
inst "$moddir/dhclient.conf" "/etc/dhclient.conf"
-instmods ecb arc4
-# bridge modules
-instmods bridge stp llc
inst_hook pre-udev 60 "$moddir/net-genrules.sh"
inst_hook cmdline 91 "$moddir/dhcp-root.sh"
inst_hook cmdline 99 "$moddir/parse-ip-opts.sh"
--- /dev/null
+#!/bin/bash
+# Include wired net drivers, excluding wireless
+for modname in $(find "$srcmods/kernel/drivers" -name '*.ko'); do
+ if nm -uPA $modname | grep -q eth_type_trans; then
+ if echo "$modname" | grep -q wireless; then
+ continue
+ else
+ instmods $modname
+ fi
+ fi
+done
+instmods ecb arc4
+# bridge modules
+instmods bridge stp llc
inst_hook pre-trigger 10 "$moddir"/plymouth-pretrigger.sh
inst_hook emergency 50 "$moddir"/plymouth-emergency.sh
inst "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
-# Include KMS capable drm drivers
-for modname in $(find "$srcmods/kernel/drivers/gpu/drm" -name '*.ko'); do
- nm -uPA $modname | grep -q drm_crtc_init && instmods $modname
-done
--- /dev/null
+#!/bin/bash
+# Include KMS capable drm drivers
+for modname in $(find "$srcmods/kernel/drivers/gpu/drm" -name '*.ko'); do
+ nm -uPA $modname | grep -q drm_crtc_init && instmods $modname
+done
#!/bin/bash
inst cryptsetup
-instmods dm_crypt cbc aes sha256 xts
inst_rules "$moddir/70-luks.rules"
inst "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
inst_hook cmdline 30 "$moddir/parse-crypt.sh"
--- /dev/null
+#!/bin/bash
+instmods dm_crypt cbc aes sha256 xts
#!/bin/bash
-if [ -z "$drivers" ]; then
- drivers="sd_mod =fs"
- # Include block controller drivers
- for modname in $(find "$srcmods/kernel/drivers" -name '*.ko'); do
- if nm -uPA $modname | egrep -q 'ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register'; then
- drivers="${drivers} $modname"
- fi
- done
-fi
-instmods $drivers
[ -f /etc/modprobe.conf ] && dracut_install /etc/modprobe.conf
dracut_install $(find /etc/modprobe.d/ -type f -name '*.conf')
--- /dev/null
+#!/bin/bash
+if [ -z "$drivers" ]; then
+ drivers="sd_mod =fs"
+ # Include block controller drivers
+ for modname in $(find "$srcmods/kernel/drivers" -name '*.ko'); do
+ if nm -uPA $modname | egrep -q 'ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register'; then
+ drivers="${drivers} $modname"
+ fi
+ done
+fi
+instmods $drivers
# inst /etc/passwd
# inst /etc/group
-instmods =drivers/md
-
if [ -x /lib/udev/vol_id ]; then
inst_rules "$moddir/61-mdadm.rules"
else
--- /dev/null
+#!/bin/bash
+instmods =drivers/md
+
inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
inst "$moddir/iscsiroot" "/sbin/iscsiroot"
inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
-instmods iscsi_tcp crc32c
--- /dev/null
+#!/bin/bash
+instmods iscsi_tcp crc32c
fi
inst "$moddir/nbdroot" "/sbin/nbdroot"
-instmods nbd
--- /dev/null
+#!/bin/bash
+instmods nbd
dracut_install $(ls {/usr,}$LIBDIR/libnfsidmap*.so* 2>/dev/null )
dracut_install $(ls {/usr,}$LIBDIR/libnss*.so 2>/dev/null)
-instmods nfs sunrpc ipv6
inst_hook cmdline 90 "$moddir/parse-nfsroot.sh"
inst_hook pre-pivot 70 "$moddir/nfsroot-cleanup.sh"
inst "$moddir/nfsroot" "/sbin/nfsroot"
--- /dev/null
+#!/bin/bash
+instmods nfs sunrpc ipv6