Compare commits

..

100 Commits
0.3 ... 0.6

Author SHA1 Message Date
Harald Hoyer
a8b15b36bf version 0.6 2009-07-22 15:07:47 +02:00
Harald Hoyer
33ee031c4a 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
2009-07-22 15:07:11 +02:00
Harald Hoyer
f24a2d46b7 fix kernel modules dir handling 2009-07-21 18:26:47 +02:00
Harald Hoyer
6a389cfca8 dracut.spec: generic requires bridge-utils for brctl 2009-07-21 18:11:50 +02:00
Harald Hoyer
26537a5b79 add --fwdir parameter to dracut
--fwdir [DIR]
              specify additional directory, where to look for firmwares
2009-07-21 18:11:43 +02:00
Harald Hoyer
aae88014c7 do not BuildRequire kernel-firmware for dracut-generic 2009-07-21 17:50:49 +02:00
Harald Hoyer
441d31b927 use kernel module directory specified on command line in modules also 2009-07-21 17:37:41 +02:00
Harald Hoyer
04db5fdc15 dracut: add --kmoddir directory, where to look for kernel modules
-k, --kmoddir [DIR]
              specify the directory, where to look for kernel modules
2009-07-21 17:25:12 +02:00
Harald Hoyer
0592128b1e dracut-gencmdline: output root device and plymouth theme 2009-07-21 17:23:26 +02:00
Harald Hoyer
308b10311c mdraid: first remove the partitions, then add to the md raid 2009-07-21 15:40:11 +02:00
Harald Hoyer
7045d15460 dmraid/mdraid: use ENV{DEVTYPE} instead of ATTR{partition} 2009-07-21 15:01:41 +02:00
Harald Hoyer
6c034582d2 redhat-i18n: export LANG 2009-07-21 11:53:56 +02:00
Harald Hoyer
57b965ef4b dmraid/mdraid: install "partx" 2009-07-21 11:31:15 +02:00
Harald Hoyer
f4785648fb plymouth: also trigger dri subsystem 2009-07-21 11:30:40 +02:00
Harald Hoyer
e368513370 manpage: add docu for rd_NO_MDIMSM 2009-07-17 16:04:13 +02:00
Harald Hoyer
b54cac21c1 Makefile: make clean before rpm 2009-07-17 16:00:20 +02:00
Harald Hoyer
acff0cc10c version 0.5 2009-07-17 16:00:20 +02:00
Harald Hoyer
a6f8c08347 dracut-gencmdline - generate the kernel command line for the local host 2009-07-17 16:00:20 +02:00
Harald Hoyer
47e1402108 nfs: do not install whole passwd, grep for rpc user 2009-07-17 16:00:20 +02:00
Harald Hoyer
1336db4f1c lvm: output info on rd_NO_LVM 2009-07-17 16:00:20 +02:00
Harald Hoyer
6c1d16ad29 lvm: install lvm.conf in hostonly mode 2009-07-17 16:00:19 +02:00
Harald Hoyer
0de01de409 mdraid: do not handle isw_raid_member if rd_NO_MDIMSM is set in udev ENV
install md-noimsm.sh if mdadm does not support imsm.
2009-07-17 16:00:19 +02:00
Harald Hoyer
499befa692 mdraid: only install mdadm.conf in hostonly mode 2009-07-17 16:00:19 +02:00
Harald Hoyer
435185d7ab mdraid: do not install passwd/group 2009-07-17 16:00:19 +02:00
Harald Hoyer
e0fd2e2f74 dmraid: handle isw_raid_member if rd_NO_MDIMSM is set in udev ENV 2009-07-17 16:00:19 +02:00
Harald Hoyer
024cd021d4 dmraid: redirect error to vinfo 2009-07-17 16:00:19 +02:00
Harald Hoyer
87194701de output info on rd_NO_DM 2009-07-17 16:00:19 +02:00
Harald Hoyer
4578763326 crypt: output info, on rd_NO_LUKS handling 2009-07-17 16:00:19 +02:00
Harald Hoyer
7c00784e5c plymouth: install all themes and make them selectable by command line
Bootsplash - plymouth
       rd_plytheme=<theme name>
              specify the plymouth bootsplash theme (fallback is text)
2009-07-17 16:00:09 +02:00
Harald Hoyer
53e1c5b996 init: add "pre-trigger" and "initqueue" breakpoints 2009-07-17 14:47:49 +02:00
Harald Hoyer
835d568916 plymouth: removed console_init call
/lib/udev/console_init should be called from the udev rules already
2009-07-17 10:17:28 +02:00
Harald Hoyer
4f945a3932 dmraid.sh: activate all dmraids, if no rd_DM_UUID is specified 2009-07-17 10:16:46 +02:00
Harald Hoyer
20cfd14f41 dmraid.rules: cleanup 2009-07-17 10:16:16 +02:00
Harald Hoyer
376cfd1c27 lvm_scan: do not overwrite a preexisting /etc/lvm/lvm.conf 2009-07-17 10:13:33 +02:00
Harald Hoyer
c0dc4c5d1e dracut-lib: fixed quiet argument parsing 2009-07-17 10:13:01 +02:00
Harald Hoyer
532d7d9be4 dracut-lib: output warn() and die() to stderr 2009-07-17 10:12:52 +02:00
Warren Togami
beb097d9f1 Bridged network boot
* SYNTAX
bridge=<bridgename>:<ethname>
If bridge without parameters, assume bridge=br0:eth0
* When <ethname> would be configured by network scripts, instead create a bridge named <bridgename> then add <ethname> to that bridge.
* Then $netif becomes <bridgename> instead of <ethname> and all existing scripts process netroot mount via this new $netif instead of <ethname>.
* Include a few test cases in NFS and NBD
2009-07-16 16:58:19 -04:00
Warren Togami
44f1ab8285 Remove 63-luks.rules, it is no longer used 2009-07-16 09:34:07 -04:00
Warren Togami
81f83dab0a More informative failure messages or rdbreak. 2009-07-15 21:10:16 -04:00
Warren Togami
c3cd4c76d7 Standardize boot failed language. 2009-07-15 16:42:34 -04:00
Harald Hoyer
1702e6c660 dracut-lib: if "quiet" is specified, do not print info() to console 2009-07-15 18:40:56 +02:00
Harald Hoyer
e6df817525 install all /lib/kbd to initramfs, if not host only
KEYBOARDTYPE=sun|pc
   will be written to /etc/sysconfig/keyboard in the initramfs

KEYTABLE=<keytable file>
   will be written to /etc/sysconfig/keyboard in the initramfs

SYSFONT= Console font
   will be written to /etc/sysconfig/i18n in the initramfs

SYSFONTACM= Console map.
   will be written to /etc/sysconfig/i18n in the initramfs

UNIMAP= Unicode font map.
   will be written to /etc/sysconfig/i18n in the initramfs

LANG=<locale>
   will be written to /etc/sysconfig/i18n in the initramfs
   LANG= set locale for all categories, can be any two letter ISO
   language code
2009-07-15 18:37:44 +02:00
Harald Hoyer
f4da80735a Makefile: add debug module to the testimage target 2009-07-15 18:27:21 +02:00
Harald Hoyer
d34a6d07c1 extend TEST-12-RAID-DEG to check for UUID command line parameters 2009-07-15 18:27:21 +02:00
Harald Hoyer
f874872fc2 add command line parameters to specify exact actions for root assembly
LVM
       rd_NO_LVM
              disable LVM detection

       rd_LVM_VG=<volume group name>
              only activate the volume groups with the given name

crypto LUKS
       rd_NO_LUKS
              disable crypto LUKS detection

       rd_LUKS_UUID=<luks uuid>
              only activate the LUKS partitions with the given UUID

MD
       rd_NO_MD
              disable MD RAID detection

       rd_MD_UUID=<md uuid>
              only activate the raid sets with the given UUID

DMRAID
       rd_NO_DM
              disable DM RAID detection

       rd_DM_UUID=<dmraid uuid>
              only activate the raid sets with the given UUID
2009-07-15 18:27:21 +02:00
Hans de Goede
2240d47fe5 Fix lvm on top of dmraid
The lvm rules were failing to identify PV's on mdraid because
blkid/vol_id has not been run on md raidsets by previous rules.
2009-07-15 18:27:21 +02:00
Harald Hoyer
449adc611f add info() and vinfo() to dracut-lib
- corrected the loglevel for warn()
- prepended with "dracut: " for kmesg to seperate from kernel messages

you can pipe to vinfo() for informational messages
2009-07-15 18:27:21 +02:00
Harald Hoyer
584e55654c remove partitions from raid devices before they are used for something
else
2009-07-15 18:27:20 +02:00
Harald Hoyer
1adaf3372c limit the devices for which lvm vgscan will scan
Build the filter list and create /etc/lvm/lvm.conf for all LVM_member
devices found by udev.
2009-07-15 18:27:20 +02:00
Harald Hoyer
52c3715fd4 change the way init arguments are stripped from the command line
$initrdargs now holds all command line options we want to strip from the
command line. Command line parsers can extend this space separated list.
2009-07-15 18:27:20 +02:00
Harald Hoyer
dd1f72b3dd dmraid.rules changed comment in header 2009-07-15 18:27:20 +02:00
Hans de Goede
3564cb7c2c Make Intel BIOS raid use mdraid instead of dmraid when mdadm 3.0 is available
Intel BIOS raid is being shifted from dmraid to mdraid because mdraid offers
more features. So if an imsm metadata capable mdadm is present use mdraid
instead of dmraid for isw_raid_member's

This patch also adds code to mdraid_start.sh so that the raidsets
inside the imsm containers get started once udev is done probing
(doing this earlier leads to potentially degraded use of the sets and
 an unwanted resync).
2009-07-15 18:27:20 +02:00
Hans de Goede
3d2a316013 10redhat-i18n: Fix handling of kbd maps which are a symlink
Some keyboard maps are symlinks to others, we were not handling this
properly, this patch fixes this.
2009-07-15 18:27:20 +02:00
Harald Hoyer
da1c03c8a0 dracut-lib add getargs()
getargs returns a space seperated list with all values found for a key
on the kernel command line
2009-07-15 18:27:20 +02:00
Daniel Drake
f47478b336 switch_root: add subroot support
The current switch_root can only switch to a new root that is the root
of a mount point.

This patch adds support for "subroots", where the new root is somewhere
below a mount point. It does this by adding in a few extra steps to
chroot into the subroot after the enclosing partition has been moved
and entered.

This will be used by OLPC, who sort-of have 2 copies of Fedora stored
on a single partition under different directory trees, where the
initramfs decides which one to boot into.
2009-07-14 13:53:44 +02:00
Harald Hoyer
6281504d33 add testsuite for degraded RAID-5 array 2009-07-14 13:44:38 +02:00
Harald Hoyer
4a4c88236b modified test description for TEST-10-RAID 2009-07-14 13:44:07 +02:00
Harald Hoyer
3e26772cde run /bin/sh with the full path from the udev rules 2009-07-14 13:20:34 +02:00
Harald Hoyer
b2543662a1 add the final mdraid_start to the "blkid" rules also 2009-07-14 13:17:07 +02:00
Harald Hoyer
3076b67917 run a final "mdadm -IRs" after udev has settled 2009-07-13 18:19:32 +02:00
Harald Hoyer
21e033f8ef prevent LVM scan loops
lvm vgscan causes "change" events for all devices, to prevent a loop,
remember the devices, which trigger the scan of the devices.
2009-07-13 18:19:09 +02:00
Harald Hoyer
4fafddf78f add test for simple root on LVM 2009-07-13 16:41:05 +02:00
Harald Hoyer
c81a97d1a7 install "ln" per default 2009-07-13 16:24:41 +02:00
Harald Hoyer
9a139a430a let softlink to dmraid initqueue scan end with ".sh" 2009-07-13 16:24:41 +02:00
Harald Hoyer
e3b4125e83 delay lvm scan, until udev has settled 2009-07-13 16:24:41 +02:00
Harald Hoyer
aceddbe8a4 do not pass rdshell option to real init 2009-07-13 16:24:41 +02:00
Harald Hoyer
4286a25041 do not force to run the mdraid array for the incremental add 2009-07-13 16:24:41 +02:00
Harald Hoyer
00c5ab3e33 only install mount script, if nbd-client succeeded 2009-07-13 16:24:35 +02:00
Harald Hoyer
c094baa0fb install mount script if iscsistart succeeded and add iscsi udev rule 2009-07-13 15:03:11 +02:00
Harald Hoyer
1c709728ec removed warning "No ip= argument(s) for netroot provided..." 2009-07-13 15:03:11 +02:00
Harald Hoyer
2a652c0b95 add environment variables for different udev versions 2009-07-13 15:03:11 +02:00
Harald Hoyer
89056045f5 check for root after udevadm settle returns 2009-07-13 15:03:11 +02:00
Harald Hoyer
6aca2e0366 add kernel-modules module to iscsi server 2009-07-13 15:03:11 +02:00
Harald Hoyer
07253f00ca add documentation of the init hooks 2009-07-13 15:03:11 +02:00
Harald Hoyer
04f816de49 fixed LVM udev rules to run not only for dm-* devices 2009-07-13 15:03:10 +02:00
Harald Hoyer
14940c2a5c fixed typo in mdadm udev rule 2009-07-13 15:03:10 +02:00
Harald Hoyer
4d06c74ea6 only install one dmraid scan job once in the initqueue 2009-07-13 12:10:47 +02:00
Harald Hoyer
d72eec354a test for empty udev queue with timeout=1 instead of 0
older udev versions do not support timeout=0
2009-07-13 12:10:47 +02:00
Harald Hoyer
e60123c2ed removed bash check from md incremental rules 2009-07-13 12:10:46 +02:00
Warren Togami
19c258b689 NFSv4 rpcbind should need only the rpcbind user, not the entire /etc/passwd.
TODO: /etc/passwd and /etc/group are not removed yet due to 90mdraid.
      dledford said he'll go in and clean this up since he has the hardware
      to actually test the mdmon stuff.
2009-07-09 14:33:33 -04:00
Warren Togami
dacba77805 rdbreak should imply rdshell. If sleeping forever say so, so the user doesn't wonder. 2009-07-08 13:51:43 -04:00
Harald Hoyer
616f1557b1 version 0.4 2009-07-04 10:05:38 +02:00
Harald Hoyer
a75c29be45 remove redirection of output to /dev/kmesg
until we have a way to mark our messages to come from dracut.
2009-07-04 09:57:10 +02:00
Harald Hoyer
a3a3448d8c rdshell 2009-07-03 18:28:09 +02:00
Harald Hoyer
58dbb43eac initqueue now loops until /dev/root exists or root is mounted
init now has the following points to inject scripts:

