Compare commits

..

108 Commits
0.4 ... 0.7

Author SHA1 Message Date
Harald Hoyer
21007cb6ec version 0.7 2009-07-25 11:09:35 +02:00
Harald Hoyer
31f7db66a8 strip binaries in initramfs
--strip
              strip binaries in the initramfs (default)

       --nostrip
              do not strip binaries in the initramfs
2009-07-25 11:09:35 +02:00
Harald Hoyer
4f18fe8296 dracut/dracut-gencmdline: fixed copyright header 2009-07-25 11:09:35 +02:00
Harald Hoyer
5494f08cc5 add dracut-catimages
Usage: ./dracut-catimages [OPTION]... <initramfs> <base image>
[<image>...]
Creates initial ramdisk image by concatenating several images from the
command
line and /boot/dracut/

  -f, --force           Overwrite existing initramfs file.
  -i, --imagedir        Directory with additional images to add
                        (default: /boot/dracut/)
  -o, --overlaydir      Overlay directory, which contains files that
                        will be used to create an additional image
  --nooverlay           Do not use the overlay directory
  --noimagedir          Do not use the additional image directory
  -h, --help            This message
  --debug               Output debug information of the build process
  -v, --verbose         Verbose output during the build process
2009-07-25 11:09:35 +02:00
Harald Hoyer
c1a37d928f dracut-lib: getarg(), getargs() read command line also from /etc/cmdline
Also honor parameters in /etc/cmdline.

getarg(): If the argument is first fround in /proc/cmdline, then it is
used
2009-07-25 11:09:35 +02:00
Harald Hoyer
0375106c78 add source_conf for static configuration variables
source_conf sources all *.conf files of a directory

