Compare commits

...

140 Commits
013 ... 014

Author SHA1 Message Date
Harald Hoyer
ef8b121e2c version 014 2011-12-15 09:19:05 +01:00
Harald Hoyer
76bba2a1fc dracut.spec: only apply patches, if there are any 2011-12-15 09:19:05 +01:00
Harald Hoyer
45abddb069 renamed dracut.kernel.7 to dracut.cmdline.7 2011-12-15 09:19:04 +01:00
Harald Hoyer
f74775ba1c 99fs-lib/fs-lib.sh: handle nfs as nop
handle fstype=nfs for fsck and let it be a nop
2011-12-15 08:54:49 +01:00
Harald Hoyer
1939a4f96e 99fs-lib/fs-lib.sh: accept "UUID=" and "LABEL=" for fsck_single
with the reuse of crypt-lib.sh devnames() and putting it in
dracut-lib.sh, fsck_single() can use more generic names from /etc/fstab
2011-12-15 08:54:48 +01:00
Harald Hoyer
452e46dbfc 90mdraid/mdraid-waitclean.sh: add rd.md.waitclean parameter
add rd.md.waitclean parameter, which defaults to 0
https://bugzilla.redhat.com/show_bug.cgi?id=759148
2011-12-02 13:03:02 +01:00
Colin Guthrie
7eb8797b81 Fix /usr mounting due to variable name typo 2011-12-02 13:03:01 +01:00
Harald Hoyer
ed919de0a7 dracut.spec: move sbindir from /sbin to /usr/bin
https://fedoraproject.org/wiki/Features/UsrMove
2011-12-02 13:03:01 +01:00
Harald Hoyer
c5a6599080 Makefile, dracut.spec: move dracut to /usr/lib/dracut
Move dracut to /usr/lib/dracut.
We should not have picked /usr/share/dracut. Dracut is no ordinary "data".
2011-12-02 13:03:00 +01:00
Harald Hoyer
a9e8ca4ab4 git2spec.pl: strip path from patches 2011-11-17 11:03:08 +01:00
Harald Hoyer
a1abd64aff 90mdraid: wait for md devices to become clean
After assembling all devices, just wait for the raid devices to become
clean, before booting further.
2011-11-17 10:14:23 +01:00
Amadeusz Żołnowski
2799897ad8 Makefile: Append target files names for man pages.
Edited-By: harald@redhat.com: removed trailing whitespace
2011-11-16 15:32:07 +01:00
Harald Hoyer
191f6945ac test: moved TEST-14-IMSM to old.TEST-14-IMSM
TEST-14-IMSM does not work anymore in qemu instances
2011-11-16 14:05:57 +01:00
Harald Hoyer
0be1785aea test: introduce $TESTDIR tmpdir
to keep the git source tree clean, test files are now created in a
$TESTDIR created with mktemp.
2011-11-16 14:04:27 +01:00
Harald Hoyer
bf7487ab18 90dmsquash-live: wait for the /dev/mapper/live-rw device
wait for the /dev/mapper/live-rw device
2011-11-16 14:03:38 +01:00
Harald Hoyer
4e05cb4023 cryptroot-ask.sh: use key file, if specified in crypttab and present
if a key file is specified in crypttab and present in the initramfs use
it to open the device.

https://bugzilla.redhat.com/show_bug.cgi?id=751640
2011-11-16 11:42:09 +01:00
Harald Hoyer
dd03dea22e 90mdraid: remove mdadm_auto.sh completly
remove mdadm_auto.sh completly, because "mdadm -As --auto=yes" does not
add new appearing devices.
2011-11-16 10:50:21 +01:00
Harald Hoyer
0ec40e08d5 dracut: add install_items to dracut.conf
install_items+=" <file>[ <file> ...] "

    Specify additional files to include in the initramfs, separated by
    spaces.
2011-11-15 17:13:40 +01:00
Harald Hoyer
d1b7efd578 40network/ifup: add "brd +" to "ip addr add"
Unlike "ifconfig", the "ip" command does not set a broadcast address
unless explicitly requested.

add "brd +" to make "ip" calculate the broadcast address on the fly
2011-11-15 11:54:14 +01:00
Harald Hoyer
d00f97a7db 40network: check for brctl
if a bridge is configured on the kernel command line and brctl is
missing call die()
2011-11-15 09:47:29 +01:00
Harald Hoyer
7e800bfffc 99base/dracut-lib.sh: wait_for_if_up() extend wait time
Some NICs take longer than 2 seconds to ifup. Wait a little bit longer
now (20s).
2011-11-15 09:47:29 +01:00
Harald Hoyer
f6783bee07 95fcoe: support bnx2fc
To start bnx2fc, we need to run fipvlan only and not dcbtool.  DCBX is run
automatically in the hardware, but VLAN discovery needs to be started by
fipvlan.

https://bugzilla.redhat.com/show_bug.cgi?id=736094
2011-11-15 09:47:28 +01:00
Harald Hoyer
760dcc6a65 lvm, dm, dmraid: cleanup, which module installs what
The dm module, which lvm and dmraid depend on, installed dmraid
shared libs. The lvm module installed udev rules, which were
already installed by the dm module.
Cleaned up those issues.
2011-11-15 09:47:28 +01:00
Harald Hoyer
2e1b9171bf 02fips-aesni: add fips with aesni-intel
add this dracut module, if you want to start in FIPS mode with
the aesni-intel kernel module
2011-11-15 09:47:26 +01:00
Harald Hoyer
ef6900eb79 dracut: create var/log directory in the initramfs
https://bugzilla.redhat.com/show_bug.cgi?id=701864
2011-11-15 09:47:26 +01:00
Harald Hoyer
3fa9d4d717 95iscsi: add iscsiuio
install iscsiuio
start iscsiuio
stop iscsiuio before switching root
2011-11-15 09:47:25 +01:00
Harald Hoyer
ecf9496d17 95iscsi/parse-iscsiroot.sh: force load a lot of kernel modules
A lot of iSCSI driver are not autoloaded, so we have to manually
force load them.
2011-11-15 09:47:24 +01:00
Harald Hoyer
50acb19719 95iscsi/iscsiroot: use initiator-name from ibft firmware if unset
If initiator-name is unset, try to read it from the ibft firmware.
2011-11-15 09:47:23 +01:00
Harald Hoyer
745af91663 dracut-lib.sh: add killproc() 2011-11-15 09:47:22 +01:00
Harald Hoyer
87af1cba3c 50plymouth/plymouth-pretrigger.sh: respect primary console setting
The kernel's primary console device is determined by the last "console="
argument on the kernel command line. This setting should be respected by
dracut-generated initial RAM disks.

Steps to Reproduce:
(Easiest using a KVM VM, virt-manager and "virsh console")
1. Boot with a kernel command line ending in
 console=tty0 console=ttyS0,115200
2. Observe both tty0 and ttyS0.

The output of init scripts is sent to ttyS0, as the final "console="
argument determines the primary console device as per
Documentation/serial-console.txt in the kernel sources.

https://bugzilla.redhat.com/show_bug.cgi?id=752073
2011-11-15 09:47:22 +01:00
Daniel Drake
ce335a0d5c 99base/init: avoid using cp -t
-t is not supported by busybox's cp.

Signed-off-by: Daniel Drake <dsd@laptop.org>
2011-11-15 09:47:20 +01:00
Harald Hoyer
01f896d38e dracut.spec: remove xen module 2011-11-15 09:47:20 +01:00
Harald Hoyer
9af39cbe31 Makefile, git2spec.pl: use temporary builddir
to build the dracut rpm, use a temporary builddir
2011-11-15 09:47:19 +01:00
Harald Hoyer
1133b5e07a 99fs-lib/module-setup.sh: only include fsck helper needed for hostonly
for the host-only initramfs, check all relevant disks for the
filesystem type and only include those fsck tools, which are needed.
2011-11-15 09:47:18 +01:00
Harald Hoyer
470ee2d214 99base/init, 98usrmount: mount /usr if found in /sysroot/etc/fstab
We cannot boot correctly without /usr, because of
http://www.freedesktop.org/wiki/Software/systemd/separate-usr-is-broken
so, we mount /usr readonly.
2011-11-15 09:47:17 +01:00
Harald Hoyer
b0692d0311 add wait_for_dev() and wait_for_mount() 2011-11-15 09:47:16 +01:00
Harald Hoyer
9549014694 fs-lib: install /etc/e2fsck.conf, if e2fsck is installed 2011-11-07 09:38:30 +01:00
Harald Hoyer
e696ade15d 90kernel-modules/module-setup.sh: include usb mass storage drivers 2011-11-07 09:38:30 +01:00
Brian C. Lane
03cec38834 inst_script should call inst_simple (#750603)
inst_script checks for a shebang, if it doesn't exist it exits.
If it does it should not be calling inst_binary, it should call
inst_simple like it used to.
2011-11-02 08:18:26 +01:00
Will Woods
03b5494ca1 apply-live-updates.sh: copy without glob
cp $SRC/* $DEST will skip dotfiles in $SRC.
( cd $SRC; cp -a -t $DEST . ) will copy everything.
2011-10-21 13:18:06 +02:00
Paolo Bonzini
028a79b8a1 remove the xen dracut module
The Xen module is unnecessary and it has been for a while.
Most Xen systems will not be using the module, even now, because
xen-detect is not installed by default on most Xen systems, and
dracut uses xen-detect to decide whether to include the module.

It also has some problems:

1) it does not try loading xen_platform_pci;

2) it loads modules unnecessarily; modules.alias is where all Xen support
should reside.  Assuming xenbus_probe_frontend and xen_platform_pci
are loaded so that Xen devices are probed, other modules are picked up
automatically thanks to aliases such as

    alias xen:vbd xen_blkfront

3) Even not-so-recent kernels (say 2.6.32) require the xen_platform_pci
and xenbus_probe_frontend modules even for non-paravirtualized guests.
60xen/module-setup.sh picks the module only for PV guests.

So, just require xenbus_probe_frontend to be builtin, and also
xen_platform_pci for fully-virtualized guests, and remove the module.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2011-10-21 13:18:06 +02:00
Harald Hoyer
7c3a7bd1f0 dracut.spec: require new util-linux version with new switch_root
new switch_root knows how to handle "/run"
2011-10-21 12:35:34 +02:00
Harald Hoyer
85cda6ae16 dracut.spec: apply patches with git
This will take all renames and mode changes.
2011-10-21 12:35:07 +02:00
Harald Hoyer
f60995adb4 dracut-functions:inst_script() call inst_binary() with found bin
call inst_binary() with the already found executable to prevent
searching for the binary again
2011-10-21 12:33:05 +02:00
Harald Hoyer
4637c5c242 dracut-functions: do not install files from current directory
Protect against relative pathnames without a slash for all inst_*()
functions.
2011-10-21 10:57:13 +02:00
Harald Hoyer
624c70d763 90livenet: do not install by default 2011-10-21 10:29:58 +02:00
Harald Hoyer
bfdc0eba0b 90dmsquash-live: do not install by default 2011-10-21 10:29:58 +02:00
Harald Hoyer
4f6eb791b4 90livenet/module-setup.sh: silence check for wget 2011-10-21 09:35:38 +02:00
Harald Hoyer
b01885338b dracut-functions: inst_dir() handle relative symlinks 2011-10-20 13:06:53 +02:00
Harald Hoyer
44cef0d563 dracut-logger: re-set debugging 2011-10-20 13:06:53 +02:00
Harald Hoyer
d73bbd57ee 90livenet: check() for wget 2011-10-20 13:06:53 +02:00
Michal Soltys
5259da1043 minor changes
- in 10i18n - do stty -iutf8 on non-utf8 consoles, for consistency with
  iutf8 on utf8 ones
- vim modeline in xml file

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-10-20 13:06:52 +02:00
Harald Hoyer
c2801d0938 99base/dracut-lib.sh: add /etc/cmdline/*.conf parsing
modules and overlay images can set default kernel command line
parameters in /etc/cmdline/*.conf in the initramfs.
2011-10-20 13:06:52 +02:00
Harald Hoyer
15a5dc5b89 99base/init: fix check for in kernel polling 2011-10-20 13:06:52 +02:00
Harald Hoyer
e2d92b5adf */module-setup.sh: turn off debugging for module search
turn off debugging for module search, because it clutters the debug log
2011-10-20 13:06:37 +02:00
Harald Hoyer
6f00044317 95udev-rules/module-setup.sh: correctly create udevd symlink 2011-10-20 13:06:34 +02:00
Harald Hoyer
d3be5a89e5 netroot: do not die, if arping failed 2011-10-19 14:24:07 +02:00
Michal Soltys
f8342dd5f2 check root candidates more carefully
This is from the following thread:

http://thread.gmane.org/gmane.linux.raid/35753/focus=35795

Additional tests + more specific info.

Signed-off-by: Michal Soltys <soltys@ziu.info>

[harald@redhat.com: usable_root(): relaxed check for root]
2011-10-19 14:23:54 +02:00
Will Woods
54ba7acba1 dmsquash-live: fix log message about root/liveroot 2011-10-18 17:13:50 +02:00
Will Woods
2cd4a8065a dracut-lib.sh: fix dropped backslashes in CMDLINE
The "read" shell builtin consumes backslashes, which is a problem if
your root device is something like "LABEL=Fedora\x2016".

Using "read -r" tells the shell to leave backslashes alone.
2011-10-18 17:13:48 +02:00
Michal Soltys
7e8228cf5a dracut: remove duplicate options
'-I' and '--fwdir' were both read_arg and push_arg, and the latter has
priority.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-10-18 11:33:56 +02:00
Michal Soltys
d239b550ce explicitly verify bash version
A simple check in main dracut script.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-10-11 09:37:02 +02:00
Michal Soltys
c32bda6bb9 bash3 compat patch
This patch replaces:

- {var}>... redirections with functionally identical eval construct +
  explicit FDs
- ^^ and ,, case modifiers with temporary shopt

This allows us to lower minimum required bash version
to at least 3.1 (with current code).

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-10-11 09:37:01 +02:00
Dave Young
61bc3bbc0e dracut.conf.5.xml: tag mismatch fix
build failed with:
xsltproc -o dracut.conf.5 -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl dracut.conf.5.xml
dracut.conf.5.xml:169: parser error : Opening and ending tag mismatch: para line 168 and listitem
        </listitem>

Fix it by change to </para> at the end

Signed-off-by: Dave Young <dyoung@redhat.com>
2011-10-11 09:37:01 +02:00
Harald Hoyer
450f5d6694 95udev-rules/module-setup.s: fixed symlink for udevd to initdir 2011-10-10 20:17:16 +02:00
Harald Hoyer
ffcfc0e432 dracut.*.xml: s/exisiting/existing/g 2011-10-10 11:55:52 +02:00
Michal Soltys
c44e3cb4e5 dracut-functions: conv/normalize minor corrections
mostly with reference to earlier commit:

- bash doesn't need unsetting locals
- make normalize_path() a bit faster, also make sure we remove all
  trailing slashes
- normalize paths before tests

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-10-10 11:54:26 +02:00
Michal Soltys
4c5da0157f manuals: add info about fs-lib (fsck) configuration
in dracut.8.xml & dracut.conf.5.xml

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-10-10 11:54:26 +02:00
Michal Soltys
25b45979f2 fs-lib: add ability to choose fsck tools
in dracut.conf:

fscks="<tools>"
nofscks="yes"

and similary on command line:

--fscks [LIST] (in addition to conf's, if defined there)
--nofscks

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-10-10 11:54:26 +02:00
Michal Soltys
77270329ba dracut.8: add missing lvmconf info
Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-10-10 11:54:25 +02:00
Michal Soltys
c1609dd497 convert_abs_rel() fixups
- IFS was not preserved, and modified value could leak to outside functions

- the '.' relative path should be returned for arguments such as /x/y/z
  /x/y - but not for $1 == $2 ones

- $1 == $2 is self-looping link, so it returns final component of its
  name

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-10-10 11:54:25 +02:00
Dave Young
88b3e00515 dracut: check mktemp return value
in slackware the default mktemp is not from coreutils.
A simply make in test directory mangled my rootfs due
to initdir is blank

Also mktemp could failed with other reason like ENOSPC or EPERM
2011-10-10 11:41:14 +02:00
WANG Cong
0c3a8dea88 update the documentation of '--[no]prefix'
In

commit fd786adcf5
Author: Harald Hoyer <harald@redhat.com>
Date:   Wed Apr 20 16:47:40 2011 +0200

    dracut: make prefix configurable

Harald changed the meaning of --prefix/--noprefix, but
forgot to update their documentation. This patch
fixes that.

Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
2011-10-07 10:13:17 +02:00
Harald Hoyer
e0f9ecc6a4 95udev-rules/module-setup.sh: also search in /lib/udev and /usr/lib/udev 2011-10-06 10:25:08 +02:00
Harald Hoyer
54ffd5447d 90mdraid/module-setup.sh: fixed sed arguments 2011-10-04 13:30:35 +02:00
Harald Hoyer
e0e9221e23 90mdraid/mdraid_start.sh: fix path to md sysfs 2011-10-04 13:06:33 +02:00
Harald Hoyer
77a57d5eaf order mdadm and lvm timeout operations 2011-10-04 13:03:45 +02:00
John Reiser
d23159a69c dracut [PATCH]es: parallelize block_module filter and net_module_filter
Filtering modules requires enough work that instmods() in the
next pipeline stage was rarely busy.  Parallelize the two
filters which do the most work.  Also fix a filename-vs-contents
mistake in net_module_filter.

--
John Reiser, jreiser@BitWagon.com

>From f4533a2ceca52c443ddebec01eeaa35d51c39c1b Mon Sep 17 00:00:00 2001
From: John Reiser <jreiser@BitWagon.com>
Date: Tue, 13 Sep 2011 17:41:43 -0700
Subject: [PATCH 1/3] Parallelize block_module_filter
2011-09-30 09:40:49 +02:00
John Reiser
9e103df45e dracut [PATCH] Parameter expansion occurs before command evaluation.
Bash shell expands all ${parameter} before evaluating a command.
For multiple declarations and assignments within the same 'local' command,
then new variables or new values that appear towards the left
do not affect parameter expansion towards the right.

--
John Reiser, jreiser@BitWagon.com

>From 507ad6f66fc66f868a9e5fdd3806e012c4022baa Mon Sep 17 00:00:00 2001
From: John Reiser <jreiser@BitWagon.com>
Date: Fri, 23 Sep 2011 07:37:43 -0700
Subject: [PATCH] Parameter expansion occurs before command evaluation.

${parameter} on the right is expanded before evaluating "local var=value"
on the left.
2011-09-30 09:40:49 +02:00
Michal Soltys
9fc3f04520 90mdraid: adjust /dev/md loops
Include '_' to also handle old partitionable arrays (pre-2.6.28).

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 17:34:51 +02:00
Michal Soltys
ae816bb6aa 90mdraid: more thorough 64-md-raid.rules edit
Catch more variations of incremental assembly.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 17:24:16 +02:00
Michal Soltys
db9b9f396e 90mdraid: check precisely for supported contaiers
ID_FS_TYPE can be much more than just ddf/imsm/linux raid member, so
do the proper checks.

This reverts certain changes from:
cf5891424e

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 17:14:42 +02:00
Harald Hoyer
08769b7f8a dracut-functions: inst_rules() add missing "" 2011-09-22 16:14:38 +02:00
Michal Soltys
f07aaccd06 99fs-lib: export FSTAB_FILE before fsck call
Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 15:53:51 +02:00
Amadeusz Żołnowski
7c14b3688c dracut: create /dev besides /proc, /sys and so
How it worked without it?  The issue only manifests itself with
initramfs integrated into kernel.
2011-09-22 15:53:50 +02:00
Harald Hoyer
69063507d4 dracut-logger: bail out early, if we don't have to log anything 2011-09-22 15:49:25 +02:00
Michal Soltys
cb28815405 str_replace() fix
Whitespace removal in:

	out="${out}${chop# }$r"

will damage certain strings, for example the following call:

	str_replace ' aax aaxaa' x y

would return 'aayaayaa' instead of ' aay aayaa'.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 15:46:11 +02:00
Harald Hoyer
76f5fa549c dracut-functions: inst_rules() do not check std dirs for abs path
if an absolute path is given, we should not check the standard udev rule
directories.
2011-09-22 15:43:34 +02:00
Harald Hoyer
662ed0a13f 99fs-lib/fs-lib.sh: fsck btrfs via mounting like xfs
btrfsck is only for manual repairing your filesystem
2011-09-22 15:37:28 +02:00
Harald Hoyer
75e8f476e7 TEST-40-NBD: relaxed check on ext3 filesystem options
onerror=continue does not seem to be displayed for new kernels
2011-09-22 15:37:27 +02:00
Michal Soltys
a025cc17f0 90mdraid: fix/adjust 65-md* rules and related scripts
Reworked the flow of the rules file a bit, removed redundant tests, also
should be easier to follow. It's much shorter now as well, a bit more
similar to 90lvm script - both revolve around same concepts after all.

There's no reason to treat conf-assembled arrays differently from
incremental ones. Once we hit timeout in init's udev loop, we can use
common script (mdraid_start.sh) to try force inactive arrays
into degraded mode.

md-finished.sh was kind-of out of place - it didn't really wait for any
particular device(s) to show up, just watched if onetime mdadm scripts
are still in place. Furthermore, after moving mdraid_start to --timeout
initqueue, it didn't really have too much to watch at all, besides
mdadm_auto (and that served no purpose, as we do wait for concrete
devices).

Either way, with stock 64-md fixes, current version of 65-md*.rules does
the following:

- limits assembly to certain uuids, if specified
- watch for no ddf/imsm
- if mdadm.conf => setup onetime -As script, without forced --run option
- if !mdadm.conf => incrementally assemble
- for both cases, setup timeout script, run-forcing arrays as a last resort

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 15:37:26 +02:00
Michal Soltys
cf5891424e 90(md|dm)raid: recognize ddf container
This patch adds ddf support, consistently with imsm/isw options.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 15:37:26 +02:00
Michal Soltys
66426469d0 90mdraid: fix/adjust force-run script
1) mdadm -As --auto=yes --run 2>&1 | vinfo (removed)

Currently such auto assembly will not complete or force-run partially
assembled arrays. It might assemble "concurrent" separate array and
force-run it, if possible (though the chances of suddenly showing
missing components in this scenario - a script run after udev timeout -
are pretty thin). See [1] for details. Also see #3 below.

2) mdadm -Is --run 2>&1 (removed)

This will only force-run native arrays - arrays in containers will not
be affected. See [1] for details. Also see #3 below.

3) mdadm -R run loop (implicitly handles #1 & #2)

This loop does everywthing that #1 & #2 are expected to do. Thus, the
above invocations are simply redundant and this is the most safe and
flexible option.

Also, it shouldn't be necessary to go under md/ directory, as those are
just symlinks to /dev/md[0-9]*.

Certain checks were changed to strict ones (array state, degraded state)
instead of relying on env tricks.

'cat' was added explicitly to installed programs (it has been used
implicitly in shutdown script either way)

4) mdmon bug

See [1] for details as well. In short - force-run arrays in containers
will not have mdmon started, so we do that manually.

5) stop/run queue magic

Also removed. mdadm -R will only cause change events to the array
itself, and they should not be an issue.

[1] http://article.gmane.org/gmane.linux.raid/35133

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 15:37:25 +02:00
Michal Soltys
9383421c1c 90mdraid: fix/adjust mdraid-cleanup
Stop both arrays (first pass) and containers (second pass).
Loop only over /dev/md[0-9]*
Call cleanup script only once, make sure it's after crypt cleanup.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 15:37:25 +02:00
Michal Soltys
5f6a71b38a 90mdraid: containers are not runnable
Remove whole "start a container logic".