/cmdline/*.sh
   scripts for command line parsing

/pre-udev/*.sh
   scripts to run before udev is started

/pre-trigger/*.sh
   scripts to run before the main udev trigger is pulled

/initqueue/*.sh
   runs in parallel to the udev trigger
   Udev events can add scripts here with /sbin/initqueue.
   If /sbin/initqueue is called with the "--onetime" option, the script
   will be removed after it was run.
   If /initqueue/work is created and udev >= 143 then this loop can
   process the jobs in parallel to the udevtrigger.
   If the udev queue is empty and no root device is found or no root
   filesystem was mounted, the user will be dropped to a shell after
   a timeout.
   Scripts can remove themselves from the initqueue by "rm $job".

/pre-mount/*.sh
   scripts to run before the root filesystem is mounted
   NFS is an exception, because it has no device node to be created
   and mounts in the udev events

/mount/*.sh
   scripts to mount the root filesystem
   NFS is an exception, because it has no device node to be created
   and mounts in the udev events
   If the udev queue is empty and no root device is found or no root
   filesystem was mounted, the user will be dropped to a shell after
   a timeout.

/pre-pivot/*.sh
   scripts to run before the real init is executed and the initramfs
   disappears
   All processes started before should be killed here.

The behaviour of the dmraid module demonstrates how to use the new
mechanism. If it detects a device which is part of a raidmember from a
udev rule, it installs a job to scan for dmraid devices, if the udev
queue is empty. After a scan, it removes itsself from the queue.
2009-07-03 18:11:38 +02:00
Harald Hoyer
5b2db7d177 put back the nfs mount in the udev event
it solves the following case:

root=/dev/nfs nfsroot=server:/path

- the server could be reachable on any interface
- any interface can get an IP by dhcp
- only one IP is allowed to mount the root
2009-07-03 14:56:20 +02:00
Harald Hoyer
aa254c5596 fail iscsiroot, if iscsistart fails 2009-07-03 14:47:49 +02:00
Harald Hoyer
da04062e72 add rm to be installed for initqueue 2009-07-03 13:27:26 +02:00
Harald Hoyer
3b51f4f30b add firmware packages to be required by the dracut-generic package 2009-07-03 13:17:08 +02:00
Harald Hoyer
5cc26464e0 remove 50plymouth-pre0.7 module 2009-07-03 12:44:45 +02:00
Harald Hoyer
9719024132 Defer mount to the real mount loop
Udev rules set a /dev/root symlink to the real root and add
a mount script to /mount/. This enables the proper use of pre-mount
scripts and prevents mount being killed by a udev timeout.
2009-07-03 12:38:43 +02:00
Harald Hoyer
83701d66f6 output everything to /dev/kmesg and add dmesg for the emergency_shell 2009-07-03 12:34:51 +02:00
Harald Hoyer
f601799e94 add binutiles requirement to specfile (because of nm) 2009-07-03 12:06:16 +02:00
Harald Hoyer
e2dbd86f09 add kernel-modules module to testsuite images 2009-07-03 12:06:11 +02:00
Daniel Drake
1b9cae5cb2 Remove modules dependency
This makes it possible to build a dracut initramfs without modules,
where all needed kernel drivers are built into the kernel image.
2009-07-02 17:18:09 +02:00
Daniel Drake
259e58a904 Add firmware loading support 2009-07-02 17:13:07 +02:00
Seewer Philippe
a55711cd86 Don't use absolute paths for utilities 2009-07-02 17:13:06 +02:00
Harald Hoyer
a8e47195dd do not add debug module by default 2009-07-02 14:50:46 +02:00
Harald Hoyer
624b52c440 fixed adding modules via -a 2009-07-02 14:50:22 +02:00
Harald Hoyer
4f4454b61f add "--add" option to the manpage 2009-07-02 13:14:57 +02:00
94 changed files with 2122 additions and 391 deletions

View File

@@ -1,4 +1,4 @@
VERSION=0.3
VERSION=0.6
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
prefix = /usr
@@ -22,6 +22,7 @@ install:
mkdir -p $(DESTDIR)$(pkglibdir)/modules.d
mkdir -p $(DESTDIR)$(mandir)/man8
install -m 0755 dracut $(DESTDIR)$(sbindir)/dracut
install -m 0755 dracut-gencmdline $(DESTDIR)$(sbindir)/dracut-gencmdline
install -m 0755 modules.d/99base/switch_root $(DESTDIR)$(sbindir)/switch_root
install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf
install -m 0755 dracut-functions $(DESTDIR)$(pkglibdir)/dracut-functions
@@ -33,6 +34,7 @@ clean:
rm -f *~
rm -f modules.d/99base/switch_root
rm -f test-*.img
rm -f dracut-*.rpm dracut-*.tar.bz2
make -C test clean
archive: dracut-$(VERSION)-$(GITVERSION).tar.bz2
@@ -46,7 +48,7 @@ dracut-$(VERSION)-$(GITVERSION).tar.bz2:
git archive --format=tar HEAD --prefix=dracut-$(VERSION)-$(GITVERSION)/ |bzip2 > dracut-$(VERSION)-$(GITVERSION).tar.bz2
rpm: dracut-$(VERSION).tar.bz2
rpm: clean dracut-$(VERSION).tar.bz2
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" -ba dracut.spec
rm -fr BUILD BUILDROOT
@@ -61,5 +63,14 @@ check: all
make -C test check
testimage: all
./dracut -l -f test-$(shell uname -r).img $(shell uname -r)
./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

6
README.kernel Normal file
View File

@@ -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.

View File

@@ -49,4 +49,48 @@ check: Dracut calls this program to check and see if a module can be installed
Any other files in the module will not be touched by dracut directly.
You are encouraged to provide a README that descrobes what the module is for.
You are encouraged to provide a README that describes what the module is for.
HOOKS
=====
init has the following hook points to inject scripts:
/cmdline/*.sh
scripts for command line parsing
/pre-udev/*.sh
scripts to run before udev is started
/pre-trigger/*.sh
scripts to run before the main udev trigger is pulled
/initqueue/*.sh
runs in parallel to the udev trigger
Udev events can add scripts here with /sbin/initqueue.
If /sbin/initqueue is called with the "--onetime" option, the script
will be removed after it was run.
If /initqueue/work is created and udev >= 143 then this loop can
process the jobs in parallel to the udevtrigger.
If the udev queue is empty and no root device is found or no root
filesystem was mounted, the user will be dropped to a shell after
a timeout.
Scripts can remove themselves from the initqueue by "rm $job".
/pre-mount/*.sh
scripts to run before the root filesystem is mounted
Network filesystems like NFS that do not use device files are an
exception. Root can be mounted already at this point.
/mount/*.sh
scripts to mount the root filesystem
If the udev queue is empty and no root device is found or no root
filesystem was mounted, the user will be dropped to a shell after
a timeout.
/pre-pivot/*.sh
scripts to run before the real init is executed and the initramfs
disappears
All processes started before should be killed here.

48
dracut
View File

@@ -22,6 +22,11 @@ Creates initial ramdisk images for preloading modules
-a, --add [LIST] Add a space-separated list of dracut 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 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
@@ -48,6 +53,10 @@ while (($# > 0)); do
-o|--omit) omit_dracutmodules_l="$2"; shift;;
-a|--add) add_dracutmodules_l="$2"; shift;;
-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";;
@@ -61,6 +70,8 @@ while (($# > 0)); do
shift
done
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
[[ $debug ]] && {
export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
set -x
@@ -77,7 +88,10 @@ done
[[ $omit_dracutmodules_l ]] && omit_dracutmodules=$omit_dracutmodules_l
[[ $add_dracutmodules_l ]] && add_dracutmodules="$add_dracutmodules $add_dracutmodules_l"
[[ $drivers_l ]] && drivers=$drivers_l
[[ $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
@@ -100,6 +114,10 @@ esac
[[ $2 ]] && kernel=$2 || kernel=$(uname -r)
[[ $1 ]] && outfile=$(readlink -f $1) || outfile="/boot/initrd-$kernel.img"
srcmods="/lib/modules/$kernel/"
[ -n "$drivers_dir" ] && srcmods="$drivers_dir"
export srcmods
if [[ -f $outfile && ! $force ]]; then
echo "Will not override existing initramfs ($outfile) without --force"
exit 1
@@ -113,12 +131,15 @@ trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.
# Need to be able to have non-root users read stuff (rpcbind etc)
chmod 755 "$initdir"
export initdir hookdirs dsrc dracutmodules drivers debug beverbose
export initdir hookdirs dsrc dracutmodules drivers \
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.
@@ -128,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
@@ -138,9 +166,11 @@ echo $mods_to_load
## final stuff that has to happen
# generate module dependencies for the initrd
if ! /sbin/depmod -a -b "$initdir" $kernel; then
echo "\"/sbin/depmod -a $kernel\" failed."
exit 1
if [ -d "$initdir/lib/modules/$kernel" ]; then
if ! depmod -a -b "$initdir" $kernel; then
echo "\"depmod -a $kernel\" failed."
exit 1
fi
fi
# make sure that library links are correct and up to date

View File

@@ -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
@@ -257,7 +257,7 @@ check_modules() {
[[ $dracutmodules != all ]] && ! strstr "$dracutmodules" "$mod" && \
continue
strstr "$omit_dracutmodules" "$mod" && continue
if ! strstr "$add_dracutmodules" " $mod "; then
if ! strstr "$add_dracutmodules" "$mod"; then
should_source_module "$moddir" || continue
fi
mods_to_load+=" $mod "
@@ -266,8 +266,8 @@ check_modules() {
# install kernel modules, and handle installing all their dependencies as well.
instmods() {
[[ "$no_kernel" = "yes" ]] && return
local mod mpargs modpath modname cmd
local srcmods="/lib/modules/$kernel/"
while (($# > 0)); do
mod=${1%.ko}
case $mod in
@@ -295,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
@@ -305,14 +305,20 @@ instmods() {
dinfo "Installing dependencies for $mod ($modpath)"
instmods $mpargs $modname
fi
inst_simple "$modpath"
done
for fw in $(/sbin/modinfo -F firmware $mod 2>/dev/null); do
if [[ -f /lib/firmware/$fw ]]; then
inst_simple "/lib/firmware/$fw"
else
dwarning "Possible missing firmware /lib/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

700
dracut-gencmdline Executable file
View File

@@ -0,0 +1,700 @@
#!/bin/bash --norc
#
#
# Copyright 2005-2008 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# code taken from mkinitrd
#
#. /usr/libexec/initrd-functions
function error() {
local NONL=""
if [ "$1" == "-n" ]; then
NONL="-n"
shift
fi
echo $NONL "$@" >&2
}
function vecho() {
return
local NONL=""
if [ "$1" == "-n" ]; then
NONL="-n"
shift
fi
is_verbose && echo $NONL "$@"
}
# module dep finding and installation functions
moduledep() {
MPARGS=""
if [ "$1" == "--ignore-install" ]; then
MPARGS="$MPARGS --ignore-install"
shift
fi
vecho -n "Looking for deps of module $1"
deps=""
deps=$(modprobe $MPARGS --set-version $kernel --show-depends $1 2>/dev/null| awk '/^insmod / { print gensub(".*/","","g",$2) }' | while read foo ; do [ "${foo%%.ko}" != "$1" ] && echo -n "${foo%%.ko} " ; done)
[ -n "$deps" ] && vecho ": $deps" || vecho
}
if [ $UID != 0 ]; then
error "$0 must be run as root."
exit 1
fi
export MALLOC_PERTURB_=204
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
export PATH
. /etc/rc.d/init.d/functions
# Set the umask. For iscsi, the initrd can contain plaintext
# password (chap secret), so only allow read by owner.
umask 077
VERSION=6.0.87
PROBE="yes"
MODULES=""
GRAPHICSMODS=""
PREMODS=""
DMRAIDS=""
ncryptodevs=0
ncryptoparts=0
ncryptolvs=0
ncryptoraids=0
root=""
scsi_wait_scan="no"
NET_LIST=""
LD_SO_CONF=/etc/ld.so.conf
LD_SO_CONF_D=/etc/ld.so.conf.d/
[ -e /etc/sysconfig/mkinitrd ] && . /etc/sysconfig/mkinitrd
CONFMODS="$MODULES"
MODULES=""
ARCH=$(uname -m | sed -e 's/s390x/s390/')
compress=1
allowmissing=""
target=""
kernel=""
force=""
img_vers=""
builtins=""
modulefile=/etc/modules.conf
[ "$ARCH" != "s390" ] && withusb=1
rc=0
nolvm=""
nodmraid=""
IMAGESIZE=8000
PRESCSIMODS=""
fstab="/etc/fstab"
vg_list=""
net_list="$NET_LIST"
usage () {
if [ "$1" == "-n" ]; then
cmd=echo
else
cmd=error
fi
$cmd "usage: `basename $0` [--version] [--help] [-v] [-f]"
if [ "$1" == "-n" ]; then
exit 0
else
exit 1
fi
}
qpushd() {
pushd "$1" >/dev/null 2>&1
}
qpopd() {
popd >/dev/null 2>&1
}
resolve_device_name() {
echo "$1"
# echo "resolve_device_name $1" 1>&2
}
freadlink() {
/usr/bin/readlink -f "$1"
}
finddevnoinsys() {
majmin="$1"
if [ -n "$majmin" ]; then
dev=$(for x in /sys/block/* ; do find $x/ -name dev ; done | while read device ; do \
echo "$majmin" | cmp -s $device && echo $device ; done)
if [ -n "$dev" ]; then
dev=${dev%%/dev}
dev=${dev%%/}
echo "$dev"
return 0
fi
fi
return 1
}
finddevicedriverinsys () {
if is_iscsi $PWD; then
handleiscsi "$PWD"
return
fi
while [ "$PWD" != "/sys/devices" ]; do
deps=
if [ -f modalias ]; then
MODALIAS=$(cat modalias)
if [ "${MODALIAS::7}" == "scsi:t-" ]; then
scsi_wait_scan=yes
fi
moduledep $MODALIAS
unset MODALIAS
fi
cd ..
done
}
findstoragedriverinsys () {
local sysfs=$(freadlink "$1")
# if its a partition look at the device holding the partition
if [ -f "$sysfs/start" ]; then
sysfs=$(freadlink ${sysfs%/*})
fi
if [[ ! "$sysfs" =~ '^/sys/.*block/.*$' ]]; then
#error "WARNING: $sysfs is a not a block sysfs path, skipping"
return
fi
case " $handleddevices " in
*" $sysfs "*)
return ;;
*) handleddevices="$handleddevices $sysfs" ;;
esac
if [[ "$sysfs" =~ '^/sys/.*block/md[0-9]+$' ]]; then
local raid=${sysfs##*/}
vecho "Found MDRAID component $raid"
handleraid $raid
fi
if [[ "$sysfs" =~ '^/sys/.*block/dm-[0-9]+$' ]]; then
vecho "Found DeviceMapper component ${sysfs##*/}"
handledm $(cat $sysfs/dev |cut -d : -f 1) $(cat $sysfs/dev |cut -d : -f 2)
fi
for slave in $(ls -d "$sysfs"/slaves/* 2>/dev/null) ; do
findstoragedriverinsys "$slave"
done
if [ -L "$sysfs/device" ]; then
qpushd $(freadlink "$sysfs/device")
finddevicedriverinsys
qpopd
fi
}
findstoragedriver () {
local device="$1"
if [ ! -b "$device" ]; then
#error "WARNING: $device is a not a block device, skipping"
return
fi
local majmin=$(get_numeric_dev dec "$device")
local sysfs=$(finddevnoinsys "$majmin")
if [ -z "$sysfs" ]; then
#error "WARNING: $device major:minor $majmin not found, skipping"
return
fi
vecho "Looking for driver for $device in $sysfs"
findstoragedriverinsys "$sysfs"
}
iscsi_get_rec_val() {
# The open-iscsi 742 release changed to using flat files in
# /var/lib/iscsi.
result=$(grep "^${2} = " "$1" | sed -e s'/.* = //')
}
iscsi_set_parameters() {
path=$1
vecho setting iscsi parameters
tmpfile=$(mktemp)
# Check once before getting explicit values, so we can output a decent
# error message.
/sbin/iscsiadm --show -m session -r $path > $tmpfile
if [ ! -s $tmpfile ]; then
echo Unable to find iscsi record for $path
exit 1
fi
nit_name=$(grep "^InitiatorName=" /etc/iscsi/initiatorname.iscsi | \
sed -e "s/^InitiatorName=//")
iscsi_get_rec_val $tmpfile "node.name"
tgt_name=${result}
iscsi_get_rec_val $tmpfile "node.tpgt"
tpgt=${result}
# iscsistart wants node.conn[0].address / port
iscsi_get_rec_val $tmpfile 'node.conn\[0\].address'
tgt_ipaddr=${result}
iscsi_get_rec_val $tmpfile 'node.conn\[0\].port'
tgt_port=${result}
# Note: we get chap secrets (passwords) in plaintext, and also store
# them in the initrd.
iscsi_get_rec_val $tmpfile "node.session.auth.username"
chap=${result}
if [ -n "${chap}" -a "${chap}" != "<empty>" ]; then
chap="-u ${chap}"
iscsi_get_rec_val $tmpfile "node.session.auth.password"
chap_pw="-w ${result}"
else
chap=""
fi
iscsi_get_rec_val $tmpfile "node.session.auth.username_in"
chap_in=${result}
if [ -n "${chap_in}" -a "${chap_in}" != "<empty>" ]; then
chap_in="-U ${chap_in}"
iscsi_get_rec_val $tmpfile "node.session.auth.password_in"
chap_in_pw="-W ${result}"
else
chap_in=""
fi
rm $tmpfile
}
emit_iscsi () {
if [ -n "${iscsi_devs}" ]; then
for dev in ${iscsi_devs}; do
iscsi_set_parameters $dev
# recid is not really used, just use 0 for it
echo "/bin/iscsistart -t ${tgt_name} -i ${nit_name} \
-g ${tpgt} -a ${tgt_ipaddr} ${chap} ${chap_pw} \
${chap_in} ${chap_in_pw}"
done
fi
}
is_iscsi() {
path=$1
if echo $path | grep -q "/platform/host[0-9]*/session[0-9]*/target[0-9]*:[0-9]*:[0-9]*/[0-9]*:[0-9]*:[0-9]*:[0-9]*"; then
return 0
else
return 1
fi
}
handledm() {
major=$1
minor=$2
while read dmstart dmend dmtype r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 ; do
case "$dmtype" in
crypt)
# this device is encrypted; find the slave device and see
# whether the encryption is LUKS; if not, bail.
slavedev=$(finddevnoinsys $r3)
# get the basename, then s,!,/, in case it's a cciss device
slavedev=$(echo ${slavedev##*/} | tr '!' '/')
cryptsetup isLuks "/dev/$slavedev" 2>/dev/null || continue
find_base_dm_mods
dmname=$(dmsetup info -j $major -m $minor -c --noheadings -o name)
# do the device resolution dance to get /dev/mapper/foo
# since 'lvm lvs' doesn't like dm-X device nodes
if [[ "$slavedev" =~ ^dm- ]]; then
majmin=$(get_numeric_dev dec "/dev/$slavedev")
for dmdev in /dev/mapper/* ; do
dmnum=$(get_numeric_dev dev $dmdev)
if [ $dmnum = $majmin ]; then
slavedev=${dmdev#/dev/}
break
fi
done
fi
# determine if $slavedev is an LV
# if so, add the device to latecryptodevs
# if not, add the device to cryptodevs
local vg=$(lvshow /dev/$slavedev)
if [ -n "$vg" ]; then
eval cryptolv${ncryptolvs}='"'/dev/$slavedev $dmname'"'
let ncryptolvs++
elif grep -q "^$slavedev :" /proc/mdstat ; then
eval cryptoraid${ncryptoraids}='"'/dev/$slavedev $dmname'"'
let ncryptoraids++
else
eval cryptoparts${ncryptoparts}='"'/dev/$slavedev $dmname'"'
let ncryptoparts++
fi
let ncryptodevs++
findstoragedriver "/dev/$slavedev"
;;
esac
done << EOF
$(dmsetup table -j $major -m $minor 2>/dev/null)
EOF
local name=$(dmsetup info --noheadings -c -j $major -m $minor -o name)
local vg=$(lvshow "/dev/mapper/$name")
local raids=$(/sbin/dmraid -s -craidname 2>/dev/null | grep -vi "no raid disks")
if [ -n "$vg" ]; then
vg=`echo $vg` # strip whitespace
case " $vg_list " in
*" $vg "*) ;;
*) vg_list="$vg_list $vg"
[ -z "$nolvm" ] && find_base_dm_mods
;;
esac
fi
for raid in $raids ; do
if [ "$raid" == "$name" ]; then
case " $DMRAIDS " in
*" $raid "*) ;;
*) DMRAIDS="$DMRAIDS $raid"
[ -z "$nodmraid" ] && find_base_dm_mods
;;
esac
break
fi
done
}
handleiscsi() {
vecho "Found iscsi component $1"
# We call iscsi_set_parameters once here to figure out what network to
# use (it sets tgt_ipaddr), and once again to emit iscsi values,
# not very efficient.
iscsi_set_parameters $1
iscsi_devs="$iscsi_devs $1"
netdev=$(/sbin/ip route get to $tgt_ipaddr | \
sed 's|.*dev \(.*\).*|\1|g' | awk '{ print $1; exit }')
addnetdev $netdev
}
handleraid() {
local start=0
if [ -n "$noraid" -o ! -f /proc/mdstat ]; then
return 0
fi
levels=$(awk "/^$1[ ]*:/ { print\$4 }" /proc/mdstat)
for level in $levels ; do
case $level in
linear)
start=1
;;
multipath)
start=1
;;
raid[01] | raid10)
start=1
;;
raid[456])
start=1
;;
*)
error "raid level $level (in /proc/mdstat) not recognized"
;;
esac
done
if [ "$start" = 1 ]; then
raiddevices="$raiddevices $1"
fi
return $start
}
lvshow() {
lvm lvs --ignorelockingfailure --noheadings -o vg_name \
$1 2>/dev/null | egrep -v '^ *(WARNING:|Volume Groups with)'
}
vgdisplay() {
lvm vgdisplay --ignorelockingfailure -v $1 2>/dev/null |
sed -n 's/PV Name//p'
}
dmmods_found="n"
find_base_dm_mods()
{
[ "$dmmods_found" == "n" ] || return
dmmods_found="y"
}
savedargs=$*
while [ $# -gt 0 ]; do
case $1 in
--fstab*)
if [ "$1" != "${1##--fstab=}" ]; then
fstab=${1##--fstab=}
else
fstab=$2
shift
fi
;;
-v|--verbose)
set_verbose true
;;
--net-dev*)
if [ "$1" != "${1##--net-dev=}" ]; then
net_list="$net_list ${1##--net-dev=}"
else
net_list="$net_list $2"
shift
fi
;;
--rootdev*)
if [ "$1" != "${1##--rootdev=}" ]; then
rootdev="${1##--rootdev=}"
else
rootdev="$2"
shift
fi
;;
--thawdev*)
if [ "$1" != "${1##--thawdev=}" ]; then
thawdev="${1##--thawdev=}"
else
thawdev="$2"
shift
fi
;;
--rootfs*)
if [ "$1" != "${1##--rootfs=}" ]; then
rootfs="${1##--rootfs=}"
else
rootfs="$2"
shift
fi
;;
--rootopts*)
if [ "$1" != "${1##--rootopts=}" ]; then
rootopts="${1##--rootopts=}"
else
rootopts="$2"
shift
fi
;;
--root*)
if [ "$1" != "${1##--root=}" ]; then
root="${1##--root=}"
else
root="$2"
shift
fi
;;
--loopdev*)
if [ "$1" != "${1##--loopdev=}" ]; then
loopdev="${1##--loopdev=}"
else
loopdev="$2"
shift
fi
;;
--loopfs*)
if [ "$1" != "${1##--loopfs=}" ]; then
loopfs="${1##--loopfs=}"
else
loopfs="$2"
shift
fi
;;
--loopopts*)
if [ "$1" != "${1##--loopopts=}" ]; then
loopopts="${1##--loopopts=}"
else
loopopts="$2"
shift
fi
;;
--looppath*)
if [ "$1" != "${1##--looppath=}" ]; then
looppath="${1##--looppath=}"
else
looppath="$2"
shift
fi
;;
--help)
usage -n
;;
*)
if [ -z "$target" ]; then
target=$1
elif [ -z "$kernel" ]; then
kernel=$1
else
usage
fi
;;
esac
shift
done
[ -z "$rootfs" ] && rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' $fstab)
[ -z "$rootopts" ] && rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' $fstab)
[ -z "$rootopts" ] && rootopts="defaults"
[ -z "$rootdev" ] && rootdev=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' $fstab)
# check if it's nfsroot
physdev=""
if [ "$rootfs" == "nfs" ]; then
if [ "x$net_list" == "x" ]; then
handlenfs $rootdev
fi
else
# check if it's root by label
rdev=$rootdev
if [[ "$rdev" =~ ^(UUID=|LABEL=) ]]; then
rdev=$(resolve_device_name "$rdev")
fi
rootopts=$(echo $rootopts | sed -e 's/^r[ow],//' -e 's/,_netdev//' -e 's/_netdev//' -e 's/,r[ow],$//' -e 's/,r[ow],/,/' -e 's/^r[ow]$/defaults/' -e 's/$/,ro/')
findstoragedriver "$rdev"
fi
# find the first swap dev which would get used for swsusp
[ -z "$thawdev" ] && thawdev=$(awk '/^[ \t]*[^#]/ { if ($3 == "swap") { print $1; exit }}' $fstab)
swsuspdev="$thawdev"
if [ -n "$swsuspdev" ]; then
if [[ "$swsuspdev" =~ ^(UUID=|LABEL=) ]]; then
swsuspdev=$(resolve_device_name "$swsuspdev")
fi
findstoragedriver "$swsuspdev"
fi
cemit()
{
cat
}
emit()
{
NONL=""
if [ "$1" == "-n" ]; then
NONL="-n"
shift
fi
echo $NONL "$@"
}
emitdmraids()
{
if [ -z "$nodmraid" -a -n "$DMRAIDS" ]; then
for raid in $DMRAIDS; do
echo -n "rd_DM_UUID=$raid "
done
fi
}
# HACK: module loading + device creation isn't necessarily synchronous...
# this will make sure that we have all of our devices before trying
# things like RAID or LVM
emitdmraids
emitcrypto()
{
local luksuuid=$(grep "^$2 " /etc/crypttab 2>/dev/null| awk '{ print $2 }')
if [ -z "$luksuuid" ]; then
luksuuid="$2"
fi
echo -n "rd_LUKS_UUID=$luksuuid "
}
for cryptdev in ${!cryptopart@} ; do
emitcrypto `eval echo '$'$cryptdev`
done
if [ -n "$raiddevices" ]; then
for dev in $raiddevices; do
echo -n "rd_MD_UUID=${dev} "
done
fi
for cryptdev in ${!cryptoraid@} ; do
emitcrypto `eval echo '$'$cryptdev`
done
if [ -z "$nolvm" -a -n "$vg_list" ]; then
for vg in $vg_list; do
echo -n "rd_LVM_VG=$vg "
done
fi
for cryptdev in ${!cryptolv@} ; do
emitcrypto `eval echo '$'$cryptdev`
done
# output local keyboard/18n settings
. /etc/sysconfig/keyboard
. /etc/sysconfig/i18n
for i in KEYTABLE SYSFONT SYSFONTACM UNIMAP LANG; do
val=$(eval echo \$$i)
[[ $val ]] && echo -n "$i=$val "
done
if [ -n "$KEYBOARDTYPE" -a "$KEYBOARDTYPE" != "pc" ]; then
echo -n "KEYBOARDTYPE=$KEYBOARDTYPE "
fi
if [ -n "$rootdev" ]; then
echo -n "root=$rootdev "
fi
if [ -L /usr/share/plymouth/themes/default.plymouth ]; then
theme=$(basename \
$(dirname \
$(readlink -f \
/usr/share/plymouth/themes/default.plymouth)))
[ -n "$theme" ] && echo -n "rd_plytheme=$theme "
fi
echo
# vim:ts=8:sw=4:sts=4:et

View File

@@ -24,9 +24,24 @@ Modules are located in
.BR \-o ", " \-\-omit " \fILIST\fR"
omit a space-separated list of dracut modules.
.TP
.BR \-a ", " \-\-add " \fILIST\fR"
add a space-separated list of dracut modules.
.TP
.BR \-d ", " \-\-drivers " \fILIST\fR"
specify a space-separated list of kernel modules to include in the initramfs.
.TP
.BR \-k ", " \-\-kmoddir " \fI[DIR]\fR
specify the directory, where to look for kernel modules
.TP
.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
@@ -75,6 +90,67 @@ root filesystem.
specify e.g. \fI/dev/sda1\fR or
\fI/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1\fR
.SH I18N
e.g. LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=de-latin1-nodeadkeys
.TP
.B KEYBOARDTYPE=sun|pc
will be written to /etc/sysconfig/keyboard in the initramfs
.TP
.B KEYTABLE=<keytable filename>
will be written to /etc/sysconfig/keyboard in the initramfs
.TP
.B SYSFONT= Console font
will be written to /etc/sysconfig/i18n in the initramfs
.TP
.B SYSFONTACM= Unicode font map
will be written to /etc/sysconfig/i18n in the initramfs
.TP
.B UNIMAP= Unicode font map
will be written to /etc/sysconfig/i18n in the initramfs
.TP
.B LANG=<locale>
will be written to /etc/sysconfig/i18n in the initramfs
.SH Bootsplash - plymouth
.TP
.B rd_plytheme=<theme name>
specify the plymouth bootsplash theme (fallback is text)
.SH LVM
.TP
.B rd_NO_LVM
disable LVM detection
.TP
.B rd_LVM_VG=<volume group name>
only activate the volume groups with the given name
.SH crypto LUKS
.TP
.B rd_NO_LUKS
disable crypto LUKS detection
.TP
.B rd_LUKS_UUID=<luks uuid>
only activate the LUKS partitions with the given UUID
.SH MD
.TP
.B rd_NO_MD
disable MD RAID detection
.TP
.B rd_NO_MDIMSM
no MD RAID for imsm/isw raids, use dmraid instead
.TP
.B rd_MD_UUID=<md uuid>
only activate the raid sets with the given UUID
.SH DMRAID
.TP
.B rd_NO_DM
disable DM RAID detection
.TP
.B rd_DM_UUID=<dmraid uuid>
only activate the raid sets with the given UUID
.SH DHCP
.TP
.B root=dhcp
@@ -164,6 +240,9 @@ do not load kernel module <drivername>
.SH Debug
.TP
.B rdshell
drop to a shell, if the imitramfs fails
.TP
.B rdinitdebug
set -x for the dracut shell
.TP

View File

@@ -11,9 +11,8 @@
%define rdist %{?dist}
%endif
Name: dracut
Version: 0.3
Version: 0.6
Release: 1%{?rdist}
Summary: Initramfs generator using udev
Group: System Environment/Base
@@ -27,6 +26,7 @@ Requires: module-init-tools
Requires: cpio
Requires: coreutils
Requires: findutils
Requires: binutils
Requires: grep
Requires: mktemp
Requires: mount
@@ -51,19 +51,32 @@ 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}
Requires: rpcbind nfs-utils
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
%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}
@@ -87,6 +100,7 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,0755)
%doc README HACKING TODO COPYING AUTHORS
/sbin/dracut
/sbin/dracut-gencmdline
%if 0%{?with_switch_root}
/sbin/switch_root
%endif
@@ -100,7 +114,20 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,0755)
%doc README.generic
%files kernel
%defattr(-,root,root,0755)
%doc README.kernel
%changelog
* Wed Jul 22 2009 Harald Hoyer harald@redhat.com 0.6-1
- version 0.6
* Fri Jul 17 2009 Harald Hoyer <harald@redhat.com> 0.5-1
- version 0.5
* Sat Jul 04 2009 Harald Hoyer <harald@redhat.com> 0.4-1
- version 0.4
* Thu Jul 02 2009 Harald Hoyer <harald@redhat.com> 0.3-1
- version 0.3

View File

@@ -1,4 +1,5 @@
#!/bin/bash
findkeymap () {
local MAP=$1
[[ ! -f $MAP ]] && \
@@ -18,46 +19,67 @@ findkeymap () {
done
}
install_local()
{
# FIXME: i18n stuff isn't really distro-independent :/
if [[ -f /etc/sysconfig/keyboard || -f /etc/sysconfig/console/default.kmap ]]; then
if [ -f /etc/sysconfig/console/default.kmap ]; then
KEYMAP=/etc/sysconfig/console/default.kmap
else
. /etc/sysconfig/keyboard
[[ $KEYTABLE && -d /lib/kbd/keymaps ]] && KEYMAP="$KEYTABLE.map"
fi
if [[ $KEYMAP ]]; then
[ -f /etc/sysconfig/keyboard ] && inst /etc/sysconfig/keyboard
inst loadkeys
findkeymap $KEYMAP
if [[ -f /etc/sysconfig/keyboard || -f /etc/sysconfig/console/default.kmap ]]; then
if [ -f /etc/sysconfig/console/default.kmap ]; then
KEYMAP=/etc/sysconfig/console/default.kmap
else
. /etc/sysconfig/keyboard
[[ $KEYTABLE && -d /lib/kbd/keymaps ]] && KEYMAP="$KEYTABLE.map"
fi
if [[ $KEYMAP ]]; then
[ -f /etc/sysconfig/keyboard ] && inst /etc/sysconfig/keyboard
inst loadkeys
findkeymap $KEYMAP
for FN in $KEYMAPS; do
inst $FN
for FN in $KEYMAPS; do
if [ -L $FN ]; then
TARGET=$(readlink -f $FN)
TG=$(echo $TARGET | sed -e 's/\.gz$//' -e 's/\.bz2$//')
LN=$(echo $FN | sed -e 's/\.gz$//' -e 's/\.bz2$//')
mkdir -p "$initdir/$(dirname $LN)"
ln -s "$TG" "$initdir/$LN"
FN=$TARGET
fi
inst $FN
case $FN in
*.gz) gzip -d "$initdir$FN" ;;
*.bz2) bzip2 -d "$initdir$FN" ;;
esac
done
fi
fi
if [ -f /etc/sysconfig/i18n ]; then
. /etc/sysconfig/i18n
inst /etc/sysconfig/i18n
[[ $SYSFONT ]] || SYSFONT=latarcyrheb-sun16
inst setfont
for FN in /lib/kbd/consolefonts/$SYSFONT.* ; do
inst "$FN"
case $FN in
*.gz) gzip -d "$initdir$FN" ;;
*.bz2) bzip2 -d "$initdir$FN" ;;
*.gz) gzip -d "$initdir$FN" ;;
*.bz2) bzip2 -d "$initdir$FN" ;;
esac
done
done
[[ $SYSFONTACM ]] && inst /lib/kbd/consoletrans/$SYSFONTACM
[[ $UNIMAP ]] && inst /lib/kbd/unimaps/$UNIMAP
fi
fi
}
if [ -f /etc/sysconfig/i18n ]; then
. /etc/sysconfig/i18n
inst /etc/sysconfig/i18n
[[ $SYSFONT ]] || SYSFONT=latarcyrheb-sun16
inst setfont
for FN in /lib/kbd/consolefonts/$SYSFONT.* ; do
inst "$FN"
case $FN in
*.gz) gzip -d "$initdir$FN" ;;
*.bz2) bzip2 -d "$initdir$FN" ;;
esac
if [[ $hostonly ]]; then
install_local
else
for i in $(find /lib/kbd -type f -print); do
dracut_install $i
done
[[ $SYSFONTACM ]] && inst /lib/kbd/consoletrans/$SYSFONTACM
[[ $UNIMAP ]] && inst /lib/kbd/unimaps/$UNIMAP
dracut_install gzip bzip2
fi
dracut_install /lib/udev/console_*
dracut_install /lib/udev/console_*
dracut_install setfont loadkeys
inst_rules 10-console.rules
inst_hook cmdline 20 "$moddir/parse-i18n.sh"

View File

@@ -0,0 +1,21 @@
inst_key_val()
{
local value
value=$(getarg $1)
[ -n "$value" ] && printf '%s="%s"\n' $1 $value >> $2
initrdargs="$initrdargs $1"
}
mkdir -p /etc/sysconfig
inst_key_val KEYBOARDTYPE /etc/sysconfig/keyboard
inst_key_val KEYTABLE /etc/sysconfig/keyboard
inst_key_val SYSFONT /etc/sysconfig/i18n
inst_key_val SYSFONTACM /etc/sysconfig/i18n
inst_key_val UNIMAP /etc/sysconfig/i18n
inst_key_val LANG /etc/sysconfig/i18n
if [ -f /etc/sysconfig/i18n ]; then
. /etc/sysconfig/i18n
export LANG
fi

View File

@@ -1,4 +1,4 @@
#!/bin/sh
which ip dhclient hostname >/dev/null 2>&1 || exit 1
which ip dhclient hostname brctl >/dev/null 2>&1 || exit 1
exit 255

View File

@@ -60,6 +60,14 @@ fi
# $netif reads easier than $1
netif=$1
# bridge this interface?
if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
if [ "$netif" = "$ethname" ]; then
netif="$bridgename"
fi
fi
# bail immediately if the interface is already up
# or we don't need the network
[ -f "/tmp/net.$netif.up" ] && exit 0
@@ -77,6 +85,15 @@ fi
# XXX need error handling like dhclient-script
# start bridge if necessary
if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
ip link set $ethname up
# Create bridge and add eth to bridge
brctl addbr $bridgename
brctl setfd $bridgename 0
brctl addif $bridgename $ethname
fi
# No ip lines default to dhcp
ip=$(getarg ip)
[ -z "$ip" ] && do_dhcp;

View File

@@ -1,23 +1,13 @@
#!/bin/bash
dracut_install ip dhclient hostname
# Include wired net drivers, excluding wireless
for modname in $(find "/lib/modules/$kernel/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
dracut_install ip dhclient hostname brctl
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
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"
inst_hook cmdline 98 "$moddir/parse-bridge.sh"
inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh"
# TODO ifcfg config style is redhat specific, this should probably

View File

@@ -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

View File

@@ -14,25 +14,30 @@ fix_bootif() {
# Write udev rules
{
# bridge: attempt only the defined interface
if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
IFACES=$ethname
fi
# BOOTIF says everything, use only that one
BOOTIF=$(getarg 'BOOTIF=')
if [ -n "$BOOTIF" ] ; then
BOOTIF=$(fix_bootif "$BOOTIF")
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue /sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
# If we have to handle multiple interfaces, handle only them.
elif [ -n "$IFACES" ] ; then
for iface in $IFACES ; do
printf 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="%s", RUN+="/sbin/initqueue /sbin/ifup $env{INTERFACE}"\n' "$iface"
printf 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
done
# Default: We don't know the interface to use, handle all
else
printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/initqueue /sbin/ifup $env{INTERFACE}"\n'
printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n'
fi
# Udev event 'online' only gets fired from ifup/dhclient-script.
# No special rules required
printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/initqueue /sbin/netroot $env{INTERFACE}"\n'
printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/netroot $env{INTERFACE}"\n'
} > /etc/udev/rules.d/60-net.rules

View File

@@ -0,0 +1,53 @@
#!/bin/sh
#
# Format:
# bridge=<bridgename>:<ethname>
#
# bridge without parameters assumes bridge=br0:eth0
#
# return if bridge already parsed
[ -n "$bridgename" ] && return
# Check if bridge parameter is valid
if getarg ip= >/dev/null ; then
if [ -z "$netroot" ] ; then
die "No netboot configured, bridge is invalid"
fi
fi
parsebridge() {
local v=${1}:
set --
while [ -n "$v" ]; do
set -- "$@" "${v%%:*}"
v=${v#*:}
done
unset bridgename ethname
case $# in
0) bridgename=br0; ethname=eth0 ;;
1) die "bridge= requires two parameters" ;;
2) bridgename=$1; ethname=$2 ;;
*) die "bridge= requires two parameters" ;;
esac
}
unset bridgename ethname
# Parse bridge for bridgename and ethname
if getarg bridge >/dev/null; then
# Read bridge= parameters if they exist
bridge="$(getarg bridge=)"
if [ ! "$bridge" = "bridge" ]; then
parsebridge "$(getarg bridge=)"
fi
# Simple default bridge
if [ -z "$bridgename" ]; then
bridgename=br0
ethname=eth0
fi
echo "bridgename=$bridgename" > /tmp/bridge.info
echo "ethname=$ethname" >> /tmp/bridge.info
return
fi

View File

@@ -45,9 +45,8 @@ getarg ip= >/dev/null && getarg BOOTIF= >/dev/null && \
# No more parsing stuff, BOOTIF says everything
[ -n "$(getarg BOOTIF)" ] && return
# Warn if defaulting to ip=dhcp
if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] ; then
warn "No ip= argument(s) for netroot provided, defaulting to DHCP"
# No ip= argument(s) for netroot provided, defaulting to DHCP
return;
fi
@@ -143,4 +142,4 @@ fi
[ -n "$IFACES" ] && echo $IFACES > /tmp/net.ifaces
# We need a ip= line for the configured bootdev=
[ -n "$NEEDBOOTDEV" ] && [ -z "$BOOTDEVOK" ] && die "Bootdev Argument '$BOOTDEV' not found"
[ -n "$NEEDBOOTDEV" ] && [ -z "$BOOTDEVOK" ] && die "Bootdev Argument '$BOOTDEV' not found"

View File

@@ -6,11 +6,14 @@
read IFACES < /tmp/net.ifaces
for netif in $IFACES ; do
# bridge?
unset bridge
if [ "$netif" = "$bridgename" ]; then
bridge=yes
fi
cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
echo "# Generated by dracut initrd" > /tmp/net.$netif.ifcfg
echo "DEVICE=$netif" >> /tmp/net.$netif.ifcfg
echo "HWADDR=$(cat /sys/class/net/$netif/address)" >> /tmp/net.$netif.ifcfg
echo "TYPE=Ethernet" >> /tmp/net.$netif.ifcfg
echo "ONBOOT=yes" >> /tmp/net.$netif.ifcfg
if [ -f /tmp/net.$netif.lease ]; then
echo "BOOTPROTO=dhcp" >> /tmp/net.$netif.ifcfg
@@ -22,4 +25,23 @@ for netif in $IFACES ; do
echo "NETMASK=$mask" >> /tmp/net.$netif.ifcfg
[ -n "$gw" ] && echo "GATEWAY=$gw" >> /tmp/net.$netif.ifcfg
fi
# bridge needs differente things written to ifcfg
if [ -z "$bridge" ]; then
# standard interface
echo "HWADDR=$(cat /sys/class/net/$netif/address)" >> /tmp/net.$netif.ifcfg
echo "TYPE=Ethernet" >> /tmp/net.$netif.ifcfg
echo "NAME=\"Boot Disk\"" >> /tmp/net.$netif.ifcfg
else
# bridge
echo "TYPE=Bridge" >> /tmp/net.$netif.ifcfg
echo "NAME=\"Boot Disk\"" >> /tmp/net.$netif.ifcfg
# write separate ifcfg file for the raw eth interface
echo "DEVICE=$ethname" >> /tmp/net.$ethname.ifcfg
echo "TYPE=Ethernet" >> /tmp/net.$ethname.ifcfg
echo "ONBOOT=yes" >> /tmp/net.$ethname.ifcfg
echo "HWADDR=$(cat /sys/class/net/$ethname/address)" >> /tmp/net.$ethname.ifcfg
echo "BRIDGE=$netif" >> /tmp/net.$ethname.ifcfg
echo "NAME=$ethname" >> /tmp/net.$ethname.ifcfg
fi
done

View File

@@ -1,11 +0,0 @@
# hacky rules to try to try unlocking dm-crypt devs
#
# Copyright 2008, Red Hat, Inc.
# Jeremy Katz <katzj@redhat.com>
SUBSYSTEM!="block", GOTO="luks_end"
ACTION!="add|change", GOTO="luks_end"
ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"
LABEL="luks_end"

View File

@@ -1,3 +0,0 @@
#!/bin/bash
[[ $1 = -d ]] && echo crypt
[[ -x /sbin/plymouthd && -x /bin/plymouth && ! /usr/sbin/plymouth-set-default-theme ]]

View File

@@ -1,4 +0,0 @@
#!/bin/sh
[ -b /dev/mapper/$2 ] || exec /bin/plymouth ask-for-password --command="/sbin/cryptsetup luksOpen -T1 $1 $2"

View File

@@ -1,8 +0,0 @@
#!/bin/bash
. "$moddir"/plymouth-populate-initrd
inst_hook pre-udev 10 "$moddir"/plymouth-start.sh
inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh
inst_rules "$moddir/63-luks.rules"
inst "$moddir"/cryptroot-ask.sh /lib/udev/cryptroot-ask
inst cryptsetup

View File

@@ -1,4 +0,0 @@
#!/bin/sh
[ -x /bin/plymouth ] && /bin/plymouth --newroot=$NEWROOT

View File

@@ -1,25 +0,0 @@
#!/bin/bash
if ldd /sbin/plymouthd |grep -q lib64; then
LIBDIR="/usr/lib64"
else
LIBDIR="/usr/lib"
fi
PLYMOUTH_LOGO_FILE="/usr/share/pixmaps/system-logo-white.png"
PLYMOUTH_PLUGIN_NAME=$(plymouth-set-default-plugin)
inst /sbin/plymouthd /bin/plymouthd
dracut_install /bin/plymouth "${LIBDIR}/plymouth/text.so" \
"${LIBDIR}/plymouth/details.so" "${PLYMOUTH_LOGO_FILE}" \
/etc/system-release "${LIBDIR}/plymouth/${PLYMOUTH_PLUGIN_NAME:=text}.so"
mkdir -p "${initdir}/usr/share/plymouth"
[[ -f ${LIBDIR}/plymouth/default.so ]] && inst ${LIBDIR}/plymouth/default.so
if [[ -d /usr/share/plymouth/${PLYMOUTH_PLUGIN_NAME} ]]; then
for x in "/usr/share/plymouth/${PLYMOUTH_PLUGIN_NAME}"/* ; do
[[ -f "$x" ]] || break
inst $x
done
fi
# vim:ts=8:sw=4:sts=4:et

View File

@@ -1,31 +0,0 @@
#!/bin/sh
[ -c /dev/null ] || mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/systty c 4 0
mknod /dev/tty c 5 0
[ -c /dev/console ] || mknod /dev/console c 5 1
[ -c /dev/ptmx ] || mknod /dev/ptmx c 5 2
mknod /dev/fb c 29 0
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mknod /dev/tty5 c 4 5
mknod /dev/tty6 c 4 6
mknod /dev/tty7 c 4 7
mknod /dev/tty8 c 4 8
mknod /dev/tty9 c 4 9
mknod /dev/tty10 c 4 10
mknod /dev/tty11 c 4 11
mknod /dev/tty12 c 4 12
mknod /dev/ttyS0 c 4 64
mknod /dev/ttyS1 c 4 65
mknod /dev/ttyS2 c 4 66
mknod /dev/ttyS3 c 4 67
/lib/udev/console_init tty0
[ -x /bin/plymouthd ] && /bin/plymouthd
[ -x /bin/plymouth ] && /bin/plymouth --show-splash

View File

@@ -1,12 +0,0 @@
# hacky rules to try to try unlocking dm-crypt devs
#
# Copyright 2008, Red Hat, Inc.
# Jeremy Katz <katzj@redhat.com>
SUBSYSTEM!="block", GOTO="luks_end"
ACTION!="add|change", GOTO="luks_end"
ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue /sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"
LABEL="luks_end"

View File

@@ -9,13 +9,33 @@
# we already asked for this device
[ -f /tmp/cryptroot-asked-$2 ] && exit 0
# flock against other interactive activities
{ flock -s 9;
/bin/plymouth ask-for-password --prompt "$1 is password protected" --command="/sbin/cryptsetup luksOpen -T1 $1 $2"
} 9>/.console.lock
. /lib/dracut-lib.sh
LUKS=$(getargs rd_LUKS_UUID=)
ask=1
if [ -n "$LUKS" ]; then
ask=0
for luks in $LUKS; do
if [ "${2##$luks}" != "$2" ]; then
ask=1
fi
done
fi
if [ $ask -gt 0 ]; then
# flock against other interactive activities
{ flock -s 9;
/bin/plymouth ask-for-password \
--prompt "$1 is password protected" \
--command="/sbin/cryptsetup luksOpen -T1 $1 $2"
} 9>/.console.lock
fi
# mark device as asked
>> /tmp/cryptroot-asked-$2
unset LUKS
unset ask
unset luks
exit 0

View File

@@ -1,10 +1,7 @@
#!/bin/bash
. "$moddir"/plymouth-populate-initrd
inst_hook cmdline 30 "$moddir/parse-plymouth.sh"
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 "/lib/modules/$kernel/kernel/drivers/gpu/drm" -name '*.ko'); do
nm -uPA $modname | grep -q drm_crtc_init && instmods $modname
done

View File

@@ -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

View File

@@ -0,0 +1,19 @@
initrdargs="$initrdargs rd_plytheme"
PLYMOUTH_THEMEDIR=/usr/share/plymouth/themes
PLYMOUTH_THEME=$(getarg rd_plytheme=)
if [ -n "$PLYMOUTH_THEME" ]; then
if [ -f "${PLYMOUTH_THEMEDIR}/${PLYMOUTH_THEME}/${PLYMOUTH_THEME}.plymouth" ]; then
info "Setting theme $PLYMOUTH_THEME"
(
cd $PLYMOUTH_THEMEDIR;
ln -fs "${PLYMOUTH_THEME}/${PLYMOUTH_THEME}.plymouth" default.plymouth 2>&1 | vinfo;
)
else
warn "Theme $PLYMOUTH_THEME not found!"
fi
fi
unset PLYMOUTH_THEME
unset PLYMOUTH_THEMEDIR

View File

@@ -8,31 +8,46 @@ PLYMOUTH_LOGO_FILE="/usr/share/pixmaps/system-logo-white.png"
PLYMOUTH_THEME=$(plymouth-set-default-theme)
inst /sbin/plymouthd /bin/plymouthd
dracut_install /bin/plymouth "${LIBDIR}/plymouth/text.so" \
"${LIBDIR}/plymouth/details.so" \
"/usr/share/plymouth/themes/details/details.plymouth" \
"/usr/share/plymouth/themes/text/text.plymouth" \
dracut_install /bin/plymouth \
"${PLYMOUTH_LOGO_FILE}" \
/etc/system-release
if [[ -f "${LIBDIR}/plymouth/${PLYMOUTH_THEME:=text}.so" ]]; then
dracut_install "${LIBDIR}/plymouth/${PLYMOUTH_THEME:=text}.so"
fi
mkdir -p "${initdir}/usr/share/plymouth"
if [[ -d /usr/share/plymouth/themes/${PLYMOUTH_THEME} ]]; then
for x in "/usr/share/plymouth/themes/${PLYMOUTH_THEME}"/* ; do
[[ -f "$x" ]] || break
inst $x
done
fi
if [[ $hostonly ]]; then
dracut_install "${LIBDIR}/plymouth/text.so" \
"${LIBDIR}/plymouth/details.so" \
"/usr/share/plymouth/themes/details/details.plymouth" \
"/usr/share/plymouth/themes/text/text.plymouth" \
if [ -L /usr/share/plymouth/themes/default.plymouth ]; then
inst /usr/share/plymouth/themes/default.plymouth
# Install plugin for this theme
PLYMOUTH_PLUGIN=$(grep "^ModuleName=" /usr/share/plymouth/themes/default.plymouth |awk -F= {'print $2'})
inst ${LIBDIR}/plymouth/${PLYMOUTH_PLUGIN}.so
if [[ -d /usr/share/plymouth/themes/${PLYMOUTH_THEME} ]]; then
for x in "/usr/share/plymouth/themes/${PLYMOUTH_THEME}"/* ; do
[[ -f "$x" ]] || break
inst $x
done
fi
if [ -L /usr/share/plymouth/themes/default.plymouth ]; then
inst /usr/share/plymouth/themes/default.plymouth
# Install plugin for this theme
PLYMOUTH_PLUGIN=$(grep "^ModuleName=" /usr/share/plymouth/themes/default.plymouth |awk -F= {'print $2'})
inst ${LIBDIR}/plymouth/${PLYMOUTH_PLUGIN}.so
fi
else
for x in /usr/share/plymouth/themes/*/* ; do
[[ -f "$x" ]] || continue
THEME_DIR=$(dirname "$x")
mkdir -p "${initdir}/$THEME_DIR"
dracut_install "$x"
done
for x in ${LIBDIR}/plymouth/*.so ; do
[[ -f "$x" ]] || continue
dracut_install "$x"
done
(
cd ${initdir}/usr/share/plymouth/themes;
ln -s text/text.plymouth default.plymouth 2>&1;
)
fi
# vim:ts=8:sw=4:sts=4:et

View File

@@ -1,21 +1,18 @@
#!/bin/sh
# first trigger graphics subsystem
udevadm trigger --attr-match=class=0x030000
# first trigger graphics and tty subsystem
udevadm trigger --subsystem-match=graphics --subsystem-match=tty >/dev/null 2>&1
# add nomatch for full trigger
udevtriggeropts="$udevtriggeropts --subsystem-nomatch=graphics --subsystem-nomatch=tty"
udevadm settle --timeout=30 >/dev/null 2>&1
[ -c /dev/null ] || mknod /dev/null c 1 3
# first trigger graphics subsystem
udevadm trigger --attr-match=class=0x030000 >/dev/null 2>&1
# first trigger graphics and tty subsystem
udevadm trigger --subsystem-match=graphics --subsystem-match=drm --subsystem-match=tty >/dev/null 2>&1
udevadm settle --timeout=30 2>&1 | vinfo
[ -c /dev/zero ] || mknod /dev/zero c 1 5
[ -c /dev/systty ] || mknod /dev/systty c 4 0
[ -c /dev/fb ] || mknod /dev/fb c 29 0
[ -c /dev/hvc0 ] || mknod /dev/hvc0 c 229 0
info "Starting plymouth daemon"
[ -x /bin/plymouthd ] && /bin/plymouthd
/lib/udev/console_init tty0
/bin/plymouth --show-splash
/bin/plymouth --show-splash 2>&1 | vinfo

View File

@@ -7,6 +7,6 @@
SUBSYSTEM!="block", GOTO="luks_end"
ACTION!="add|change", GOTO="luks_end"
ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue /sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"
ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue --onetime /sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"
LABEL="luks_end"

View File

@@ -9,11 +9,26 @@
# we already asked for this device
[ -f /tmp/cryptroot-asked-$2 ] && exit 0
# flock against other interactive activities
{ flock -s 9;
echo -n "$1 is password protected "
/sbin/cryptsetup luksOpen -T1 $1 $2
} 9>/.console.lock
. /lib/dracut-lib.sh
LUKS=$(getargs rd_LUKS_UUID=)
ask=1
if [ -n "$LUKS" ]; then
ask=0
for luks in $LUKS; do
if [ "${2##$luks}" != "$2" ]; then
ask=1
fi
done
fi
if [ $ask -gt 0 ]; then
# flock against other interactive activities
{ flock -s 9;
echo -n "$1 is password protected "
/sbin/cryptsetup luksOpen -T1 $1 $2
} 9>/.console.lock
fi
# mark device as asked
>> /tmp/cryptroot-asked-$2

View File

@@ -1,5 +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"

View File

@@ -0,0 +1,2 @@
#!/bin/bash
instmods dm_crypt cbc aes sha256 xts

View File

@@ -0,0 +1,7 @@
initrdargs="$initrdargs rd_NO_LUKS rd_LUKS_UUID"
if getarg rd_NO_LUKS; then
info "rd_NO_LUKS: removing cryptoluks activation"
rm -f /etc/udev/rules.d/70-luks.rules
fi

View File

@@ -0,0 +1,19 @@
# This file causes block devices with RAID (dmraid) signatures to
# automatically cause dmraid_scan to be run.
# See udev(8) for syntax
SUBSYSTEM!="block", GOTO="dm_end"
ACTION!="add|change", GOTO="dm_end"
ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="dm_end"
ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}!="?*", GOTO="dm_end"
ENV{ID_FS_TYPE}!="*_raid_member", , GOTO="dm_end"
TEST=="/tmp/.dmraid_scan-%k", GOTO="dm_end"
RUN+="/bin/sh -c '>/tmp/.dmraid_scan-%k; /bin/ln -fs /sbin/dmraid_scan /initqueue/dmraid_scan.sh'"
ENV{DEVTYPE}!="partition", \
RUN+="/sbin/partx -d $env{DEVNAME}"
LABEL="dm_end"

27
modules.d/90dmraid/dmraid.sh Normal file → Executable file
View File

@@ -1,3 +1,26 @@
dmraid -ay -Z
udevadm settle --timeout=30 >/dev/null 2>&1
#!/bin/sh
if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
[ -h "$job" ] && rm -f "$job"
DM_RAIDS=$(getargs rd_DM_UUID=)
# run dmraid if udev has settled
info "Scanning for dmraid devices $DM_RAIDS"
if [ -n "$DM_RAIDS" ]; then
# only activate specified DM RAIDS
SETS=$(dmraid -c -s)
info "Found dmraid sets:"
echo $SETS|vinfo
for r in $DM_RAIDS; do
for s in $SETS; do
if [ "${s##$r}" != "$s" ]; then
info "Activating $s"
dmraid -ay $s 2>&1 | vinfo
fi
done
done
else
# scan and activate all DM RAIDS
dmraid -ay 2>&1 | vinfo
fi
fi

View File

@@ -1,4 +1,5 @@
#!/bin/bash
dracut_install dmraid
inst_hook pre-mount 10 "$moddir/dmraid.sh"
dracut_install dmraid partx
inst "$moddir/dmraid.sh" /sbin/dmraid_scan
inst_rules 64-md-raid.rules
inst_rules "$moddir/61-dmraid-imsm.rules"

View File

@@ -0,0 +1,6 @@
initrdargs="$initrdargs rd_DM_UUID rd_NO_DM"
if getarg rd_NO_DM; then
info "rd_NO_DM: removing DM RAID activation"
rm /etc/udev/rules.d/61-dmraid*.rules
fi

View File

@@ -1,13 +1,3 @@
#!/bin/bash
if [ -z "$drivers" ]; then
drivers="sd_mod =fs"
# Include block controller drivers
for modname in $(find "/lib/modules/$kernel/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')

View File

@@ -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

View File

@@ -6,11 +6,13 @@
SUBSYSTEM!="block", GOTO="lvm_end"
ACTION!="add|change", GOTO="lvm_end"
KERNEL!="dm-*", GOTO="lvm_end"
IMPORT{program}="vol_id --export $tempnode"
KERNEL=="dm-[0-9]*", IMPORT{program}="vol_id --export $tempnode"
KERNEL=="md[0-9]*|md/*", IMPORT{program}="vol_id --export $tempnode"
ENV{ID_FS_TYPE}=="LVM2_member", RUN+="/bin/sh -c '/sbin/lvm vgscan; /sbin/lvm vgchange -ay'"
ENV{ID_FS_TYPE}=="LVM2_member", \
TEST!="/tmp/.lvm_scan-%k", \
RUN+="/bin/sh -c '>/tmp/.lvm_scan-%k; /bin/ln -fs /sbin/lvm_scan /initqueue/lvm_scan.sh'"
OPTIONS="link_priority=-100"
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"

View File

@@ -6,11 +6,13 @@
SUBSYSTEM!="block", GOTO="lvm_end"
ACTION!="add|change", GOTO="lvm_end"
KERNEL!="dm-*", GOTO="lvm_end"
IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
KERNEL=="dm-[0-9]*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
KERNEL=="md[0-9]*|md/*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
ENV{ID_FS_TYPE}=="LVM2_member", RUN+="/bin/sh -c '/sbin/lvm vgscan; /sbin/lvm vgchange -ay'"
ENV{ID_FS_TYPE}=="LVM2_member", \
TEST!="/tmp/.lvm_scan-%k", \
RUN+="/bin/sh -c '>/tmp/.lvm_scan-%k; /bin/ln -fs /sbin/lvm_scan /initqueue/lvm_scan.sh'"
OPTIONS="link_priority=-100"
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"

View File

@@ -5,3 +5,10 @@ if [ -x /lib/udev/vol_id ]; then
else
inst_rules "$moddir/64-lvm.rules" 64-device-mapper.rules
fi
if [[ $hostonly ]]; then
[ -f /etc/lvm/lvm.conf ] && inst /etc/lvm/lvm.conf
fi
inst "$moddir/lvm_scan.sh" /sbin/lvm_scan
inst_hook cmdline 30 "$moddir/parse-lvm.sh"

37
modules.d/90lvm/lvm_scan.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/sh
if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
[ -h "$job" ] && rm -f "$job"
# run lvm scan if udev has settled
VGS=$(getargs rd_LVM_VG=)
[ -d /etc/lvm ] || mkdir -p /etc/lvm
# build a list of devices to scan
lvmdevs=$(
for f in /tmp/.lvm_scan-*; do
[ -e "$f" ] || continue
echo -n "${f##/tmp/.lvm_scan-} "
done
)
if [ ! -e /etc/lvm/lvm.conf ]; then
{
echo 'devices {';
echo -n ' filter = [ '
for dev in $lvmdevs; do
printf '"a|^/dev/%s$|", ' $dev;
done;
echo '"r/.*/" ]';
echo 'types = [ "blkext", 1024 ]'
echo '}';
} > /etc/lvm/lvm.conf
lvmwritten=1
fi
info "Scanning devices $lvmdevs for LVM volume groups $VGS"
lvm vgscan 2>&1 | vinfo
lvm vgchange -ay $VGS 2>&1 | vinfo
[ "$lvmwritten" ] && rm -f /etc/lvm/lvm.conf
unset lvmwritten
fi

View File

@@ -0,0 +1,7 @@
initrdargs="$initrdargs rd_NO_LVM rd_LVM_VG"
if getarg rd_NO_LVM; then
info "rd_NO_LVM: removing LVM activation"
rm -f /etc/udev/rules.d/64-lvm*.rules
fi

View File

@@ -1,12 +1 @@
# This file causes block devices with Linux RAID (mdadm) signatures to
# automatically cause mdadm to be run.
# See udev(8) for syntax
SUBSYSTEM!="block", GOTO="raid_end"
ACTION!="add|change", GOTO="raid_end"
KERNEL=="md/*", GOTO="raid_end"
KERNEL=="md*", IMPORT{program}="vol_id --export $tempnode"
ENV{ID_FS_TYPE}=="linux_raid_member", RUN+="/sbin/mdadm -IR $root/%k"
LABEL="raid_end"
SUBSYSTEM=="block", ACTION=="add|change", KERNEL=="md[0-9]*|md_d[0-9]*|md/*", IMPORT{program}="vol_id --export $tempnode"

View File

@@ -0,0 +1,25 @@
# This file causes block devices with Linux RAID (mdadm) signatures to
# automatically cause mdadm to be run.
# See udev(8) for syntax
ACTION!="add", GOTO="md_inc_end"
SUBSYSTEM!="block", GOTO="md_inc_end"
ENV{ID_FS_TYPE}!="linux_raid_member|isw_raid_member", GOTO="md_inc_end"
ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_inc_end"
TEST=="/tmp/.mdraid_start-%k", GOTO="md_inc_end"
IMPORT{program}="/sbin/mdadm --examine --export $tempnode"
# UUID CHECK
LABEL="do_md_inc"
ENV{DEVTYPE}!="partition", \
RUN+="/sbin/partx -d $env{DEVNAME}"
RUN+="/sbin/mdadm -I --no-degraded $env{DEVNAME}"
RUN+="/bin/sh -c '>/tmp/.mdraid_start-%k; /bin/ln -s /sbin/mdraid_start /initqueue/mdraid_start.sh'"
LABEL="md_inc_end"

View File

@@ -1,8 +0,0 @@
# This file causes block devices with Linux RAID (mdadm) signatures to
# automatically cause mdadm to be run.
# See udev(8) for syntax
SUBSYSTEM=="block", ACTION=="add", ENV{ID_FS_TYPE}=="linux_raid_member", \
IMPORT{program}="/sbin/mdadm --examine --export $tempnode", \
RUN+="/bin/bash -c '[ ! -f /dev/.in_sysinit ] && /sbin/mdadm -I $env{DEVNAME}'"

View File

@@ -1,20 +1,37 @@
#!/bin/bash
dracut_install mdadm
inst /etc/passwd
inst /etc/group
instmods =drivers/md
dracut_install mdadm partx
# XXX: mdmon really needs to run as non-root?
# If so, write only the user it needs in the initrd's /etc/passwd (and maybe /etc/group)
# in a similar fashion to modules.d/95nfs. Do not copy /etc/passwd and /etc/group from
# the system into the initrd.
# dledford has hardware to test this, so he should be able to clean this up.
# inst /etc/passwd
# inst /etc/group
if [ -x /lib/udev/vol_id ]; then
inst_rules "$moddir/61-mdadm.rules"
else
inst_rules "$moddir/65-md-incremental.rules"
inst_rules 64-md-raid.rules
fi
[ -f /etc/mdadm/mdadm.conf ] && inst /etc/mdadm/mdadm.conf /etc/mdadm.conf
[ -f /etc/mdadm.conf ] && inst /etc/mdadm.conf
inst_rules "$moddir/65-md-incremental-imsm.rules"
if ! mdadm -Q -e imsm /dev/null &> /dev/null; then
inst_hook pre-trigger 30 "$moddir/md-noimsm.sh"
fi
if [[ $hostonly ]]; then
[ -f /etc/mdadm/mdadm.conf ] && inst /etc/mdadm/mdadm.conf /etc/mdadm.conf
[ -f /etc/mdadm.conf ] && inst /etc/mdadm.conf
fi
if [ -x /sbin/mdmon ] ; then
dracut_install mdmon
inst_hook pre-pivot 30 "$moddir/mdmon-pre-pivot.sh"
fi
inst "$moddir/mdraid_start.sh" /sbin/mdraid_start
inst_hook pre-trigger 30 "$moddir/parse-md.sh"

View File

@@ -0,0 +1,3 @@
#!/bin/bash
instmods =drivers/md

View File

@@ -0,0 +1,2 @@
info "rd_NO_MDIMSM: no MD RAID for imsm/isw raids"
udevadm control --property=rd_NO_MDIMSM=1

View File

@@ -0,0 +1,18 @@
#!/bin/sh
if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
[ -h "$job" ] && rm -f "$job"
# run mdadm if udev has settled
info "Assembling MD RAID arrays"
# and activate any containers
for md in /dev/md?*; do
case $md in
/dev/md*p*) ;;
*)
info "Starting MD RAID array $md"
mdadm -R $md 2>&1 | vinfo
mdadm -IR $md 2>&1 | vinfo
esac
done
fi

