diff options
author | Harald Hoyer <harald@eeepc.(none)> | 2009-07-22 12:43:26 +0200 |
---|---|---|
committer | Harald Hoyer <harald@eeepc.(none)> | 2009-07-22 15:07:11 +0200 |
commit | 33ee031c4ac32b113d0319f082d426139c48990c (patch) | |
tree | 4bb1f5bb824b70e0939299b2105929e2d21617fb | |
parent | f24a2d46b73993e79967a7a0cd9afe8222ba7f36 (diff) | |
download | dracut-33ee031c4ac32b113d0319f082d426139c48990c.tar.gz dracut-33ee031c4ac32b113d0319f082d426139c48990c.tar.bz2 dracut-33ee031c4ac32b113d0319f082d426139c48990c.zip |
dracut: add --kernel-only and --no-kernel arguments
--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
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | README.kernel | 6 | ||||
-rwxr-xr-x | dracut | 30 | ||||
-rwxr-xr-x | dracut-functions | 39 | ||||
-rw-r--r-- | dracut.8 | 6 | ||||
-rw-r--r-- | dracut.spec | 21 | ||||
-rwxr-xr-x | modules.d/40network/install | 13 | ||||
-rwxr-xr-x | modules.d/40network/installkernel | 14 | ||||
-rwxr-xr-x | modules.d/50plymouth/install | 4 | ||||
-rwxr-xr-x | modules.d/50plymouth/installkernel | 5 | ||||
-rwxr-xr-x | modules.d/90crypt/install | 1 | ||||
-rwxr-xr-x | modules.d/90crypt/installkernel | 2 | ||||
-rwxr-xr-x | modules.d/90kernel-modules/install | 10 | ||||
-rwxr-xr-x | modules.d/90kernel-modules/installkernel | 11 | ||||
-rwxr-xr-x | modules.d/90mdraid/install | 2 | ||||
-rwxr-xr-x | modules.d/90mdraid/installkernel | 3 | ||||
-rwxr-xr-x | modules.d/95iscsi/install | 1 | ||||
-rwxr-xr-x | modules.d/95iscsi/installkernel | 2 | ||||
-rwxr-xr-x | modules.d/95nbd/install | 1 | ||||
-rwxr-xr-x | modules.d/95nbd/installkernel | 2 | ||||
-rwxr-xr-x | modules.d/95nfs/install | 1 | ||||
-rwxr-xr-x | modules.d/95nfs/installkernel | 2 |
22 files changed, 122 insertions, 63 deletions
@@ -65,3 +65,12 @@ check: all 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 + + + diff --git a/README.kernel b/README.kernel new file mode 100644 index 00000000..f477ee5a --- /dev/null +++ b/README.kernel @@ -0,0 +1,6 @@ +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. + @@ -23,8 +23,10 @@ Creates initial ramdisk images for preloading modules -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 @@ -53,6 +55,8 @@ while (($# > 0)); do -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";; @@ -87,6 +91,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH [[ $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 @@ -127,12 +132,14 @@ trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die. 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. @@ -142,7 +149,14 @@ check_modules 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 diff --git a/dracut-functions b/dracut-functions index 2178dd74..6fef83ac 100755 --- a/dracut-functions +++ b/dracut-functions @@ -1,8 +1,8 @@ #!/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 @@ -17,10 +17,6 @@ # 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="" @@ -238,6 +234,10 @@ check_module_deps() { 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 @@ -266,6 +266,7 @@ check_modules() { # 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} @@ -294,7 +295,7 @@ instmods() { [[ $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 @@ -304,16 +305,20 @@ instmods() { 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 @@ -36,6 +36,12 @@ specify the directory, where to look for kernel modules .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 diff --git a/dracut.spec b/dracut.spec index d74a5215..afd940b4 100644 --- a/dracut.spec +++ b/dracut.spec @@ -51,7 +51,6 @@ BuildArch: noarch %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} @@ -60,16 +59,24 @@ Requires: iscsi-initiator-utils 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} @@ -107,6 +114,10 @@ rm -rf $RPM_BUILD_ROOT %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 diff --git a/modules.d/40network/install b/modules.d/40network/install index 79fbf57c..e66c72f8 100755 --- a/modules.d/40network/install +++ b/modules.d/40network/install @@ -1,22 +1,9 @@ #!/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" diff --git a/modules.d/40network/installkernel b/modules.d/40network/installkernel new file mode 100755 index 00000000..96e87b19 --- /dev/null +++ b/modules.d/40network/installkernel @@ -0,0 +1,14 @@ +#!/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 diff --git a/modules.d/50plymouth/install b/modules.d/50plymouth/install index 89a0a093..eedf4f6a 100755 --- a/modules.d/50plymouth/install +++ b/modules.d/50plymouth/install @@ -5,7 +5,3 @@ inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh 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 diff --git a/modules.d/50plymouth/installkernel b/modules.d/50plymouth/installkernel new file mode 100755 index 00000000..4b281e8c --- /dev/null +++ b/modules.d/50plymouth/installkernel @@ -0,0 +1,5 @@ +#!/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 diff --git a/modules.d/90crypt/install b/modules.d/90crypt/install index 9ffe90e4..13195039 100755 --- a/modules.d/90crypt/install +++ b/modules.d/90crypt/install @@ -1,6 +1,5 @@ #!/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" diff --git a/modules.d/90crypt/installkernel b/modules.d/90crypt/installkernel new file mode 100755 index 00000000..7a58ea3e --- /dev/null +++ b/modules.d/90crypt/installkernel @@ -0,0 +1,2 @@ +#!/bin/bash +instmods dm_crypt cbc aes sha256 xts diff --git a/modules.d/90kernel-modules/install b/modules.d/90kernel-modules/install index e6db3e16..b3fb0df1 100755 --- a/modules.d/90kernel-modules/install +++ b/modules.d/90kernel-modules/install @@ -1,13 +1,3 @@ #!/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') diff --git a/modules.d/90kernel-modules/installkernel b/modules.d/90kernel-modules/installkernel new file mode 100755 index 00000000..d86f3fbd --- /dev/null +++ b/modules.d/90kernel-modules/installkernel @@ -0,0 +1,11 @@ +#!/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 diff --git a/modules.d/90mdraid/install b/modules.d/90mdraid/install index 2303f5d0..07ca96c0 100755 --- a/modules.d/90mdraid/install +++ b/modules.d/90mdraid/install @@ -11,8 +11,6 @@ dracut_install mdadm partx # inst /etc/passwd # inst /etc/group -instmods =drivers/md - if [ -x /lib/udev/vol_id ]; then inst_rules "$moddir/61-mdadm.rules" else diff --git a/modules.d/90mdraid/installkernel b/modules.d/90mdraid/installkernel new file mode 100755 index 00000000..d26bafac --- /dev/null +++ b/modules.d/90mdraid/installkernel @@ -0,0 +1,3 @@ +#!/bin/bash +instmods =drivers/md + diff --git a/modules.d/95iscsi/install b/modules.d/95iscsi/install index 7f8c2e27..6386410b 100755 --- a/modules.d/95iscsi/install +++ b/modules.d/95iscsi/install @@ -6,4 +6,3 @@ inst iscsi-iname 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 diff --git a/modules.d/95iscsi/installkernel b/modules.d/95iscsi/installkernel new file mode 100755 index 00000000..1dcf19a6 --- /dev/null +++ b/modules.d/95iscsi/installkernel @@ -0,0 +1,2 @@ +#!/bin/bash +instmods iscsi_tcp crc32c diff --git a/modules.d/95nbd/install b/modules.d/95nbd/install index 0b87def6..195c27e5 100755 --- a/modules.d/95nbd/install +++ b/modules.d/95nbd/install @@ -9,4 +9,3 @@ else fi inst "$moddir/nbdroot" "/sbin/nbdroot" -instmods nbd diff --git a/modules.d/95nbd/installkernel b/modules.d/95nbd/installkernel new file mode 100755 index 00000000..c8eea5ec --- /dev/null +++ b/modules.d/95nbd/installkernel @@ -0,0 +1,2 @@ +#!/bin/bash +instmods nbd diff --git a/modules.d/95nfs/install b/modules.d/95nfs/install index 2e96e5da..7f96cc75 100755 --- a/modules.d/95nfs/install +++ b/modules.d/95nfs/install @@ -16,7 +16,6 @@ fi 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" diff --git a/modules.d/95nfs/installkernel b/modules.d/95nfs/installkernel new file mode 100755 index 00000000..fa31aa23 --- /dev/null +++ b/modules.d/95nfs/installkernel @@ -0,0 +1,2 @@ +#!/bin/bash +instmods nfs sunrpc ipv6 |