Containers once assembled, always remain in 'inactive' state.
Any attempt to run a container with mdadm -IR is a no-op, and any
attempt with just mdadm -R ends with an error.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 15:37:23 +02:00
Michal Soltys
e3e5128cf2 90mdraid: adjust stock mdadm udev rules
Currently shipped mdadm rules incrementally assemble all imsm and native
raids, and do so unconditionally. This causes few issues:

- fine-grained controls in 65-md* are shadowed - for example,
  mdadm.conf's presence tests or uuid checks
- 90dmraid might also conflict with 90mdraid, if user prefers the former
  to handle containers
- possibly other subtle issues

This patch adjusts the behaviour.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-09-22 15:37:23 +02:00
Harald Hoyer
6d385c7111 mount securityfs in a seperate dracut module 2011-09-22 15:37:23 +02:00
Harald Hoyer
16457c869d mount securityfs in a seperate dracut module 2011-09-20 11:16:53 +02:00
Harald Hoyer
d63fdc1198 99base/init: mount securityfs with source "securityfs" instead of dest 2011-09-20 10:10:29 +02:00
Harald Hoyer
ca8d4e8933 Do not use /run/udev/rules.d for udev rules
for rules, which should not be called in the real root.

Stale rules can cause this:
https://bugzilla.redhat.com/show_bug.cgi?id=734096
2011-09-19 12:21:51 +02:00
Harald Hoyer
6d82a0470e 99base/init: remove /dev/root helper symlink
Any tool relying on /dev/root has to be fixed.
2011-09-19 12:20:55 +02:00
Harald Hoyer
e41e5b78c6 90dmsquash-live: do not symlink to /dev/live
/dev/live should not be used anyway
2011-09-19 12:20:11 +02:00
Harald Hoyer
baa5c11363 dmsquash-live-root: load filesystem modules before mounting loop images
might prevent https://bugzilla.redhat.com/show_bug.cgi?id=735199
2011-09-02 20:01:57 +02:00
Harald Hoyer
380b8b516e dmsquash-live-root: use blkid to determine fstype of images
prevents:
dracut: FATAL: cannot mount live image (unknown filesystem type)
https://bugzilla.redhat.com/show_bug.cgi?id=735199
2011-09-02 20:01:50 +02:00
Harald Hoyer
86880b8ff7 99base/init: removed cdrom polling reset code
This is done globally now.
2011-09-02 19:19:40 +02:00
Harald Hoyer
59f288ce63 dracut: cp with sparse 2011-09-02 19:19:40 +02:00
Harald Hoyer
dffb93feaf 99base/init: do not fail, when importing the original kernel environment 2011-09-01 16:01:21 +02:00
John Reiser
f9708da223 instmods: factor out egrep of "FATAL: Module .* not found" 2011-09-01 10:30:59 +02:00
John Reiser
0024702fe7 instmods: sanity for _mpargs 2011-09-01 10:30:58 +02:00
John Reiser
881eda695e instmods: get filenames from stdin if no args; use it
Use bash  "[[ string =~ pattern ]]"  instead of "egrep -q".
Replace control-dominated serial fondling
	for var in $(proc1); do proc2 var; done
with data-dominated parallel pipeline
	proc1  |  while read var; do proc2 var; done
Together this is a large savings.

[harald@redhat.com: fixed network kernel module filter]
2011-09-01 10:30:29 +02:00
John Reiser
e6024e0030 install_kmod_with_fw: make fast case faster 2011-09-01 10:03:57 +02:00
John Reiser
ceebd9ac76 filter_kernel_modules is a specialized filter_kernel_modules_by_path 2011-09-01 10:03:54 +02:00
John Reiser
3f590c7840 inst_simple, inst_dir: make fast case faster
This small stuff saves 1.7% per dropped statement during "dracut --profile".
Fixing the comment about /lib -> lib64 is REQUIRED!
2011-09-01 10:03:54 +02:00
Harald Hoyer
f063d0e89f 95udev-rules: add input_id 2011-08-31 16:48:20 +02:00
Harald Hoyer
5f06f0c367 dracut-functions: hmac checksum files can be symlinks, too
use inst() instead of inst_simple() to install the hmac files
2011-08-31 15:22:09 +02:00
Harald Hoyer
1e2f60993f 99base/init: move switch_root breakpoint to a later point in the script 2011-08-30 16:23:17 +02:00
Harald Hoyer
ed42e64cfc 99base/init: save and restore environment given from the kernel 2011-08-30 16:22:46 +02:00
Harald Hoyer
2c0b5281f5 90crypt/parse-crypt.sh: also accept the beginning of the LUKS UUID
2e0c003435 introduced a too strict test
for LUKS UUIDs
2011-08-30 14:43:57 +02:00
John Reiser
f4ca564ba6 build initramfs: unclear _mpargs in instmods()
The local variable _mpargs in function instmods() in file dracut-functions
looks peculiar.  The documentation is non-existent, but still ...

First, $_mpargs is not passed to modprobe via for_each_kmod_dep.
This is strange because my guess is that "_mpargs" means
"extra arguments for modprobe".