init will now source all /etc/conf.d/*.conf files
2009-07-25 11:09:34 +02:00
Harald Hoyer
2b9dfbbeae dracut: usage(): break line for 80 chars 2009-07-25 11:09:34 +02:00
Warren Togami
47b5c0f290 With NFS root, it is possible /tmp/net.ifaces might not exist during pre-pivot.
- udevadm settle will wait for it if necessary.
- Move write-ifcfg.sh later during pre-pivot to reduce likelihood of settling being necessary.
2009-07-24 15:26:33 -04:00
Harald Hoyer
4e6d8fd691 dracut.8: correct manpage entry for ip= 2009-07-24 12:06:12 +02:00
Harald Hoyer
34a369ed2d dracut.8: corrections of parameters and fixed typos 2009-07-24 11:54:08 +02:00
Harald Hoyer
3e6d2b31ea removed all direct references to /proc/cmdline
use getarg() and getargs() from /lib/dracut-lib.sh instead of
reinventing the wheel
2009-07-24 11:54:08 +02:00
Harald Hoyer
13beb248bc dracut: print help for unknow options 2009-07-24 11:54:08 +02:00
Harald Hoyer
b03edf372f 40network/parse-bridge: add bridge to $initrdargs 2009-07-24 11:54:08 +02:00
David Dillow
e663608c40 dash compatible substitution 2009-07-23 23:16:31 -04:00
Warren Togami
ef380e9de8 Turns out this is really a misconfigured DHCP server, apply the same workaround as Debian and upstream dhclient-script. 2009-07-23 16:22:00 -04:00
Warren Togami
39f3a51d65 Fix multiple search domains with proper quoting (thanks dcbw)
Otherwise \032 appears instead of spaces.
2009-07-23 14:31:58 -04:00
Harald Hoyer
4809126378 99base/init: fix argument stripping 2009-07-23 18:57:20 +02:00
Harald Hoyer
6c4b24afb0 nfsroot-cleanup: don't try to read from nonexistant /tmp/nfs.rpc_pipefs_path 2009-07-23 18:27:33 +02:00
Harald Hoyer
c1b2cc48d6 40network/check: source dracut-functions over exported variable 2009-07-23 18:20:11 +02:00
Michael Ploujnikov
fdb3d52d59 use a variable to hold the regex
single quote regexps in variables to make it work with bash-3.1
2009-07-23 15:33:40 +02:00
Michael Ploujnikov
d726d811f1 fix spelling use the modules.d directory name 2009-07-23 15:21:18 +02:00
Marc Grimme
2fe2945869 nfsroot-cleanup: make /var/lib/nfs/rpc_pipefs path configurable
/tmp/nfs.rpc_pipefs_path can contain the path where
/var/lib/nfs/rpc_pipefs will be moved before switch_root.

This is useful if /var is a separate partition in the real root.
2009-07-23 12:19:54 +02:00
Marc Grimme
f016dccc89 95debug: optionally install the debug tools 2009-07-23 12:19:17 +02:00
Marc Grimme
c993cfb32f 40network/check: output which binary is missing for the network module 2009-07-23 12:17:57 +02:00
Marc Grimme
9aaf7c3a33 dracut_install: add "-o" option
Calling dracut_install will optionally install the file. This is useful
for the debug module.
2009-07-23 12:15:54 +02:00
Harald Hoyer
0e77eb3782 dmraid/mdraid: only try to delete partition 1-1024
add "--nr 1-1024" to partx, otherwise partx will try to delete
partitions 1-INT_MAX, which takes a long time.
2009-07-23 11:58:24 +02:00
Harald Hoyer
93ce0a7a1c 95s390: add support to boot from s390 dasds
command line parameter:

DASD
       dasd=....
              same syntax as the kernel module parameter (s390 only)
2009-07-22 16:35:49 +02:00
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
91 changed files with 2304 additions and 297 deletions

View File

@@ -1,4 +1,4 @@
VERSION=0.4
VERSION=0.7
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
prefix = /usr
@@ -22,6 +22,8 @@ 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 dracut-catimages $(DESTDIR)$(sbindir)/dracut-catimages
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 +35,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 +49,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 +64,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

2
README
View File

@@ -21,7 +21,7 @@ as hooks are guaranteed to be the path to slow-down.
Most of the initrd generation functionality in dracut is provided by a bunch
of generator modules that are sourced by the main dracut script to install
specific functionality into the initrd. They live in the modules subdirectory,
specific functionality into the initrd. They live in the modules.d subdirectory,
and use functionality provided by dracut-functions to do their work.
Some general rules for writing modules:
* Use one of the inst family of functions to actually install files

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

@@ -16,7 +16,7 @@ dracut_install_dir/modules.d/
it easy for an earlier module to override the functionality of a
later module, so that you can have a distro or system specific
module override or modify the functionality of a generic module
without having to patch the mode generic module.
without having to patch the more generic module.
install: dracut sources this script to install the functionality that a
module implements onto the initrd. For the most part, this amounts
@@ -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.

92
dracut
View File

@@ -5,8 +5,21 @@
# of the various mkinitrd implementations out there
#
# Copyright 2008, Red Hat, Inc. Jeremy Katz <katzj@redhat.com>
# GPLv2 header here
# 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
# 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/>.
#
usage() {
@@ -22,6 +35,14 @@ 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
--strip Strip binaries in the initramfs (default)
--nostrip Do not strip binaries in the initramfs
-h, --help This message
--debug Output debug information of the build process
-v, --verbose Verbose output during the build process
@@ -48,6 +69,12 @@ 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";;
--strip) do_strip_l="yes";;
--nostrip) do_strip_l="no";;
-h|--help) usage; exit 1 ;;
--debug) debug="yes";;
-v|--verbose) beverbose="yes";;
@@ -56,6 +83,7 @@ while (($# > 0)); do
-H|--hostonly) hostonly="-h" ;;
-i|--include) include_src="$2"; include_target="$3"; shift 2;;
-I|--install) install_items="$2"; shift;;
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
*) break ;;
esac
shift
@@ -79,7 +107,12 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
[[ $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
[[ $do_strip_l ]] && do_strip=$do_strip_l
[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
[[ $fw_dir ]] || fw_dir=/lib/firmware
[[ $do_strip ]] || do_strip=yes
[[ $allowlocal && -f "$(dirname $0)/dracut-functions" ]] && dsrc="$(dirname $0)" || dsrc=$dracutbasedir
@@ -102,6 +135,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
@@ -115,12 +152,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.
@@ -130,7 +170,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
@@ -162,6 +209,35 @@ unset item
[[ "$beverbose" = "yes" ]] && (du -c "$initdir" | sort -n)
# strip binaries
if [ "$do_strip" = "yes" ] ; then
for p in strip objdump sed grep find; do
if ! which $p >/dev/null 2>&1; then
derror "Could not find '$p'. You should run $0 with '--nostrip'."
do_strip=no
fi
done
fi
if [ "$do_strip" = "yes" ] ; then
for f in $(find "$initdir" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; |
grep -v ' shared object,' |
sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped/\1/p'); do
dinfo "Stripping $f"
strip -g "$f" || :
#
# FIXME: only strip -g for now
#
#strip -g --strip-unneeded "$f" || :
#note="-R .note"
#if objdump -h $f | grep '^[ ]*[0-9]*[ ]*.note[ ]' -A 1 | \
# grep -q ALLOC; then
# note=
#fi
#strip -R .comment $note "$f" || :
done
fi
( cd "$initdir"; find . |cpio -H newc -o |gzip -9 > "$outfile"; )
[[ "$beverbose" = "yes" ]] && ls -lh "$outfile"

124
dracut-catimages Executable file
View File

@@ -0,0 +1,124 @@
#!/bin/bash --norc
# Copyright 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
# 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/>.
#
dwarning() {
echo "Warning: $@" >&2
}
dinfo() {
[[ $beverbose ]] && echo "$@" >&2
}
derror() {
echo "Error: $@" >&2
}
usage() {
# 80x25 linebreak here ^
echo "Usage: $0 [OPTION]... <initramfs> <base image> [<image>...]
Creates initial ramdisk image by concatenating several images from the command
line and /boot/dracut/
-f, --force Overwrite existing initramfs file.
-i, --imagedir Directory with additional images to add
(default: /boot/dracut/)
-o, --overlaydir Overlay directory, which contains files that
will be used to create an additional image
--nooverlay Do not use the overlay directory
--noimagedir Do not use the additional image directory
-h, --help This message
--debug Output debug information of the build process
-v, --verbose Verbose output during the build process
"
}
imagedir=/boot/dracut/
overlay=/var/lib/dracut/overlay
while (($# > 0)); do
case $1 in
-f|--force) force=yes;;
-i|--imagedir) imagedir=$2;shift;;
-o|--overlaydir) overlay=$2;shift;;
--nooverlay) no_overlay=yes;shift;;
--noimagedir) no_imagedir=yes;shift;;
-h|--help) usage; exit 1 ;;
--debug) debug="yes";;
-v|--verbose) beverbose="yes";;
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
*) break ;;
esac
shift
done
outfile=$1; shift
if [ -z "$outfile" ]; then
derror "No output file specified."
usage
exit 1
fi
baseimage=$1; shift
if [ -z "$baseimage" ]; then
derror "No base image specified."
usage
exit 1
fi
if [ -f $outfile -a -z "$force" ]; then
derror "Will not override existing initramfs ($outfile) without --force"
exit 1
fi
if [ -z "$no_imagedir" -a ! -d "$imagedir" ]; then
derror "Image directory $overlay is not a directory"
exit 1
fi
if [ -z "$no_overlay" -a ! -d "$overlay" ]; then
derror "Overlay $overlay is not a directory"
exit 1
fi
if [ -z "$no_overlay" ]; then
ofile="$imagedir/90-overlay.img"
dinfo "Creating image $ofile from directory $overlay"
( cd "$overlay"; find . |cpio --quiet -H newc -o |gzip -9 > "$ofile"; )
fi
if [ -z "$no_imagedir" ]; then
images=$(for i in $imagedir/*.img;do [ -f $i ] || continue; echo $i; done)
fi
images="$images $@"
dinfo "Using base image $baseimage"
cat $baseimage > $outfile
for i in $images; do
dinfo "Appending $i"
cat $i >> $outfile
done
dinfo "Created $outfile"
exit 0

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=""
@@ -111,11 +107,13 @@ inst_binary() {
derror "dracut cannot create an initrd."
exit 1
fi
[[ $line =~ ([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*) ]] || continue
so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
[[ $line =~ $so_regex ]] || continue
FILE=${BASH_REMATCH[1]}
[[ -f ${initdir}$FILE ]] && continue
# see if we are loading an optimized version of a shared lib.
if [[ $FILE =~ ^(/lib[^/]*).* ]]; then
lib_regex='^(/lib[^/]*).*'
if [[ $FILE =~ $lib_regex ]]; then
TLIBDIR=${BASH_REMATCH[1]}
BASE="${FILE##*/}"
# prefer nosegneg libs, then unoptimized ones.
@@ -141,7 +139,8 @@ inst_script() {
read -r -n 80 line <"$1"
# If debug is set, clean unprintable chars to prevent messing up the term
[[ $debug ]] && line=$(echo -n "$line" | tr -c -d '[:print:][:space:]')
[[ $line =~ (#! *)(/[^ ]+).* ]] || return 1
shebang_regex='(#! *)(/[^ ]+).*'
[[ $line =~ $shebang_regex ]] || return 1
inst "${BASH_REMATCH[2]}" && inst_simple "$@"
}
@@ -204,12 +203,25 @@ inst_hook() {
}
dracut_install() {
local optional=
while (($# > 0)); do
# Might be nice to optionally install a binary
if [ "$1" == "-o" ]; then
optional="yes"
shift
continue
fi
if inst "$1" ; then
shift
continue
fi
derror "Failed to install $1"; exit 1
if [ "$optional" == "yes" ]; then
dwarning "Skipping program $1 as it cannot be found and is flagged to be optional"
shift
continue
else
derror "Failed to install $1"; exit 1
fi
done
}
@@ -238,6 +250,10 @@ check_module_deps() {
should_source_module() {
local dep
[[ -x $1/install ]] || return 1
if [[ "$kernel_only" = "yes" ]]; then
[[ -x $1/installkernel ]] && return 0
return 1
fi
[[ -x $1/check ]] || return 0
"$1/check" $hostonly || return 1
for dep in $("$1/check" -d); do
@@ -266,8 +282,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 +311,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 +321,20 @@ instmods() {
dinfo "Installing dependencies for $mod ($modpath)"
instmods $mpargs $modname
fi
inst_simple "$modpath"
done
for fw in $(modinfo -F firmware $mod 2>/dev/null); do
if [[ -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

699
dracut-gencmdline Executable file
View File

@@ -0,0 +1,699 @@
#!/bin/bash --norc
#
# 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
# 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

@@ -30,6 +30,24 @@ add a space-separated list of dracut modules.
.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 \-\-strip
strip binaries in the initramfs (default)
.TP
.BR \-\-nostrip
do not strip binaries in the initramfs
.TP
.BR \-h ", " \-\-help
display help text and exit.
.TP
@@ -78,6 +96,72 @@ 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 DASD
.TP
.B dasd=....
same syntax as the kernel module parameter (s390 only)
.SH DHCP
.TP
.B root=dhcp
@@ -151,13 +235,13 @@ This syntax is only usable in cases where you are directly mounting the volume a
.TP bootdev=<interface>
.B specify the network interface to boot from
.TP
.B ip=[dhcp|on|any]
.B ip={dhcp|on|any}
get ip from dhcp server from all interfaces. If root=dhcp, loop sequentially through all interfaces (eth0, eth1, ...) and use the first with a valid DHCP root-path.
.TP
.B ip=<interface>:[dhcp|on|any]
.B ip=<interface>:{dhcp|on|any}
get ip from dhcp server on a specific interface
.TP
.B ip=<client-IP-number>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|]
.B ip=<client-IP-number>:[<server-id>]:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:{none|off}
explicit network configuration
.SH Misc
@@ -168,13 +252,16 @@ do not load kernel module <drivername>
.SH Debug
.TP
.B rdshell
drop to a shell, if the imitramfs fails
allow dropping to a shell, if root mounting fails
.TP
.B rdinitdebug
set -x for the dracut shell
.TP
.B rdbreak=[pre-udev|pre-mount|mount|pre-pivot|]
drop the shell on defined breakpoint
.B rdbreak
drop to a shell at the end
.TP
.B rdbreak={pre-udev|pre-mount|mount|pre-pivot|commandline|initqueue}
drop to a shell on defined breakpoint
.TP
.B rdudevinfo
set udev to loglevel info

View File

@@ -12,7 +12,7 @@
%endif
Name: dracut
Version: 0.4
Version: 0.7
Release: 1%{?rdist}
Summary: Initramfs generator using udev
Group: System Environment/Base
@@ -38,6 +38,7 @@ Requires: filesystem >= 2.1.0, cpio, device-mapper, initscripts >= 8.63-1
Requires: e2fsprogs >= 1.38-12, libselinux, libsepol, coreutils
Requires: mdadm, elfutils-libelf, plymouth >= 0.7.0
Requires: cryptsetup-luks
Requires: bridge-utils
%ifnarch s390 s390x
Requires: dmraid
Requires: kbd
@@ -51,24 +52,43 @@ BuildArch: noarch
%description
dracut is a new, event-driven initramfs infrastructure based around udev.
%package generic
Summary: Metapackage to build a generic initramfs
Summary: Metapackage to build a generic initramfs with dracut
Requires: %{name} = %{version}-%{release}
Requires: rpcbind nfs-utils
Requires: iscsi-initiator-utils
Requires: nbd
Requires: net-tools iproute
Requires: kernel-firmware
Requires: plymouth-system-theme plymouth-theme-charge plymouth-theme-solar
%description generic
This package requires everything which is needed to build a generic
all purpose initramfs with dracut.
%package kernel
Summary: Metapackage to build generic initramfs with dracut with only kernel modules
Requires: %{name} = %{version}-%{release}
Requires: ql2100-firmware
Requires: ql2200-firmware
Requires: ql23xx-firmware
Requires: ql2400-firmware
Requires: ql2500-firmware
%description generic
This package requires everything which is needed to build a generic
all purpose initramfs.
%description kernel
This package requires everything which is needed to build a initramfs with all
kernel modules and firmware files needed by dracut modules.
%package tools
Summary: dracut tools to build the local initramfs
Requires: %{name} = %{version}-%{release}
Requires: ql2100-firmware
Requires: ql2200-firmware
Requires: ql23xx-firmware
Requires: ql2400-firmware
Requires: ql2500-firmware
%description tools
This package contains tools to assemble the local initrd and host configuration.
%prep
%setup -q -n %{name}-%{version}%{?dashgittag}
@@ -85,6 +105,9 @@ make install DESTDIR=$RPM_BUILD_ROOT sbindir=/sbin sysconfdir=/etc mandir=%{_man
rm -f $RPM_BUILD_ROOT/sbin/switch_root
%endif
mkdir -p $RPM_BUILD_ROOT/boot/dracut
mkdir -p $RPM_BUILD_ROOT/var/lib/dracut/overlay
%clean
rm -rf $RPM_BUILD_ROOT
@@ -105,7 +128,29 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,0755)
%doc README.generic
%files kernel
%defattr(-,root,root,0755)
%doc README.kernel
%files tools
%defattr(-,root,root,0755)
%doc COPYING
/sbin/dracut-gencmdline
/sbin/dracut-catimages
%dir /boot/dracut
%dir /var/lib/dracut
%dir /var/lib/dracut/overlay
%changelog
* Fri Jul 24 2009 Harald Hoyer <harald@redhat.com> 0.7-1
- version 0.7
* 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

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,19 @@
#!/bin/sh
which ip dhclient hostname >/dev/null 2>&1 || exit 1
. $dracutfunctions
for program in ip hostname; do
which $program >/dev/null 2>&1
if [ $? -ne 0 ]; then
dwarning "Could not find program \"$program\" required by network."
exit 1
fi
done
for program in dhclient brctl; do
which $program >/dev/null 2>&1
if [ $? -ne 0 ]; then
dwarning "Could not find program \"$program\" it might be required by network."
fi
done
exit 255

View File

@@ -7,7 +7,7 @@ setup_interface() {
bcast=$new_broadcast_address
gw=${new_routers%%,*}
domain=$new_domain_name
search=$new_domain_search
search=$(printf "$new_domain_search")
namesrv=$new_domain_name_servers
hostname=$new_host_name
@@ -23,7 +23,7 @@ setup_interface() {
[ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
[ -n "${search}${domain}" ] && echo search $search $domain > /tmp/net.$netif.resolv.conf
[ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
if [ -n "$namesrv" ] ; then
for s in $namesrv; do
echo nameserver $s

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,16 +85,23 @@ 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;
# Specific configuration, spin through the kernel command line
# looking for ip= lines
[ "$CMDLINE" ] || read CMDLINE </proc/cmdline;
for p in $CMDLINE; do
[ -n "${p%ip=*}" ] && continue
ip_to_var ${p#ip=}
for p in $(getargs ip=); do
ip_to_var $p
# If this option isn't directed at our interface, skip it
[ -n "$dev" ] && [ "$dev" != "$netif" ] && continue

View File

@@ -1,27 +1,17 @@
#!/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
# go into its own module at one time
inst_hook pre-pivot 20 "$moddir/write-ifcfg.sh"
inst_hook pre-pivot 85 "$moddir/write-ifcfg.sh"
mkdir -p "${initdir}/var/run"

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,6 +14,11 @@ 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=')

View File

@@ -0,0 +1,54 @@
#!/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
initrdargs="$initrdargs bridge"
# 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,18 +45,16 @@ 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
# Count ip= lines to decide whether we need bootdev= or not
if [ -z "$NEEDBOOTDEV" ] ; then
[ "$CMDLINE" ] || read CMDLINE < /proc/cmdline
local count=0
for p in $CMDLINE; do
[ "${p%%=*}" = "ip" ] && count=$(( $count + 1 ))
for p in $(getargs ip=); do
count=$(( $count + 1 ))
done
[ $count -gt 1 ] && NEEDBOOTDEV=1
fi
@@ -69,11 +67,8 @@ fi
# Check ip= lines
# XXX Would be nice if we could errorcheck ip addresses here as well
[ "$CMDLINE" ] || read CMDLINE < /proc/cmdline
for p in $CMDLINE; do
[ -n "${p%ip=*}" ] && continue
ip_to_var ${p#ip=}
for p in $(getargs ip=); do
ip_to_var $p
# We need to have an ip= line for the specified bootdev
[ -n "$NEEDBOOTDEV" ] && [ "$dev" = "$BOOTDEV" ] && BOOTDEVOK=1
@@ -86,28 +81,28 @@ for p in $CMDLINE; do
# Error checking for autoconf in combination with other values
case $autoconf in
error) die "Error parsing option '$p'";;
error) die "Error parsing option 'ip=$p'";;
bootp|rarp|both) die "Sorry, ip=$autoconf is currenty unsupported";;
none|off) \
[ -z "$ip" ] && \
die "For argument '$p'\nValue '$autoconf' without static configuration does not make sense"
die "For argument 'ip=$p'\nValue '$autoconf' without static configuration does not make sense"
[ -z "$mask" ] && \
die "Sorry, automatic calculation of netmask is not yet supported"
;;
dhcp|on|any) \
[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
die "Sorry, '$p' does not make sense for multiple interface configurations"
die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"
[ -n "$ip" ] && \
die "For argument '$p'\nSorry, setting client-ip does not make sense for '$autoconf'"
die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoconf'"
;;
*) die "For argument '$p'\nSorry, unknown value '$autoconf'";;
*) die "For argument 'ip=$p'\nSorry, unknown value '$autoconf'";;
esac
if [ -n "$dev" ] ; then
# We don't like duplicate device configs
if [ -n "$IFACES" ] ; then
for i in $IFACES ; do
[ "$dev" = "$i" ] && die "For argument '$p'\nDuplication configurations for '$dev'"
[ "$dev" = "$i" ] && die "For argument 'ip=$p'\nDuplication configurations for '$dev'"
done
fi
# IFACES list for later use
@@ -143,4 +138,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

@@ -1,16 +1,21 @@
#!/bin/sh
# NFS root might have reached here before /tmp/net.ifaces was written
udevadm settle --timeout=30
# Don't write anything if we don't know our bootdev
[ -f /tmp/net.ifaces ] || return 1
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 +27,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,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 --onetime /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

@@ -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 --nr 1-1024 $env{DEVNAME}"
LABEL="dm_end"

View File

@@ -1,12 +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", GOTO="dm_end"
ACTION!="add|change", GOTO="dm_end"
ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="dm_end"
ENV{ID_FS_TYPE}=="*_raid_member", RUN+="/sbin/initqueue /sbin/dmraid_scan \$0"
LABEL="dm_end"

View File

@@ -1,8 +1,26 @@
#!/bin/sh
if udevadm settle --timeout=0 >/dev/null 2>&1; then
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
dmraid -ay -Z
[ -e "$job" ] && rm -f "$job"
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,5 +1,5 @@
#!/bin/bash
dracut_install dmraid
dracut_install dmraid partx
inst "$moddir/dmraid.sh" /sbin/dmraid_scan
inst_rules 64-md-raid.rules
inst_rules "$moddir/61-dmraid.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 --nr 1-1024 $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

View File

@@ -1,3 +1,3 @@
#!/bin/bash
dracut_install ln ps grep more cat rm strace free showmount
dracut_install ping netstat rpcinfo
dracut_install -o ps grep more cat rm strace free showmount
dracut_install -o 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

@@ -30,10 +30,7 @@ fi
netif="$1"
root="$2"
# read static conf settings
for conf in conf/conf.d/*; do
[ -f ${conf} ] && . ${conf}
done
source_all /etc/conf.d
# If it's not iscsi we don't continue
[ "${root%%:*}" = "iscsi" ] || exit 1
@@ -122,7 +119,10 @@ echo "InitiatorName='$iscsi_initiator'" > /dev/.initiatorname.iscsi
# FIXME $iscsi_protocol??
echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > /mount/01-$$-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 \
@@ -132,6 +132,12 @@ iscsistart -i $iscsi_initiator -t $iscsi_target_name \
${iscsi_in_username+-U $iscsi_in_username} \
${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=
exit 0

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,17 +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=="nbd0", SYMLINK+="root"\n'> /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

@@ -1,3 +1,6 @@
[ -f /tmp/nfs.rpc_pipefs_path ] && rpcpipefspath=`cat /tmp/nfs.rpc_pipefs_path`
[ -z "$rpcpipefspath" ] && rpcpipefspath=var/lib/nfs/rpc_pipefs
pid=$(pidof rpc.statd)
[ -n "$pid" ] && kill $pid
@@ -9,10 +12,10 @@ pid=$(pidof rpcbind)
if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then
# try to create the destination directory
[ -d $NEWROOT/var/lib/nfs/rpc_pipefs ] || mkdir -p $NEWROOT/var/lib/nfs/rpc_pipefs 2>/dev/null
[ -d $NEWROOT/$rpcpipefspath ] || mkdir -p $NEWROOT/$rpcpipefspath 2>/dev/null
if [ -d $NEWROOT/var/lib/nfs/rpc_pipefs ]; then
mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/var/lib/nfs/rpc_pipefs
if [ -d $NEWROOT/$rpcpipefspath ]; then
mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/$rpcpipefspath
else
umount /var/lib/nfs/rpc_pipefs
fi

View File

@@ -1,5 +1,4 @@
#!/bin/sh
dracut_install ln
inst_hook cmdline 95 "$moddir/parse-block.sh"
inst_hook pre-udev 30 "$moddir/block-genrules.sh"
inst_hook mount 99 "$moddir/mount-root.sh"

5
modules.d/95s390/check Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
arch=$(arch)
[ "$arch" = "s390" -o "$arch" = "s390x" ] || exit 1
exit 0

3
modules.d/95s390/install Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
inst_hook cmdline 30 "$moddir/parse-s390.sh"

5
modules.d/95s390/installkernel Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
instmods dasd_mod dasd_eckd_mod dasd_fba_mod \
zfcp

9
modules.d/95s390/parse-s390.sh Executable file
View File

@@ -0,0 +1,9 @@
initrdargs="$initrdargs dasd"
[ -d /etc/modprobe.d ] || mkdir /etc/modprobe.d
dasd_arg=$(getarg dasd=)
if [ -n "$dasd_arg" ]; then
echo "option dasd_mod dasd=$dasd_arg" >> /etc/modprobe.d/dasd.conf
fi
unset dasd_arg

View File

@@ -1,6 +1,10 @@
getarg() {
local o line
[ "$CMDLINE" ] || read CMDLINE </proc/cmdline;
if [ -z "$CMDLINE" ]; then
read CMDLINE_ETC </etc/cmdline;
read CMDLINE </proc/cmdline;
CMDLINE="$CMDLINE $CMDLINE_ETC"
fi
for o in $CMDLINE; do
[ "$o" = "$1" ] && return 0
[ "${o%%=*}" = "${1%=}" ] && { echo ${o#*=}; return 0; }
@@ -8,20 +12,69 @@ getarg() {
return 1
}
getargs() {
local o line found
if [ -z "$CMDLINE" ]; then
read CMDLINE_ETC </etc/cmdline;
read CMDLINE </proc/cmdline;
CMDLINE="$CMDLINE $CMDLINE_ETC"
fi
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
for f in "/$1"/*.sh; do [ -f "$f" ] && . "$f"; done
}
source_conf() {
local f
[ "$1" ] && [ -d "/$1" ] || return
for f in "/$1"/*.conf; do [ -f "$f" ] && . "$f"; done
}
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

@@ -11,13 +11,14 @@ emergency_shell()
echo ; echo
echo $@
source_all emergency
if getarg rdshell; then
echo ; echo
echo "Dropping to a shell. Good luck!"
echo
if getarg rdshell || getarg rdbreak; then
echo "Dropping to debug shell."
echo
sh -i
else
while :; do sleep 1;done
echo "Boot has failed, sleeping forever."
while :; do sleep 365d;done
fi
}
@@ -58,6 +59,8 @@ mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1
UDEVVERSION=$(udevadm --version)
source_conf /etc/conf.d
# run scriptlets to parse the command line
getarg 'rdbreak=cmdline' && emergency_shell "Break before cmdline"
source_all cmdline
@@ -81,14 +84,26 @@ 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
getarg 'rdbreak=initqueue' && emergency_shell "Break before initqueue"
i=0
while :; do
# bail out, if we have mounted the root filesystem
@@ -102,6 +117,12 @@ while :; do
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
@@ -120,7 +141,7 @@ while :; do
[ -n "$queuetriggered" ] && continue
if udevadm settle --timeout=0 >/dev/null 2>&1; then
if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
# no more udev jobs
sleep 0.5
i=$(($i+1))
@@ -154,7 +175,7 @@ while :; do
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.
@@ -168,7 +189,7 @@ done
emergency_shell
}
getarg rdbreak && emergency_shell
getarg rdbreak && emergency_shell "Break before switch_root"
HARD=""
while pidof udevd >/dev/null 2>&1; do
@@ -187,15 +208,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 2
done
initargs="$initargs $x"
done

View File

@@ -1,6 +1,6 @@
#!/bin/bash
dracut_install mount mknod mkdir modprobe pidof sleep chroot \
sed ls flock cp mv dmesg rm
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

@@ -1,10 +1,5 @@
#!/bin/sh
if getarg rdblacklist= >/dev/null ; then
[ "$CMDLINE" ] || read CMDLINE < /proc/cmdline
for p in $CMDLINE; do
[ -n "${p%rdblacklist=*}" ] && continue
echo "blacklist ${p#rdblacklist=}" >> /etc/modprobe.d/initramfsblacklist.conf
done
fi
for p in $(getargs rdblacklist=); do
echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf
done

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)}

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

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

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

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