View File

@@ -0,0 +1,32 @@
initrdargs="$initrdargs rd_MD_UUID rd_NO_MD rd_NO_MDIMSM"
if getarg rd_NO_MD; then
info "rd_NO_MD: removing MD RAID activation"
rm /etc/udev/rules.d/65-md-incremental*.rules
else
MD_UUID=$(getargs rd_MD_UUID=)
# rewrite the md rules to only process the specified raid array
if [ -n "$MD_UUID" ]; then
for f in /etc/udev/rules.d/65-md-incremental*.rules; do
[ -e "$f" ] || continue
mv $f ${f}.bak
while read line; do
if [ "${line/UUID CHECK//}" != "$line" ]; then
for uuid in $MD_UUID; do
printf 'ENV{MD_UUID}=="%s", GOTO="do_md_inc"\n' $uuid
done;
printf 'GOTO="md_inc_end"\n';
else
echo $line;
fi
done < ${f}.bak > $f
rm ${f}.bak
done
fi
fi
if getarg rd_NO_MDIMSM; then
info "rd_NO_MDIMSM: no MD RAID for imsm/isw raids"
udevadm control --property=rd_NO_MDIMSM=1
fi

4
modules.d/95debug/check Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
# do not add this module by default
exit 1

View File

@@ -1,3 +1,3 @@
#!/bin/bash
dracut_install ln ps grep more dmesg cat rm strace free showmount
dracut_install ps grep more cat rm strace free showmount
dracut_install ping netstat rpcinfo