Second, the leading "--" will be lopped when a leading pathname
is stripped via
	_mod=${_mod##*/}
It seems to me that a leading "--" should inhibit modification.

Here's the corresponding patch to current HEAD (from dracut-013.)
2011-08-30 13:58:45 +02:00
Harald Hoyer
ab55a117e2 99base/init: only poll cdroms, if the kernel does support autopolling 2011-08-29 19:12:47 +02:00
Harald Hoyer
a3381af1de 50plymouth: add plymouth.enable kernel command line option 2011-08-29 18:32:24 +02:00
Harald Hoyer
82dfee9960 dracut.spec: fixed rhel/fedora version checks 2011-08-29 13:11:49 +02:00
Harald Hoyer
1073b9f93a 90mdraid/65-md-incremental-imsm.rules: incremental run to settled
move incremental run to settled queue again

https://bugzilla.redhat.com/show_bug.cgi?id=732967
2011-08-24 17:23:00 +02:00
Harald Hoyer
8cf621ffd9 dracut-functions: fix inst_dir() for non-absolute dirs 2011-08-23 12:50:03 +02:00
Przemysław Rudy
2e0c003435 luks key on ext dev - wait for luks
This really waits for the luks mapper device, so luksOpen can do it job
2011-08-22 11:27:00 +02:00
Amadeusz Żołnowski
1f735f82cc crypt: changed cmdline arg name from rd.luks.tout to rd.luks.key.tout 2011-08-22 11:19:22 +02:00
Przemysław Rudy
c70f6415f8 luks key on ext dev - wait for luks
This asks for the luks passphrase if key is not found for defined time (if defined with rd.luks.tout cmd line):

 modules.d/90crypt/cryptroot-ask.sh |   21 ++++++++++++++++++---
 modules.d/90crypt/parse-crypt.sh   |    5 +++--
 2 files changed, 21 insertions(+), 5 deletions(-)
2011-08-22 11:19:22 +02:00
Amadeusz Żołnowski
07aeaae356 livenet: take into account other ca-bundle paths; use inst_any for that 2011-08-22 11:19:21 +02:00
Amadeusz Żołnowski
3378a54f15 dracut-functions: new function: inst_any [-d dest] f1 [f2 [f3 ...]] 2011-08-22 11:19:19 +02:00
Leho Kraav
641d84a4ec 99base: whitespace fix 2011-08-22 11:19:19 +02:00
Amadeusz Żołnowski
581dd40e73 90crypt: ask_for_password pings plymouthd
If plymouthd is not started, ask_for_password shouldn't try to prompt
for password with GUI and should use text prompt instead.
2011-08-19 15:18:04 +02:00
Harald Hoyer
a76dc27801 dracut-functions: speed up inst_dir() 2011-08-19 10:24:49 +02:00
John Reiser
bc313467bd build initramfs: prelink --undo /sbin/*
Fix a typo (omitting the 's' in "sbin") which caused
"prelink --undo" twice on      /bin/*,  and
"prelink --undo" omitted for  /sbin/*.
2011-08-19 08:10:57 +02:00
Harald Hoyer
d619fb5e1c dracut: unset LD_LIBRARY_PATH
LD_LIBRARY_PATH is not set in the initramfs, so it should not be set
while finding our libraries.
2011-08-19 08:08:18 +02:00
Harald Hoyer
d670e21998 dracut-functions: s/emergency-shutdown/shutdown-emergency/g 2011-08-17 17:40:59 +02:00
Harald Hoyer
ea8e543bb8 add TEST-16-DMSQUASH
This is a test for Fedora LiveCDs created via livecd-tools
2011-08-17 13:42:16 +02:00
Harald Hoyer
e7b8fe03e8 profile.py: parse the output of "dracut --profile" for profiling 2011-08-17 10:08:23 +02:00
Will Woods
fb216d1a7c fix live crash with livenet installed
parse-livenet.sh shouldn't mess with $root unless it finds a valid URL.
2011-08-17 09:02:22 +02:00
Harald Hoyer
566dab2ac1 90dmsquash-live/dmsquash-live-root: include fs_lib.sh for det_fs()
https://bugzilla.redhat.com/show_bug.cgi?id=730579
2011-08-17 08:24:30 +02:00
Harald Hoyer
4a049ce556 add x-bit to *.sh 2011-08-12 16:29:28 +02:00
109 changed files with 2045 additions and 1020 deletions

View File

@@ -1,14 +1,15 @@
VERSION=013
VERSION=014
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
prefix ?= /usr
libdir ?= ${prefix}/lib
datadir ?= ${prefix}/share
pkglibdir ?= ${datadir}/dracut
pkglibdir ?= ${libdir}/dracut
sysconfdir ?= ${prefix}/etc
sbindir ?= ${prefix}/sbin
bindir ?= ${prefix}/sbin
mandir ?= ${prefix}/share/man
manpages = dracut.8 dracut.kernel.7 dracut.conf.5 dracut-catimages.8 dracut-gencmdline.8
manpages = dracut.8 dracut.cmdline.7 dracut.conf.5 dracut-catimages.8 dracut-gencmdline.8
.PHONY: install clean archive rpm testimage test all check AUTHORS doc
@@ -26,25 +27,26 @@ dracut.html: dracut.xml $(manpages)
install: doc
mkdir -p $(DESTDIR)$(pkglibdir)
mkdir -p $(DESTDIR)$(sbindir)
mkdir -p $(DESTDIR)$(bindir)
mkdir -p $(DESTDIR)$(sysconfdir)
mkdir -p $(DESTDIR)$(pkglibdir)/modules.d
mkdir -p $(DESTDIR)$(mandir)/man{5,7,8}
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 mkinitrd-dracut.sh $(DESTDIR)$(sbindir)/mkinitrd
install -m 0755 lsinitrd $(DESTDIR)$(sbindir)/lsinitrd
install -m 0755 dracut $(DESTDIR)$(bindir)/dracut
install -m 0755 dracut-gencmdline $(DESTDIR)$(bindir)/dracut-gencmdline
install -m 0755 dracut-catimages $(DESTDIR)$(bindir)/dracut-catimages
install -m 0755 mkinitrd-dracut.sh $(DESTDIR)$(bindir)/mkinitrd
install -m 0755 lsinitrd $(DESTDIR)$(bindir)/lsinitrd
install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf
mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d
install -m 0755 dracut-functions $(DESTDIR)$(pkglibdir)/dracut-functions
install -m 0755 dracut-logger $(DESTDIR)$(pkglibdir)/dracut-logger
cp -arx modules.d $(DESTDIR)$(pkglibdir)
install -m 0644 dracut.8 $(DESTDIR)$(mandir)/man8
install -m 0644 dracut-catimages.8 $(DESTDIR)$(mandir)/man8
install -m 0644 dracut-gencmdline.8 $(DESTDIR)$(mandir)/man8
install -m 0644 dracut.conf.5 $(DESTDIR)$(mandir)/man5
install -m 0644 dracut.kernel.7 $(DESTDIR)$(mandir)/man7
install -m 0644 dracut.8 $(DESTDIR)$(mandir)/man8/dracut.8
install -m 0644 dracut-catimages.8 $(DESTDIR)$(mandir)/man8/dracut-catimages.8
install -m 0644 dracut-gencmdline.8 $(DESTDIR)$(mandir)/man8/dracut-gencmdline.8
install -m 0644 dracut.conf.5 $(DESTDIR)$(mandir)/man5/dracut.conf.5
install -m 0644 dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.cmdline.7
ln -s dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7
clean:
$(RM) *~
@@ -66,13 +68,13 @@ dracut-$(VERSION).tar.gz:
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |gzip > dracut-$(VERSION).tar.gz
rpm: dracut-$(VERSION).tar.bz2
mkdir -p rpmbuild
cp dracut-$(VERSION).tar.bz2 rpmbuild
cd rpmbuild; ../git2spec.pl $(VERSION) < ../dracut.spec > dracut.spec; \
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
cp dracut-$(VERSION).tar.bz2 "$$rpmbuild"; \
$$src/git2spec.pl $(VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
(cd "$$rpmbuild"; rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
--define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
--define "_rpmdir $$PWD" -ba dracut.spec && \
( cd ..; mv rpmbuild/noarch/*.rpm .; mv rpmbuild/*.src.rpm .;rm -fr rpmbuild; ls *.rpm )
--define "_rpmdir $$PWD" -ba dracut.spec; ) && \
( mv "$$rpmbuild"/noarch/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm )
syncheck:
@ret=0;for i in dracut-logger modules.d/99base/init modules.d/*/*.sh; do \

40
NEWS
View File

@@ -1,3 +1,43 @@
dracut-014
==========
- new dracut arguments:
--lvmconf
--nolvmconf
--fscks [LIST]
--nofscks
- new .conf options:
install_items
fscks
nofscks
- new kernel options:
rd.md.ddf
rd.md.waitclean
plymouth.enable
- dracut move from /sbin to /usr/bin
- dracut modules dir moved from /usr/share/dracut to /usr/lib/dracut
- profiling with "dracut --profile"
- new TEST-16-DMSQUASH, test for Fedora LiveCDs
- speedup of initramfs creation
- ask_for_password fallback to CLI
- mdraid completely switched to incremental assembly
- no more cdrom polling
- "switch_root" breakpoint is now very late
- /dev/live is gone
- /dev/root is gone
- fs-lib dracut module for fscks added
- xen dracut module removed
- usb mass storage kernel drivers now included
- usrmount dracut module added:
mount /usr if found in /sysroot/etc/fstab
- only include fsck helper needed for hostonly
- fcoe: support for bnx2fc
- support iSCSI drivers: qla4xxx, cxgb3i, cxgb4i, bnx2i, be2iscsi
- fips-aesni dracut module added
- add install_items to dracut.conf
install_items+=" <file>[ <file> ...] "
- speedup internal testsuite
- internal testsuite: store temporary data in a temporary dir
dracut-013
==========
- speedup of initramfs creation

51
dracut
View File

@@ -35,7 +35,7 @@ Creates initial ramdisk images for preloading modules
-f, --force Overwrite existing initramfs file.
-m, --modules [LIST] Specify a space-separated list of dracut modules to
call when building the initramfs. Modules are located
in /usr/share/dracut/modules.d.
in /usr/lib/dracut/modules.d.
-o, --omit [LIST] Omit a space-separated list of dracut modules.
-a, --add [LIST] Add a space-separated list of dracut modules.
-d, --drivers [LIST] Specify a space-separated list of kernel modules to
@@ -59,6 +59,8 @@ Creates initial ramdisk images for preloading modules
--nomdadmconf Do not include local /etc/mdadm.conf
--lvmconf Include local /etc/lvm/lvm.conf
--nolvmconf Do not include local /etc/lvm/lvm.conf
--fscks [LIST] Add a space-separated list of fsck helpers.
--nofscks Inhibit installation of any fsck helpers.
-h, --help This message
--debug Output debug information of the build process
--profile Output profile information of the build process
@@ -78,7 +80,7 @@ Creates initial ramdisk images for preloading modules
from. Default: /etc/dracut.conf.d
-l, --local Local mode. Use modules from the current working
directory instead of the system-wide installed in
/usr/share/dracut/modules.d.
/usr/lib/dracut/modules.d.
Useful when running dracut from a git checkout.
-H, --hostonly Host-Only mode: Install only what is needed for
booting the local host instead of a generic host.
@@ -202,14 +204,14 @@ while (($# > 0)); do
-o|--omit) push_arg omit_dracutmodules_l "$@" || shift;;
-d|--drivers) push_arg drivers_l "$@" || shift;;
--filesystems) push_arg filesystems_l "$@" || shift;;
-I|--install) push_arg install_items "$@" || shift;;
-I|--install) push_arg install_items_l "$@" || shift;;
--fwdir) push_arg fw_dir_l "$@" || shift;;
--fscks) push_arg fscks_l "$@" || shift;;
--nofscks) nofscks_l="yes";;
-k|--kmoddir) read_arg drivers_dir_l "$@" || shift;;
-c|--conf) read_arg conffile "$@" || shift;;
--confdir) read_arg confdir "$@" || shift;;
-L|--stdlog) read_arg stdloglvl_l "$@" || shift;;
-I|--install) read_arg install_items "$@" || shift;;
--fwdir) read_arg fw_dir_l "$@" || shift;;
--compress) read_arg compress_l "$@" || shift;;
--prefix) read_arg prefix_l "$@" || shift;;
-f|--force) force=yes;;
@@ -265,6 +267,7 @@ fi
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
unset LD_LIBRARY_PATH
[[ $debug ]] && {
export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
@@ -277,7 +280,7 @@ export PATH
debug=yes
}
[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && \
dracutbasedir="$(readlink -f ${0%/*})"
@@ -323,6 +326,18 @@ if (( ${#add_drivers_l[@]} )); then
done
fi
if (( ${#fscks_l[@]} )); then
while pop fscks_l val; do
fscks+=" $val "
done
fi
if (( ${#install_items_l[@]} )); then
while pop install_items_l val; do
push install_items $val
done
fi
# these options override the stuff in the config file
if (( ${#dracutmodules_l[@]} )); then
dracutmodules=''
@@ -373,11 +388,12 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
[[ $use_fstab_l ]] && use_fstab=$use_fstab_l
[[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l
[[ $lvmconf_l ]] && lvmconf=$lvmconf_l
[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
[[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware"
[[ $do_strip ]] || do_strip=no
[[ $compress_l ]] && compress=$compress_l
[[ $show_modules_l ]] && show_modules=$show_modules_l
[[ $nofscks_l ]] && nofscks="yes"
# eliminate IFS hackery when messing with fw_dir
fw_dir=${fw_dir//:/ }
@@ -406,6 +422,13 @@ else
exit 1
fi
# Verify bash version, curret minimum is 3.1
if (( ${BASH_VERSINFO[0]} < 3 ||
( ${BASH_VERSINFO[0]} == 3 && ${BASH_VERSINFO[1]} < 1 ) )); then
dfatal 'You need at least Bash 3.1 to use dracut, sorry.'
exit 1
fi
dracutfunctions=$dracutbasedir/dracut-functions
export dracutfunctions
@@ -471,6 +494,10 @@ fi
readonly TMPDIR=/var/tmp
readonly initdir=$(mktemp --tmpdir=/var/tmp/ -d -t initramfs.XXXXXX)
[ -d "$initdir" ] || {
dfatal "mktemp failed."
exit 1
}
# clean up after ourselves no matter how we die.
trap 'ret=$?;[[ $keep ]] && echo "Not removing $initdir." >&2 || rm -rf "$initdir";exit $ret;' EXIT
@@ -483,7 +510,7 @@ chmod 755 "$initdir"
export initdir dracutbasedir dracutmodules drivers \
fw_dir drivers_dir debug no_kernel kernel_only \
add_drivers mdadmconf lvmconf filesystems \
use_fstab libdir usrlibdir \
use_fstab libdir usrlibdir fscks nofscks \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug
@@ -500,7 +527,7 @@ if [[ $prefix ]]; then
fi
if [[ $kernel_only != yes ]]; then
for d in bin etc lib "$libdir" sbin tmp usr var usr/bin usr/sbin; do
for d in bin etc lib "$libdir" sbin tmp usr var var/log usr/bin usr/sbin; do
[[ -e "${initdir}${prefix}/$d" ]] && continue
if [ -h "/$d" ]; then
inst "/$d" "${prefix}/$d"
@@ -509,7 +536,7 @@ if [[ $kernel_only != yes ]]; then
fi
done
for d in proc sys sysroot root run run/lock run/initramfs; do
for d in dev proc sys sysroot root run run/lock run/initramfs; do
if [ -h "/$d" ]; then
inst "/$d"
else
@@ -642,14 +669,14 @@ type hardlink &>/dev/null && {
if strstr "$modules_loaded" " fips " && command -v prelink >/dev/null; then
for i in $initdir/bin/* \
$initdir/bin/* \
$initdir/sbin/* \
$initdir/usr/bin/* \
$initdir/usr/sbin/*; do
[ -x $i ] && prelink -u $i &>/dev/null
done
fi
if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet | \
if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \
$compress > "$outfile"; ); then
dfatal "dracut: creation of $outfile failed"
exit 1

View File

@@ -83,28 +83,30 @@ print_vars() {
}
normalize_path() {
p=$1
while [[ ${p#*//*} != $p ]]; do
p=${p/\/\///}
done
echo $p
shopt -q -s extglob
set -- "${1//+(\/)//}"
shopt -q -u extglob
echo "${1%/}"
}
convert_abs_rel() {
local __current __absolute __abssize __cursize __i __level __newpath
local __current __absolute __abssize __cursize __newpath __oldifs
local -i __i __level
# PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
if [[ "$1" == "$2" ]]
then
echo "."
return
fi
__current=$(normalize_path "$1")
__absolute=$(normalize_path "$2")
IFS="/"
set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
__current=($__current)
__absolute=($__absolute)
# corner case #1 - self looping link
[[ "$1" == "$2" ]] && { echo "${1##*/}"; return; }
# corner case #2 - own dir link
[[ "${1%/*}" == "$2" ]] && { echo "."; return; }
__oldifs="$IFS"
IFS="/"
__current=($1)
__absolute=($2)
IFS="$__oldifs"
__abssize=${#__absolute[@]}
__cursize=${#__current[@]}
@@ -266,26 +268,20 @@ check_vol_slaves() {
}
# Install a directory, keeping symlinks as on the original system.
# Example: if /lib64 points to /lib on the host, "inst_dir /lib/file"
# Example: if /lib points to /lib64 on the host, "inst_dir /lib/file"
# will create ${initdir}/lib64, ${initdir}/lib64/file,
# and a symlink ${initdir}/lib -> lib64.
inst_dir() {
local _file=""
local _oldifs="$IFS"
local _part
local _dir="$1"
IFS="/"
set -- $_dir
IFS=$_oldifs
_dir="$@"
[[ -e ${initdir}$_dir ]] && return 0
[[ -e ${initdir}/"$1" ]] && return 0 # already there
local _dir="$1" _part="${1%/*}" _file
while [[ "$_part" != "${_part%/*}" ]] && ! [[ -e "${initdir}/${_part}" ]]; do
_dir="$_part $_dir"
_part=${_part%/*}
done
# iterate over parent directories
for _part in $_dir; do
[[ $_part ]] || continue
_file="$_file/$_part"
[[ -e ${initdir}$_file ]] && continue
for _file in $_dir; do
if [[ -L $_file ]]; then
# create link as the original
local target=$(readlink -f "$_file")
@@ -294,12 +290,12 @@ inst_dir() {
inst_dir "$target"
inst_symlink "$_file"
else
[[ -h ${initdir}$_file ]] && _file=$(readlink "${initdir}$_file")
[[ -h ${initdir}/$_file ]] && _file=$(readlink "${initdir}/$_file")
# create directory
mkdir -m 0755 -p "${initdir}$_file" || return 1
[[ -e "${initdir}/$_file" ]] || mkdir -m 0755 -p "${initdir}/$_file" || return 1
if [[ -d "$_file" ]]; then
chmod --reference="$_file" "${initdir}$_file"
chmod u+w "${initdir}$_file"
chmod --reference="$_file" "${initdir}/$_file"
chmod u+w "${initdir}/$_file"
fi
fi
done
@@ -310,20 +306,21 @@ inst_dir() {
# Location of the image dir is assumed to be $initdir
# We never overwrite the target if it exists.
inst_simple() {
local _src target
[[ -f $1 ]] || return 1
_src=$1 target="${2:-$1}"
if ! [[ -d ${initdir}$target ]]; then
[[ -e ${initdir}$target ]] && return 0
[[ -h ${initdir}$target ]] && return 0
[[ -f "$1" ]] || return 1
strstr "$1" "/" || return 1
local _src=$1 target="${2:-$1}"
if ! [[ -d ${initdir}/$target ]]; then
[[ -e ${initdir}/$target ]] && return 0
[[ -h ${initdir}/$target ]] && return 0
inst_dir "${target%/*}"
fi
# install checksum files also
if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then
inst_simple "${_src%/*}/.${_src##*/}.hmac" "${target%/*}/.${target##*/}.hmac"
inst "${_src%/*}/.${_src##*/}.hmac" "${target%/*}/.${target##*/}.hmac"
fi
ddebug "Installing $_src"
cp -pfL "$_src" "${initdir}$target"
cp --sparse=always -pfL "$_src" "${initdir}/$target"
}
# find symlinks linked to given library file
@@ -355,24 +352,25 @@ rev_lib_symlinks() {
# It handles making symlinks according to how the original library
# is referenced.
inst_library() {
local _src=$1 _dest=${2:-$1} _lib _reallib _symlink
[[ -e $initdir$_dest ]] && return 0
local _src="$1" _dest=${2:-$1} _lib _reallib _symlink
strstr "$1" "/" || return 1
[[ -e $initdir/$_dest ]] && return 0
if [[ -L $_src ]]; then
# install checksum files also
if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then
inst_simple "${_src%/*}/.${_src##*/}.hmac" "${_dest%/*}/.${_dest##*/}.hmac"
inst "${_src%/*}/.${_src##*/}.hmac" "${_dest%/*}/.${_dest##*/}.hmac"
fi
_reallib=$(readlink -f "$_src")
inst_simple "$_reallib" "$_reallib"
inst_dir "${_dest%/*}"
ln -sfn $(convert_abs_rel "${_dest}" "${_reallib}") "${initdir}${_dest}"
ln -sfn $(convert_abs_rel "${_dest}" "${_reallib}") "${initdir}/${_dest}"
else
inst_simple "$_src" "$_dest"
fi
# Create additional symlinks. See rev_symlinks description.
for _symlink in $(rev_lib_symlinks $_src) $(rev_lib_symlinks $_reallib); do
[[ ! -e $initdir$_symlink ]] && {
[[ ! -e $initdir/$_symlink ]] && {
ddebug "Creating extra symlink: $_symlink"
inst_symlink $_symlink
}
@@ -400,7 +398,7 @@ inst_binary() {
_bin=$(find_binary "$1") || return 1
_target=${2:-$_bin}
inst_symlink $_bin $_target && return 0
[[ -e $initdir$_target ]] && return 0
[[ -e $initdir/$_target ]] && return 0
# If the binary being installed is also a library, add it to the loop.
_so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
@@ -418,7 +416,7 @@ inst_binary() {
fi
[[ $_line =~ $_so_regex ]] || continue
_file=${BASH_REMATCH[1]}
[[ -e ${initdir}$_file ]] && continue
[[ -e ${initdir}/$_file ]] && continue
# See if we are loading an optimized version of a shared lib.
if [[ $_file =~ $_lib_regex ]]; then
@@ -443,19 +441,22 @@ inst_binary() {
# same as above, except for shell scripts.
# If your shell script does not start with shebang, it is not a shell script.
inst_script() {
[[ -f $1 ]] || return 1
local _bin
_bin=$(find_binary "$1") || return 1
shift
local _line _shebang_regex
read -r -n 80 _line <"$1"
read -r -n 80 _line <"$_bin"
# If debug is set, clean unprintable chars to prevent messing up the term
[[ $debug ]] && _line=$(echo -n "$_line" | tr -c -d '[:print:][:space:]')
_shebang_regex='(#! *)(/[^ ]+).*'
[[ $_line =~ $_shebang_regex ]] || return 1
inst "${BASH_REMATCH[2]}" && inst_simple "$@"
inst "${BASH_REMATCH[2]}" && inst_simple "$_bin" "$@"
}
# same as above, but specialized for symlinks
inst_symlink() {
local _src=$1 _target=$initdir${2:-$1} _realsrc
local _src=$1 _target=$initdir/${2:-$1} _realsrc
strstr "$1" "/" || return 1
[[ -L $1 ]] || return 1
[[ -L $_target ]] && return 0
_realsrc=$(readlink -f "$_src")
@@ -480,12 +481,14 @@ inst_rules() {
inst_dir "/lib/udev/rules.d"
inst_dir "$_target"
for _rule in "$@"; do
for r in /lib/udev/rules.d /etc/udev/rules.d; do
if [[ -f $r/$_rule ]]; then
_found="$r/$_rule"
inst_simple "$_found"
fi
done
if [ "${rule#/}" = "$rule" ]; then
for r in /lib/udev/rules.d /etc/udev/rules.d; do
if [[ -f $r/$_rule ]]; then
_found="$r/$_rule"
inst_simple "$_found"
fi
done
fi
for r in '' ./ $dracutbasedir/rules.d/; do
if [[ -f ${r}$_rule ]]; then
_found="${r}$_rule"
@@ -518,7 +521,7 @@ inst() {
[[ $hookdirs ]] || {
hookdirs="cmdline pre-udev pre-trigger netroot initqueue pre-mount"
hookdirs+=" pre-pivot mount emergency emergency-shutdown shutdown"
hookdirs+=" pre-pivot mount emergency shutdown-emergency shutdown"
export hookdirs
}
@@ -537,6 +540,34 @@ inst_hook() {
inst_simple "$3" "/lib/dracut/hooks/${1}/${2}${3##*/}"
}
# install any of listed files
#
# If first argument is '-d' and second some destination path, first accessible
# source is installed into this path, otherwise it will installed in the same
# path as source. If none of listed files was installed, function return 1.
# On first successful installation it returns with 0 status.
#
# Example:
#
# inst_any -d /bin/foo /bin/bar /bin/baz
#
# Lets assume that /bin/baz exists, so it will be installed as /bin/foo in
# initramfs.
inst_any() {
local to f
[[ $1 = '-d' ]] && to="$2" && shift 2
for f in "$@"; do
if [[ -e $f ]]; then
[[ $to ]] && inst "$f" "$to" && return 0
inst "$f" && return 0
fi
done
return 1
}
dracut_install() {
local _optional=no
if [[ $1 = '-o' ]]; then
@@ -760,13 +791,14 @@ check_module_dir() {
# Install a single kernel module along with any firmware it may require.
# $1 = full path to kernel module to install
install_kmod_with_fw() {
local _modname=${1##*/} _fwdir _found _fw
_modname=${_modname%.ko*}
# no need to go further if the module is already installed
[[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] \
&& return 0
inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" \
|| return $?
local _modname=${1##*/} _fwdir _found _fw
_modname=${_modname%.ko*}
for _fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
_found=''
for _fwdir in $fw_dir; do
@@ -794,10 +826,11 @@ install_kmod_with_fw() {
# It will be passed the full path to the found kernel module
# $2 = module to get dependencies for
# rest of args = arguments to modprobe
# _fderr specifies FD passed from surrounding scope
for_each_kmod_dep() {
local _func=$1 _kmod=$2 _cmd _modpath _options _found=0
shift 2
modprobe "$@" --ignore-install --show-depends $_kmod 2>"$initdir/modprobe.err" | (
modprobe "$@" --ignore-install --show-depends $_kmod 2>&${_fderr} | (
while read _cmd _modpath _options; do
[[ $_cmd = insmod ]] || continue
$_func ${_modpath} || exit $?
@@ -806,9 +839,6 @@ for_each_kmod_dep() {
[[ $_found -eq 0 ]] && exit 1
exit 0
)
egrep -v 'FATAL: Module .* not found.' "$initdir/modprobe.err" | derror
rm -f "$initdir/modprobe.err"
return $?
}
# filter kernel modules to install certain modules that meet specific
@@ -840,85 +870,96 @@ filter_kernel_modules_by_path () (
esac
done
)
# filter kernel modules to install certain modules that meet specific
# requirements.
# $1 = function to call with module name to filter.
# This function will be passed the full path to the module to test.
# The behaviour of this function can vary depending on whether $hostonly is set.
# If it is, we will only look at modules that are already in memory.
# If it is not, we will look at all kernel modules
# This function returns the full filenames of modules that match $1
filter_kernel_modules () (
local _modname _filtercmd
find_kernel_modules_by_path () (
if ! [[ $hostonly ]]; then
_filtercmd='find "$srcmods/kernel/drivers" "$srcmods/extra"'
_filtercmd+=' "$srcmods/weak-updates" -name "*.ko" -o -name "*.ko.gz"'
_filtercmd+=' 2>/dev/null'
find "$srcmods/kernel/$1" "$srcmods/extra" "$srcmods/weak-updates" \
-name "*.ko" -o -name "*.ko.gz" 2>/dev/null
else
_filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename '
_filtercmd+='-k $kernel 2>/dev/null'
cut -d " " -f 1 </proc/modules \
| xargs modinfo -F filename -k $kernel 2>/dev/null
fi
for _modname in $(eval $_filtercmd); do
case $_modname in
*.ko) "$1" "$_modname" && echo "$_modname";;
*.ko.gz) gzip -dc "$_modname" > $initdir/$$.ko
$1 $initdir/$$.ko && echo "$_modname"
rm -f $initdir/$$.ko
;;
esac
done
)
filter_kernel_modules () {
filter_kernel_modules_by_path drivers "$1"
}
find_kernel_modules () {
find_kernel_modules_by_path drivers
}
# install kernel modules along with all their dependencies.
instmods() {
[[ $no_kernel = yes ]] && return
local _mod _mpargs _moddirname
local _ret=0
while (($# > 0)); do
_mod=${1%.ko*}
# called [sub]functions inherit _fderr
local _fderr=9
function inst1mod() {
local _mod="$1"
case $_mod in
=*)
# This introduces 2 incompatible meanings for =* arguments
# to instmods. We need to decide which one to keep.
if [[ $_mod = =ata && -f $srcmods/modules.block ]]; then
instmods $_mpargs \
$(egrep 'ata|ahci' "${srcmods}/modules.block")
( [[ "$_mpargs" ]] && echo $_mpargs
egrep 'ata|ahci' "${srcmods}/modules.block" ) \
| instmods
elif [ -f $srcmods/modules.${_mod#=} ]; then
instmods $_mpargs $(cat ${srcmods}/modules.${_mod#=} )
( [[ "$_mpargs" ]] && echo $_mpargs
cat "${srcmods}/modules.${_mod#=}" ) \
| instmods
else
instmods $_mpargs $(find "$srcmods" -path "*/${_mod#=}/*")
( [[ "$_mpargs" ]] && echo $_mpargs
find "$srcmods" -path "*/${_mod#=}/*" ) \
| instmods
fi
;;
--*)
_mod=${_mod##*/}
_mpargs+=" $_mod";;
i2o_scsi) shift; continue;; # Do not load this diagnostic-only module
--*) _mpargs+=" $_mod" ;;
i2o_scsi) return ;; # Do not load this diagnostic-only module
*) _mod=${_mod##*/}
# if we are already installed, skip this module and go on
# to the next one.
[[ -f $initdir/$1 ]] && { shift; continue; }
[[ -f $initdir/$1 ]] && return
# If we are building a host-specific initramfs and this
# module is not already loaded, move on to the next one.
[[ $hostonly ]] && ! grep -qe "\<${_mod//-/_}\>" /proc/modules \
&& ! echo $add_drivers | grep -qe "\<${_mod}\>" && {
shift; continue
}
&& ! echo $add_drivers | grep -qe "\<${_mod}\>" \
&& return
# We use '-d' option in modprobe only if modules prefix path
# differs from default '/'. This allows us to use Dracut with
# old version of modprobe which doesn't have '-d' option.
_moddirname=${srcmods%%/lib/modules/*}
local _moddirname=${srcmods%%/lib/modules/*}
[[ -n ${_moddirname} ]] && _moddirname="-d ${_moddirname}/"
# ok, load the module, all its dependencies, and any firmware
# it may require
for_each_kmod_dep install_kmod_with_fw $_mod \
--set-version $kernel ${_moddirname}
--set-version $kernel ${_moddirname} $_mpargs
((_ret+=$?))
;;
esac
shift
done
return $_ret
}
function instmods_1() {
local _ret=0 _mod _mpargs
if (($# == 0)); then # filenames from stdin
while read _mod; do
inst1mod "${_mod%.ko*}"
done
fi
while (($# > 0)); do # filenames as arguments
inst1mod ${1%.ko*}
shift
done
return $_ret
}
# Capture all stderr from modprobe to _fderr. We could use {var}>...
# redirections, but that would make dracut require bash4 at least.
eval "( instmods_1 \"\$@\" ) ${_fderr}>&1" \
| egrep -v 'FATAL: Module .* not found.' | derror
return $?
}

View File

@@ -271,12 +271,8 @@ _dlvl2syslvl() {
# - @c INFO to @c info
# - @c DEBUG and @c TRACE both to @c debug
_do_dlog() {
[ -z "$maxloglvl" ] && return 0
local lvl="$1"; shift
local lvlc=$(_lvl2char "$lvl") || return 0
[ $lvl -le $maxloglvl ] || return 0
local msg="$lvlc: $*"
[ $lvl -le $stdloglvl ] && echo "$msg" >&2
@@ -307,6 +303,9 @@ _do_dlog() {
# dwarn "This is a warning"
# echo "This is a warning" | dwarn
dlog() {
[ -z "$maxloglvl" ] && return 0
[ $1 -le $maxloglvl ] || return 0
if [ $# -gt 1 ]; then
_do_dlog "$@"
else
@@ -314,7 +313,6 @@ dlog() {
_do_dlog "$1" "$line"
done
fi
[ -n "$debug" ] && set -x || :
}
## @brief Logs message at TRACE level (6)
@@ -324,6 +322,7 @@ dlog() {
dtrace() {
set +x
dlog 6 "$@"
[ -n "$debug" ] && set -x || :
}
## @brief Logs message at DEBUG level (5)
@@ -333,6 +332,7 @@ dtrace() {
ddebug() {
set +x
dlog 5 "$@"
[ -n "$debug" ] && set -x || :
}
## @brief Logs message at INFO level (4)
@@ -342,6 +342,7 @@ ddebug() {
dinfo() {
set +x
dlog 4 "$@"
[ -n "$debug" ] && set -x || :
}
## @brief Logs message at WARN level (3)
@@ -351,6 +352,7 @@ dinfo() {
dwarn() {
set +x
dlog 3 "$@"
[ -n "$debug" ] && set -x || :
}
## @brief It's an alias to dwarn() function.
@@ -360,6 +362,7 @@ dwarn() {
dwarning() {
set +x
dwarn "$@"
[ -n "$debug" ] && set -x || :
}
## @brief Logs message at ERROR level (2)
@@ -369,6 +372,7 @@ dwarning() {
derror() {
set +x
dlog 2 "$@"
[ -n "$debug" ] && set -x || :
}
## @brief Logs message at FATAL level (1)
@@ -378,4 +382,5 @@ derror() {
dfatal() {
set +x
dlog 1 "$@"
[ -n "$debug" ] && set -x || :
}

View File

@@ -1,5 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- This document was created with Syntext Serna Free. --><!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
<!-- vim: set ts=8 sts=2 sw=2 et: -->
<refentry id="dracut8">
<refentryinfo>
<title>dracut</title>
@@ -82,7 +83,7 @@ which are needed to access the root filesystem.</para>
<para>
For a complete list of kernel command line options see
<citerefentry>
<refentrytitle>dracut.kernel</refentrytitle>
<refentrytitle>dracut.cmdline</refentrytitle>
<manvolnum>7</manvolnum>
</citerefentry>
</para>
@@ -111,7 +112,7 @@ For a complete list of kernel command line options see
<para>specify a space-separated list of dracut modules to call
when building the initramfs.
Modules are located in
<filename>/usr/share/dracut/modules.d</filename>. This parameter can be specified multiple times.</para>
<filename>/usr/lib/dracut/modules.d</filename>. This parameter can be specified multiple times.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -227,6 +228,41 @@ include in the generic initramfs. This parameter can be specified multiple times
<para>do not include local <filename>/etc/mdadm.conf</filename></para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--lvmconf</option>
</term>
<listitem>
<para>include local <filename>/etc/lvm/lvm.conf</filename></para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--nolvmconf</option>
</term>
<listitem>
<para>do not include local <filename>/etc/lvm/lvm.conf</filename></para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--fscks [LIST]</option>
</term>
<listitem>
<para>add a space-separated list of fsck tools, in addition to
<filename>dracut.conf</filename>'s specification; the
installation is opportunistic (non-existing tools are ignored)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--nofscks</option>
</term>
<listitem>
<para>inhibit installation of any fsck tools</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--strip</option>
@@ -245,10 +281,10 @@ include in the generic initramfs. This parameter can be specified multiple times
</varlistentry>
<varlistentry>
<term>
<option>--prefix</option>
<option>--prefix&nbsp;<replaceable>&lt;dir&gt;</replaceable></option>
</term>
<listitem>
<para>prefix initramfs files with /run/initramfs/</para>
<para>prefix initramfs files with the specified directory</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -256,7 +292,7 @@ include in the generic initramfs. This parameter can be specified multiple times
<option>--noprefix</option>
</term>
<listitem>
<para>do not prefix initramfs files with /run/initramfs/ (default)</para>
<para>do not prefix initramfs files (default)</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -333,7 +369,7 @@ Default:
<listitem>
<para>activates the local mode. dracut will use modules from the current working
directory instead of the system-wide installed modules in
<filename>/usr/share/dracut/modules.d</filename>.
<filename>/usr/lib/dracut/modules.d</filename>.
This is useful when running dracut from a git checkout.</para>
</listitem>
</varlistentry>
@@ -360,7 +396,23 @@ the local host instead of a generic host.
<para>Use <filename>/etc/fstab</filename> instead of <filename>/proc/self/mountinfo</filename>.</para>
</listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term>
<option>--add_fstab;&nbsp;<replaceable>&lt;filename&gt;</replaceable>&nbsp;</option>
</term>
<listitem>
<para>Add entries of <replaceable>&lt;filename&gt;</replaceable> to the initramfs /etc/fstab.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--mount;&nbsp;&quot;<replaceable>&lt;device&gt;</replaceable> <replaceable>&lt;mountpoint&gt;</replaceable> <replaceable>&lt;filesystem type&gt;</replaceable> <replaceable>&lt;filesystem options&gt;</replaceable>&quot;</option>
</term>
<listitem>
<para>Add entries of <replaceable>&lt;filename&gt;</replaceable> to the initramfs /etc/fstab.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-i</option>
</term>
@@ -546,7 +598,7 @@ set in the configuration files.</para>
<title>See Also</title>
<para>
<citerefentry>
<refentrytitle>dracut.kernel</refentrytitle>
<refentrytitle>dracut.cmdline</refentrytitle>
<manvolnum>7</manvolnum>
</citerefentry>
<citerefentry>

View File

@@ -1,8 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- This document was created with Syntext Serna Free. --><!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" []>
<!-- vim: set ts=8 sts=2 sw=2 et: -->
<refentry id="dracutkernel7">
<refentryinfo>
<title>dracut.kernel</title>
<title>dracut.cmdline</title>
<productname>dracut</productname>
<authorgroup>
<author>
@@ -14,12 +15,12 @@
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>dracut.kernel</refentrytitle>
<refentrytitle>dracut.cmdline</refentrytitle>
<manvolnum>7</manvolnum>
<refmiscinfo class="version"/>
</refmeta>
<refnamediv>
<refname>dracut.kernel</refname>
<refname>dracut.cmdline</refname>
<refpurpose>dracut kernel command line options</refpurpose>
</refnamediv>
<refsect1>
@@ -342,6 +343,12 @@ This parameter can be specified multiple times.</para>
<para>disable MD RAID for imsm/isw raids, use DM RAID instead</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>rd.md.ddf</envar>=0</term>
<listitem>
<para>disable MD RAID for SNIA ddf raids, use DM RAID instead</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>rd.md.conf</envar>=0
@@ -350,6 +357,14 @@ This parameter can be specified multiple times.</para>
<para>ignore mdadm.conf included in initramfs</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>rd.md.waitclean</envar>=1
</term>
<listitem>
<para>wait for any resync, recovery, or reshape activity to finish before continuing</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>rd.md.uuid=<replaceable>&lt;md raid uuid&gt;</replaceable></envar>
@@ -696,11 +711,17 @@ rd.znet=ctc,0.0.0600,0.0.0601,0.0.0602,protocol=bar</programlisting></para>
<title>Plymouth Boot Splash</title>
<variablelist>
<varlistentry>
<term><envar>rd.plymouth</envar>=0</term>
<term><envar>plymouth.enable</envar>=0</term>
<listitem>
<para>disable the plymouth bootsplash.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>rd.plymouth</envar>=0</term>
<listitem>
<para>disable the plymouth bootsplash only for the initramfs.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
@@ -1256,6 +1277,14 @@ set in the configuration files.</para>
<para>Can contain additional command line options.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<filename>/etc/cmdline.d/*.conf</filename>
</term>
<listitem>
<para>Can contain additional command line options.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>

View File

@@ -29,3 +29,12 @@ mdadmconf="yes"
# install local /etc/lvm/lvm.conf
lvmconf="yes"
# A list of fsck tools to install. If it's not specified, module's hardcoded
# default is used, currently: "umount mount /sbin/fsck* xfs_db xfs_check
# xfs_repair e2fsck jfs_fsck reiserfsck btrfsck". The installation is
# opportunistic, so non-existing tools are just ignored.
#fscks=""
# inhibit installation of any fsck tools
#nofscks="yes"

View File

@@ -1,5 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- This document was created with Syntext Serna Free. --><!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
<!-- vim: set ts=8 sts=2 sw=2 et: -->
<refentry id="dracutconf5">
<refentryinfo>
<title>dracut.conf</title>
@@ -45,7 +46,7 @@ overwrite parameters set in <filename>/etc/dracut.conf</filename>. Each line spe
<listitem>
<para>Specify a space-separated list of dracut modules to
call when building the initramfs. Modules are located
in <filename>/usr/share/dracut/modules.d</filename>.</para>
in <filename>/usr/lib/dracut/modules.d</filename>.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -110,6 +111,14 @@ initramfs.</para>
<para>Specify additional directories, where to look for firmwares, separated by <constant>:</constant></para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>install_items+=&quot;&#160;<replaceable>&lt;file&gt;</replaceable>[ <replaceable>&lt;file&gt;</replaceable>&nbsp;...]&nbsp;&quot;</envar>
</term>
<listitem>
<para>Specify additional files to include in the initramfs, separated by spaces.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>do_strip=&quot;<replaceable>{yes|no}</replaceable>&quot;</envar>
@@ -138,6 +147,14 @@ initramfs.</para>
<para>Use <filename>/etc/fstab</filename> instead of <filename>/proc/self/mountinfo</filename>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>add_fstab+=&quot;&nbsp;<replaceable>&lt;filename&gt;</replaceable>&nbsp;&quot;</envar>
</term>
<listitem>
<para>Add entries of <replaceable>&lt;filename&gt;</replaceable> to the initramfs /etc/fstab.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>mdadmconf=&quot;<replaceable>{yes|no}</replaceable>&quot;</envar>
@@ -154,6 +171,27 @@ initramfs.</para>
<para>Include local <filename>/etc/lvm/lvm.conf</filename> (default=yes)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>fscks=&quot;&nbsp;<replaceable>&lt;fsck tools&gt;</replaceable>&nbsp;&quot;</envar>
</term>
<listitem>
<para>Add a space-separated list of fsck tools. If nothing is
specified, the default is: &quot;<replaceable>umount mount
/sbin/fsck* xfs_db xfs_check xfs_repair e2fsck jfs_fsck
reiserfsck btrfsck</replaceable>&quot;
</para>
<para>The installation is opportunistic (non-existing tools are ignored).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>nofscks=&quot;<replaceable>{yes}</replaceable>&quot;</envar>
</term>
<listitem>
<para>If specified, inhibit installation of any fsck tools.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>kernel_only=&quot;<replaceable>{yes|no}</replaceable>&quot;</envar>
@@ -233,7 +271,7 @@ The configuration files are read in alphanumerical order.</para>
<manvolnum>8</manvolnum>
</citerefentry>
<citerefentry>
<refentrytitle>dracut.kernel</refentrytitle>
<refentrytitle>dracut.cmdline</refentrytitle>
<manvolnum>7</manvolnum>
</citerefentry>
</para>

View File

@@ -1,3 +1,5 @@
%define dracutlibdir %{_prefix}/lib/dracut
# Variables must be defined
%define with_nbd 1
@@ -11,7 +13,7 @@ Version: xxx
Release: xxx
Summary: Initramfs generator using udev
%if 0%{?fedora}
%if 0%{?fedora} || 0%{?rhel} > 6
Group: System Environment/Base
%endif
%if 0%{?suse_version}
@@ -24,15 +26,15 @@ URL: https://dracut.wiki.kernel.org/
Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2
BuildArch: noarch
BuildRequires: dash bash
%if 0%{?fedora}
BuildRequires: dash bash git
%if 0%{?fedora} || 0%{?rhel} > 6
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%endif
%if 0%{?suse_version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
%if 0%{?fedora}
%if 0%{?fedora} || 0%{?rhel} > 6
BuildRequires: docbook-style-xsl docbook-dtds libxslt
%endif
@@ -72,18 +74,13 @@ Requires: module-init-tools >= 3.7-9
Requires: sed
Requires: tar
Requires: udev
Requires: util-linux >= 2.20
%if 0%{?fedora}
Requires: util-linux >= 2.16
%if 0%{?fedora} || 0%{?rhel} > 6
Requires: initscripts >= 8.63-1
Requires: plymouth >= 0.8.0-0.2009.29.09.19.1
%endif
%if 0%{?suse_version}
Requires: util-linux >= 2.16
%endif
%description
Dracut contains tools to create a bootable initramfs for 2.6 Linux kernels.
Unlike existing implementations, dracut does hard-code as little as possible
@@ -101,7 +98,7 @@ Requires: nbd
Requires: iproute
Requires: bridge-utils
%if 0%{?fedora}
%if 0%{?fedora} || 0%{?rhel} > 6
Requires: iscsi-initiator-utils
Requires: nfs-utils
Requires: dhclient
@@ -119,7 +116,7 @@ Provides: dracut-generic = %{version}-%{release}
This package requires everything which is needed to build a generic
all purpose initramfs with network support with dracut.
%if 0%{?fedora}
%if 0%{?fedora} || 0%{?rhel} > 6
%package fips
Summary: Dracut modules to build a dracut initramfs with an integrity check
Requires: %{name} = %{version}-%{release}
@@ -137,6 +134,15 @@ This package requires everything which is needed to build an
all purpose initramfs with dracut, which does an integrity check.
%endif
%package fips-aesni
Summary: Dracut modules to build a dracut initramfs with an integrity check with aesni-intel
Requires: %{name}-fips = %{version}-%{release}
%description fips-aesni
This package requires everything which is needed to build an
all purpose initramfs with dracut, which does an integrity check
and adds the aesni-intel kernel module.
%package caps
Summary: Dracut modules to build a dracut initramfs which drops capabilities
Requires: %{name} = %{version}-%{release}
@@ -156,24 +162,38 @@ This package contains tools to assemble the local initrd and host configuration.
%prep
%setup -q -n %{name}-%{version}
%if %{defined PATCH1}
git init
git config user.email "dracut-maint@redhat.com"
git config user.name "Fedora dracut team"
git add .
git commit -a -q -m "%{version} baseline."
# Apply all the patches.
git am -p1 %{patches}
%endif
%build
make
%install
%if 0%{?fedora}
%if 0%{?fedora} || 0%{?rhel} > 6
rm -rf $RPM_BUILD_ROOT
%endif
make install DESTDIR=$RPM_BUILD_ROOT sbindir=/sbin \
make install DESTDIR=$RPM_BUILD_ROOT \
libdir=%{_prefix}/lib \
bindir=%{_bindir} \
sysconfdir=/etc mandir=%{_mandir}
echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/%{_datadir}/dracut/modules.d/10rpmversion/dracut-version
echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/10rpmversion/dracut-version
%if 0%{?fedora} == 0
rm -fr $RPM_BUILD_ROOT/%{_datadir}/dracut/modules.d/01fips
%if 0%{?fedora} == 0 && 0%{?rhel} == 0
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/01fips
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/02fips-aesni
%endif
# remove gentoo specific modules
rm -fr $RPM_BUILD_ROOT/%{_datadir}/dracut/modules.d/50gensplash
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/50gensplash
mkdir -p $RPM_BUILD_ROOT/boot/dracut
mkdir -p $RPM_BUILD_ROOT/var/lib/dracut/overlay
@@ -181,7 +201,7 @@ mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log
touch $RPM_BUILD_ROOT%{_localstatedir}/log/dracut.log
mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/initramfs
%if 0%{?fedora}
%if 0%{?fedora} || 0%{?rhel} > 6
install -m 0644 dracut.conf.d/fedora.conf.example $RPM_BUILD_ROOT/etc/dracut.conf.d/01-dist.conf
install -m 0644 dracut.conf.d/fips.conf.example $RPM_BUILD_ROOT/etc/dracut.conf.d/40-fips.conf
%endif
@@ -191,8 +211,8 @@ install -m 0644 dracut.conf.d/suse.conf.example $RPM_BUILD_ROOT/etc/dracut.con
%endif
%if 0%{?fedora} <= 12 && 0%{?rhel} < 6 && 0%{?suse_version} <= 9999
rm $RPM_BUILD_ROOT/sbin/mkinitrd
rm $RPM_BUILD_ROOT/sbin/lsinitrd
rm $RPM_BUILD_ROOT%{_bindir}/mkinitrd
rm $RPM_BUILD_ROOT%{_bindir}/lsinitrd
%endif
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
@@ -204,90 +224,97 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,0755)
%doc README HACKING TODO COPYING AUTHORS NEWS dracut.html dracut.png dracut.svg
/sbin/dracut
%{_bindir}/dracut
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999
/sbin/mkinitrd
/sbin/lsinitrd
%{_bindir}/mkinitrd
%{_bindir}/lsinitrd
%endif
%dir %{_datadir}/dracut
%dir %{_datadir}/dracut/modules.d
%{_datadir}/dracut/dracut-functions
%{_datadir}/dracut/dracut-logger
%dir %{dracutlibdir}
%dir %{dracutlibdir}/modules.d
%{dracutlibdir}/dracut-functions
%{dracutlibdir}/dracut-logger
%config(noreplace) /etc/dracut.conf
%if 0%{?fedora} || 0%{?suse_version}
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} > 6
%config /etc/dracut.conf.d/01-dist.conf
%endif
%dir /etc/dracut.conf.d
%{_mandir}/man8/dracut.8*
%{_mandir}/man7/dracut.kernel.7*
%{_mandir}/man7/dracut.cmdline.7*
%{_mandir}/man5/dracut.conf.5*
%{_datadir}/dracut/modules.d/00bootchart
%{_datadir}/dracut/modules.d/00dash
%{_datadir}/dracut/modules.d/05busybox
%{_datadir}/dracut/modules.d/10i18n
%{_datadir}/dracut/modules.d/10rpmversion
%{_datadir}/dracut/modules.d/50plymouth
%{_datadir}/dracut/modules.d/60xen
%{_datadir}/dracut/modules.d/90btrfs
%{_datadir}/dracut/modules.d/90crypt
%{_datadir}/dracut/modules.d/90dm
%{_datadir}/dracut/modules.d/90dmraid
%{_datadir}/dracut/modules.d/90dmsquash-live
%{_datadir}/dracut/modules.d/90kernel-modules
%{_datadir}/dracut/modules.d/90lvm
%{_datadir}/dracut/modules.d/90mdraid
%{_datadir}/dracut/modules.d/90multipath
%{_datadir}/dracut/modules.d/91crypt-gpg
%{_datadir}/dracut/modules.d/95debug
%{_datadir}/dracut/modules.d/95resume
%{_datadir}/dracut/modules.d/95rootfs-block
%{_datadir}/dracut/modules.d/95dasd
%{_datadir}/dracut/modules.d/95dasd_mod
%{_datadir}/dracut/modules.d/95fstab-sys
%{_datadir}/dracut/modules.d/95zfcp
%{_datadir}/dracut/modules.d/95terminfo
%{_datadir}/dracut/modules.d/95udev-rules
%{_datadir}/dracut/modules.d/97biosdevname
%{_datadir}/dracut/modules.d/97masterkey
%{_datadir}/dracut/modules.d/98ecryptfs
%{_datadir}/dracut/modules.d/98integrity
%{_datadir}/dracut/modules.d/98selinux
%{_datadir}/dracut/modules.d/98syslog
%{_datadir}/dracut/modules.d/99base
%{_datadir}/dracut/modules.d/99fs-lib
%{_datadir}/dracut/modules.d/99shutdown
%{dracutlibdir}/modules.d/00bootchart
%{dracutlibdir}/modules.d/00dash
%{dracutlibdir}/modules.d/05busybox
%{dracutlibdir}/modules.d/10i18n
%{dracutlibdir}/modules.d/10rpmversion
%{dracutlibdir}/modules.d/50plymouth
%{dracutlibdir}/modules.d/90btrfs
%{dracutlibdir}/modules.d/90crypt
%{dracutlibdir}/modules.d/90dm
%{dracutlibdir}/modules.d/90dmraid
%{dracutlibdir}/modules.d/90dmsquash-live
%{dracutlibdir}/modules.d/90kernel-modules
%{dracutlibdir}/modules.d/90lvm
%{dracutlibdir}/modules.d/90mdraid
%{dracutlibdir}/modules.d/90multipath
%{dracutlibdir}/modules.d/91crypt-gpg
%{dracutlibdir}/modules.d/95debug
%{dracutlibdir}/modules.d/95resume
%{dracutlibdir}/modules.d/95rootfs-block
%{dracutlibdir}/modules.d/95dasd
%{dracutlibdir}/modules.d/95dasd_mod
%{dracutlibdir}/modules.d/95fstab-sys
%{dracutlibdir}/modules.d/95zfcp
%{dracutlibdir}/modules.d/95terminfo
%{dracutlibdir}/modules.d/95udev-rules
%{dracutlibdir}/modules.d/96securityfs
%{dracutlibdir}/modules.d/97biosdevname
%{dracutlibdir}/modules.d/97masterkey
%{dracutlibdir}/modules.d/98ecryptfs
%{dracutlibdir}/modules.d/98integrity
%{dracutlibdir}/modules.d/98selinux
%{dracutlibdir}/modules.d/98syslog
%{dracutlibdir}/modules.d/98usrmount
%{dracutlibdir}/modules.d/99base
%{dracutlibdir}/modules.d/99fs-lib
%{dracutlibdir}/modules.d/99shutdown
%config(noreplace) /etc/logrotate.d/dracut_log
%attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log
%dir %{_sharedstatedir}/initramfs
%files network
%defattr(-,root,root,0755)
%{_datadir}/dracut/modules.d/40network
%{_datadir}/dracut/modules.d/95fcoe
%{_datadir}/dracut/modules.d/95iscsi
%{_datadir}/dracut/modules.d/90livenet
%{_datadir}/dracut/modules.d/95nbd
%{_datadir}/dracut/modules.d/95nfs
%{_datadir}/dracut/modules.d/45ifcfg
%{_datadir}/dracut/modules.d/95znet
%{dracutlibdir}/modules.d/40network
%{dracutlibdir}/modules.d/95fcoe
%{dracutlibdir}/modules.d/95iscsi
%{dracutlibdir}/modules.d/90livenet
%{dracutlibdir}/modules.d/95nbd
%{dracutlibdir}/modules.d/95nfs
%{dracutlibdir}/modules.d/45ifcfg
%{dracutlibdir}/modules.d/95znet
%if 0%{?fedora}
%if 0%{?fedora} || 0%{?rhel} > 6
%files fips
%defattr(-,root,root,0755)
%{_datadir}/dracut/modules.d/01fips
%{dracutlibdir}/modules.d/01fips
%config(noreplace) /etc/dracut.conf.d/40-fips.conf
%endif
%files fips-aesni
%defattr(-,root,root,0755)
%doc COPYING
%{dracutlibdir}/modules.d/02fips-aesni
%files caps
%defattr(-,root,root,0755)
%{_datadir}/dracut/modules.d/02caps
%{dracutlibdir}/modules.d/02caps
%files tools
%defattr(-,root,root,0755)
%{_mandir}/man8/dracut-gencmdline.8*
%{_mandir}/man8/dracut-catimages.8*
/sbin/dracut-gencmdline
/sbin/dracut-catimages
%{_bindir}/dracut-gencmdline
%{_bindir}/dracut-catimages
%dir /boot/dracut
%dir /var/lib/dracut
%dir /var/lib/dracut/overlay

View File

@@ -170,7 +170,7 @@ include ld.so.conf.d/*.conf</screen>
<para>To see a list of available dracut modules, use the <option>--list-modules</option> option:</para>
<screen># dracut --list-modules</screen>
<para>or, if you have a dracut version earlier than <literal>008</literal>, issue the command:</para>
<screen># for mod in /usr/share/dracut/modules.d/*; do echo ${mod##*/??}; done</screen>
<screen># for mod in /usr/lib/dracut/modules.d/*; do echo ${mod##*/??}; done</screen>
</section>
<section>
<title>Omitting dracut Modules</title>
@@ -534,7 +534,7 @@ Key slot 0 unlocked. </screen></para>
<title>Developer Manual</title>
<section>
<title>dracut Components</title>
<para>dracut uses a modular system to build and extend the initramfs image. All modules are located in <filename>/usr/share/dracut/modules.d</filename> or in <filename><replaceable>&lt;git-src&gt;</replaceable>/modules.d</filename>. The most basic dracut module is <filename>99base</filename>. In <filename>99base</filename> the initial shell script <command>init</command> is defined, which gets run by the kernel after initramfs loading. Although you can replace <command>init</command> with your own version of <filename>99base</filename>, this is not encouraged. Instead you should use, if possible, the hooks of dracut. All hooks, and the point of time in which they are executed, are described in <xref linkend="stages"/>.</para>
<para>dracut uses a modular system to build and extend the initramfs image. All modules are located in <filename>/usr/lib/dracut/modules.d</filename> or in <filename><replaceable>&lt;git-src&gt;</replaceable>/modules.d</filename>. The most basic dracut module is <filename>99base</filename>. In <filename>99base</filename> the initial shell script <command>init</command> is defined, which gets run by the kernel after initramfs loading. Although you can replace <command>init</command> with your own version of <filename>99base</filename>, this is not encouraged. Instead you should use, if possible, the hooks of dracut. All hooks, and the point of time in which they are executed, are described in <xref linkend="stages"/>.</para>
<para>The main script, which creates the initramfs is <command>dracut</command> itsself. It parses all arguments and sets up the directory, in which everything is installed. It then executes all <command>check</command>, <command>install</command>, <command>installkernel</command> scripts found in the modules, which are to be processed. After everything is installed, the install directory is archived and compressed to the final initramfs image. All helper functions used by <command>check</command>, <command>install</command> and <command>installkernel</command> are found in in the file <filename>dracut-functions</filename>. These shell functions are available to all module installer (<command>install</command>, <command>installkernel</command>) scripts, without the need to source <filename>dracut-functions</filename>.</para>
<para>A module can check the preconditions for <command>install</command> and <command>installkernel</command> with the <command>check</command> script. Also dependencies can be expressed with <command>check</command>. If a module passed <command>check</command>, <command>install</command> and <command>installkernel</command> will be called to install all of the necessary files for the module. To split between kernel and non-kernel parts of the installation, all kernel module related parts have to be in <command>installkernel</command>. All other files found in a module directory are module specific and mostly are hook scripts and udev rules.</para>
</section>
@@ -721,9 +721,9 @@ done
<title>dracut.conf</title>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.conf.5.xml" encoding="UTF-8" parse="xml"/>
</section>
<section id="dracut.kernel">
<title>dracut.kernel</title>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.kernel.7.xml" encoding="UTF-8" parse="xml"/>
<section id="dracut.cmdline">
<title>dracut.cmdline</title>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.cmdline.7.xml" encoding="UTF-8" parse="xml"/>
</section>
</appendix>
</book>

View File

@@ -18,27 +18,21 @@ sub last_tag {
sub create_patches {
my $tag=shift;
my $pdir=shift;
my $num=0;
open( GIT, 'git format-patch --no-renames -N --no-signature '.$tag.' |');
open( GIT, 'git format-patch -N --no-signature -o "'.$pdir.'" '.$tag.' |');
@lines=<GIT>;
close GIT; # be done
return @lines;
};
sub filter_patch {
my $patch=shift;
open(P, $patch);
@lines=<P>;
close(P);
grep (/^ 0 files changed/, @lines);
}
use POSIX qw(strftime);
my $datestr = strftime "%Y%m%d", gmtime;
my $tag=shift;
my $pdir=shift;
$tag=&last_tag if not defined $tag;
my @patches=&create_patches($tag);
my @patches=&create_patches($tag, $pdir);
my $num=$#patches + 2;
$tag=~s/[^0-9]+?([0-9]+)/$1/;
my $release="$num.git$datestr";
@@ -55,22 +49,12 @@ while(<>) {
print $_;
$num=1;
for(@patches) {
next if filter_patch $_;
s/.*\///g;
print "Patch$num: $_";
$num++;
}
print "\n";
}
elsif (/^%setup/) {
print $_;
$num=1;
for(@patches) {
next if filter_patch $_;
print "%patch$num -p1\n";
$num++;
}
print "\n";
}
else {
print $_;
}

View File

@@ -0,0 +1,30 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
return 255
}
depends() {
return 0
}
installkernel() {
local _fipsmodules _mod
_fipsmodules="aesni-intel"
mkdir -m 0755 -p "${initdir}/etc/modprobe.d"
for _mod in $_fipsmodules; do
if instmods $_mod; then
echo $_mod >> "${initdir}/etc/fipsmodules"
echo "blacklist $_mod" >> "${initdir}/etc/modprobe.d/fips.conf"
fi
done
}
install() {
return 0
}

View File

@@ -22,6 +22,7 @@ set_terminal() {
stty -F ${dev} iutf8
else
printf '\033%%@' >&7
stty -F ${dev} -iutf8
fi
}

View File

@@ -150,22 +150,24 @@ install() {
inst_simple ${kbddir}/unimaps/${FONT_UNIMAP}.uni
fi
shopt -q -s nocasematch
if [[ ${UNICODE} ]]
then
if [[ ${UNICODE^^} = YES || ${UNICODE} = 1 ]]
if [[ ${UNICODE} = YES || ${UNICODE} = 1 ]]
then
UNICODE=1
elif [[ ${UNICODE^^} = NO || ${UNICODE} = 0 ]]
elif [[ ${UNICODE} = NO || ${UNICODE} = 0 ]]
then
UNICODE=0
else
UNICODE=''
fi
fi
if [[ ! ${UNICODE} && ${LANG^^} =~ .*\.UTF-?8 ]]
if [[ ! ${UNICODE} && ${LANG} =~ .*\.UTF-?8 ]]
then
UNICODE=1
fi
shopt -q -u nocasematch
mksubdirs ${initdir}${I18N_CONF}
mksubdirs ${initdir}${VCONFIG_CONF}

View File

@@ -63,7 +63,7 @@ do_static() {
# do not flush addr for ipv6
strstr $ip '*:*:*' || \
echo ip addr flush dev $netif
echo ip addr add $ip/$mask dev $netif
echo ip addr add $ip/$mask brd + dev $netif
} > /tmp/net.$netif.up
[ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw

View File

@@ -24,15 +24,40 @@ depends() {
installkernel() {
# Include wired net drivers, excluding wireless
net_module_test() {
net_module_filter() {
local _net_drivers='eth_type_trans|register_virtio_device'
local _unwanted_drivers='/(wireless|isdn|uwb)/'
egrep -q $_net_drivers "$1" && \
egrep -qv 'iw_handler_get_spy' "$1" && \
[[ ! $1 =~ $_unwanted_drivers ]]
# subfunctions inherit following FDs
local _merge=8 _side2=9
function nmf1() {
local _fname _fcont
while read _fname; do
[[ $_fname =~ $_unwanted_drivers ]] && continue
case "$_fname" in
*.ko) _fcont="$(< $_fname)" ;;
*.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
esac
[[ $_fcont =~ $_net_drivers
&& ! $_fcont =~ iw_handler_get_spy ]] \
&& echo "$_fname"
done
}
function rotor() {
local _f1 _f2
while read _f1; do
echo "$_f1"
if read _f2; then
echo "$_f2" 1>&${_side2}
fi
done | nmf1 1>&${_merge}
}
# Use two parallel streams to filter alternating modules.
set +x
eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
[[ $debug ]] && set -x
}
instmods $(filter_kernel_modules_by_path drivers/net net_module_test)
find_kernel_modules_by_path drivers/net | net_module_filter | instmods
instmods ecb arc4
# bridge modules

View File

@@ -119,7 +119,7 @@ if [ -n "$netroot_ip" ]; then
fi
fi
if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
die "Resolving $dest via ARP on $netif failed"
dinfo "Resolving $dest via ARP on $netif failed"
fi
# Source netroot hooks before we start the handler

View File

@@ -18,6 +18,7 @@ if getarg bond= >/dev/null ; then
if [ -z "$netroot" ] ; then
die "No netboot configured, bond is invalid"
fi
command -v brctl >/dev/null 2>&1 || die "No 'brctl' installed"
fi
# We translate list of slaves to space-separated here to mwke it easier to loop over them in ifup

View File

@@ -16,6 +16,7 @@ if getarg bridge= >/dev/null ; then
if [ -z "$netroot" ] ; then
die "No netboot configured, bridge is invalid"
fi
command -v brctl >/dev/null 2>&1 || die "No 'brctl' installed"
fi
parsebridge() {

View File

@@ -2,7 +2,7 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if getargbool 1 rd.plymouth -n rd_NO_PLYMOUTH; then
if getargbool 1 plymouth.enable && getargbool 1 rd.plymouth -n rd_NO_PLYMOUTH; then
[ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
# first trigger graphics subsystem
udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1
@@ -18,7 +18,9 @@ if getargbool 1 rd.plymouth -n rd_NO_PLYMOUTH; then
info "Starting plymouth daemon"
mkdir -m 0755 /run/plymouth
[ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0
consoledev=$(getarg console= | sed -e 's/,.*//')
consoledev=${consoledev:-tty0}
[ -x /lib/udev/console_init ] && /lib/udev/console_init "/dev/$consoledev"
[ -x /bin/plymouthd ] && /bin/plymouthd --attach-to-session --pid-file /run/plymouth/pid
/bin/plymouth --show-splash 2>&1 | vinfo
# reset tty after plymouth messed with it

View File

@@ -1,42 +0,0 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
# No Xen-detect? Boo!!
if ! hash xen-detect 2>/dev/null; then
[[ -d /usr/lib/xen-default ]] && \
hash -p /usr/lib/xen-default/bin/xen-detect xen-detect || return 1
fi
. $dracutfunctions
[[ $debug ]] && set -x
# Yes, we are under Xen PV env.
xen-detect | grep -q -v PV || return 0
return 1
}
depends() {
return 0
}
installkernel() {
local _i
for _i in \
xenbus_probe_frontend xen-pcifront \
xen-fbfront xen-kbdfront xen-blkfront xen-netfront \
; do
modinfo -k $kernel $_i >/dev/null 2>&1 && instmods $_i
done
}
install() {
hash xen-detect 2>/dev/null || \
hash -p /usr/lib/xen-default/bin/xen-detect xen-detect
inst "$(hash -t xen-detect)" /sbin/xen-detect
inst_hook pre-udev 40 "$moddir/xen-pre-udev.sh"
}

View File

@@ -1,13 +0,0 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
xen-detect
RC=$?
if [ "$RC" = "1" ] ; then
modprobe xenbus_probe_frontend
modprobe xen-kbdfront
modprobe xen-fbfront
modprobe xen-blkfront
modprobe xen-netfront
modprobe xen-pcifront
fi

View File

@@ -4,13 +4,15 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
if [ -e /dev/root ]; then
if strstr "$(udevadm info --query=env --name=/dev/root)" "ID_FS_TYPE=btrfs"; then
dev="${1:-/dev/root}"
if [ -e "$dev" ]; then
if strstr "$(udevadm info --query=env \"--name=$dev\")" "ID_FS_TYPE=btrfs"; then
info "Checking, if btrfs device complete"
unset __btrfs_mount
mount -o ro /dev/root /tmp >/dev/null 2>&1
mount -o ro "$dev" /tmp >/dev/null 2>&1
__btrfs_mount=$?
[ $__btrfs_mount -eq 0 ] && umount /dev/root >/dev/null 2>&1
[ $__btrfs_mount -eq 0 ] && umount "$dev" >/dev/null 2>&1
exit $__btrfs_mount
fi
fi

39
modules.d/90crypt/crypt-lib.sh Normal file → Executable file
View File

@@ -47,7 +47,7 @@ ask_for_password() {
{ flock -s 9;
# Prompt for password with plymouth, if installed and running.
if [ -x /bin/plymouth ]; then
if [ -x /bin/plymouth ] && /bin/plymouth --ping; then
/bin/plymouth ask-for-password \
--prompt "$ply_prompt" --number-of-tries=$ply_tries \
--command="$ply_cmd"
@@ -100,43 +100,6 @@ test_dev() {
return $ret
}
# Get kernel name for given device. Device may be the name too (then the same
# is returned), a symlink (full path), UUID (prefixed with "UUID=") or label
# (prefixed with "LABEL="). If just a beginning of the UUID is specified or
# even an empty, function prints all device names which UUIDs match - every in
# single line.
#
# NOTICE: The name starts with "/dev/".
#
# Example:
# devnames UUID=123
# May print:
# /dev/dm-1
# /dev/sdb1
# /dev/sdf3
devnames() {
local dev="$1"; local d; local names
case "$dev" in
UUID=*)
dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \
&& return 255
[ -z "$dev" ] && return 255
;;
LABEL=*) dev="$(blkid -L "${dev#LABEL=}")" || return 255 ;;
/dev/?*) ;;
*) return 255 ;;
esac
for d in $dev; do
names="$names
$(readlink -e -q "$d")" || return 255
done
echo "${names#
}"
}
# match_dev devpattern dev
#
# Returns true if 'dev' matches 'devpattern'. Both 'devpattern' and 'dev' are

View File

@@ -22,6 +22,9 @@ NEWROOT=${NEWROOT:-"/sysroot"}
# default luksname - luks-UUID
luksname=$2
# fallback to passphrase
ask_passphrase=1
# if device name is /dev/dm-X, convert to /dev/mapper/name
if [ "${1##/dev/dm-}" != "$1" ]; then
device="/dev/mapper/$(dmsetup info -c --noheadings -o name "$1")"
@@ -31,7 +34,7 @@ fi
# TODO: improve to support what cmdline does
if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -n rd_NO_CRYPTTAB; then
while read name dev rest; do
while read name dev luksfile rest; do
# ignore blank lines and comments
if [ -z "$name" -o "${name#\#}" != "$name" ]; then
continue
@@ -61,26 +64,45 @@ fi
# Open LUKS device
#
info "luksOpen $device $luksname"
info "luksOpen $device $luksname $luksfile"
if [ -n "$(getarg rd.luks.key)" ]; then
if tmp=$(getkey /tmp/luks.keys $device); then
keydev="${tmp%%:*}"
keypath="${tmp#*:}"
else
info "No key found for $device. Will try later."
initqueue --unique --onetime --settled \
--name cryptroot-ask-$luksname \
$(command -v cryptroot-ask) "$@"
exit 0
if [ -n "$luksfile" -a "$luksfile" != "none" -a -e "$luksfile" ]; then
if cryptsetup --key-file "$luksfile" luksOpen "$device" "$luksname"; then
ask_passphrase=0
fi
unset tmp
info "Using '$keypath' on '$keydev'"
readkey "$keypath" "$keydev" "$device" \
| cryptsetup -d - luksOpen "$device" "$luksname"
unset keypath keydev
else
while [ -n "$(getarg rd.luks.key)" ]; do
if tmp=$(getkey /tmp/luks.keys $device); then
keydev="${tmp%%:*}"
keypath="${tmp#*:}"
else
if [ $# -eq 3 ]; then
if [ $3 -eq 0 ]; then
info "No key found for $device. Fallback to passphrase mode."
break
fi
info "No key found for $device. Will try $3 time(s) more later."
set -- "$1" "$2" "$(($3 - 1))"
else
info "No key found for $device. Will try later."
fi
initqueue --unique --onetime --settled \
--name cryptroot-ask-$luksname \
$(command -v cryptroot-ask) "$@"
exit 0
fi
unset tmp
info "Using '$keypath' on '$keydev'"
readkey "$keypath" "$keydev" "$device" \
| cryptsetup -d - luksOpen "$device" "$luksname"
unset keypath keydev
ask_passphrase=0
break
done
fi
if [ $ask_passphrase -ne 0 ]; then
luks_open="$(command -v cryptsetup) luksOpen"
ask_for_password --ply-tries 5 \
--ply-cmd "$luks_open -T1 $device $luksname" \
@@ -90,7 +112,7 @@ else
unset luks_open
fi
unset device luksname
unset device luksname luksfile
# mark device as asked
>> /tmp/cryptroot-asked-$2

View File

@@ -11,6 +11,7 @@ else
} > /etc/udev/rules.d/70-luks.rules.new
LUKS=$(getargs rd.luks.uuid rd_LUKS_UUID)
tout=$(getarg rd.luks.key.tout)
if [ -n "$LUKS" ]; then
for luksid in $LUKS; do
@@ -20,11 +21,25 @@ else
printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
printf -- '--name cryptroot-ask-%%k %s ' $(command -v cryptroot-ask)
printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID}"\n'
printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $tout
} >> /etc/udev/rules.d/70-luks.rules.new
printf -- '[ -e /dev/disk/by-uuid/*%s* ]\n' $luksid \
>> $hookdir/initqueue/finished/90-crypt.sh
[ -e $hookdir/initqueue/finished/90-crypt.sh ] || \
{
printf -- 'UUIDS=:\n'
printf -- 'for dm in /dev/dm-*; do\n'
printf -- '[ -e "$dm" ] || exit 1\n'
printf -- 'dmid=`/sbin/dmsetup info -c -o uuid --noheadings "$dm"`\n'
printf -- 'uuid=${dmid#CRYPT-LUKS*-}\n'
printf -- '[ "x$uuid" = "x$dmid" ] && continue\n'
printf -- 'UUIDS="${UUIDS}${uuid%%%%-*}:"\n'
printf -- 'done\n'
} > $hookdir/initqueue/finished/90-crypt.sh
uuid=$luksid
while [ "$uuid" != "${uuid#*-}" ]; do uuid=${uuid%%-*}${uuid#*-}; done
printf -- '[ "x${UUIDS#*:%s*:}" != "x$UUIDS" ] || exit 1\n' $uuid >> $hookdir/initqueue/finished/90-crypt.sh
{
printf -- '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid
printf -- 'warn "crypto LUKS UUID "%s" not found"\n' $luksid
@@ -34,7 +49,7 @@ else
{
printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' $(command -v initqueue)
printf -- '--unique --onetime --name cryptroot-ask-%%k '
printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID}"\n' $(command -v cryptroot-ask)
printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $(command -v cryptroot-ask) $tout
} >> /etc/udev/rules.d/70-luks.rules.new
fi

0
modules.d/90crypt/parse-keydev.sh Normal file → Executable file
View File

0
modules.d/90dm/dm-shutdown.sh Normal file → Executable file
View File

View File

@@ -22,7 +22,7 @@ install() {
type -P dmeventd >/dev/null && dracut_install dmeventd
for _i in {"$libdir","$usrlibdir"}/libdmraid-events*.so; do
for _i in {"$libdir","$usrlibdir"}/libdevmapper-event.so*; do
[ -e "$_i" ] && dracut_install "$_i"
done

View File

@@ -10,6 +10,7 @@ ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="dm_end"
ENV{ID_FS_TYPE}!="*_raid_member", , GOTO="dm_end"
ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}!="?*", GOTO="dm_end"
ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}!="?*", GOTO="dm_end"
ENV{rd_NO_DM}=="?*", GOTO="dm_end"

View File

@@ -44,6 +44,10 @@ install() {
inst_rules 64-md-raid.rules
fi
for _i in {"$libdir","$usrlibdir"}/libdmraid-events*.so*; do
[ -e "$_i" ] && dracut_install "$_i"
done
inst_rules "$moddir/61-dmraid-imsm.rules"
#inst "$moddir/dmraid-cleanup.sh" /sbin/dmraid-cleanup
inst_hook pre-trigger 30 "$moddir/parse-dm.sh"

View File

@@ -12,3 +12,7 @@ if ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM |
udevproperty rd_NO_MDIMSM=1
fi
if ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF || getarg noddfmd; then
info "rd.md.ddf=0: no MD RAID for SNIA ddf raids"
udevproperty rd_NO_MDDDF=1
fi

View File

@@ -1,7 +1,8 @@
#!/bin/sh
if [ -b /dev/mapper/live-rw ]; then
if [ "`echo /updates/*`" != "/updates/*" ]; then
if pushd /updates &>/dev/null; then
echo "Applying updates to live image..."
/bin/cp -a /updates/* $NEWROOT
/bin/cp -a -t $NEWROOT .
popd &>/dev/null
fi
fi

View File

@@ -3,24 +3,17 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
case "$root" in
live:/dev/*)
{
printf 'KERNEL=="%s", SYMLINK+="live"\n' \
${root#live:/dev/}
printf 'SYMLINK=="%s", SYMLINK+="live"\n' \
${root#live:/dev/}
} >> $UDEVRULESD/99-live-mount.rules
{
printf 'KERNEL=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root $env{DEVNAME}"\n' \
${root#live:/dev/}
printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root $env{DEVNAME}"\n' \
${root#live:/dev/}
} >> $UDEVRULESD/99-live-squash.rules
echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/dmsquash.sh
} >> /etc/udev/rules.d/99-live-squash.rules
wait_for_dev "${root#live:}"
;;
live:*)
if [ -f "${root#live:}" ]; then
/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root "${root#live:}"
echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/dmsquash.sh
fi
;;
esac

View File

@@ -3,6 +3,8 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
[ -f /tmp/root.info ] && . /tmp/root.info
PATH=/usr/sbin:/usr/bin:/sbin:/bin
@@ -43,9 +45,7 @@ fi
# determine filesystem type for a filesystem image
det_img_fs() {
local _img="$1" _loop=$(losetup -f) _fs
losetup $_loop $_img; _fs=$(det_fs $_loop); losetup -d $_loop
echo $_fs
blkid -s TYPE -u noraid -o value "$1"
}
for arg in $CMDLINE; do case $arg in ro|rw) liverw=$arg ;; esac; done
@@ -54,11 +54,13 @@ mkdir -m 0755 -p /run/initramfs/live
if [ -f $livedev ]; then
# no mount needed - we've already got the LiveOS image in initramfs
# check filesystem type and handle accordingly
case `det_img_fs $livedev` in
squashfs) SQUASHED=$livedev ;;
fstype=$(det_img_fs $livedev)
case $fstype in
squashfs) SQUASHED=$livedev;;
auto) die "cannot mount live image (unknown filesystem type)" ;;
*) FSIMG=$livedev ;;
esac
[ -e /sys/fs/$fstype ] || modprobe $fstype
else
mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live
if [ "$?" != "0" ]; then

View File

@@ -6,5 +6,4 @@ if [ "${root%%:*}" = "liveiso" ]; then
printf 'KERNEL=="loop0", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root `/sbin/losetup -f --show %s`"\n' \
${root#liveiso:}
} >> /etc/udev/rules.d/99-liveiso-mount.rules
echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/dmsquash.sh
fi

View File

@@ -5,7 +5,7 @@
check() {
# a live host-only image doesn't really make a lot of sense
[[ $hostonly ]] && return 1
return 0
return 255
}
depends() {

View File

@@ -41,7 +41,9 @@ case "$liveroot" in
live:/*.[Ii][Mm][Gg]|/*.[Ii][Mm][Gg])
[ -f "${root#live:}" ] && rootok=1 ;;
esac
info "root was $root, liveroot is now $liveroot"
info "liveroot was $liveroot, is now $root"
# make sure that init doesn't complain
[ -z "$root" ] && root="live"
wait_for_dev /dev/mapper/live-rw

View File

@@ -4,10 +4,31 @@
installkernel() {
if [[ -z $drivers ]]; then
block_module_test() {
local blockfuncs='ahci_init_controller|ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device'
egrep -q "$blockfuncs" "$1"
block_module_filter() {
local _blockfuncs='ahci_init_controller|ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect'
# subfunctions inherit following FDs
local _merge=8 _side2=9
function bmf1() {
local _f
while read _f; do case "$_f" in
*.ko) [[ $(< $_f) =~ $_blockfuncs ]] && echo "$_f" ;;
*.ko.gz) [[ $(gzip -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
esac
done
}
function rotor() {
local _f1 _f2
while read _f1; do
echo "$_f1"
if read _f2; then
echo "$_f2" 1>&${_side2}
fi
done | bmf1 1>&${_merge}
}
# Use two parallel streams to filter alternating modules.
set +x
eval "( ( rotor ) ${_side2}>&1 | bmf1 ) ${_merge}>&1"
[[ $debug ]] && set -x
}
hostonly='' instmods sr_mod sd_mod scsi_dh scsi_dh_rdac scsi_dh_emc
hostonly='' instmods pcmcia firewire-ohci
@@ -18,7 +39,7 @@ installkernel() {
# install unix socket support
hostonly='' instmods unix
instmods "=drivers/pcmcia" =ide "=drivers/usb/storage"
instmods $(filter_kernel_modules block_module_test)
find_kernel_modules | block_module_filter | instmods
# if not on hostonly mode, install all known filesystems,
# if the required list is not set via the filesystems variable
if ! [[ $hostonly ]]; then

View File

@@ -4,7 +4,8 @@
check() {
# a live, host-only image doesn't really make a lot of sense
[[ $hostonly ]] && return 1
return 0
command -v wget >/dev/null || return 1
return 255
}
depends() {
@@ -15,7 +16,9 @@ depends() {
install() {
dracut_install wget
mkdir -m 0755 -p "$initdir/etc/ssl/certs"
if ! inst_simple /etc/ssl/certs/ca-bundle.crt; then
if ! inst_any -t /etc/ssl/certs/ca-bundle.crt \
/etc/ssl/certs/ca-bundle.crt \
/etc/ssl/certs/ca-certificates.crt; then
dwarn "Couldn't find SSL CA cert bundle; HTTPS won't work."
fi

View File

@@ -12,8 +12,8 @@ liveurl="${liveurl#live:}"
case "$liveurl" in
http://*|https://*|ftp://*)
netroot="livenet:$liveurl"
root="livenet" # quiet complaints from init
rootok=1 ;;
esac
root="livenet" # quiet complaints from init
echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/livenet.sh

View File

@@ -13,7 +13,7 @@ PROGRAM=="/bin/sh -c 'for i in $sys/$devpath/holders/dm-[0-9]*; do [ -e $$i ] &&
GOTO="lvm_end"
RUN+="/sbin/initqueue --settled --onetime --unique /sbin/lvm_scan"
RUN+="/sbin/initqueue --timeout --onetime --unique /sbin/lvm_scan --partial"
RUN+="/sbin/initqueue --timeout --name 51-lvm_scan --onetime --unique /sbin/lvm_scan --partial"
RUN+="/bin/sh -c '>/tmp/.lvm_scan-%k;'"
LABEL="lvm_end"

View File

@@ -48,7 +48,7 @@ install() {
fi
fi
inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules 11-dm-lvm.rules
inst_rules 11-dm-lvm.rules
# Gentoo ebuild for LVM2 prior to 2.02.63-r1 doesn't install above rules
# files, but provides the one below:
inst_rules 64-device-mapper.rules

View File

@@ -10,12 +10,7 @@ if ! getargbool 1 rd.lvm -n rd_NO_LVM; then
rm -f /etc/udev/rules.d/64-lvm*.rules
else
for dev in $(getargs rd.lvm.vg rd_LVM_VG=) $(getargs rd.lvm.lv rd_LVM_LV=); do
printf '[ -e "/dev/%s" ] || return 1\n' $dev \
>> $hookdir/initqueue/finished/lvm.sh
{
printf '[ -e "/dev/%s" ] || ' $dev
printf 'warn "LVM "%s" not found"\n' $dev
} >> $hookdir/emergency/90-lvm.sh
wait_for_dev "/dev/$dev"
done
fi

View File

@@ -2,87 +2,39 @@
# automatically cause mdadm to be run.
# See udev(8) for syntax
ACTION!="add|change", GOTO="md_inc_end"
SUBSYSTEM!="block", GOTO="md_inc_end"
ENV{ID_FS_TYPE}!="linux_raid_member|isw_raid_member", GOTO="md_inc_end"
ACTION!="add|change", GOTO="md_end"
SUBSYSTEM!="block", GOTO="md_end"
ENV{rd_NO_MD}=="?*", GOTO="md_end"
KERNEL=="md*", GOTO="md_end"
ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_inc_end"
ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_try"
GOTO="md_end"
ENV{rd_NO_MD}=="?*", GOTO="md_inc_end"
LABEL="md_try"
ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_end"
ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}=="?*", GOTO="md_end"
PROGRAM=="/bin/sh -c 'for i in $sys/$devpath/holders/md[0-9]*; do [ -e $$i ] && exit 0; done; exit 1;' ", \
GOTO="md_inc_end"
# already done ?
PROGRAM="/bin/sh -c 'for i in $sys/$devpath/holders/md[0-9_]*; do [ -e $$i ] && exit 0; done; exit 1;' ", \
GOTO="md_end"
# for native arrays - array's uuid has to be specified
# for containers - container's uuid has to be specified
# TODO : how to get embedded array's uuid having container's component ?
#
# UUID CHECK
ENV{DEVTYPE}!="partition", \
RUN+="/sbin/partx -d --nr 1-1024 $env{DEVNAME}"
KERNEL!="md*", IMPORT{program}="/sbin/mdadm --examine --export $tempnode"
# UUID CHECK
LABEL="do_md_inc"
RUN+="/sbin/initqueue --timeout --name 50-mdraid_start --onetime --unique /sbin/mdraid_start"
#
# if rd_MDADMCONF do not assemble incrementally
# defer auto assembly until the udev queue is settled
# Incrementally build the md array; this will automatically assemble
# any eventual containers as well (imsm, ddf)
#
ENV{rd_MDADMCONF}!="?*", GOTO="md_auto_end"
LABEL="md_incremental"
RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"
RUN+="/sbin/initqueue --timeout --onetime --unique /sbin/mdadm_auto"
GOTO="md_inc_end"
LABEL="md_auto_end"
#
# Incrementally build the md array
#
RUN+="/sbin/mdadm -I $env{DEVNAME}"
RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"
LABEL="md_inc_end"
#
# Handle non-container raid arrays
#
ACTION=="add|change", \
KERNEL=="md[0-9]*|md/*", \
ENV{MD_LEVEL}!="container", \
ENV{MD_CONTAINER}!="?*", \
ENV{rd_MDADMCONF}!="?*", \
ENV{rd_NO_MD}!="?*", \
GOTO="do_raidstart"
GOTO="end_raidstart"
LABEL="do_raidstart"
# check if array is not inactive anymore
TEST=="md/array_state", ATTR{md/array_state}!="|inactive", GOTO="end_raidstart"
RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"
RUN+="/sbin/initqueue --timeout --onetime --unique /sbin/mdraid_start"
LABEL="end_raidstart"
#
# Handle container raid arrays
#
ACTION=="add|change", \
KERNEL=="md[0-9]*|md/*", \
ENV{DEVTYPE}!="partition", \
ENV{MD_LEVEL}=="container", \
ENV{rd_MDADMCONF}!="?*", \
ENV{rd_NO_MD}!="?*", \
GOTO="do_container"
GOTO="end_container"
LABEL="do_container"
RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"
RUN+="/sbin/initqueue --timeout --onetime --unique --name mdcontainer_start-%k /sbin/mdcontainer_start $env{DEVNAME}"
LABEL="end_container"
LABEL="md_end"

5
modules.d/90mdraid/md-noddf.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
info "rd.md.ddf=0: no MD RAID for SNIA ddf raids"
udevproperty rd_NO_MDDDF=1

View File

@@ -2,4 +2,4 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
info "rd.md.imsm=0: no MD RAID for imsm/isw raids"
udevproperty rd_NO_MDIMSM=1
udevproperty rd_NO_MDIMSM=1

0
modules.d/90mdraid/md-shutdown.sh Normal file → Executable file
View File

View File

@@ -1,9 +0,0 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
for f in $hookdir/initqueue/settled/mdcontainer_start* $hookdir/initqueue/settled/mdraid_start* $hookdir/initqueue/settled/mdadm_auto*; do
[ -e $f ] && exit 1
done
$UDEV_QUEUE_EMPTY >/dev/null 2>&1 || exit 1
exit 0

View File

@@ -1,7 +0,0 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
info "Autoassembling MD Raid"
mdadm -As --auto=yes --run 2>&1 | vinfo

View File

@@ -1,12 +0,0 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
md=$1
udevadm control --stop-exec-queue
# and activate any containers
mdadm -IR $md 2>&1 | vinfo
ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null
ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
udevadm control --start-exec-queue

View File

@@ -2,18 +2,22 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# stop everything which is not busy
for i in /dev/md* /dev/md/*; do
[ -b $i ] || continue
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
mddetail=$(udevadm info --query=property --name=$i)
case "$mddetail" in
*MD_LEVEL=container*)
;;
*DEVTYPE=partition*)
;;
*)
mdadm --stop $i >/dev/null 2>&1
;;
esac
containers=""
for md in /dev/md[0-9_]*; do
[ -b "$md" ] || continue
udevinfo="$(udevadm info --query=env --name=$md)"
strstr "$udevinfo" "DEVTYPE=partition" && continue
if strstr "$udevinfo" "MD_LEVEL=container"; then
containers="$containers $md"
continue
fi
mdadm -S "$md" >/dev/null 2>&1
done
for md in $containers; do
mdadm -S "$md" >/dev/null 2>&1
done
unset containers udevinfo

View File

@@ -0,0 +1,26 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if getargbool 0 rd.md.waitclean; then
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
containers=""
for md in /dev/md[0-9_]*; do
[ -b "$md" ] || continue
udevinfo="$(udevadm info --query=env --name=$md)"
strstr "$udevinfo" "DEVTYPE=partition" && continue
if strstr "$udevinfo" "MD_LEVEL=container"; then
containers="$containers $md"
continue
fi
info "Waiting for $md to become clean"
mdadm -W "$md" >/dev/null 2>&1
done
for md in $containers; do
info "Waiting for $md to become clean"
mdadm -W "$md" >/dev/null 2>&1
done
unset containers udevinfo
fi

View File

@@ -3,24 +3,34 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# run mdadm if udev has settled
info "Assembling MD RAID arrays"
udevadm control --stop-exec-queue
mdadm -As --auto=yes --run 2>&1 | vinfo
mdadm -Is --run 2>&1 | vinfo
_md_force_run() {
local _udevinfo
local _path_s
local _path_d
# try to force-run anything not running yet
for md in /dev/md[0-9_]*; do
[ -b "$md" ] || continue
_udevinfo="$(udevadm info --query=env --name="$md")"
strstr "$_udevinfo" "MD_LEVEL=container" && continue
strstr "$_udevinfo" "DEVTYPE=partition" && continue
# there could still be some leftover devices
# which have had a container added
for md in /dev/md[0-9]* /dev/md/*; do
[ -b "$md" ] || continue
udevinfo="$(udevadm info --query=env --name=$md)"
strstr "$udevinfo" "MD_UUID=" && continue
strstr "$udevinfo" "MD_LEVEL=container" && continue
strstr "$udevinfo" "DEVTYPE=partition" && continue
mdadm --run "$md" 2>&1 | vinfo
done
unset udevinfo
_path_s="/sys/$(udevadm info -q path -n "$md")/md/array_state"
[ ! -r "$_path_s" ] && continue
ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null
ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
udevadm control --start-exec-queue
# inactive ?
[ "$(cat "$_path_s")" != "inactive" ] && continue
mdadm -R "$md" 2>&1 | vinfo
# still inactive ?
[ "$(cat "$_path_s")" = "inactive" ] && continue
_path_d="${_path_s%/*}/degraded"
[ ! -r "$_path_d" ] && continue
# workaround for mdmon bug
[ "$(cat "$_path_d")" -gt "0" ] && mdmon --takeover "$md"
done
}
_md_force_run

View File

@@ -20,7 +20,7 @@ check() {
check_block_and_slaves is_mdraid "$_rootdev" || return 1
else
# root is not on a block device, use the shotgun approach
blkid | egrep -q '(linux|isw)_raid' || return 1
blkid | egrep -q '(linux|isw|ddf)_raid' || return 1
fi
}
@@ -37,7 +37,7 @@ installkernel() {
}
install() {
dracut_install mdadm partx
dracut_install mdadm partx cat
# XXX: mdmon really needs to run as non-root?
@@ -50,13 +50,22 @@ install() {
if [ ! -x /lib/udev/vol_id ]; then
inst_rules 64-md-raid.rules
# remove incremental assembly from stock rules, so they don't shadow
# 65-md-inc*.rules and its fine-grained controls, or cause other problems
# when we explicitly don't want certain components to be incrementally
# assembled
sed -i -r -e '/RUN\+?="[[:alpha:]/]*mdadm[[:blank:]]+(--incremental|-I)[[:blank:]]+(\$env\{DEVNAME\}|\$tempnode)"/d' "${initdir}/lib/udev/rules.d/64-md-raid.rules"
fi
inst_rules "$moddir/65-md-incremental-imsm.rules"
# guard against pre-3.0 mdadm versions, that can't handle containers
if ! mdadm -Q -e imsm /dev/null &> /dev/null; then
inst_hook pre-trigger 30 "$moddir/md-noimsm.sh"
fi
if ! mdadm -Q -e ddf /dev/null &> /dev/null; then
inst_hook pre-trigger 30 "$moddir/md-noddf.sh"
fi
if [[ $hostonly ]] || [[ $mdadmconf = "yes" ]]; then
if [ -f /etc/mdadm.conf ]; then
@@ -72,10 +81,9 @@ install() {
inst_hook pre-udev 30 "$moddir/mdmon-pre-udev.sh"
inst "$moddir/mdraid_start.sh" /sbin/mdraid_start
inst "$moddir/mdcontainer_start.sh" /sbin/mdcontainer_start
inst "$moddir/mdadm_auto.sh" /sbin/mdadm_auto
inst "$moddir/md_finished.sh" /sbin/md_finished.sh
inst_hook pre-trigger 30 "$moddir/parse-md.sh"
inst_hook pre-mount 10 "$moddir/mdraid-waitclean.sh"
inst "$moddir/mdraid-cleanup.sh" /sbin/mdraid-cleanup
inst_hook shutdown 30 "$moddir/md-shutdown.sh"
}

View File

@@ -13,12 +13,14 @@ else
[ -e "$f" ] || continue
while read line; do
if [ "${line%%UUID CHECK}" != "$line" ]; then
printf 'IMPORT{program}="/sbin/mdadm --examine --export $tempnode"\n'
for uuid in $MD_UUID; do
printf 'ENV{MD_UUID}=="%s", GOTO="do_md_inc"\n' $uuid
printf 'ENV{MD_UUID}=="%s", GOTO="md_uuid_ok"\n' $uuid
done;
printf 'GOTO="md_inc_end"\n';
printf 'GOTO="md_end"\n'
printf 'LABEL="md_uuid_ok"\n'
else
echo $line;
echo "$line"
fi
done < "${f}" > "${f}.new"
mv "${f}.new" "$f"
@@ -34,6 +36,7 @@ fi
if ! getargbool 1 rd.md.conf -n rd_NO_MDADMCONF; then
rm -f /etc/mdadm/mdadm.conf /etc/mdadm.conf
ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
fi
# noiswmd nodmraid for anaconda / rc.sysinit compatibility
@@ -42,3 +45,9 @@ if ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM || getarg noiswmd || getarg nodmrai
info "no MD RAID for imsm/isw raids"
udevproperty rd_NO_MDIMSM=1
fi
# same thing with ddf containers
if ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF || getarg noddfmd || getarg nodmraid; then
info "no MD RAID for SNIA ddf raids"
udevproperty rd_NO_MDDDF=1
fi

View File

@@ -33,13 +33,20 @@ depends() {
}
installkernel() {
mp_mod_test() {
local mpfuncs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target'
egrep -q "$mpfuncs" "$1"
set +x
mp_mod_filter() {
local _mpfuncs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target'
local _f
while read _f; do case "$_f" in
*.ko) [[ $(< $_f) =~ $_mpfuncs ]] && echo "$_f" ;;
*.ko.gz) [[ $(gzip -dc <$_f) =~ $_mpfuncs ]] && echo "$_f" ;;
esac
done
}
instmods $(filter_kernel_modules_by_path drivers/scsi mp_mod_test)
instmods $(filter_kernel_modules_by_path drivers/md mp_mod_test)
( find_kernel_modules_by_path drivers/scsi;
find_kernel_modules_by_path drivers/md ) | mp_mod_filter | instmods
[[ $debug ]] && set -x
}
install() {

0
modules.d/91crypt-gpg/crypt-gpg-lib.sh Normal file → Executable file
View File

View File

@@ -23,6 +23,9 @@ dcb=$2
ip link set "$netif" up
wait_for_if_up "$netif"
netdriver=$(readlink -f /sys/class/net/$netif/device/driver)
netdriver=${netdriver##*/}
if [ "$dcb" = "dcb" ]; then
# Note lldpad will stay running after switchroot, the system initscripts
# are to kill it and start a new lldpad to take over. Data is transfered
@@ -35,6 +38,11 @@ if [ "$dcb" = "dcb" ]; then
dcbtool sc "$netif" app:fcoe e:1 a:1 w:1
sleep 1
fipvlan "$netif" -c -s
elif [ "$netdriver" = "bnx2x" ]; then
# If driver is bnx2x, do not use /sys/module/fcoe/parameters/create but fipvlan
modprobe 8021q
udevadm settle --timeout=30
fipvlan "$netif" -c -s
else
echo -n "$netif" > /sys/module/fcoe/parameters/create
fi

View File

@@ -25,6 +25,7 @@ install() {
inst dcbtool
inst fipvlan
inst lldpad
inst readlink
mkdir -m 0755 -p "$initdir/var/lib/lldpad"

View File

@@ -20,6 +20,13 @@
# If it's not set we don't continue
[ -z "$fcoe" ] && return
# BRCM: Later, should check whether bnx2x is loaded first before loading bnx2fc so do not load bnx2fc when there are no Broadcom adapters
[ -e /sys/module/fcoe/parameters/create ] || modprobe -a fcoe || die "FCoE requested but kernel/initrd does not support FCoE"
modprobe bnx2fc >/dev/null 2>&1
udevadm settle --timeout=30
# FCoE actually supported?
[ -e /sys/module/fcoe/parameters/create ] || modprobe fcoe || die "FCoE requested but kernel/initrd does not support FCoE"

View File

@@ -0,0 +1,6 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[ -e /sys/module/bnx2i ] && killproc iscsiuio

View File

@@ -40,6 +40,8 @@ modprobe crc32c 2>/dev/null
[ -e /tmp/root.info ] && . /tmp/root.info
[ -e /sys/module/bnx2i ] && iscsiuio
if getargbool 0 rd.iscsi.firmware -y iscsi_firmware ; then
if [ -n "${root%%block:*}" ]; then
# if root is not specified try to mount the whole iSCSI LUN
@@ -134,6 +136,12 @@ handle_netroot()
# if missing?
fi
if [ -z $iscsi_initiator ]; then
if [ -f /sys/firmware/ibft/initiator/initiator-name ]; then
iscsi_initiator=$(while read line; do echo $line;done < /sys/firmware/ibft/initiator-name)
fi
fi
if [ -z $iscsi_target_port ]; then
iscsi_target_port=3260
fi

View File

@@ -41,20 +41,28 @@ depends() {
}
installkernel() {
instmods iscsi_tcp iscsi_ibft crc32c
iscsi_module_test() {
instmods iscsi_tcp iscsi_ibft crc32c bnx2i iscsi_boot_sysfs qla4xxx cxgb3i cxgb4i be2iscsi
iscsi_module_filter() {
local _iscsifuncs='iscsi_register_transport'
fgrep -q "$_iscsifuncs" "$1"
local _f
while read _f; do case "$_f" in
*.ko) [[ $(< $_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
*.ko.gz) [[ $(gzip -dc <$_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
esac
done
}
instmods $(filter_kernel_modules_by_path drivers/scsi iscsi_module_test)
find_kernel_modules_by_path drivers/scsi \
| iscsi_module_filter | instmods
}
install() {
dracut_install umount
dracut_install -o iscsiuio
inst iscsistart
inst hostname
inst iscsi-iname
inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
inst_hook pre-pivot 90 "$moddir/cleanup-iscsi.sh"
inst "$moddir/iscsiroot" "/sbin/iscsiroot"
inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
}

View File

@@ -51,10 +51,17 @@ if [ -n "$iscsiroot" ] ; then
[ -z "$netroot" ] || [ "$netroot" = "iscsi" ] && netroot=iscsi:$iscsiroot
fi
modprobe -q qla4xxx
modprobe -q cxgb3i
modprobe -q cxgb4i
modprobe -q bnx2i
modprobe -q be2iscsi
# iscsi_firmware does not need argument checking
if [ -n "$iscsi_firmware" ] ; then
netroot=${netroot:-iscsi}
modprobe iscsi_ibft
modprobe -q iscsi_boot_sysfs 2>/dev/null
modprobe -q iscsi_ibft
fi
# If it's not iscsi we don't continue
@@ -68,7 +75,9 @@ if [ -z "$iscsi_firmware" ] ; then
fi
# ISCSI actually supported?
[ -e /sys/devices/virtual/iscsi_transport ] || modprobe iscsi_tcp || die "iscsiroot requested but kernel/initrd does not support iscsi"
if ! [ -e /sys/module/iscsi_tcp ]; then
modprobe -q iscsi_tcp || die "iscsiroot requested but kernel/initrd does not support iscsi"
fi
# Done, all good!
rootok=1
@@ -76,5 +85,3 @@ rootok=1
# Shut up init error check
[ -z "$root" ] && root="iscsi"
echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/iscsi.sh

View File

@@ -38,6 +38,7 @@ if [ "${root%%:*}" = "nbd" ] ; then
fi
netroot=$root
unset root
fi
# If it's not nbd we don't continue
@@ -55,7 +56,8 @@ incol2 /proc/devices nbd || modprobe nbd || die "nbdroot requested but kernel/in
rootok=1
# Shut up init error check
[ -z "$root" ] && root="nbd"
echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/nbd.sh
if [ -z "$root" ]; then
root=block:/dev/root
wait_for_dev /dev/root
fi

View File

@@ -17,7 +17,7 @@ if [ -n "$resume" ]; then
${resume#/dev/};
printf "SYMLINK==\"%s\", ACTION==\"add|change\", SYMLINK+=\"/dev/resume\"\n" \
${resume#/dev/};
} >> $UDEVRULESD/99-resume-link.rules
} >> /etc/udev/rules.d/99-resume-link.rules
{
if [ -x /usr/sbin/resume ]; then
@@ -35,13 +35,7 @@ if [ -n "$resume" ]; then
printf '[ -e "%s" ] && { ln -s "%s" /dev/resume; rm "$job"; }\n' \
"$resume" "$resume" >> $hookdir/initqueue/settled/resume.sh
echo '[ -e /dev/resume ]' > $hookdir/initqueue/finished/resume.sh
{
printf '[ -e /dev/resume ] || '
printf 'warn "resume device "%s" not found"\n' "$resume"
} >> $hookdir/emergency/00-resume.sh
wait_for_dev "/dev/resume"
elif ! getarg noresume; then
{

View File

@@ -8,10 +8,10 @@ if [ "${root%%:*}" = "block" ]; then
${root#block:/dev/}
printf 'SYMLINK=="%s", SYMLINK+="root"\n' \
${root#block:/dev/}
} >> $UDEVRULESD/99-root.rules
} >> /etc/udev/rules.d/99-root.rules
printf '[ -e "%s" ] && { ln -s "%s" /dev/root 2>/dev/null; rm "$job"; }\n' \
"${root#block:}" "${root#block:}" > $hookdir/initqueue/settled/blocksymlink.sh
echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/block.sh
wait_for_dev "${root#block:}"
fi

View File

@@ -7,7 +7,9 @@ install() {
# FIXME: would be nice if we didn't have to know which rules to grab....
# ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
# of the rules we want so that we just copy those in would be best
dracut_install udevd udevadm
dracut_install udevadm
[ -x /sbin/udevd ] && dracut_install udevd
for i in /etc/udev/udev.conf /etc/group; do
inst_simple $i
done
@@ -49,15 +51,26 @@ install() {
fw_unit_symlinks.sh \
hid2hci \
path_id \
input_id \
scsi_id \
usb_id \
vol_id \
pcmcia-socket-startup \
pcmcia-check-broken-cis \
udevd \
; do
[ -e /lib/udev/$_i ] && dracut_install /lib/udev/$_i
[ -e /usr/lib/udev/$_i ] && dracut_install /usr/lib/udev/$_i
done
if ! [ -e "$initdir/sbin/udevd" ]; then
if [ -x /usr/lib/udev/udevd ]; then
ln -s /usr/lib/udev/udevd "$initdir/sbin/udevd"
elif [ -x /lib/udev/udevd ]; then
ln -s /lib/udev/udevd "$initdir/sbin/udevd"
fi
fi
[ -f /etc/arch-release ] && \
inst "$moddir/load-modules.sh" /lib/udev/load-modules.sh

View File

@@ -0,0 +1,15 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
return 255
}
depends() {
return 0
}
install() {
inst_hook cmdline 60 "$moddir/securityfs.sh"
}

View File

@@ -0,0 +1,10 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
SECURITYFSDIR="/sys/kernel/security"
export SECURITYFSDIR
if ! ismounted "${SECURITYFSDIR}"; then
mount -t securityfs -o nosuid,noexec,nodev securityfs ${SECURITYFSDIR} >/dev/null 2>&1
fi

View File

@@ -7,7 +7,7 @@ check() {
}
depends() {
echo masterkey
echo masterkey securityfs
return 0
}

View File

@@ -0,0 +1,16 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
return 0
}
depends() {
return 0
}
install() {
inst_hook pre-pivot 50 "$moddir/mount-usr.sh"
}

View File

@@ -0,0 +1,32 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type info >/dev/null 2>&1 || . /lib/dracut-lib.sh
type fsck_single >/dev/null 2>&1 || . /lib/fs-lib.sh
mount_usr()
{
local _dev _mp _fs _opts _rest _usr_found _ret
# check, if we have to mount the /usr filesystem
while read _dev _mp _fs _opts _rest; do
if [ "$_mp" = "/usr" ]; then
echo "$_dev $NEWROOT/$_mp $_fs ${_opts},ro $_rest"
_usr_found="1"
break
fi
done < "$NEWROOT/etc/fstab" >> /etc/fstab
if [ "x$_usr_found" != "x" ]; then
# we have to mount /usr
fsck_single "$_dev" "$_fs" "$_opts"
_ret=$?
echo $_ret >/run/initramfs/usr-fsck
if [ $_ret -ne 255 ]; then
info "Mounting /usr"
mount "$NEWROOT/usr" 2>&1 | vinfo
fi
fi
}
mount_usr

View File

@@ -24,7 +24,7 @@ str_replace() {
while strstr "${in}" "$s"; do
chop="${in%%$s*}"
out="${out}${chop# }$r"
out="${out}${chop}$r"
in="${in#*$s}"
done
echo "${out}${in}"
@@ -32,15 +32,22 @@ str_replace() {
_getcmdline() {
local _line
local _i
unset _line
if [ -z "$CMDLINE" ]; then
if [ -e /etc/cmdline ]; then
while read _line; do
while read -r _line; do
CMDLINE_ETC="$CMDLINE_ETC $_line";
done </etc/cmdline;
fi
read CMDLINE </proc/cmdline;
CMDLINE="$CMDLINE $CMDLINE_ETC"
for _i in /etc/cmdline.d/*.conf; do
[ -e "$_i" ] || continue
while read -r _line; do
CMDLINE_ETC_D="$CMDLINE_ETC_D $_line";
done <"$_i";
done
read -r CMDLINE </proc/cmdline;
CMDLINE="$CMDLINE_ETC_D $CMDLINE_ETC $CMDLINE"
fi
}
@@ -254,7 +261,10 @@ source_hook() {
check_finished() {
local f
for f in $hookdir/initqueue/finished/*.sh; do { [ -e "$f" ] && ( . "$f" ) ; } || return 1 ; done
for f in $hookdir/initqueue/finished/*.sh; do
[ "$f" = "$hookdir/initqueue/finished/*.sh" ] && return 0
{ [ -e "$f" ] && ( . "$f" ) ; } || return 1
done
return 0
}
@@ -372,7 +382,7 @@ ismounted() {
wait_for_if_up() {
local cnt=0
while [ $cnt -lt 20 ]; do
while [ $cnt -lt 200 ]; do
li=$(ip link show $1)
[ -z "${li##*state UP*}" ] && return 0
sleep 0.1
@@ -544,3 +554,87 @@ foreach_uuid_until() (
return 1
)
# Get kernel name for given device. Device may be the name too (then the same
# is returned), a symlink (full path), UUID (prefixed with "UUID=") or label
# (prefixed with "LABEL="). If just a beginning of the UUID is specified or
# even an empty, function prints all device names which UUIDs match - every in
# single line.
#
# NOTICE: The name starts with "/dev/".
#
# Example:
# devnames UUID=123
# May print:
# /dev/dm-1
# /dev/sdb1
# /dev/sdf3
devnames() {
local dev="$1"; local d; local names
case "$dev" in
UUID=*)
dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \
&& return 255
[ -z "$dev" ] && return 255
;;
LABEL=*) dev="$(blkid -L "${dev#LABEL=}")" || return 255 ;;
/dev/?*) ;;
*) return 255 ;;
esac
for d in $dev; do
names="$names
$(readlink -e -q "$d")" || return 255
done
echo "${names#
}"
}
usable_root() {
local _d
[ -d $1 ] || return 1
for _d in proc sys dev; do
[ -e "$1"/$_d ] || return 1
done
return 0
}
wait_for_mount()
{
local _name
_name="$(str_replace "$1" '/' '\\x2f')"
printf '. /lib/dracut-lib.sh\nismounted "%s"\n' $1 \
>> "$hookdir/initqueue/finished/ismounted-${_name}.sh"
{
printf 'ismounted "%s" || ' $1
printf 'warn "\"%s\" is not mounted"\n' $1
} >> "$hookdir/emergency/90-${_name}.sh"
}
wait_for_dev()
{
local _name
_name="$(str_replace "$1" '/' '\\x2f')"
printf '[ -e "%s" ]\n' $1 \
>> "$hookdir/initqueue/finished/devexists-${_name}.sh"
{
printf '[ -e "%s" ] || ' $1
printf 'warn "\"%s\" does not exist"\n' $1
} >> "$hookdir/emergency/80-${_name}.sh"
}
killproc() {
local exe="$(command -v $1)"
local sig=$2
local i
[ -x "$exe" ] || return 1
for i in /proc/[0-9]*; do
[ "$i" = "/proc/1" ] && continue
if [ -e "$i"/exe ] && [ "$i/exe" -ef "$exe" ] ; then
kill $sig ${i##*/}
fi
done
}

View File

@@ -8,6 +8,8 @@
# Harald Hoyer <harald@redhat.com>
# Jeremy Katz <katzj@redhat.com>
export -p > /tmp/export.orig
wait_for_loginit()
{
set +x
@@ -84,12 +86,6 @@ RD_DEBUG=""
[ ! -d /sys/kernel ] && \
mount -t sysfs -o nosuid,noexec,nodev sysfs /sys >/dev/null 2>&1
SECURITYFSDIR="/sys/kernel/security"
export SECURITYFSDIR
if ! ismounted "${SECURITYFSDIR}"; then
mount -t securityfs -o nosuid,noexec,nodev ${SECURITYFSDIR} ${SECURITYFSDIR} >/dev/null 2>&1
fi
if [ -x /lib/systemd/systemd-timestamp ]; then
RD_TIMESTAMP=$(/lib/systemd/systemd-timestamp)
else
@@ -137,7 +133,7 @@ fi
if ! ismounted /run; then
mkdir -m 0755 /newrun
mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /newrun >/dev/null 2>&1
cp -a -t /newrun /run/*
cp -a /run/* /newrun
mount --move /newrun /run
rm -fr /newrun
fi
@@ -205,7 +201,8 @@ getarg 'rd.break=pre-trigger' 'rdbreak=pre-trigger' && emergency_shell -n pre-tr
source_hook pre-trigger
# then the rest
udevadm trigger --action=add $udevtriggeropts >/dev/null 2>&1
udevadm trigger --type=subsystems --action=add >/dev/null 2>&1
udevadm trigger --type=devices --action=add >/dev/null 2>&1
getarg 'rd.break=initqueue' 'rdbreak=initqueue' && emergency_shell -n initqueue "Break before initqueue"
@@ -246,25 +243,20 @@ while :; do
# no more udev jobs and queues empty.
sleep 0.5
# dirty hack for some cdrom drives,
# which report no medium for quiet
# some time.
for cdrom in /sys/block/sr*; do
[ -e "$cdrom" ] || continue
# skip, if cdrom medium was already found
strstr "$(udevadm info --query=env --path=${cdrom##/sys})" \
ID_CDROM_MEDIA && continue
if [ -e "$cdrom"/events_poll_msecs -a ! -e "/tmp/.poll_${cdrom##*/}" ]; then
msecs=$(while read a; do echo $a;done < "$cdrom"/events_poll_msecs)
if [ "$msecs" = "-1" ]; then
echo 250 > "$cdrom"/events_poll_msecs
> "/tmp/.poll_${cdrom##*/}"
fi
else
if [ ! -e /sys/module/block/parameters/events_dfl_poll_msecs ]; then
# if the kernel does not support autopolling
# then we have to do a
# dirty hack for some cdrom drives,
# which report no medium for quiet
# some time.
for cdrom in /sys/block/sr*; do
[ -e "$cdrom" ] || continue
# skip, if cdrom medium was already found
strstr "$(udevadm info --query=env --path=${cdrom##/sys})" \
ID_CDROM_MEDIA && continue
echo change > "$cdrom/uevent"
fi
done
done
fi
if [ $main_loop -gt $(($RDRETRY/2)) ]; then
for job in $hookdir/initqueue/timeout/*.sh; do
@@ -283,14 +275,6 @@ unset queuetriggered
unset main_loop
unset RDRETRY
# reset cdrom polling
for cdrom in /sys/block/sr*; do
[ -e "$cdrom" ] || continue
if [ -e "$cdrom"/events_poll_msecs ]; then
echo -1 > "$cdrom"/events_poll_msecs
fi
done
# pre-mount happens before we try to mount the root filesystem,
# and happens once.
getarg 'rd.break=pre-mount' 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
@@ -302,10 +286,18 @@ getarg 'rd.break=mount' 'rdbreak=mount' && emergency_shell -n mount "Break mount
# be sourced any number of times. As soon as one suceeds, no more are sourced.
i=0
while :; do
[ -d "$NEWROOT/proc" ] && break;
if ismounted "$NEWROOT"; then
usable_root "$NEWROOT" && break;
umount "$NEWROOT"
fi
for f in $hookdir/mount/*.sh; do
[ -f "$f" ] && . "$f"
[ -d "$NEWROOT/proc" ] && break;
if ismounted "$NEWROOT"; then
usable_root "$NEWROOT" && break;
warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook"
umount "$NEWROOT"
rm -f "$f"
fi
done
i=$(($i+1))
@@ -322,33 +314,12 @@ done
getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
source_hook pre-pivot
# by the time we get here, the root filesystem should be mounted.
# Try to find init and mount /usr, if needed to access init.
unset __usr_found
# By the time we get here, the root filesystem should be mounted.
# Try to find init.
for i in "$(getarg real_init=)" "$(getarg init=)" /sbin/init /etc/init /init /bin/sh; do
[ -n "$i" ] || continue
__p=$(readlink -m "$NEWROOT$i")
if [ -n "$__p" ] \
&& [ "x$__usr_found" = "x" ] \
&& [ ! -x "$__p" ] \
&& strstr "$__p" "$NEWROOT/usr" \
; then
# we have to mount /usr
while read dev mp fs opts rest; do
if [ "$mp" = "/usr" ]; then
echo "$dev $NEWROOT$mp $fs ${opts},ro $rest"
__usr_found="1"
break
fi
done < "$NEWROOT/etc/fstab" >> /etc/fstab
if [ "x$__usr_found" != "x" ]; then
info "Mounting /usr"
mount "$NEWROOT/usr" 2>&1 | vinfo
fi
fi
__p=$(readlink -f "$NEWROOT$i")
__p=$(readlink -f "${NEWROOT}/${i}")
if [ -x "$__p" ]; then
INIT="$i"
break
@@ -361,7 +332,6 @@ done
emergency_shell
}
getarg rd.break rdbreak && emergency_shell -n switch_root "Break before switch_root"
if [ $UDEVVERSION -lt 168 ]; then
# stop udev queue before killing it
@@ -395,6 +365,8 @@ for i in $(export -p); do
unset "$i";;
esac
done
. /tmp/export.orig 2>/dev/null || :
rm -f /tmp/export.orig
initargs=""
read CLINE </proc/cmdline
@@ -443,6 +415,10 @@ fi
wait_for_loginit
# remove helper symlink
[ -h /dev/root ] && rm -f /dev/root
getarg rd.break rdbreak && emergency_shell -n switch_root "Break before switch_root"
info "Switching root"
unset PS4

View File

@@ -19,8 +19,8 @@ while [ $# -gt 0 ]; do
qname="/settled";;
--finished)
qname="/finished";;
--timeout)
qname="/timeout";;
--timeout)
qname="/timeout";;
--unique)
unique="yes";;
--name)

View File

@@ -59,7 +59,12 @@ fsck_able() {
;;
btrfs)
type btrfsck >/dev/null 2>&1 &&
_drv="_drv=btrfsck fsck_drv_com" &&
_drv="_drv=none fsck_drv_btrfs" &&
return 0
;;
nfs*)
# nfs can be a nop, returning success
_drv="_drv=none :" &&
return 0
;;
*)
@@ -104,6 +109,37 @@ fsck_drv_xfs() {
return $_ret
}
fsck_drv_btrfs() {
local _ret
# fs must be cleanly mounted (and umounted) first, before attempting any
# btrfs tools - if this works, nothing else should be needed
# note, that user is always dropped into the shell, if the filesystem is
# not mountable or if -f flag is found among _fop
mkdir -p /tmp/.btrfs
info "trying to mount $_dev"
if mount -t btrfs "$_dev" "/tmp/.btrfs" >/dev/null 2>&1; then
_ret=0
info "btrfs: $_dev is clean"
umount "$_dev" >/dev/null 2>&1
else
_ret=4
warn "*** $_dev is unmountable"
fi
if [ $_ret -gt 0 ] || strstr "$_fop" "-f"; then
warn "*** Dropping you to a shell. You have"
warn "*** btrfsck available."
warn "*** Note that if btrfs didn't mount properly, it's"
warn "*** probably pretty serious condition."
emergency_shell -n "(Repair filesystem)"
fi
rm -r /tmp/.btrfs
return $_ret
}
# common code for checkers that follow usual subset of options and return codes
fsck_drv_com() {
local _ret
@@ -146,14 +182,16 @@ fsck_drv_std() {
# returns 255 if filesystem wasn't checked at all (e.g. due to lack of
# necessary tools or insufficient options)
fsck_single() {
local FSTAB_FILE=/etc/fstab.fslib
local FSTAB_FILE=/etc/fstab.empty
local _dev="$1"
local _fs="${2:-auto}"
local _fop="$3"
local _drv
[ $# -lt 2 ] && return 255
# if UUID= marks more than one device, take only the first one
[ -e "$_dev" ] || _dev=$(devnames "$_dev"| while read line; do if [ -n "$line" ]; then echo $line; break;fi;done)
[ -e "$_dev" ] || return 255
_fs=$(det_fs "$_dev" "$_fs")
fsck_able "$_fs" || return 255
@@ -166,23 +204,23 @@ fsck_single() {
# takes list of filesystems to check in parallel; we don't rely on automatic
# checking based on fstab, so empty one is passed
fsck_batch() {
local FSTAB_FILE=/etc/fstab.fslib
local FSTAB_FILE=/etc/fstab.empty
local _drv=fsck
local _dev
local _ret
local _out
[ $# -eq 0 ] && return 255
[ $# -eq 0 ] || ! type fsck >/dev/null 2>&1 && return 255
info "Checking filesystems (fsck -M -T -a):"
for _dev in "$@"; do
info " $_dev"
done
export FSTAB_FILE
_out="$(fsck -M -T "$@" -- -a)"
_ret=$?
export FSTAB_FILE
fsck_tail
return $_ret

View File

@@ -11,13 +11,55 @@ depends() {
}
install() {
dracut_install -o umount mount xfs_db xfs_check xfs_repair
dracut_install -o e2fsck
dracut_install -o jfs_fsck
dracut_install -o reiserfsck
dracut_install -o btrfsck
dracut_install -o /sbin/fsck*
local _helpers
inst "$moddir/fs-lib.sh" "/lib/fs-lib.sh"
touch ${initdir}/etc/fstab.fslib
touch ${initdir}/etc/fstab.empty
[[ "$nofscks" = "yes" ]] && return
if [[ "$fscks" = "${fscks#*[^ ]*}" ]]; then
_helpers="\
umount mount /sbin/fsck*
xfs_db xfs_check xfs_repair
e2fsck jfs_fsck reiserfsck btrfsck
"
if [[ $hostonly ]]; then
print_fs_type() { get_fs_type /dev/block/$1; }
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
_helpers="umount mount "
for fs in $(check_block_and_slaves print_fs_type "$_rootdev"); do
case "$fs" in
xfs)
_helpers+=" xfs_db xfs_repair xfs_check "
;;
ext?)
_helpers+=" e2fsck "
;;
jfs)
_helpers+=" jfs_fsck "
;;
reiserfs)
_helpers+=" reiserfsck "
;;
btrfs)
_helpers+=" btrfsck "
;;
*)
[[ -x fsck.$fs ]] && _helpers+= " fsck.$fs "
;;
esac
done
fi
fi
else
_helpers="$fscks"
fi
if strstr "$_helpers" e2fsck && [ -e /etc/e2fsck.conf ]; then
inst_simple /etc/e2fsck.conf
fi
dracut_install -o $_helpers
}

58
profile.py Normal file
View File

@@ -0,0 +1,58 @@
#
# parse the output of "dracut --profile" and produce profiling information
#
# Copyright 2011 Harald Hoyer <harald@redhat.com>
# Copyright 2011 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/>.
#
import sys
import operator
import re
loglines = sys.stdin
logpats = r'[+]+[ \t]+([^ \t]+)[ \t]+([^ \t:]+):[ ]+.*'
logpat = re.compile(logpats)
groups = (logpat.match(line) for line in loglines)
tuples = (g.groups() for g in groups if g)
def gen_times(t):
oldx=None
for x in t:
fx=float(x[0])
if oldx:
#print fx - float(oldx[0]), x[0], x[1], oldx[0], oldx[1]
yield (fx - float(oldx[0]), oldx[1])
oldx = x
colnames = ('time','line')
log = (dict(zip(colnames,t)) for t in gen_times(tuples))
if __name__ == '__main__':
e={}
for x in log:
if not x['line'] in e:
e[x['line']] = x['time']
else:
e[x['line']] += x['time']
sorted_x = sorted(e.iteritems(), key=operator.itemgetter(1), reverse=True)
for x in sorted_x:
print x[0], x[1]

View File

@@ -7,82 +7,84 @@ KVERSION=${KVERSION-$(uname -r)}
#DEBUGFAIL="rd.shell rd.break"
test_run() {
$testdir/run-qemu -hda root.ext3 -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/root.ext3 \
-m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=LABEL=dracut rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd initramfs.testing
grep -m 1 -q dracut-root-block-success root.ext3 || return 1
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1
}
test_setup() {
if [ ! -e root.ext3 ]; then
rm -f $TESTDIR/root.ext3
# Create the blank file to use as a root filesystem
dd if=/dev/zero of=root.ext3 bs=1M count=40
dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=40
kernel=$KVERSION
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 \
umount strace less
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 )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
)
(
initdir=$TESTDIR/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 \
umount strace less
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 )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
(
initdir=overlay
. $basedir/dracut-functions
dracut_install sfdisk mkfs.ext3 poweroff cp umount
inst_hook initqueue 01 ./create-root.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
(
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install sfdisk mkfs.ext3 poweroff cp umount
inst_hook initqueue 01 ./create-root.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
# 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 udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
$basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda root.ext3 -m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created root.ext3 || return 1
fi
$testdir/run-qemu \
-hda $TESTDIR/root.ext3 \
-m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut -l -i overlay / \
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
-f initramfs.testing $KVERSION || return 1
-f $TESTDIR/initramfs.testing $KVERSION || return 1
# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
}
test_cleanup() {
rm -fr overlay mnt
rm -f root.ext3 initramfs.makeroot initramfs.testing
return 0
}
. $testdir/test-functions

View File

@@ -5,23 +5,26 @@ KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell"
DISKIMAGE=/var/tmp/TEST-10-RAID-root.img
DISKIMAGE=$TESTDIR/TEST-10-RAID-root.img
test_run() {
$testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic \
$testdir/run-qemu \
-hda $DISKIMAGE \
-m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd initramfs.testing
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
}
test_setup() {
# Create the blank file to use as a root filesystem
rm -f $DISKIMAGE
dd if=/dev/null of=$DISKIMAGE bs=1M seek=40
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=overlay/source
initdir=$TESTDIR/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
@@ -38,7 +41,7 @@ test_setup() {
# second, install the files needed to make the root filesystem
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install sfdisk mke2fs poweroff cp umount
inst_hook initqueue 01 ./create-root.sh
@@ -48,36 +51,38 @@ test_setup() {
# 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 / \
$basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--nomdadmconf \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic -net none \
$testdir/run-qemu \
-hda $DISKIMAGE \
-m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.makeroot || return 1
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst ./cryptroot-ask /sbin/cryptroot-ask
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut -l -i overlay / \
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f initramfs.testing $KVERSION || return 1
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
rm -fr overlay mnt
rm -f $DISKIMAGE initramfs.makeroot initramfs.testing
return 0
}
. $testdir/test-functions

View File

@@ -7,21 +7,23 @@ KVERSION=${KVERSION-$(uname -r)}
#DEBUGFAIL="rd.break rd.shell"
test_run() {
$testdir/run-qemu -hda root.ext2 -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 \
-m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd initramfs.testing
grep -m 1 -q dracut-root-block-success root.ext2 || return 1
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q dracut-root-block-success $TESTDIR/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=40
dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=40
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=overlay/source
initdir=$TESTDIR/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
@@ -38,7 +40,7 @@ test_setup() {
# second, install the files needed to make the root filesystem
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install sfdisk mke2fs poweroff cp umount
inst_hook initqueue 01 ./create-root.sh
@@ -48,34 +50,33 @@ test_setup() {
# 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 / \
$basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda root.ext2 -m 256M -nographic -net none \
$testdir/run-qemu -hda $TESTDIR/root.ext2 -m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created root.ext2 || return 1
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut -l -i overlay / \
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f initramfs.testing $KVERSION || return 1
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
rm -fr overlay mnt
rm -f root.ext2 initramfs.makeroot initramfs.testing
return 0
}
. $testdir/test-functions

View File

@@ -8,22 +8,23 @@ KVERSION=${KVERSION-$(uname -r)}
client_run() {
echo "CLIENT TEST START: $@"
$testdir/run-qemu -hda root.ext2 -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 -m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "$@ root=LABEL=root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL " \
-initrd initramfs.testing
if ! grep -m 1 -q dracut-root-block-success root.ext2; then
-initrd $TESTDIR/initramfs.testing
if ! grep -m 1 -q dracut-root-block-success $TESTDIR/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
sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' $TESTDIR/root.ext2
echo "CLIENT TEST END: $@ [OK]"
return 0
}
test_run() {
eval $(grep --binary-files=text -m 1 MD_UUID root.ext2)
eval $(grep --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2)
echo "MD_UUID=$MD_UUID"
client_run || return 1
@@ -51,12 +52,13 @@ test_run() {
test_setup() {
# Create the blank file to use as a root filesystem
dd if=/dev/zero of=root.ext2 bs=1M count=40
rm -f $TESTDIR/root.ext2
dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=40
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=overlay/source
initdir=$TESTDIR/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
@@ -72,7 +74,7 @@ test_setup() {
# second, install the files needed to make the root filesystem
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install sfdisk mke2fs poweroff cp umount dd grep
inst_hook initqueue 01 ./create-root.sh
@@ -82,38 +84,39 @@ test_setup() {
# 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 / \
$basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda root.ext2 -m 256M -nographic -net none \
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 \
-m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created root.ext2 || return 1
eval $(grep --binary-files=text -m 1 MD_UUID root.ext2)
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
eval $(grep --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2)
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst ./cryptroot-ask /sbin/cryptroot-ask
mkdir -p overlay/etc
echo "ARRAY /dev/md0 level=raid5 num-devices=3 UUID=$MD_UUID" > overlay/etc/mdadm.conf
mkdir -p $initdir/etc
echo "ARRAY /dev/md0 level=raid5 num-devices=3 UUID=$MD_UUID" > $initdir/etc/mdadm.conf
)
sudo $basedir/dracut -l -i overlay / \
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f initramfs.testing $KVERSION || return 1
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
rm -fr overlay mnt
rm -f root.ext2 initramfs.makeroot initramfs.testing
return 0
}
. $testdir/test-functions

View File

@@ -7,36 +7,45 @@ KVERSION=${KVERSION-$(uname -r)}
#DEBUGFAIL="rd.shell" # udev.log-priority=debug
test_run() {
LUKSARGS=$(cat luks.txt)
LUKSARGS=$(cat $TESTDIR/luks.txt)
dd if=/dev/zero of=check-success.img bs=1M count=1
dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1
echo "CLIENT TEST START: $LUKSARGS"
$testdir/run-qemu -hda root.ext2 -hdb check-success.img -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 \
-hdb $TESTDIR/check-success.img \
-m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $LUKSARGS $DEBUGFAIL" \
-initrd initramfs.testing
grep -m 1 -q dracut-root-block-success check-success.img || return 1
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
echo "CLIENT TEST END: [OK]"
dd if=/dev/zero of=check-success.img bs=1M count=1
dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1
echo "CLIENT TEST START: Any LUKS"
$testdir/run-qemu -hda root.ext2 -hdb check-success.img -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 \
-hdb $TESTDIR/check-success.img \
-m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd initramfs.testing
grep -m 1 -q dracut-root-block-success check-success.img || return 1
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
echo "CLIENT TEST END: [OK]"
dd if=/dev/zero of=check-success.img bs=1M count=1
dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1
echo "CLIENT TEST START: Wrong LUKS UUID"
$testdir/run-qemu -hda root.ext2 -hdb check-success.img -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 \
-hdb $TESTDIR/check-success.img \
-m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL rd.luks.uuid=failme" \
-initrd initramfs.testing
grep -m 1 -q dracut-root-block-success check-success.img && return 1
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img && return 1
echo "CLIENT TEST END: [OK]"
return 0
@@ -44,12 +53,13 @@ test_run() {
test_setup() {
# Create the blank file to use as a root filesystem
dd if=/dev/zero of=root.ext2 bs=1M count=80
rm -f $TESTDIR/root.ext2
dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=80
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=overlay/source
initdir=$TESTDIR/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
@@ -65,7 +75,7 @@ test_setup() {
# second, install the files needed to make the root filesystem
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install sfdisk mke2fs poweroff cp umount grep
inst_hook initqueue 01 ./create-root.sh
@@ -75,42 +85,41 @@ test_setup() {
# 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 / \
$basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda root.ext2 -m 256M -nographic -net none \
$testdir/run-qemu -hda $TESTDIR/root.ext2 -m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created root.ext2 || return 1
cryptoUUIDS=$(grep --binary-files=text -m 3 ID_FS_UUID root.ext2)
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
cryptoUUIDS=$(grep --binary-files=text -m 3 ID_FS_UUID $TESTDIR/root.ext2)
for uuid in $cryptoUUIDS; do
eval $uuid
printf ' rd.luks.uuid=luks-%s ' $ID_FS_UUID
done > luks.txt
done > $TESTDIR/luks.txt
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst ./cryptroot-ask /sbin/cryptroot-ask
)
sudo $basedir/dracut -l -i overlay / \
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f initramfs.testing $KVERSION || return 1
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
rm -fr overlay mnt
rm -f root.ext2 initramfs.makeroot initramfs.testing luks.txt check-success.img
return 0
}
. $testdir/test-functions

View File

@@ -5,23 +5,26 @@ KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell"
DISKIMAGE=/var/tmp/TEST-15-BTRFSRAID-root.img
DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
test_run() {
$testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic \
$testdir/run-qemu \
-hda $DISKIMAGE \
-m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=LABEL=root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd initramfs.testing
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
}
test_setup() {
# Create the blank file to use as a root filesystem
rm -f $DISKIMAGE
dd if=/dev/null of=$DISKIMAGE bs=1M seek=1024
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=overlay/source
initdir=$TESTDIR/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
@@ -37,7 +40,7 @@ test_setup() {
# second, install the files needed to make the root filesystem
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install sfdisk mkfs.btrfs poweroff cp umount
inst_hook initqueue 01 ./create-root.sh
@@ -47,36 +50,41 @@ test_setup() {
# 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 / \
$basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash btrfs udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--nomdadmconf \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic -net none \
$testdir/run-qemu \
-hda $DISKIMAGE \
-m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=LABEL=root rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.makeroot || return 1
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1
(
initdir=overlay
(
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst ./cryptroot-ask /sbin/cryptroot-ask
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut -l -i overlay / \
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
-f initramfs.testing $KVERSION || return 1
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
rm -fr overlay mnt
rm -f $DISKIMAGE initramfs.makeroot initramfs.testing
return 0
}
. $testdir/test-functions

View File

@@ -0,0 +1,196 @@
#!/usr/bin/python -tt
#
# livecd-creator : Creates Live CD based for Fedora.
#
# Copyright 2007, Red Hat Inc.
#
# 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; version 2 of the License.
#
# 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 Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import os
import os.path
import sys
import time
import optparse
import logging
import shutil
from distutils.dir_util import copy_tree
import imgcreate
from imgcreate.fs import makedirs
class myLiveImageCreator(imgcreate.x86LiveImageCreator):
def __init__(self, ks, name, fslabel=None, releasever=None, tmpdir="/tmp",
title="Linux", product="Linux"):
imgcreate.x86LiveImageCreator.__init__(self, ks, name,
fslabel=fslabel,
releasever=releasever,
tmpdir=tmpdir)
#self._outdir=os.getenv("TESTDIR", ".")
def install(self, repo_urls = {}):
copy_tree(os.environ.get("TESTDIR", ".") + "/root-source", self._instroot)
def configure(self):
self._create_bootconfig()
def _get_kernel_versions(self):
ret = {}
version=os.uname()
version=version[2]
ret["kernel-" + version] = [version]
return ret
def __sanity_check(self):
pass
class Usage(Exception):
def __init__(self, msg = None, no_error = False):
Exception.__init__(self, msg, no_error)
def parse_options(args):
parser = optparse.OptionParser()
imgopt = optparse.OptionGroup(parser, "Image options",
"These options define the created image.")
imgopt.add_option("-c", "--config", type="string", dest="kscfg",
help="Path or url to kickstart config file")
imgopt.add_option("-b", "--base-on", type="string", dest="base_on",
help="Add packages to an existing live CD iso9660 image.")
imgopt.add_option("-f", "--fslabel", type="string", dest="fslabel",
help="File system label (default based on config name)")
# Provided for img-create compatibility
imgopt.add_option("-n", "--name", type="string", dest="fslabel",
help=optparse.SUPPRESS_HELP)
imgopt.add_option("", "--image-type", type="string", dest="image_type",
help=optparse.SUPPRESS_HELP)
imgopt.add_option("", "--compression-type", type="string", dest="compress_type",
help="Compression type recognized by mksquashfs "
"(default xz needs a 2.6.38+ kernel, gzip works "
"with all kernels, lzo needs a 2.6.36+ kernel, lzma "
"needs custom kernel.) Set to 'None' to force read "
"from base_on.",
default="xz")
imgopt.add_option("", "--releasever", type="string", dest="releasever",
default=None,
help="Value to substitute for $releasever in kickstart repo urls")
parser.add_option_group(imgopt)
# options related to the config of your system
sysopt = optparse.OptionGroup(parser, "System directory options",
"These options define directories used on your system for creating the live image")
sysopt.add_option("-t", "--tmpdir", type="string",
dest="tmpdir", default="/var/tmp",
help="Temporary directory to use (default: /var/tmp)")
sysopt.add_option("", "--cache", type="string",
dest="cachedir", default=None,
help="Cache directory to use (default: private cache")
parser.add_option_group(sysopt)
imgcreate.setup_logging(parser)
# debug options not recommended for "production" images
# Start a shell in the chroot for post-configuration.
parser.add_option("-l", "--shell", action="store_true", dest="give_shell",
help=optparse.SUPPRESS_HELP)
# Don't compress the image.
parser.add_option("-s", "--skip-compression", action="store_true", dest="skip_compression",
help=optparse.SUPPRESS_HELP)
parser.add_option("", "--skip-minimize", action="store_true", dest="skip_minimize",
help=optparse.SUPPRESS_HELP)
(options, args) = parser.parse_args()
# Pretend to be a image-creator if called with that name
options.image_type = 'livecd'
if options.image_type not in ('livecd', 'image'):
raise Usage("'%s' is a recognized image type" % options.image_type)
# image-create compatibility: Last argument is kickstart file
if len(args) == 1:
options.kscfg = args.pop()
if len(args):
raise Usage("Extra arguments given")
if options.base_on and not os.path.isfile(options.base_on):
raise Usage("Image file '%s' does not exist" %(options.base_on,))
if options.image_type == 'livecd':
if options.fslabel and len(options.fslabel) > imgcreate.FSLABEL_MAXLEN:
raise Usage("CD labels are limited to 32 characters")
if options.fslabel and options.fslabel.find(" ") != -1:
raise Usage("CD labels cannot contain spaces.")
return options
def main():
try:
options = parse_options(sys.argv[1:])
except Usage, (msg, no_error):
if no_error:
out = sys.stdout
ret = 0
else:
out = sys.stderr
ret = 2
if msg:
print >> out, msg
return ret
if os.geteuid () != 0:
print >> sys.stderr, "You must run %s as root" % sys.argv[0]
return 1
if options.fslabel:
fslabel = options.fslabel
name = fslabel
else:
name = "livecd"
fslabel = "LiveCD"
logging.info("Using label '%s' and name '%s'" % (fslabel, name))
ks = imgcreate.read_kickstart(options.kscfg)
creator = myLiveImageCreator(ks, name,
fslabel=fslabel,
releasever=options.releasever,
tmpdir=os.path.abspath(options.tmpdir))
creator.compress_type = options.compress_type
creator.skip_compression = options.skip_compression
creator.skip_minimize = options.skip_minimize
if options.cachedir:
options.cachedir = os.path.abspath(options.cachedir)
try:
creator.mount(options.base_on, options.cachedir)
creator.install()
creator.configure()
if options.give_shell:
print "Launching shell. Exit to continue."
print "----------------------------------"
creator.launch_shell()
creator.unmount()
creator.package(os.environ.get("TESTDIR", "."))
except imgcreate.CreatorError, e:
logging.error(u"Error creating Live CD : %s" % e)
return 1
finally:
creator.cleanup()
return 0
if __name__ == "__main__":
sys.exit(main())

View File

@@ -0,0 +1,22 @@
lang en_US.UTF-8
keyboard us
timezone US/Eastern
auth --useshadow --enablemd5
selinux --enforcing
firewall --disabled
part / --size 1024
repo --name=fedora --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-16&arch=$basearch
%packages
@core
anaconda-runtime
bash
kernel
passwd
policycoreutils
chkconfig
authconfig
rootfiles
%end

17
test/TEST-16-DMSQUASH/test-init Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1#*$2*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
stty sane
echo "made it to the rootfs!"
strstr "$CMDLINE" "rd.shell" && sh -i
echo "Powering down."
mount -n -o remount,ro /
poweroff -f

69
test/TEST-16-DMSQUASH/test.sh Executable file
View File

@@ -0,0 +1,69 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem on a LiveCD dmsquash filesystem"
KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell rd.break"
test_run() {
$testdir/run-qemu \
-boot order=d \
-cdrom $TESTDIR/livecd.iso \
-hda $TESTDIR/root.img \
-m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q dracut-root-block-success $TESTDIR/root.img || return 1
}
test_setup() {
mkdir -p $TESTDIR/overlay
(
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
dd if=/dev/zero of=$TESTDIR/root.img count=100
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
-a "debug dmsquash-live" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
mkdir -p $TESTDIR/root-source
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=$TESTDIR/root-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 \
umount strace less
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep syslinux isohybrid
for f in /usr/share/syslinux/*; do
inst_simple "$f"
done
inst ./test-init /sbin/init
inst $TESTDIR/initramfs.testing "/boot/initramfs-$KVERSION.img"
inst /boot/vmlinuz-$KVERSION
find_binary plymouth >/dev/null && dracut_install plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
)
python create.py -d -c livecd-fedora-minimal.ks
return 0
}
test_cleanup() {
return 0
}
. $testdir/test-functions

View File

@@ -12,14 +12,16 @@ run_server() {
# Start server first
echo "NFS TEST SETUP: Starting DHCP/NFS server"
$testdir/run-qemu -hda server.ext2 -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/server.ext2 -m 256M -nographic \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-net socket,listen=127.0.0.1:12345 \
-net socket,listen=127.0.0.1:12320 \
-serial $SERIAL \
-kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/sda rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.server -pidfile server.pid -daemonize || return 1
sudo chmod 644 server.pid || return 1
-initrd $TESTDIR/initramfs.server \
-pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
# Cleanup the terminal if we have one
tty -s && stty sane
@@ -39,25 +41,27 @@ client_test() {
echo "CLIENT TEST START: $test_name"
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
if ! dd if=/dev/zero of=client.img bs=1M count=1; then
if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then
echo "Unable to make client sda image" 1>&2
return 1
fi
$testdir/run-qemu -hda client.img -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/client.img \
-m 256M -nographic \
-net nic,macaddr=$mac,model=e1000 \
-net socket,connect=127.0.0.1:12345 \
-net socket,connect=127.0.0.1:12320 \
-kernel /boot/vmlinuz-$KVERSION \
-append "$cmdline $DEBUGFAIL rd.debug rd.retry=10 rd.info quiet ro console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.testing
-initrd $TESTDIR/initramfs.testing
if [[ $? -ne 0 ]] || ! grep -m 1 -q nfs-OK client.img; then
if [[ $? -ne 0 ]] || ! grep -m 1 -q nfs-OK $TESTDIR/client.img; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1
fi
# nfsinfo=( server:/path nfs{,4} options )
nfsinfo=($(awk '{print $2, $3, $4; exit}' client.img))
nfsinfo=($(awk '{print $2, $3, $4; exit}' $TESTDIR/client.img))
if [[ "${nfsinfo[0]%%:*}" != "$server" ]]; then
echo "CLIENT TEST INFO: got server: ${nfsinfo[0]%%:*}"
@@ -72,7 +76,7 @@ client_test() {
expected=0
check_opt=${check_opt:1}
fi
opts=${nfsinfo[2]},
while [[ $opts ]]; do
if [[ ${opts%%,*} = $check_opt ]]; then
@@ -148,6 +152,8 @@ test_nfsv3() {
client_test "NFSv3 root=dhcp DHCP proto:IP:path,options" \
52:54:00:12:34:07 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
return 0
}
test_nfsv4() {
@@ -167,12 +173,14 @@ test_nfsv4() {
client_test "NFSv4 root=dhcp DHCP proto:IP:path,options" \
52:54:00:12:34:87 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
return 0
}
test_run() {
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat server.pid)
rm -f server.pid
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
fi
if ! run_server; then
@@ -185,9 +193,9 @@ test_run() {
ret=$?
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat server.pid)
rm -f server.pid
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
fi
return $ret
@@ -195,14 +203,14 @@ test_run() {
test_setup() {
# Make server root
dd if=/dev/zero of=server.ext2 bs=1M count=60
mke2fs -F server.ext2
mkdir mnt
sudo mount -o loop server.ext2 mnt
dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=60
mke2fs -F $TESTDIR/server.ext2
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt
kernel=$KVERSION
(
initdir=mnt
initdir=$TESTDIR/mnt
. $basedir/dracut-functions
dracut_install sh ls shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux dmesg mkdir cp ping exportfs \
@@ -247,7 +255,7 @@ test_setup() {
)
# Make client root inside server root
initdir=mnt/nfs/client
initdir=$TESTDIR/mnt/nfs/client
mkdir -p $initdir
(
@@ -272,17 +280,17 @@ test_setup() {
sudo ldconfig -r "$initdir"
)
mkdir -p mnt/nfs/nfs3-5
mkdir -p mnt/nfs/ip/192.168.50.101
mkdir -p mnt/nfs/tftpboot/nfs4-5
mkdir -p $TESTDIR/mnt/nfs/nfs3-5
mkdir -p $TESTDIR/mnt/nfs/ip/192.168.50.101
mkdir -p $TESTDIR/mnt/nfs/tftpboot/nfs4-5
sudo umount mnt
rm -fr mnt
sudo umount $TESTDIR/mnt
rm -fr $TESTDIR/mnt
# Make an overlay with needed tools for the test harness
(
initdir=overlay
mkdir overlay
initdir=$TESTDIR/overlay
mkdir $TESTDIR/overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
@@ -290,26 +298,24 @@ test_setup() {
)
# Make server's dracut image
$basedir/dracut -l -i overlay / \
$basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash udev-rules base rootfs-block debug kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod e1000" \
-f initramfs.server $KVERSION || return 1
-f $TESTDIR/initramfs.server $KVERSION || return 1
# Make client's dracut image
$basedir/dracut -l -i overlay / \
$basedir/dracut -l -i $TESTDIR/overlay / \
-o "plymouth" \
-a "debug" \
-d "piix ide-gd_mod ata_piix sd_mod e1000 nfs sunrpc" \
-f initramfs.testing $KVERSION || return 1
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat server.pid)
rm -f server.pid
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
fi
rm -rf mnt overlay
rm -f server.ext2 client.img initramfs.server initramfs.testing
}
. $testdir/test-functions

View File

@@ -11,15 +11,20 @@ run_server() {
# Start server first
echo "iSCSI TEST SETUP: Starting DHCP/iSCSI server"
$testdir/run-qemu -hda server.ext2 -hdb root.ext2 -m 256M -nographic \
-hdc iscsidisk2.img -hdd iscsidisk3.img \
$testdir/run-qemu \
-hda $TESTDIR/server.ext2 \
-hdb $TESTDIR/root.ext2 \
-hdc $TESTDIR/iscsidisk2.img \
-hdd $TESTDIR/iscsidisk3.img \
-m 256M -nographic \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-net socket,listen=127.0.0.1:12345 \
-net socket,listen=127.0.0.1:12330 \
-serial $SERIAL \
-kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/sda rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.server -pidfile server.pid -daemonize || return 1
sudo chmod 644 server.pid || return 1
-initrd $TESTDIR/initramfs.server \
-pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
# Cleanup the terminal if we have one
tty -s && stty sane
@@ -31,27 +36,35 @@ run_server() {
run_client() {
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
if ! dd if=/dev/zero of=client.img bs=1M count=1; then
if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then
echo "Unable to make client sda image" 1>&2
return 1
fi
$testdir/run-qemu -hda client.img -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/client.img \
-m 256M -nographic \
-net nic,macaddr=52:54:00:12:34:00,model=e1000 \
-net socket,connect=127.0.0.1:12345 \
-net socket,connect=127.0.0.1:12330 \
-kernel /boot/vmlinuz-$KVERSION \
-append "root=LABEL=sysroot ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:eth0:off netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target1 netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2 rw quiet rd.retry=5 rd.debug rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
-initrd initramfs.testing
grep -m 1 -q iscsi-OK client.img || return 1
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q iscsi-OK $TESTDIR/client.img || return 1
if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then
echo "Unable to make client sda image" 1>&2
return 1
fi
$testdir/run-qemu -hda client.img -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/client.img \
-m 256M -nographic \
-net nic,macaddr=52:54:00:12:34:00,model=e1000 \
-net socket,connect=127.0.0.1:12345 \
-net socket,connect=127.0.0.1:12330 \
-kernel /boot/vmlinuz-$KVERSION \
-append "root=dhcp rw quiet rd.retry=5 rd.debug rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
-initrd initramfs.testing
grep -m 1 -q iscsi-OK client.img || return 1
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q iscsi-OK $TESTDIR/client.img || return 1
}
@@ -62,9 +75,9 @@ test_run() {
fi
run_client
ret=$?
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat server.pid)
rm -f server.pid
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
fi
return $ret
}
@@ -76,14 +89,14 @@ test_setup() {
fi
# Create the blank file to use as a root filesystem
dd if=/dev/zero of=root.ext2 bs=1M count=20
dd if=/dev/zero of=iscsidisk2.img bs=1M count=20
dd if=/dev/zero of=iscsidisk3.img bs=1M count=20
dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=20
dd if=/dev/null of=$TESTDIR/iscsidisk2.img bs=1M seek=20
dd if=/dev/null of=$TESTDIR/iscsidisk3.img bs=1M seek=20
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=overlay/source
initdir=$TESTDIR/overlay/source
. $basedir/dracut-functions
dracut_install sh shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux mount dmesg mkdir \
@@ -96,7 +109,7 @@ test_setup() {
# second, install the files needed to make the root filesystem
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install sfdisk mke2fs poweroff cp umount
inst_hook initqueue 01 ./create-root.sh
@@ -106,49 +119,52 @@ test_setup() {
# 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 / \
$basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
if ! dd if=/dev/zero of=client.img bs=1M count=1; then
if ! dd if=/dev/null of=$TESTDIR/client.img bs=1M seek=1; then
echo "Unable to make client sdb image" 1>&2
return 1
fi
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda root.ext2 -hdb client.img \
-hdc iscsidisk2.img -hdd iscsidisk3.img \
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 \
-hdb $TESTDIR/client.img \
-hdc $TESTDIR/iscsidisk2.img \
-hdd $TESTDIR/iscsidisk3.img \
-m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created client.img || return 1
rm client.img
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1
rm $TESTDIR/client.img
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut -l -i overlay / \
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
-o "plymouth dmraid" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f initramfs.testing $KVERSION || return 1
-f $TESTDIR/initramfs.testing $KVERSION || return 1
# Make server root
dd if=/dev/zero of=server.ext2 bs=1M count=60
mke2fs -F server.ext2
mkdir mnt
sudo mount -o loop server.ext2 mnt
dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=60
mke2fs -F $TESTDIR/server.ext2
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt
kernel=$KVERSION
(
initdir=mnt
initdir=$TESTDIR/mnt
. $basedir/dracut-functions
(
cd "$initdir";
@@ -176,25 +192,22 @@ test_setup() {
sudo ldconfig -r "$initdir"
)
sudo umount mnt
rm -fr mnt
sudo umount $TESTDIR/mnt
rm -fr $TESTDIR/mnt
# Make server's dracut image
$basedir/dracut -l -i overlay / \
$basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash udev-rules base rootfs-block debug kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod e1000" \
-f initramfs.server $KVERSION || return 1
-f $TESTDIR/initramfs.server $KVERSION || return 1
}
test_cleanup() {
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat server.pid)
rm -f server.pid
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
fi
rm -rf mnt overlay
rm -f client.ext2 server.ext2 client.img initramfs.server initramfs.testing
rm -f initramfs.makeroot root.ext2 iscsidisk2.img iscsidisk3.img
}
. $testdir/test-functions

View File

@@ -5,6 +5,7 @@ while read dev fs fstype opts rest; do
[ "$dev" = "rootfs" ] && continue
[ "$fs" != "/" ] && continue
echo "nbd-OK $fstype $opts" >/dev/sda
echo "nbd-OK $fstype $opts"
break
done < /proc/mounts
export TERM=linux

View File

@@ -14,6 +14,7 @@ lvm vgcreate dracut /dev/mapper/dracut_crypt_test && \
lvm lvcreate -l 100%FREE -n root dracut && \
lvm vgchange -ay && \
mke2fs -j /dev/dracut/root && \
/sbin/tune2fs -e continue /dev/dracut/root && \
mkdir -p /sysroot && \
mount /dev/dracut/root /sysroot && \
cp -a -t /sysroot /source/* && \

View File

@@ -14,15 +14,18 @@ run_server() {
# Start server first
echo "NBD TEST SETUP: Starting DHCP/NBD server"
$testdir/run-qemu -hda server.ext2 -hdb nbd.ext2 -hdc encrypted.ext2 \
$testdir/run-qemu \
-hda $TESTDIR/server.ext2 \
-hdb $TESTDIR/nbd.ext2 \
-hdc $TESTDIR/encrypted.ext2 \
-m 256M -nographic \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-net socket,listen=127.0.0.1:12345 \
-net socket,listen=127.0.0.1:12340 \
-serial $SERIAL \
-kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/sda rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.server -pidfile server.pid -daemonize || return 1
sudo chmod 644 server.pid || return 1
-initrd $TESTDIR/initramfs.server -pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
# Cleanup the terminal if we have one
tty -s && stty sane
@@ -40,30 +43,32 @@ client_test() {
local found opts nbdinfo
[[ $fstype ]] || fstype=ext3
[[ $fsopt ]] || fsopt="errors=continue"
[[ $fsopt ]] || fsopt="ro"
echo "CLIENT TEST START: $test_name"
# Clear out the flags for each test
if ! dd if=/dev/zero of=flag.img bs=1M count=1; then
if ! dd if=/dev/zero of=$TESTDIR/flag.img bs=1M count=1; then
echo "Unable to make client sda image" 1>&2
return 1
fi
$testdir/run-qemu -hda flag.img -m 256M -nographic \
$testdir/run-qemu \
-hda $TESTDIR/flag.img \
-m 256M -nographic \
-net nic,macaddr=$mac,model=e1000 \
-net socket,connect=127.0.0.1:12345 \
-net socket,connect=127.0.0.1:12340 \
-kernel /boot/vmlinuz-$KVERSION \
-append "$cmdline $DEBUGFAIL rd.debug rd.info ro quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.testing
-initrd $TESTDIR/initramfs.testing
if [[ $? -ne 0 ]] || ! grep -m 1 -q nbd-OK flag.img; then
if [[ $? -ne 0 ]] || ! grep -m 1 -q nbd-OK $TESTDIR/flag.img; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1
fi
# nbdinfo=( fstype fsoptions )
nbdinfo=($(awk '{print $2, $3; exit}' flag.img))
nbdinfo=($(awk '{print $2, $3; exit}' $TESTDIR/flag.img))
if [[ "${nbdinfo[0]}" != "$fstype" ]]; then
echo "CLIENT TEST END: $test_name [FAILED - WRONG FS TYPE]"
@@ -171,21 +176,21 @@ client_run() {
"root=/dev/dracut/root netroot=dhcp" || return 1
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat server.pid)
rm -f server.pid
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
fi
}
make_encrypted_root() {
# Create the blank file to use as a root filesystem
dd if=/dev/zero of=encrypted.ext2 bs=1M count=20
dd if=/dev/zero of=flag.img bs=1M count=1
dd if=/dev/null of=$TESTDIR/encrypted.ext2 bs=1M seek=20
dd if=/dev/null of=$TESTDIR/flag.img bs=1M seek=1
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=overlay/source
initdir=$TESTDIR/overlay/source
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux mount dmesg mkdir cp ping
@@ -196,9 +201,9 @@ make_encrypted_root() {
# second, install the files needed to make the root filesystem
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install mke2fs poweroff cp umount
dracut_install mke2fs poweroff cp umount tune2fs
inst_hook initqueue 01 ./create-root.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
@@ -206,30 +211,33 @@ make_encrypted_root() {
# 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 / \
$basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 ext3 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda flag.img -hdb encrypted.ext2 -m 256M \
$testdir/run-qemu \
-hda $TESTDIR/flag.img \
-hdb $TESTDIR/encrypted.ext2 \
-m 256M \
-nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created flag.img || return 1
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created $TESTDIR/flag.img || return 1
}
make_client_root() {
dd if=/dev/zero of=nbd.ext2 bs=1M count=30
mke2fs -F -j nbd.ext2
mkdir mnt
sudo mount -o loop nbd.ext2 mnt
dd if=/dev/null of=$TESTDIR/nbd.ext2 bs=1M seek=30
mke2fs -F -j $TESTDIR/nbd.ext2
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/nbd.ext2 $TESTDIR/mnt
kernel=$KVERSION
(
initdir=mnt
initdir=$TESTDIR/mnt
. $basedir/dracut-functions
dracut_install sh ls shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux dmesg mkdir cp ping
@@ -249,19 +257,19 @@ make_client_root() {
sudo ldconfig -r "$initdir"
)
sudo umount mnt
rm -fr mnt
sudo umount $TESTDIR/mnt
rm -fr $TESTDIR/mnt
}
make_server_root() {
dd if=/dev/zero of=server.ext2 bs=1M count=30
mke2fs -F server.ext2
mkdir mnt
sudo mount -o loop server.ext2 mnt
dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=30
mke2fs -F $TESTDIR/server.ext2
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt
kernel=$KVERSION
(
initdir=mnt
initdir=$TESTDIR/mnt
. $basedir/dracut-functions
dracut_install sh ls shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux dmesg mkdir cp ping grep \
@@ -286,8 +294,8 @@ make_server_root() {
sudo ldconfig -r "$initdir"
)
sudo umount mnt
rm -fr mnt
sudo umount $TESTDIR/mnt
rm -fr $TESTDIR/mnt
}
test_setup() {
@@ -300,7 +308,7 @@ test_setup() {
# Make the test image
(
initdir=overlay
initdir=$TESTDIR/overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
@@ -308,30 +316,27 @@ test_setup() {
inst ./cryptroot-ask /sbin/cryptroot-ask
)
sudo $basedir/dracut -l -i overlay / \
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
-m "dash udev-rules rootfs-block base debug kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000" \
-f initramfs.server $KVERSION || return 1
-f $TESTDIR/initramfs.server $KVERSION || return 1
sudo $basedir/dracut -l -i overlay / \
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
-o "plymouth" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000" \
-f initramfs.testing $KVERSION || return 1
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}
kill_server() {
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat server.pid)
rm -f server.pid
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
fi
}
test_cleanup() {
kill_server
rm -fr overlay mnt
rm -f flag.img server.ext2 nbd.ext2 encrypted.ext2
rm -f initramfs.server initramfs.testing initramfs.makeroot
}
. $testdir/test-functions

Some files were not shown because too many files have changed in this diff Show More