View File

@@ -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

View File

@@ -0,0 +1,2 @@
#!/bin/bash
instmods iscsi_tcp crc32c

View File

@@ -122,7 +122,10 @@ echo "InitiatorName='$iscsi_initiator'" > /dev/.initiatorname.iscsi
# FIXME $iscsi_protocol??
echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > /mount/iscsi.sh
if [ -n "${root%%block:*}" ]; then
# if root is not specified try to mount the whole iSCSI LUN
printf 'SYMLINK=="disk/by-path/*-iscsi-*-%s", SYMLINK+="root"\n' $iscsi_lun >> /etc/udev/rules.d/99-iscsi-root.rules
fi
iscsistart -i $iscsi_initiator -t $iscsi_target_name \
-g $iscsi_target_group -a $iscsi_target_ip \
@@ -130,7 +133,13 @@ iscsistart -i $iscsi_initiator -t $iscsi_target_name \
${iscsi_username+-u $iscsi_username} \
${iscsi_password+-w $iscsi_password} \
${iscsi_in_username+-U $iscsi_in_username} \
${iscsi_in_password+-W $iscsi_in_password}
${iscsi_in_password+-W $iscsi_in_password} || exit 1
# install mount script
if [ -n "${root%%block:*}" ]; then
# if root is not specified try to mount the whole iSCSI LUN
echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > /mount/01-$$-iscsi.sh
fi
# now we have a root filesystem somewhere in /dev/sda*
# let the normal block handler handle root=

View File

@@ -1,5 +1,4 @@
#!/bin/bash
inst nbd-client
inst_hook cmdline 90 "$moddir/parse-nbdroot.sh"
@@ -10,4 +9,3 @@ else
fi
inst "$moddir/nbdroot" "/sbin/nbdroot"
instmods nbd

2
modules.d/95nbd/installkernel Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
instmods nbd

View File

@@ -90,16 +90,17 @@ while [ ! -b /dev/nbd0 ]; do
i=$(( $i + 1))
done
nbd-client $preopts "$nbdserver" "$nbdport" /dev/nbd0 $opts || exit 1
# If we didn't get a root= on the command line, then we need to
# add the udev rules for mounting the nbd0 device
if [ ! -e /etc/udev/rules.d/99-mount.rules ]; then
printf 'KERNEL=="%s", RUN+="/sbin/initqueue /bin/mount -t %s -o %s %s %s"\n' \
nbd0 "$nbdfstype" "$fsopts" /dev/nbd0 "$NEWROOT" \
> /etc/udev/rules.d/99-mount.rules
ln -s /dev/nbd0 /dev/root
printf '/bin/mount -t %s -o %s %s %s\n' \
"$nbdfstype" "$fsopts" /dev/nbd0 "$NEWROOT" \
> /mount/01-$$-nbd.sh
fi
nbd-client $preopts "$nbdserver" "$nbdport" /dev/nbd0 $opts || exit 1
# NBD doesn't emit uevents when it gets connected, so kick it
echo change > /sys/block/nbd0/uevent
exit 0

View File

@@ -4,7 +4,7 @@ which rpcbind >/dev/null 2>&1 && dracut_install rpcbind
dracut_install rpc.statd mount.nfs mount.nfs4 umount
[ -f /etc/netconfig ] && dracut_install /etc/netconfig
dracut_install /etc/passwd /etc/services
dracut_install /etc/services
dracut_install /etc/nsswitch.conf /etc/rpc /etc/protocols
dracut_install rpc.idmapd /etc/idmapd.conf
if ldd $(which rpc.idmapd) |grep -q lib64; then
@@ -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"
@@ -26,7 +25,9 @@ mkdir -p "$initdir/var/lib/nfs/statd/sm"
# Rather than copy the passwd file in, just set a user for rpcbind
# We'll save the state and restart the daemon from the root anyway
#echo "rpc:x:32:32:Rpcbind:/var/lib/rpcbind:/bin/false" >> "$initdir/etc/passwd"
egrep '^rpc:' /etc/passwd >> "$initdir/etc/passwd"
egrep '^rpcuser:' /etc/passwd >> "$initdir/etc/passwd"
#which nologin >/dev/null 2>&1 && dracut_install nologin
# rpc user needs to be able to write to this directory to save the warmstart
# file

2
modules.d/95nfs/installkernel Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
instmods nfs sunrpc ipv6

View File

@@ -142,14 +142,16 @@ if [ "$nfs" = "nfs4" ]; then
[ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
# XXX Should we loop here?
exec mount -t nfs4 -o$options${nfslock+,$nfslock} \
$server:$path $NEWROOT
mount -t nfs4 -o$options${nfslock+,$nfslock} \
$server:$path $NEWROOT \
&& { [ -e /dev/root ] || >/dev/root ; }
else
# NFSv{2,3} doesn't support using locks as it requires a helper to transfer
# the rpcbind state to the new root
[ "$nfslock" = "lock" ] && \
warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
# XXX Should we loop here?
mount -t nfs -o$options${options:+,}nolock $server:$path $NEWROOT \
&& { [ -e /dev/root ] || >/dev/root ; }
fi
# NFSv{2,3} doesn't support using locks as it requires a helper to transfer
# the rpcbind state to the new root
[ "$nfslock" = "lock" ] && \
warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
# XXX Should we loop here?
exec mount -t nfs -o$options${options:+,}nolock $server:$path $NEWROOT

View File

@@ -1,8 +1,12 @@
if [ "${root%%:*}" = "block" ]; then
(
printf 'KERNEL=="%s", RUN+="/sbin/initqueue /bin/mount -t %s -o %s %s %s"\n' \
${root#block:/dev/} "$fstype" "$rflags" "${root#block:}" "$NEWROOT"
printf 'SYMLINK=="%s", RUN+="/sbin/initqueue /bin/mount -t %s -o %s %s %s"\n' \
${root#block:/dev/} "$fstype" "$rflags" "${root#block:}" "$NEWROOT"
printf 'KERNEL=="%s", SYMLINK+="root"\n' \
${root#block:/dev/}
printf 'SYMLINK=="%s", SYMLINK+="root"\n' \
${root#block:/dev/}
) >> /etc/udev/rules.d/99-mount.rules
(
printf '[ -e "%s" ] && { ln -s "%s" /dev/root; rm "$job"; }\n' \
"${root#block:}" "${root#block:}"
) >> /initqueue/blocksymlink.sh
fi

View File

@@ -12,6 +12,11 @@ inst_rules 50-udev.rules 95-late.rules
# ignore some devices in the initrd
inst_rules "$moddir/01-ignore.rules"
# for firmware loading
inst_rules 50-firmware.rules
dracut_install /lib/udev/firmware.sh
dracut_install cat uname
if [ ! -x /lib/udev/vol_id ]; then
dracut_install blkid
fi

View File

@@ -1,3 +1,3 @@
#!/bin/bash
[[ $1 = -d ]] && echo udev-rules kernel-modules
exit 0
[[ $1 = -d ]] && echo udev-rules
exit 0

View File

@@ -8,6 +8,20 @@ getarg() {
return 1
}
getargs() {
local o line found
[ "$CMDLINE" ] || read CMDLINE </proc/cmdline;
for o in $CMDLINE; do
[ "$o" = "$1" ] && return 0
if [ "${o%%=*}" = "${1%=}" ]; then
echo -n "${o#*=} ";
found=1;
fi
done
[ -n "$found" ] && return 0
return 1
}
source_all() {
local f
[ "$1" ] && [ -d "/$1" ] || return
@@ -15,13 +29,38 @@ source_all() {
}
die() {
printf "<1>FATAL: $1\n" > /dev/kmsg
printf "<1>Refusing to continue\n" > /dev/kmsg
{
echo "<1>dracut: FATAL: $@";
echo "<1>dracut: Refusing to continue";
} > /dev/kmsg
{
echo "dracut: FATAL: $@";
echo "dracut: Refusing to continue";
} >&2
exit 1
}
warn() {
printf "<1>Warning: $1\n" > /dev/kmsg
echo "<4>dracut Warning: $@" > /dev/kmsg
echo "dracut Warning: $@" >&2
}
info() {
if [ -z "$DRACUT_QUIET" ]; then
DRACUT_QUIET="no"
getarg quiet && DRACUT_QUIET="yes"
fi
echo "<6>dracut: $@" > /dev/kmsg
[ "$DRACUT_QUIET" != "yes" ] && \
echo "dracut: $@"
}
vinfo() {
while read line; do
info $line;
done
}
check_occurances() {

View File

@@ -7,41 +7,26 @@
emergency_shell()
{
source_all emergency
exec >/dev/console 2>&1 </dev/console
echo ; echo
echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
echo $@
source_all emergency
echo
sh -i
}
do_initqueue()
{
while :; do
# bail out, if we have mounted the root filesystem
[ -d "$NEWROOT/proc" ] && break;
if [ $UDEVVERSION -ge 143 ]; then
udevadm settle --exit-if-exists=/initqueue/work
else
udevadm settle --timeout=30
fi
[ -f /initqueue/work ] || break
rm /initqueue/work
for job in /initqueue/*.job; do
. $job
rm -f $job
# bail out, if we have mounted the root filesystem
[ -d "$NEWROOT/proc" ] && break;
done
done
if getarg rdshell || getarg rdbreak; then
echo "Dropping to debug shell."
echo
sh -i
else
echo "Boot has failed, sleeping forever."
while :; do sleep 365d;done
fi
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export TERM=linux
NEWROOT="/sysroot"
trap "emergency_shell" 0
trap "emergency_shell Signal caught!" 0
. /lib/dracut-lib.sh
@@ -64,7 +49,10 @@ if [ ! -c /dev/ptmx ]; then
fi
fi
getarg rdinitdebug && set -x
if getarg rdinitdebug; then
set -x
fi
mkdir /dev/shm
mkdir /dev/pts
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1
@@ -72,7 +60,7 @@ mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1
UDEVVERSION=$(udevadm --version)
# run scriptlets to parse the command line
getarg 'rdbreak=cmdline' && emergency_shell
getarg 'rdbreak=cmdline' && emergency_shell "Break before cmdline"
source_all cmdline
[ -z "$root" ] && die "No or empty root= argument"
@@ -89,48 +77,103 @@ source_all cmdline
} > /tmp/root.info
# pre-udev scripts run before udev starts, and are run only once.
getarg 'rdbreak=pre-udev' && emergency_shell
getarg 'rdbreak=pre-udev' && emergency_shell "Break before pre-udev"
source_all pre-udev
# start up udev and trigger cold plugs
udevd --daemon
getarg rdudevinfo && udevadm control --log_priority=info
getarg rdudevdebug && udevadm control --log_priority=debug
UDEV_LOG_PRIO_ARG=--log-priority
UDEV_QUEUE_EMPTY="udevadm settle --timeout=0"
if [ $UDEVVERSION -lt 140 ]; then
UDEV_LOG_PRIO_ARG=--log_priority
UDEV_QUEUE_EMPTY="udevadm settle --timeout=1"
fi
getarg rdudevinfo && udevadm control $UDEV_LOG_PRIO_ARG=info
getarg rdudevdebug && udevadm control $UDEV_LOG_PRIO_ARG=debug
getarg 'rdbreak=pre-trigger' && emergency_shell "Break before pre-trigger"
source_all pre-trigger
# then the rest
udevadm trigger $udevtriggeropts >/dev/null 2>&1
do_initqueue
getarg 'rdbreak=initqueue' && emergency_shell "Break before initqueue"
i=0
while :; do
# bail out, if we have mounted the root filesystem
[ -d "$NEWROOT/proc" ] && break;
# check if root can be mounted
[ -e /dev/root ] && break;
if [ $UDEVVERSION -ge 143 ]; then
udevadm settle --exit-if-exists=/initqueue/work --exit-if-exists=/dev/root
else
udevadm settle --timeout=30
fi
# bail out, if we have mounted the root filesystem
[ -d "$NEWROOT/proc" ] && break;
# check if root can be mounted
[ -e /dev/root ] && break;
unset queuetriggered
if [ -f /initqueue/work ]; then
rm /initqueue/work
queuetriggered="1"
fi
for job in /initqueue/*.sh; do
[ -e "$job" ] || break
job=$job . $job
# bail out, if we have mounted the root filesystem
[ -d "$NEWROOT/proc" ] && break;
# check if root can be mounted
[ -e /dev/root ] && break;
done
[ -n "$queuetriggered" ] && continue
if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
# no more udev jobs
sleep 0.5
i=$(($i+1))
[ $i -gt 20 ] \
&& { flock -s 9 ; emergency_shell "No root device found"; } 9>/.console_lock
fi
done
unset job
unset queuetriggered
# pre-mount happens before we try to mount the root filesystem,
# and happens once.
getarg 'rdbreak=pre-mount' && emergency_shell
getarg 'rdbreak=pre-mount' && emergency_shell "Break pre-mount"
source_all pre-mount
getarg 'rdbreak=mount' && emergency_shell
do_initqueue
getarg 'rdbreak=mount' && emergency_shell "Break mount"
# mount scripts actually try to mount the root filesystem, and may
# be sourced any number of times. As soon as one suceeds, no more are sourced.
i=0
while :; do
[ -d "$NEWROOT/proc" ] && break;
for f in /mount/*.sh; do
[ -f "$f" ] && . "$f"
do_initqueue
[ "$ROOTFS_MOUNTED" ] && break;
[ -d "$NEWROOT/proc" ] && break;
done
sleep 0.5
i=$(($i+1))
{ flock -s 9 ; [ $i -gt 20 ] && emergency_shell; } 9>/.console_lock
[ $i -gt 20 ] \
&& { flock -s 9 ; emergency_shell "Can't mount root filesystem"; } 9>/.console_lock
done
# pre pivot scripts are sourced just before we switch over to the new root.
getarg 'rdbreak=pre-pivot' && emergency_shell
getarg 'rdbreak=pre-pivot' && emergency_shell "Break pre-pivot"
source_all pre-pivot
# by the time we get here, the root filesystem should be mounted.
@@ -139,12 +182,12 @@ for i in "$(getarg init=)" /sbin/init /etc/init /init /bin/sh; do
[ -f "$NEWROOT$i" -a -x "$NEWROOT$i" ] && { INIT="$i"; break; }
done
[ "$INIT" ] || {
echo "Cannot find init! Please check to make sure you passed"
echo "a valid root filesystem! Dropping to a shell."
echo "Cannot find init!"
echo "Please check to make sure you passed a valid root filesystem!"
emergency_shell
}
getarg rdbreak && emergency_shell
getarg rdbreak && emergency_shell "Break before switch_root"
HARD=""
while pidof udevd >/dev/null 2>&1; do
@@ -163,15 +206,12 @@ for i in $(export -p); do
done
initargs=""
initrdargs="$initrdargs console BOOT_IMAGE rdbreak rdinitdebug rdudevinfo rdudevdebug rdnetdebug rdcopystate rdshell"
for x in "$@"; do
[ "${x%%=*}" = "console" ] && continue
[ "${x%%=*}" = "BOOT_IMAGE" ] && continue
[ "${x%%=*}" = "rdbreak" ] && continue
[ "${x%%=*}" = "rdinitdebug" ] && continue
[ "${x%%=*}" = "rdudevinfo" ] && continue
[ "${x%%=*}" = "rdudevdebug" ] && continue
[ "${x%%=*}" = "rdnetdebug" ] && continue
[ "${x%%=*}" = "rdcopystate" ] && continue
for s in $initrdargs; do
[ "${x%%=*}" = $s ] && continue 1
done
initargs="$initargs $x"
done

View File

@@ -1,5 +1,12 @@
#!/bin/sh
echo "$@" > /tmp/$$.job
mv /tmp/$$.job /initqueue/
if [ "$1" = "--onetime" ]; then
onetime="yes"
shift
fi
echo "$@" > /tmp/$$.sh
if [ -n "$onetime" ]; then
echo '[ -e "$job" ] && rm "$job"' >> /tmp/$$.sh
fi
mv /tmp/$$.sh /initqueue/
>> /initqueue/work

View File

@@ -1,5 +1,6 @@
#!/bin/bash
dracut_install mount mknod mkdir modprobe pidof sleep chroot sed ls flock cp mv
dracut_install mount mknod mkdir modprobe pidof sleep chroot \
sed ls flock cp mv dmesg rm ln
if [ ! -e "${initdir}/bin/sh" ]; then
dracut_install bash
(ln -s bash "${initdir}/bin/sh" || :)

View File

@@ -33,11 +33,63 @@
#include <ctype.h>
#include <dirent.h>
#include <err.h>
#include <libgen.h>
#ifndef MS_MOVE
#define MS_MOVE 8192
#endif
/* find the enclosing mount point of a path, by examining the backing device
* of parent directories until we reach / or find a parent with a differing
* device.
* result must be freed.
*/
static char *get_parent_mount(const char *path)
{
struct stat sb;
char dir[PATH_MAX];
char tmp[PATH_MAX];
dev_t inner_dev;
int r;
r = stat(path, &sb);
if (r != 0) {
warn("failed to stat %s", path);
return NULL;
}
inner_dev = sb.st_dev;
/* dirname has some annoying properties of modifying the input... */
strncpy(dir, path, PATH_MAX);
dir[PATH_MAX - 1] = 0; /* for safety */
while (1) {
char *parent;
strncpy(tmp, dir, PATH_MAX);
tmp[PATH_MAX - 1] = 0;
parent = dirname(tmp);
r = stat(parent, &sb);
if (r != 0) {
warn("failed to stat %s", parent);
return NULL;
}
/* if the parent directory's device differs then we have found a mount
* point */
if (sb.st_dev != inner_dev)
return strdup(dir);
strncpy(dir, parent, PATH_MAX);
dir[PATH_MAX - 1] = 0;
/* maybe we've reached / */
if (strlen(dir) == 1)
return strdup(dir);
}
}
/* remove all files/directories below dirName -- don't cross mountpoints */
static int recursiveRemove(char *dirName)
{
@@ -109,7 +161,10 @@ static int switchroot(const char *newroot)
{
/* Don't try to unmount the old "/", there's no way to do it. */
const char *umounts[] = { "/dev", "/proc", "/sys", NULL };
char *newroot_mnt;
const char *chroot_path = NULL;
int i;
int r = -1;
for (i = 0; umounts[i] != NULL; i++) {
char newmount[PATH_MAX];
@@ -131,16 +186,46 @@ static int switchroot(const char *newroot)
recursiveRemove("/");
newroot_mnt = get_parent_mount(newroot);
if (newroot_mnt && strcmp(newroot, newroot_mnt)) {
/* newroot is not a mount point, so we have to MS_MOVE the parent
* mount point and then chroot in to the "subroot" */
chroot_path = newroot + strlen(newroot_mnt);
newroot = newroot_mnt;
if (chdir(newroot)) {
warn("failed to chdir to newroot mount %s", newroot);
goto err;
}
}
if (mount(newroot, "/", NULL, MS_MOVE, NULL) < 0) {
warn("failed to mount moving %s to /", newroot);
return -1;
goto err;
}
if (chroot(".")) {
warn("failed to change root");
return -1;
goto err;
}
return 0;
if (chroot_path) {
if (chdir(chroot_path)) {
warn("failed to chdir to subroot %s", chroot_path);
goto err;
}
if (chroot(".")) {
warn("failed to change root to subroot");
goto err;
}
}
r = 0;
err:
if (newroot_mnt)
free(newroot_mnt);
return r;
}
static void usage(FILE *output)

View File

@@ -1,6 +1,6 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
for x in 63-luks.rules 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
udevadm control --reload-rules

View File

@@ -1,5 +1,5 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem on an encrypted LVM PV"
TEST_DESCRIPTION="root filesystem on an encrypted LVM PV on a RAID-5"
KVERSION=${KVERSION-$(uname -r)}
@@ -9,7 +9,7 @@ KVERSION=${KVERSION-$(uname -r)}
test_run() {
$testdir/run-qemu -hda root.ext2 -m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet console=ttyS0,115200n81 $DEBUGFAIL" \
-append "root=/dev/dracut/root rw quiet console=ttyS0,115200n81 rdshell $DEBUGFAIL" \
-initrd initramfs.testing
grep -m 1 -q dracut-root-block-success root.ext2 || return 1
}
@@ -38,14 +38,14 @@ test_setup() {
initdir=overlay
. $basedir/dracut-functions
dracut_install sfdisk mke2fs poweroff cp umount
inst_simple ./create-root.sh /pre-mount/01create-root.sh
inst_simple ./create-root.sh /initqueue/01create-root.sh
)
# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut -l -i overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block" \
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "ata_piix ext2 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay

10
test/TEST-11-LVM/Makefile Normal file
View File

@@ -0,0 +1,10 @@
all:
@make -s --no-print-directory -C ../.. all
@basedir=../.. testdir=../ ./test.sh --all
setup:
@make --no-print-directory -C ../.. all
@basedir=../.. testdir=../ ./test.sh --setup
clean:
@basedir=../.. testdir=../ ./test.sh --clean
run:
@basedir=../.. testdir=../ ./test.sh --run

27
test/TEST-11-LVM/create-root.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
udevadm control --reload-rules
# save a partition at the beginning for future flagging purposes
sfdisk -C 640 -H 2 -S 32 -L /dev/sda <<EOF
,1
,213
,213
,213
EOF
for i in sda2 sda3 sda4; do
lvm pvcreate -ff -y /dev/$i ;
done && \
lvm vgcreate dracut /dev/sda[234] && \
lvm lvcreate -l 100%FREE -n root dracut && \
lvm vgchange -ay && \
mke2fs /dev/dracut/root && \
mkdir -p /sysroot && \
mount /dev/dracut/root /sysroot && \
cp -a -t /sysroot /source/* && \
umount /sysroot && \
lvm lvchange -a n /dev/dracut/root && \
echo "dracut-root-block-created" >/dev/sda1
poweroff -f

6
test/TEST-11-LVM/cryptroot-ask Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
[ -b /dev/mapper/$2 ] && exit 0
echo -n test >/keyfile
/sbin/cryptsetup luksOpen $1 $2 </keyfile

2
test/TEST-11-LVM/hard-off.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
getarg rdinitdebug || poweroff -f

10
test/TEST-11-LVM/test-init Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab
stty sane
echo "made it to the rootfs! Powering down."
mount -n -o remount,ro /
poweroff -f

76
test/TEST-11-LVM/test.sh Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem on LVM PV"
KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rdinitdebug rdnetdebug"
test_run() {
$testdir/run-qemu -hda root.ext2 -m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet console=ttyS0,115200n81 rdshell $DEBUGFAIL" \
-initrd initramfs.testing
grep -m 1 -q dracut-root-block-success root.ext2 || return 1
}
test_setup() {
# Create the blank file to use as a root filesystem
dd if=/dev/zero of=root.ext2 bs=1M count=20
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=overlay/source
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep
inst ./test-init /sbin/init
find_binary plymouth >/dev/null && dracut_install plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
)
# second, install the files needed to make the root filesystem
(
initdir=overlay
. $basedir/dracut-functions
dracut_install sfdisk mke2fs poweroff cp umount
inst_simple ./create-root.sh /initqueue/01create-root.sh
)
# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut -l -i overlay / \
-m "dash lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "ata_piix ext2 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda root.ext2 -m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81" \
-initrd initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created root.ext2 || return 1
(
initdir=overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_simple ./hard-off.sh /emergency/01hard-off.sh
)
sudo $basedir/dracut -l -i overlay / \
-o "plymouth" \
-a "debug" \
-d "ata_piix ext2 sd_mod" \
-f initramfs.testing $KVERSION || return 1
}
test_cleanup() {
rm -fr overlay mnt
rm -f root.ext2 initramfs.makeroot initramfs.testing
}
. $testdir/test-functions

View File

@@ -0,0 +1,10 @@
all:
@make -s --no-print-directory -C ../.. all
@basedir=../.. testdir=../ ./test.sh --all
setup:
@make --no-print-directory -C ../.. all
@basedir=../.. testdir=../ ./test.sh --setup
clean:
@basedir=../.. testdir=../ ./test.sh --clean
run:
@basedir=../.. testdir=../ ./test.sh --run

View File

@@ -0,0 +1,43 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
udevadm control --reload-rules
# save a partition at the beginning for future flagging purposes
sfdisk -C 640 -H 2 -S 32 -L /dev/sda <<EOF
,1
,213
,213
,213
EOF
mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sda2 /dev/sda3 /dev/sda4
# wait for the array to finish initailizing, otherwise this sometimes fails
# randomly.
mdadm -W /dev/md0
echo -n test >keyfile
cryptsetup -q luksFormat /dev/md0 /keyfile
echo "The passphrase is test"
cryptsetup luksOpen /dev/md0 dracut_crypt_test </keyfile && \
lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test && \
lvm vgcreate dracut /dev/mapper/dracut_crypt_test && \
lvm lvcreate -l 100%FREE -n root dracut && \
lvm vgchange -ay && \
mke2fs /dev/dracut/root && \
mkdir -p /sysroot && \
mount /dev/dracut/root /sysroot && \
cp -a -t /sysroot /source/* && \
umount /sysroot && \
lvm lvchange -a n /dev/dracut/root && \
cryptsetup luksClose /dev/mapper/dracut_crypt_test && \
mdadm /dev/md0 --fail /dev/sda2 --remove /dev/sda2 && \
{
/sbin/mdadm --detail --export /dev/md0 > /tmp/mduuid ;
. /tmp/mduuid;
} && \
{
echo "dracut-root-block-created"
echo MD_UUID=$MD_UUID
}> /dev/sda1
dd if=/dev/zero of=/dev/sda2
poweroff -f

View File

@@ -0,0 +1,6 @@
#!/bin/sh
[ -b /dev/mapper/$2 ] && exit 0
echo -n test >/keyfile
/sbin/cryptsetup luksOpen $1 $2 </keyfile

View File

@@ -0,0 +1,2 @@
#!/bin/sh
getarg rdinitdebug || poweroff -f

10
test/TEST-12-RAID-DEG/test-init Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab
stty sane
echo "made it to the rootfs! Powering down."
mount -n -o remount,ro /
poweroff -f

110
test/TEST-12-RAID-DEG/test.sh Executable file
View File

@@ -0,0 +1,110 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem on an encrypted LVM PV on a degraded RAID-5"
KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rdinitdebug rdnetdebug"
client_run() {
echo "CLIENT TEST START: $@"
$testdir/run-qemu -hda root.ext2 -m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "$@ root=/dev/dracut/root rw quiet console=ttyS0,115200n81 rdshell $DEBUGFAIL " \
-initrd initramfs.testing
if ! grep -m 1 -q dracut-root-block-success root.ext2; then
echo "CLIENT TEST END: $@ [FAIL]"
return 1;
fi
sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' root.ext2
echo "CLIENT TEST END: $@ [OK]"
return 0
}
test_run() {
eval $(grep --binary-files=text -m 1 MD_UUID root.ext2)
echo "MD_UUID=$MD_UUID"
client_run || return 1
client_run rd_NO_LVM && return 1
client_run rd_LVM_VG=failme && return 1
client_run rd_LVM_VG=dracut || return 1
client_run rd_LVM_VG=dummy1 rd_LVM_VG=dracut rd_LVM_VG=dummy2 || return 1
client_run rd_MD_UUID=failme && return 1
client_run rd_NO_MD && return 1
client_run rd_MD_UUID=$MD_UUID || return 1
client_run rd_MD_UUID=dummy1 rd_MD_UUID=$MD_UUID rd_MD_UUID=dummy2 || return 1
return 0
}
test_setup() {
# Create the blank file to use as a root filesystem
dd if=/dev/zero of=root.ext2 bs=1M count=20
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=overlay/source
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep
inst ./test-init /sbin/init
find_binary plymouth >/dev/null && dracut_install plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
)
# second, install the files needed to make the root filesystem
(
initdir=overlay
. $basedir/dracut-functions
dracut_install sfdisk mke2fs poweroff cp umount dd
inst_simple ./create-root.sh /initqueue/01create-root.sh
)
# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut -l -i overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "ata_piix ext2 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda root.ext2 -m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81" \
-initrd initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created root.ext2 || return 1
(
initdir=overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_simple ./hard-off.sh /emergency/01hard-off.sh
inst ./cryptroot-ask /sbin/cryptroot-ask
)
sudo $basedir/dracut -l -i overlay / \
-o "plymouth" \
-a "debug" \
-d "ata_piix ext2 sd_mod" \
-f initramfs.testing $KVERSION || return 1
}
test_cleanup() {
rm -fr overlay mnt
rm -f root.ext2 initramfs.makeroot initramfs.testing
}
. $testdir/test-functions

View File

@@ -46,7 +46,7 @@ client_test() {
-net nic,macaddr=$mac,model=e1000 \
-net socket,mcast=230.0.0.1:1234 \
-kernel /boot/vmlinuz-$KVERSION \
-append "$cmdline $DEBUGFAIL ro quiet console=ttyS0,115200n81" \
-append "$cmdline $DEBUGFAIL rdshell ro quiet console=ttyS0,115200n81" \
-initrd initramfs.testing
if [[ $? -ne 0 ]] || ! grep -m 1 -q nfs-OK client.img; then
@@ -125,6 +125,9 @@ test_nfsv3() {
client_test "NFSv3 root=nfs:..." 52:54:00:12:34:04 \
"root=nfs:192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
client_test "NFSv3 Bridge root=nfs:..." 52:54:00:12:34:04 \
"root=nfs:192.168.50.1:/nfs/client bridge" 192.168.50.1 -wsize=4096 || return 1
client_test "NFSv3 Legacy root=IP:path" 52:54:00:12:34:04 \
"root=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
@@ -135,6 +138,9 @@ test_nfsv3() {
client_test "NFSv3 root=dhcp DHCP path,options" \
52:54:00:12:34:05 "root=dhcp" 192.168.50.1 wsize=4096 || return 1
client_test "NFSv3 Bridge Customized root=dhcp DHCP path,options" \
52:54:00:12:34:05 "root=dhcp bridge=foobr0:eth0" 192.168.50.1 wsize=4096 || return 1
client_test "NFSv3 root=dhcp DHCP IP:path,options" \
52:54:00:12:34:06 "root=dhcp" 192.168.50.2 wsize=4096 || return 1
@@ -270,7 +276,7 @@ test_setup() {
# Make server's dracut image
$basedir/dracut -l -i overlay / \
-m "dash udev-rules base rootfs-block debug" \
-m "dash udev-rules base rootfs-block debug kernel-modules" \
-d "ata_piix ext2 sd_mod e1000" \
-f initramfs.server $KVERSION || return 1

View File

@@ -1,6 +1,6 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
for x in 63-luks.rules 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
udevadm control --reload-rules

View File

@@ -3,7 +3,7 @@ TEST_DESCRIPTION="root filesystem over iSCSI"
KVERSION=${KVERSION-$(uname -r)}
#DEBUGFAIL="rdinitdebug rdnetdebug"
#DEBUGFAIL="rdinitdebug rdnetdebug rdudevinfo"
run_server() {
# Start server first
@@ -37,7 +37,7 @@ run_client() {
-net nic,macaddr=52:54:00:12:34:00,model=e1000 \
-net socket,mcast=230.0.0.1:1235 \
-kernel /boot/vmlinuz-$KVERSION \
-append "root=dhcp rw quiet console=ttyS0,115200n81 $DEBUGFAIL" \
-append "root=dhcp rw quiet console=ttyS0,115200n81 rdshell $DEBUGFAIL" \
-initrd initramfs.testing
grep -m 1 -q iscsi-OK client.img || return 1
}
@@ -81,14 +81,14 @@ test_setup() {
initdir=overlay
. $basedir/dracut-functions
dracut_install sfdisk mke2fs poweroff cp umount
inst_simple ./create-root.sh /pre-mount/01create-root.sh
inst_simple ./create-root.sh /initqueue/01create-root.sh
)
# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut -l -i overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block" \
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "ata_piix ext2 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
@@ -111,7 +111,6 @@ test_setup() {
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_simple ./hard-off.sh /emergency/01hard-off.sh
# inst ./cryptroot-ask /sbin/cryptroot-ask
)
sudo $basedir/dracut -l -i overlay / \
-o "plymouth dmraid" \
@@ -141,7 +140,6 @@ test_setup() {
dracut_install /usr/sbin/iscsi-target
instmods iscsi_tcp crc32c ipv6
inst ./targets /etc/iscsi/targets
# inst ./root.ext2 /
[ -f /etc/netconfig ] && dracut_install /etc/netconfig
which dhcpd >/dev/null 2>&1 && dracut_install dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
@@ -158,10 +156,9 @@ test_setup() {
sudo umount mnt
rm -fr mnt
# Make server's dracut image
$basedir/dracut -l -i overlay / \
-m "dash udev-rules base rootfs-block debug" \
-m "dash udev-rules base rootfs-block debug kernel-modules" \
-d "ata_piix ext2 sd_mod e1000" \
-f initramfs.server $KVERSION || return 1

View File

@@ -1,6 +1,6 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
for x in 63-luks.rules 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
udevadm control --reload-rules

View File

@@ -50,7 +50,7 @@ client_test() {
-net nic,macaddr=$mac,model=e1000 \
-net socket,mcast=230.0.0.1:1236 \
-kernel /boot/vmlinuz-$KVERSION \
-append "$cmdline $DEBUGFAIL ro quiet console=ttyS0,115200n81" \
-append "$cmdline $DEBUGFAIL rdshell ro quiet console=ttyS0,115200n81" \
-initrd initramfs.testing
if [[ $? -ne 0 ]] || ! grep -m 1 -q nbd-OK flag.img; then
@@ -106,6 +106,10 @@ test_run() {
"root=nbd:192.168.50.1:2000:ext2:errors=panic" \
ext2 errors=panic || return 1
client_test "NBD Bridge root=nbd:IP:port:fstype:fsopts" 52:54:00:12:34:00 \
"root=nbd:192.168.50.1:2000:ext2:errors=panic bridge" \
ext2 errors=panic || return 1
# There doesn't seem to be a good way to validate the NBD options, so
# just check that we don't screw up the other options
@@ -125,6 +129,9 @@ test_run() {
client_test "NBD root=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \
"root=dhcp" || return 1
client_test "NBD Bridge root=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \
"root=dhcp bridge" || return 1
client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype" \
52:54:00:12:34:02 "root=dhcp" ext2 || return 1
@@ -184,14 +191,14 @@ make_encrypted_root() {
initdir=overlay
. $basedir/dracut-functions
dracut_install mke2fs poweroff cp umount
inst_simple ./create-root.sh /pre-mount/01create-root.sh
inst_simple ./create-root.sh /initqueue/01create-root.sh
)
# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut -l -i overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block" \
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "ata_piix ext2 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
@@ -287,7 +294,7 @@ test_setup() {
)
sudo $basedir/dracut -l -i overlay / \
-m "dash udev-rules rootfs-block base debug" \
-m "dash udev-rules rootfs-block base debug kernel-modules" \
-d "ata_piix ext2 sd_mod e1000" \
-f initramfs.server $KVERSION || return 1