Compare commits

..

158 Commits
009 ... 011

Author SHA1 Message Date
Harald Hoyer
7893469fca Makefile: inc version 2011-07-18 17:05:06 +02:00
Harald Hoyer
4765889b2e TODO, NEWS: update 2011-07-18 17:04:54 +02:00
Harald Hoyer
b038e0aac9 Makefile: copy created rpms from rpmbuild in "rpm" target 2011-07-18 17:04:27 +02:00
Harald Hoyer
d8bf119dd2 dracut.spec: fixed logrotate 2011-07-18 16:33:26 +02:00
Amadeusz Żołnowski
d083dd4c39 90kernel-modules: fixed handling rd.driver.post= 2011-07-01 10:15:26 +02:00
Amadeusz Żołnowski
b52294d00b crypt: dropped plymouth --has-active-vt check on passwd prompt
As Ray Strode explains, plymouth --has-active-vt may fail if the user
passes console=ttyS0 or something other not corresponding to
console=tty0, because plymouth is outputing to the serial console and
not a VT in this case.
2011-07-01 10:15:26 +02:00
Harald Hoyer
802e7e1c2e dmsquash-live: install eject with dracut_install
the new search path does the right thing
2011-07-01 10:14:47 +02:00
Harald Hoyer
be1762caff selinux/selinux-loadpolicy.sh: set LANG=C for load_policy and restorecon
set LANG=C for chroot execed tools, because the terminal might not be
able to display the messages and the rest is not translated anyway.
2011-06-22 13:33:37 +02:00
Harald Hoyer
6a2a1ea75f base/init: do not mount devtmpfs with "noexec"
https://bugzilla.redhat.com/show_bug.cgi?id=710711

mmap /dev/zero: Operation not permitted
2011-06-17 13:50:17 +02:00
Harald Hoyer
565f6fb675 crypt/crypt-lib.sh: s/.console.lock/.console_lock/g
In the initrd, the init script and the sbin/cryptroot-ask script use
flock with different lock files for the console: /.console_lock and
/.console.lock respectively
2011-06-17 13:44:08 +02:00
Harald Hoyer
f2c6909468 base/init: mount virtual filesystems with the filesystem type as source 2011-06-17 13:14:18 +02:00
Harald Hoyer
0e6a94b329 Makefile: simplify "make rpm" 2011-05-31 16:34:37 +02:00
Harald Hoyer
cae57c60a1 shut 2011-05-31 16:34:24 +02:00
Harald Hoyer
657d68cfff mdraid: add shutdown script 2011-05-31 15:50:45 +02:00
Harald Hoyer
20636ce09f dm: add shutdown script 2011-05-31 15:50:45 +02:00
Harald Hoyer
168fa7e571 base: add shutdown script to be called from systemd 2011-05-31 15:50:43 +02:00
Harald Hoyer
55468fb9b3 dracut: use pigz, if available and no compress defined 2011-05-31 14:56:31 +02:00
Harald Hoyer
7ed1de2f1d mount-root.sh: fixed fsck and "-a" only for "ext*" 2011-05-31 14:56:30 +02:00
Harald Hoyer
c30c65c1b2 dracut-functions: do not redirect modprobe error output to /dev/null
filter modprobe error messages and log them. Very useful if modules.dep
is missing.
2011-05-23 17:40:44 +02:00
Harald Hoyer
2627d8a345 dracut-functions: make created directories writable 2011-05-20 20:08:59 +02:00
Harald Hoyer
5fe5c7d0b1 dracut: add --keep option, to inspect the initramfs directory 2011-05-20 20:08:13 +02:00
Michal Soltys
0d8c1d7fa1 95rootfs-block/block-genrules.sh: Use > instead of >>
trivial, blocksymlink.sh shouldn't exist at this point.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-05-20 17:16:51 +02:00
Michal Soltys
0216d1cda3 95rootfs-block/mount-root.sh: Rely on det_fs and wrap_fsck
Use common fsck and det_fs code. Verify filesystem type more
aggressively, which has a chance to be more resistant to
accidental mistakes.

Also, there's no need to generate custom fstab for the sake of fsck
anymore.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-05-20 17:16:51 +02:00
Michal Soltys
8b2896f9fa 95fstab-sys: use det_fs and wrap_fsck
This patch mainly adds fsck functionality to fstab-sys, with additional
sanity checks (checking for device existence, verifying fstype via
det_fs).

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-05-20 17:16:50 +02:00
Michal Soltys
e2c5015713 dracut-lib.sh: Add det_fs() and wrap_fsck()
Both functions will be used by rootfs-block and fstab-sys modules.

Both are based on code present in mount-root.sh, though few changes are
present.

det_fs:

will try to determine filesystem type for supplied device, even if it's
not auto. If fs cannot be detected, or if the detected one differs from
the supplied one - a warning is issued (so user can fix its stuff later)

wrap_fsck:

will call fsck for specific device with optionally additional
fsckoptions. The function returns fsck return value.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-05-20 17:16:50 +02:00
Michal Soltys
e639630da4 dracut-lib.sh: add vwarn() function
Similary to vinfo()

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-05-20 17:16:50 +02:00
Harald Hoyer
ce4359ea85 dracut.spec: build require dash and bash 2011-05-20 15:33:51 +02:00
Harald Hoyer
9b30d4793d base/init: do not lazy umount /run 2011-05-20 15:17:32 +02:00
Harald Hoyer
dd483f4f42 base/init: mkdir non-existant dirs 2011-05-20 15:17:32 +02:00
Harald Hoyer
543f39cb52 base/init: save timestamp earlier and remove /sys mount duplicate 2011-05-20 15:17:32 +02:00
Harald Hoyer
4826b9b0d5 base/init: mkdir $NEWROOT, if it does not exist 2011-05-20 15:17:32 +02:00
Harald Hoyer
683db19a7d base/module-setup.sh: only mkdir /lib, if it does not exist 2011-05-20 15:17:31 +02:00
Harald Hoyer
1021371daf i18n: disable systemd-vconsole-setup, until the tool is fixed 2011-05-20 15:17:31 +02:00
Harald Hoyer
6a0b3ccf4e busybox: install busybox to /usr/bin 2011-05-20 15:17:31 +02:00
Harald Hoyer
b938443e2f lsinitrd: handle new output of "file" for XZ compressed images 2011-05-20 15:17:31 +02:00
Harald Hoyer
7db18ccd13 dracut-functions: change search path for find_binary 2011-05-20 15:17:31 +02:00
Harald Hoyer
c3b0d83ddf dracut-functions: handle symlinked directories 2011-05-20 14:04:57 +02:00
Harald Hoyer
785a6cd21c dracut: handle toplevel symlinks 2011-05-20 14:03:50 +02:00
Harald Hoyer
6f22336784 dracut: s/bzip/bzip2 2011-05-20 14:02:35 +02:00
Harald Hoyer
3da7836035 dracut: fix overlayfs paths 2011-05-20 13:00:46 +02:00
Harald Hoyer
23b28c0ab5 lvm/lvm_scan.sh: remove references to lvm-cleanup
lvm-cleanup was removed long time ago
2011-05-17 12:29:47 +02:00
Will Woods
7573ac58f2 Fix "can't shift that many" crash with empty /proc/cmdline
If /proc/cmdline is empty (like if root=... is set in /etc/cmdline),
modules.d/99base/init will crash with a message saying "can't shift that
many" right before switch_root. The problem is in the block of code that
tries to look for init args. It does something like:

read CMDLINE </proc/cmdline
    [...]
    set $CMDLINE
    shift

If CMDLINE="" then "set $CMDLINE" will dump all the variables to stdout.
(That should be "set -- $CMDLINE" instead.) Since there's no $1, the
"shift" causes an error, and dracut crashes.

The 'shift' was copy-and-pasted from the previous block. It doesn't
belong here; remove it.

[Harald Hoyer <harald@redhat.com>: corrected commit message]
[Harald Hoyer <harald@redhat.com>: fixed indention]

Signed-off-by: Will Woods <wwoods@redhat.com>
2011-05-17 10:29:48 +02:00
Harald Hoyer
6787b8ccee dracut: set TMPDIR to /var/tmp
we really don't want anything else than /var/tmp for our operations.
/tmp might be too small and any other location might not fit our needs.
2011-05-16 18:10:27 +02:00
Harald Hoyer
00dd4db5d2 dracut.spec: add crypt-gpg module 2011-05-12 17:17:47 +02:00
Harald Hoyer
7417574cdb cut.conf.d/fedora.conf.example: removed filename in comment 2011-05-12 16:42:25 +02:00
Alan Pevec
f7c05c5514 dmsquash-live/dmsquash-live-root: add missing changes for /run
Change to /run/initramfs/squashfs/ was not complete.
2011-05-12 14:28:04 +02:00
Harald Hoyer
29b10e65b1 dracut-functions: make local vars local and prefix with "_" 2011-05-12 11:06:47 +02:00
Harald Hoyer
982e78234c TODO: update 2011-05-12 11:06:47 +02:00
Harald Hoyer
c09a9932b8 README: s/initrd/initramfs 2011-05-12 11:06:46 +02:00
Amadeusz Żołnowski
7aa622cd14 dracut.conf: explain dracutmodules option better 2011-05-12 11:06:46 +02:00
Amadeusz Żołnowski
37b73a235a dracut.kernel.7: crypto LUKS - info about gpg-encrypted keys 2011-05-12 11:04:56 +02:00
Harald Hoyer
beb015706b dracut-lib.sh: warn, even if "quiet" is set 2011-05-11 20:19:13 +02:00
Michal Soltys
6e43debe67 dracut-functions: remove find_rule()
Not used anymore.

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-05-10 14:46:06 +02:00
Michal Soltys
09a19bb1ba dracut-functions: update inst_binary()
This update adds support for sort-of corner case - when explicitly
specified binary (e.g. through dracut_install or inst) is a library
itself.

In such case, we would expect the binary to undergo typical
library-related handling (symlinks and such).

Apart from that, the patch cleans indenting and a few unused variables
in inst_binary() (probably leftovers from the past ?)

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-05-10 14:46:06 +02:00
Harald Hoyer
0279111026 documentation: update TODO and links 2011-05-10 14:13:58 +02:00
Harald Hoyer
f58c3ccf44 TODO: updated 2011-05-10 12:03:49 +02:00
Harald Hoyer
3b403b32fc removed trailing whitespaces 2011-05-10 11:56:09 +02:00
Harald Hoyer
e2cdb570ae dracut-functions: only dinfo() about missing firmware files
People are scared about those messages, so only dwarn() if the module
is actually loaded on the system.
2011-05-10 11:31:45 +02:00
Harald Hoyer
9a5393ac7e dracut: use /var/tmp rather than /tmp for the initramfs creation
/tmp might be to small to hold the initramfs image
2011-05-10 10:59:18 +02:00
Harald Hoyer
da5f8554a4 ifcfg/write-ifcfg.sh: do not source net.*.override, if it doesn't exist 2011-05-10 10:55:48 +02:00
Amadeusz Żołnowski
ba902275d5 new module - 91crypt-gpg
It's an extension to 90crypt module.  Adds support for GPG-encrypted
keys (symmetrically, of course).  Module is optional.
2011-05-06 12:23:52 +02:00
Amadeusz Żołnowski
3909d7edfc crypt: functions for ask-for-password and reading key
Asking for password and reading key parts are moved to separate
functions in crypt-lib.sh: ask_for_password and readkey.
2011-05-06 12:23:52 +02:00
Amadeusz Żołnowski
2f95d699dc crypt-lib.sh: 'command -v' preferred over 'type' 2011-05-06 12:23:51 +02:00
Amadeusz Żołnowski
d04de5fdd0 .gitignore: ignore dracut.html, dracut.conf.d/*.conf files, test.log 2011-05-06 12:23:50 +02:00
Amadeusz Żołnowski
f584c502a6 .gitignore: cleanup (prefix paths with /, remove unnecessary)
*~ should be globally ignored anyway.  Paths were prefix with / to be
strict.
2011-05-06 12:23:49 +02:00
Harald Hoyer
3cf14ae1ae parse-kernel.sh: wrong index was used in for loop
Thanks Mike Snitzer <msnitzer@redhat.com>
2011-05-06 12:06:20 +02:00
Harald Hoyer
7c18802966 iscsi: find iscsi kernel modules by symbol names 2011-05-04 10:19:02 +02:00
Harald Hoyer
424ecce632 plymouth/gensplash: reset tty after plymouth messed with it 2011-05-03 14:49:45 +02:00
Harald Hoyer
6019e1053c 10i18n: do not use console_init shell script, if systemd-vconsole-setup
do not use console_init shell script, if systemd-vconsole-setup is
available
2011-05-03 14:49:44 +02:00
Harald Hoyer
aad6898fe4 10i18n: s/systemd-vconsole/systemd-vconsole-setup/g 2011-05-03 10:34:06 +02:00
Harald Hoyer
44110df25a base/init: remove double nosuid from devtmpfs mount line 2011-05-03 09:59:15 +02:00
Harald Hoyer
c99014d5ef console_init/plymouth: use systemd-vconsole, if available
also init the console before starting the plymouth daemon
2011-05-03 09:59:14 +02:00
Harald Hoyer
a7ee1cd7f6 test/TEST-13-ENC-RAID-LVM: double test root disk space 2011-05-03 09:59:14 +02:00
Harald Hoyer
c3f7567a65 dracut.kernel.7.xml: clarify iscsi_firmware parameter usage 2011-05-02 11:33:05 +02:00
Harald Hoyer
ba7457ee00 network/parse-ip-opts.sh: fix ifname for ibft with all args 2011-05-02 11:30:29 +02:00
Harald Hoyer
7b069d5ea7 network/net-genrules.sh: also honor rename events 2011-05-02 11:29:58 +02:00
Marian Ganisin
c34130f705 don't overwrite ifname=
[Harald Hoyer <harald@redhat.com>: replaced grep with strstr]
[Harald Hoyer <harald@redhat.com>: handle multiple ifname= arguments]
2011-05-02 11:28:29 +02:00
Marian Ganisin
cc8f077e9f skip condition fixed 2011-05-02 11:28:22 +02:00
Marian Ganisin
ccacb45c52 correct module name 2011-05-02 11:28:04 +02:00
Harald Hoyer
1325cddee9 let rpc user own /var/lib/rpcbind
https://bugzilla.redhat.com/show_bug.cgi?id=698160
2011-05-02 11:27:12 +02:00
Harald Hoyer
80df37f475 fcoe: moved edd detection to settled initqueue
At the time of modprobing edd, all pci devices must exist and have to be
initialized for the symlinks to work.
2011-05-02 11:25:13 +02:00
Harald Hoyer
979c4a9304 dracut: revert prelink, if fips module was used 2011-05-02 11:19:12 +02:00
Harald Hoyer
4257798f8a fips: forward port RHEL-6 fips changes
- also support FIPS on separate LVM partition
- use small settle loop to get /boot
- "set -e" has no effect, if we use "||"
- make fips work with encrypted root and seperate boot
- moved to pre-pivot to support /boot in /
2011-05-02 11:15:46 +02:00
Harald Hoyer
12b9736228 dm: add 11-dm.rules for udev-168 and cleanup-db
add OPTIONS+="db_persist" to dm devices, to persist through a
udevadm info --cleanup-db
2011-05-02 10:55:44 +02:00
Amadeusz Żołnowski
64fcb3cce7 kernel-modules: inst modules.builtin if there's no modules.builtin.bin
Also report failure if none of them exist.
2011-04-28 15:44:54 +02:00
Michal Soltys
336eb5b04c modules.d/99base/init: missing slash in ismounted check
ismounted sys -> ismounted /sys

Signed-off-by: Michal Soltys <soltys@ziu.info>
2011-04-28 15:44:54 +02:00
Harald Hoyer
f024bf0dcd base, crypt: install umount, because it is used 2011-04-20 16:51:39 +02:00
Harald Hoyer
fd786adcf5 dracut: make prefix configurable 2011-04-20 16:47:40 +02:00
Harald Hoyer
0743486127 test/TEST-11-LVM, test/TEST-14-IMSM: update test cases
- more diskspace
- add /run
- drop to shell in test-init
2011-04-14 15:24:50 +02:00
Harald Hoyer
bf512ee2e0 base/init: export RD_TIMESTAMP 2011-04-14 15:23:05 +02:00
Harald Hoyer
b99dc517d6 inc version 2011-04-14 12:03:24 +02:00
Harald Hoyer
6a168568a5 base/init: use "udevadm control --exit" and "udevadm info --cleanup-db"
For udev >= 168 use the advanced udevadm features for shutting down udev.

Thanks Kay!!!
2011-04-14 12:00:11 +02:00
Harald Hoyer
dbad9f4661 Move all files to /run/initramfs
Given that we boot into a modern Linux distribution with the "/run" toplevel
directory, we can easily mount move the whole /run directory to the real
root in the end and have the complete initramfs later on in
/run/initramfs. All log files and /run states are still accessible and
to save space /run/initramfs can be removed later on.

Because the kernel does not mount a tmpfs on /run prior to unpacking the
initramfs cpio image, we have to copy ourselves very early to a tmpfs
and mount it on /run.
Due to lazy umount the old initramfs binaries should
be removed in the end by switch_root.

This feature can be turned on with "--prefix".
2011-04-12 12:08:50 +02:00
Harald Hoyer
7eb40c488c base: s#initlog#loginit#g for consistency 2011-04-12 11:07:40 +02:00
Harald Hoyer
2a9b703903 set udev property hookdir
Revert "mdraid/65-md-incremental-imsm.rules: s#$hookdir#/lib/dracut/hooks/"

This reverts commit e1f68dc6a0.
2011-04-12 08:45:31 +02:00
Harald Hoyer
65e0dd452c base/init: removed rd.copystate
all files are available in /run/initramfs
2011-04-12 08:32:03 +02:00
Harald Hoyer
5d7cdc38d0 base/init: removed rd.timestamp and automatically export RD_* 2011-04-12 08:30:33 +02:00
Harald Hoyer
e1f68dc6a0 mdraid/65-md-incremental-imsm.rules: s#$hookdir#/lib/dracut/hooks/ 2011-04-11 19:25:00 +02:00
Harald Hoyer
06ae51be51 TEST-50-MULTINIC/client-init: drop to shell, if "rd.shell" 2011-04-11 19:24:59 +02:00
Harald Hoyer
8a6ecb19b9 TEST-50-MULTINIC/test.sh: add /run dir and "ls" to client image 2011-04-11 19:24:59 +02:00
Harald Hoyer
1254925f1e dracut: do not install ld.so.conf* for kernel-only 2011-04-11 19:24:59 +02:00
Harald Hoyer
a6c34848eb base/init: set DRACUT_QUIET based on "loglevel" and "quiet" 2011-04-11 19:24:59 +02:00
Harald Hoyer
182660d864 base/init: set PATH like new kernels do 2011-04-11 13:58:33 +02:00
Harald Hoyer
3fc621ee45 iscsi/mount-lun.sh: use NEWROOT 2011-04-11 13:35:27 +02:00
Harald Hoyer
8234b92d85 crypt/cryptroot-ask.sh: check and use NEWROOT 2011-04-11 13:34:58 +02:00
Harald Hoyer
6822764f25 base/dracut-lib.sh: add ismounted() 2011-04-11 13:34:34 +02:00
Harald Hoyer
0d837ebf2a base/dracut-lib.sh: turn on PS4 for bash debugging 2011-04-11 13:34:06 +02:00
Harald Hoyer
8f5d36896d loginit: create pid and kill loginit by pid 2011-04-11 13:17:24 +02:00
Harald Hoyer
e365864bbc removed switch_root.c 2011-04-11 13:12:30 +02:00
Harald Hoyer
df60555037 precreate /run/udev/rules.d 2011-04-11 13:02:14 +02:00
Harald Hoyer
6730280c5b crypt/parse-crypt.sh: fixed rule creation
"\n" was missing
create rules file on tmp file and rename it later
2011-04-08 13:50:10 +02:00
Harald Hoyer
fb59f4c967 get rid of absolute PATHs 2011-04-08 13:49:06 +02:00
Harald Hoyer
77e2cadd88 base/init: fixed "unset" of vars 2011-04-08 13:27:28 +02:00
Harald Hoyer
a2cb4dbc82 base/dracut-lib.sh:incol2() return 1 on error 2011-04-08 13:27:07 +02:00
Harald Hoyer
36e30eb096 init: s/RDDEBUG/RD_DEBUG/g 2011-04-08 13:26:23 +02:00
Harald Hoyer
03f405bc04 init: move /.die to /run/initramfs/.die 2011-04-08 13:26:02 +02:00
Harald Hoyer
4abb498d79 initqueue: add "--finished" 2011-04-08 13:25:49 +02:00
Harald Hoyer
ef85627e93 test/TEST-01-BASIC/test.sh: uncomment debug options 2011-04-08 13:25:22 +02:00
Harald Hoyer
486ec65745 TEST-01-BASIC: softlink fstab to proc/mounts in test-init 2011-04-08 13:25:18 +02:00
Harald Hoyer
dd26a551c2 test/TEST-01-BASIC: add basic ext3 test 2011-04-08 11:17:31 +02:00
Alan Pevec
93724aa28f dmsquash-live: hide plymouth while checking ISO
Fixes long-standing FIXME
Latest isomd5sum added an option to abort media check with ESC key,
but that key is taken by plymouth for switching to the detailed log
messages, making it impossible to abort checkisomd5.
Tested in text mode.
2011-04-08 10:54:05 +02:00
Harald Hoyer
4c2a28c64b dracut-functions: ln -s with '-fn' 2011-04-08 10:42:42 +02:00
Harald Hoyer
2a72df9cf0 busybox/module-setup.sh: do not create absolute symlinks 2011-04-08 10:39:57 +02:00
Harald Hoyer
6600691ff1 README.modules: update documentation 2011-04-08 10:39:52 +02:00
Harald Hoyer
d125a47061 mkdir always with -m 0755 2011-04-08 10:39:46 +02:00
Harald Hoyer
8daaa46478 loginit: fix loglevel 2011-04-08 10:39:40 +02:00
Harald Hoyer
0a9d5422c6 dracut.kernel.7.xml: add FIPS parameter doc 2011-04-08 10:34:01 +02:00
Harald Hoyer
02c1bd6bb6 fips: add "rd.fips.skipkernel" boot option 2011-04-08 10:27:32 +02:00
Harald Hoyer
1cd1da13da iscsi: add additional hardcoded modules
https://bugzilla.redhat.com/show_bug.cgi?id=692781
https://bugzilla.redhat.com/show_bug.cgi?id=689694
2011-04-08 10:26:33 +02:00
Harald Hoyer
ea8ca78af0 crypt/parse-crypt.sh: fix udev rule creation 2011-04-08 10:23:58 +02:00
Harald Hoyer
dc4fc03e4b fcoe/parse-fcoe.sh: s#source#.#g
dash does not understand "source"
2011-04-08 10:22:59 +02:00
Amadeusz Żołnowski
76353076c0 dracut: don't fail on empty /etc/ld.so.conf.d/ 2011-04-04 14:12:25 +02:00
Harald Hoyer
829c258554 lsinitrd: default to /boot/initramfs-$(uname -r).img 2011-03-31 19:50:31 +02:00
Harald Hoyer
5dcd565dab NEWS: inc version and add NEWS 2011-03-31 18:49:27 +02:00
Harald Hoyer
7838d85351 dracut.spec: drop net-tools requirement 2011-03-31 18:49:02 +02:00
Harald Hoyer
db59288d79 PKGBUILD, debian/*: changed URLs to kernel.org 2011-03-31 18:48:27 +02:00
Harald Hoyer
82794b4b90 dracut.spec: fixed URL 2011-03-31 18:45:49 +02:00
Harald Hoyer
b4fbdbbe1e Makefile: "make dist" now generates .tar.gz 2011-03-31 18:45:01 +02:00
Harald Hoyer
9853774351 base/init: reset PATH after the /run move 2011-03-31 14:10:22 +02:00
Harald Hoyer
79471f365e base/dracut-lib.sh: changed kmgs log levels
New kernel/dmesg understands syslog levels, so we log with "+24" to indicate
that dracut is a daemon (current init).
2011-03-31 13:12:38 +02:00
Harald Hoyer
98b108284c dmsquash-live/dmsquash-live-genrules.sh: fixed udev rule location
Fixed the rule directory to $UDEVRULESD
2011-03-31 08:24:15 +02:00
Harald Hoyer
8ee30d09a4 plymouth: use /run/plymouth/pid instead of /run/initramfs/plymouth 2011-03-30 16:24:57 +02:00
Harald Hoyer
01583ae4ad fips: fixed "boot=<dev>" handling 2011-03-30 14:57:01 +02:00
Harald Hoyer
249f8b5bfc base/init: fixed compat /dev/.initramfs copy 2011-03-30 03:23:37 +02:00
Harald Hoyer
561d7f4d7c doc: s#/init.log#/run/initramfs/init.log#g 2011-03-30 03:22:14 +02:00
Harald Hoyer
4ad453445a base/dracut-lib.sh: relax getargbool value parsing
if a non-boolean value was specified, like "yes" or "no",
getargbool() would error, because we check for "$val -eq 0"
2011-03-30 01:45:17 +02:00
Harald Hoyer
e620bb01da base/init: fix cdrom polling 2011-03-30 00:01:00 +02:00
Harald Hoyer
7931bf0420 plymouth gensplash: check for console_init before calling it
Thanks Jon Ander Hernandez!
2011-03-29 16:38:11 +02:00
Jon Ander Hernandez
c174aea07d Ensure rpc_pipefs is mounted
While on some systems (like Fedora) rpc_pipefs is mounted
automatically when sunrpc module is loaded, on Debian based systems it
needs to be mounted manually.
2011-03-29 16:17:03 +02:00
Harald Hoyer
85323dcbb9 40network/dhcp-root.sh: s#initqueue-finished#initqueue/finished#g 2011-03-29 15:46:53 +02:00
Harald Hoyer
8bc650d9dc dracut: add "/lib/firmware/updates" to default firmware path 2011-03-29 15:32:34 +02:00
Harald Hoyer
ea216a650e dracut: removed extra char in "Including modules done" 2011-03-29 14:45:08 +02:00
Harald Hoyer
a16ebfd56a dracut-functions: bashified ret=ret+$? to ret+=$? 2011-03-29 11:30:27 +02:00
Harald Hoyer
2aad23443e dracut: source reformat with line breaks 2011-03-29 11:27:15 +02:00
Harald Hoyer
8a5354a9a5 dracut: simplify $kernel version argument setting 2011-03-29 11:21:54 +02:00
Amadeusz Żołnowski
dbf381f7fb dracut: don't skip zero-length string outfile argument
When '' was passed as outfile, dracut generated name with following
pattern:

  /boot/initramfs-$kernel

With commit 486a1b9324 dracut skips ''
argument.
2011-03-29 10:52:50 +02:00
Harald Hoyer
1080ce600a Revert "dracut: don't skip zero-length string outfile argument"
This reverts commit 0dd37f13c5.
2011-03-29 10:52:22 +02:00
Harald Hoyer
0dd37f13c5 dracut: don't skip zero-length string outfile argument
When '' was passed as outfile, dracut generated name with following
pattern:

  /boot/initramfs-${kernel}.img

With commit 486a1b9324 dracut skips ''
argument.
2011-03-29 10:25:24 +02:00
163 changed files with 2230 additions and 1643 deletions

16
.gitignore vendored
View File

@@ -1,8 +1,10 @@
/dracut.8
/dracut-catimages.8
/dracut.conf.5
/dracut.conf.d/*.conf
/dracut-gencmdline.8
/dracut.html
/dracut.kernel.7
/modules.d/99base/switch_root
/test/*/test.log
test*.img
modules.d/99base/switch_root
*~
dracut.kernel.7
dracut.conf.5
dracut.8
dracut-catimages.8
dracut-gencmdline.8

View File

@@ -1,4 +1,4 @@
VERSION=009
VERSION=011
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
prefix ?= /usr
@@ -10,15 +10,10 @@ mandir ?= ${prefix}/share/man
manpages = dracut.8 dracut.kernel.7 dracut.conf.5 dracut-catimages.8 dracut-gencmdline.8
.PHONY: install clean archive rpm testimage test all check AUTHORS
.PHONY: install clean archive rpm testimage test all check AUTHORS doc
ifeq (1,${WITH_SWITCH_ROOT})
targets = modules.d/99base/switch_root
else
targets =
endif
all: $(targets) $(manpages) dracut.html
doc: $(manpages) dracut.html
all: syncheck
%: %.xml
xsltproc -o $@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
@@ -29,10 +24,7 @@ dracut.html: dracut.xml $(manpages)
--stringparam html.stylesheet http://docs.redhat.com/docs/en-US/Common_Content/css/default.css \
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
modules.d/99base/switch_root: switch_root.c
gcc -D _GNU_SOURCE -D 'PACKAGE_STRING="dracut"' -std=gnu99 -fsigned-char -g -O2 -o modules.d/99base/switch_root switch_root.c
install:
install: doc
mkdir -p $(DESTDIR)$(pkglibdir)
mkdir -p $(DESTDIR)$(sbindir)
mkdir -p $(DESTDIR)$(sysconfdir)
@@ -43,9 +35,6 @@ install:
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
ifeq (1,${WITH_SWITCH_ROOT})
install -m 0755 modules.d/99base/switch_root $(DESTDIR)$(sbindir)/switch_root
endif
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
@@ -56,15 +45,11 @@ endif
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
ifeq (1,${WITH_SWITCH_ROOT})
rm $(DESTDIR)$(pkglibdir)/modules.d/99base/switch_root
endif
clean:
$(RM) *~
$(RM) */*~
$(RM) */*/*~
$(RM) modules.d/99base/switch_root
$(RM) test-*.img
$(RM) dracut-*.rpm dracut-*.tar.bz2
$(RM) $(manpages) dracut.html
@@ -72,27 +57,23 @@ clean:
archive: dracut-$(VERSION)-$(GITVERSION).tar.bz2
dist: dracut-$(VERSION).tar.bz2
dist: dracut-$(VERSION).tar.gz
dracut-$(VERSION).tar.bz2:
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |bzip2 > dracut-$(VERSION).tar.bz2
dracut-$(VERSION)-$(GITVERSION).tar.bz2:
git archive --format=tar HEAD --prefix=dracut-$(VERSION)-$(GITVERSION)/ |bzip2 > dracut-$(VERSION)-$(GITVERSION).tar.bz2
dracut-$(VERSION).tar.gz:
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |gzip > dracut-$(VERSION).tar.gz
rpm: clean dracut-$(VERSION).tar.bz2
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" -ba dracut.spec
rm -fr BUILD BUILDROOT
gitrpm: dracut-$(VERSION)-$(GITVERSION).tar.bz2
echo "%define gittag $(GITVERSION)" > dracut.spec.git
cat dracut.spec >> dracut.spec.git
mv dracut.spec dracut.spec.bak
mv dracut.spec.git dracut.spec
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" --define "gittag $(GITVERSION)" -ba dracut.spec || :
mv dracut.spec.bak dracut.spec
rm -fr BUILD BUILDROOT
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" \
--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
syncheck:
@ret=0;for i in dracut-logger modules.d/99base/init modules.d/*/*.sh; do \

14
NEWS
View File

@@ -1,3 +1,17 @@
dracut-011
==========
- use udev-168 features for shutting down udev
- introduce "--prefix" to put all initramfs files in e.g "/run/initramfs"
- new shutdown script (called by systemd >= 030) to disassemble the root device
- lots of bugfixes
- new module for gpg-encrypted keys - 91crypt-gpg
dracut-010
==========
- lots of bugfixes
- plymouth: use /run/plymouth/pid instead of /run/initramfs/plymouth
- add "/lib/firmware/updates" to default firmware path
dracut-009
==========
- dracut generator

View File

@@ -3,7 +3,7 @@ pkgver=$(date +%s)
pkgrel=$(git log --pretty=format:%h |head -n 1)
pkgdesc="Initramfs generation utility"
arch=('i686' 'x86_64')
url="http://sourceforge.net/apps/trac/dracut/"
url="https://dracut.wiki.kernel.org/"
license=('GPL')
conflicts=('dracut' 'mkinitcpio')
provides=('dracut=9999' 'mkinitcpio=9999')

50
README
View File

@@ -19,19 +19,19 @@ we'll grow some hooks for running arbitrary commands in the flow of
the script, but it's worth trying to resist the urge as much as we can
as hooks are guaranteed to be the path to slow-down.
Most of the initrd generation functionality in dracut is provided by a bunch
Most of the initramfs generation functionality in dracut is provided by a bunch
of generator modules that are sourced by the main dracut script to install
specific functionality into the initrd. They live in the modules.d
specific functionality into the initramfs. They live in the modules.d
subdirectory, and use functionality provided by dracut-functions to do their
work.
Some general rules for writing modules:
* Use one of the inst family of functions to actually install files
on to the initrd. They handle mangling the pathnames and (for binaries,
on to the initramfs. They handle mangling the pathnames and (for binaries,
scripts, and kernel modules) installing dependencies as appropriate so
you do not have to.
* Scripts that end up on the initrd should be POSIX compliant. dracut
will try to use /bin/dash as /bin/sh for the initrd if it is available,
* Scripts that end up on the initramfs should be POSIX compliant. dracut
will try to use /bin/dash as /bin/sh for the initramfs if it is available,
so you should install it on your system -- dash aims for strict POSIX
compliance to the extent possible.
* Hooks MUST be POSIX compliant -- they are sourced by the init script,
@@ -51,27 +51,33 @@ possible. Every distribution has their own tool here and it's not
something which is really interesting to have separate across them.
So contributions to help decrease the distro-dependencies are welcome.
Currently dracut lives on sourceforge.
Currently dracut lives on kernel.org.
The tarballs can be found here:
http://www.kernel.org/pub/linux/utils/boot/dracut/
ftp://ftp.kernel.org/pub/linux/utils/boot/dracut/
Git:
git://git.kernel.org/pub/scm/boot/dracut/dracut.git
http://git.kernel.org/pub/scm/boot/dracut/dracut.git
https://git.kernel.org/pub/scm/boot/dracut/dracut.git
Git Web:
http://git.kernel.org/?p=boot/dracut/dracut.git
Git Web RSS Feed:
http://git.kernel.org/?p=boot/dracut/dracut.git;a=rss
Project Page:
https://sourceforge.net/projects/dracut/
http://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html
Drop Harald Hoyer <harald@redhat.com> a mail, if you want to help with
the documentation, git access, etc.
Project Wiki:
http://dracut.wiki.kernel.org
Git Repository:
http://dracut.git.sourceforge.net/
git://dracut.git.sourceforge.net/gitroot/dracut/dracut
Trac Instance:
http://apps.sourceforge.net/trac/dracut/
The git tree can be found at
git://dracut.git.sourceforge.net/gitroot/dracut/dracut for now. See the TODO
file for things which still need to be done and HACKING for some
instructions on how to get started. There is also a mailing list that
is being used for the discussion -- initramfs@vger.kernel.org. It is
a typical vger list, send mail to majordomo@vger.kernel.org with body
See the TODO file for things which still need to be done and HACKING for
some instructions on how to get started. There is also a mailing list
that is being used for the discussion -- initramfs@vger.kernel.org.
It is a typical vger list, send mail to majordomo@vger.kernel.org with body
of 'subscribe initramfs email@host.com'

View File

@@ -4,7 +4,7 @@ structure:
dracut_install_dir/modules.d/
00modname/
install
module-setup.sh
check
<other files as needed by the hook>
@@ -18,16 +18,27 @@ dracut_install_dir/modules.d/
module override or modify the functionality of a generic module
without having to patch the more generic module.
install: dracut sources this script to install the functionality that a
module-setup.sh:
dracut sources this script to install the functionality that a
module implements onto the initrd. For the most part, this amounts
to copying files from the host system onto the initrd in a controlled
manner. dracut supplies several install functions that are
manner.
install():
This function of module-setup.sh is called to install all
non-kernel files. dracut supplies several install functions that are
specialized for different file types. Browse through dracut-functions
fore more details. dracut also provides a $moddir variable if you
need to install a file from the module directory, such as an initrd
hook, a udev rule, or a specialized executable.
check: Dracut calls this program to check and see if a module can be installed
installkernel():
This function of module-setup.sh is called to install all
kernel related files.
check():
Dracut calls this function to check and see if a module can be installed
on the initrd.
When called without options, check should check to make sure that
@@ -35,21 +46,20 @@ check: Dracut calls this program to check and see if a module can be installed
are present. It should exit with a 0 if they are, and a 1 if they are
not.
When called with -h, it should perform the same check that it would
without any options, and it should also check to see if the
When called with $hostonly set, it should perform the same check
that it would without it set, and it should also check to see if the
functionality the module implements is being used on the host system.
For example, if this module handles installing support for LUKS
encrypted volumes, it should return 0 if all the tools to handle
encrpted volumes are available and the host system has the root
partition on an encrypted volume, 1 otherwise.
When called with -d, it should output a list of dracut modules
depends():
This function should output a list of dracut modules
that it relies upon. An example would be the nfs and iscsi modules,
which rely on the network module to detect and configure network
interfaces.
Check may take additional options in the future.
Any other files in the module will not be touched by dracut directly.
You are encouraged to provide a README that describes what the module is for.
@@ -60,39 +70,39 @@ HOOKS
init has the following hook points to inject scripts:
/cmdline/*.sh
/lib/dracut/hooks/cmdline/*.sh
scripts for command line parsing
/pre-udev/*.sh
/lib/dracut/hooks/pre-udev/*.sh
scripts to run before udev is started
/pre-trigger/*.sh
/lib/dracut/hooks/pre-trigger/*.sh
scripts to run before the main udev trigger is pulled
/initqueue/*.sh
/lib/dracut/hooks/initqueue/*.sh
runs in parallel to the udev trigger
Udev events can add scripts here with /sbin/initqueue.
If /sbin/initqueue is called with the "--onetime" option, the script
will be removed after it was run.
If /initqueue/work is created and udev >= 143 then this loop can
process the jobs in parallel to the udevtrigger.
If /lib/dracut/hooks/initqueue/work is created and udev >= 143 then
this loop can process the jobs in parallel to the udevtrigger.
If the udev queue is empty and no root device is found or no root
filesystem was mounted, the user will be dropped to a shell after
a timeout.
Scripts can remove themselves from the initqueue by "rm $job".
/pre-mount/*.sh
/lib/dracut/hooks/pre-mount/*.sh
scripts to run before the root filesystem is mounted
Network filesystems like NFS that do not use device files are an
exception. Root can be mounted already at this point.
/mount/*.sh
/lib/dracut/hooks/mount/*.sh
scripts to mount the root filesystem
If the udev queue is empty and no root device is found or no root
filesystem was mounted, the user will be dropped to a shell after
a timeout.
/pre-pivot/*.sh
/lib/dracut/hooks/pre-pivot/*.sh
scripts to run before the real init is executed and the initramfs
disappears
All processes started before should be killed here.

23
TODO
View File

@@ -1,2 +1,23 @@
See https://sourceforge.net/apps/trac/dracut/wiki/TODO
Current TODO list, broken into things which are relevant for the initramfs itself (/init et al) vs the generator. A lot of things are/should be marked with "FIXME" in the code
INITRAMFS TODO
- The hard-coded list of udev rules that we care about is kind of lame.
- automatic kexec fallback
- panic fallback
GENERATOR TODO
- Default module specification could use some work
- udev rule copying, as mentioned above, is a bit too hard-coded
- pkg-config integration, to make it easy for other packages to use us.
- add recovery image creator (mkrecovery)
CODE TODO
- document functions
- make function vars local, and prefix with "_"
Future Enhancement Requests
- run ssh server to enter crypto password or perform debugging (supported by debian)
- Bug 524727 - Dracut + encrypted root + networking

4
debian/control vendored
View File

@@ -4,8 +4,8 @@ Priority: optional
Maintainer: Philippe Seewer <philippe.seewer@bfh.ch>
Build-Depends: debhelper (>= 5.0), cdbs
Standards-Version: 3.8.4
Vcs-Browser: http://dracut.git.sourceforge.net/git/gitweb-index.cgi
Vcs-Git: git://dracut.git.sourceforge.net/gitroot/dracut/dracut
Vcs-Browser: http://git.kernel.org/?p=boot/dracut/dracut.git
Vcs-Git: git://git.kernel.org/pub/scm/boot/dracut/dracut.git
Package: dracut
Architecture: all

2
debian/copyright vendored
View File

@@ -3,7 +3,7 @@ Fri Nov 20 15:45:00 +0100
Sources can be downloaded from:
https://sourceforge.net/projects/dracut/
http://www.kernel.org/pub/linux/utils/boot/dracut/
Upstream Maintainer:
Harald Hoyer <harald@redhat.com>

134
dracut
View File

@@ -53,6 +53,8 @@ Creates initial ramdisk images for preloading modules
--no-kernel Do not install kernel drivers and firmware files
--strip Strip binaries in the initramfs
--nostrip Do not strip binaries in the initramfs (default)
--prefix [DIR] Prefix initramfs files with [DIR]
--noprefix Do not prefix initramfs files (default)
--mdadmconf Include local /etc/mdadm.conf
--nomdadmconf Do not include local /etc/mdadm.conf
--lvmconf Include local /etc/lvm/lvm.conf
@@ -108,6 +110,7 @@ Creates initial ramdisk images for preloading modules
--list-modules List all available dracut modules.
-M, --show-modules Print included module's name to standard output during
build.
--keep Keep the temporary initramfs for debugging purposes
EOF
}
@@ -187,7 +190,6 @@ push_arg() {
fi
}
kernel="unset"
verbosity_mod_l=0
while (($# > 0)); do
@@ -207,11 +209,13 @@ while (($# > 0)); do
-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;;
--kernel-only) kernel_only="yes"; no_kernel="no";;
--no-kernel) kernel_only="no"; no_kernel="yes";;
--strip) do_strip_l="yes";;
--nostrip) do_strip_l="no";;
--noprefix) prefix_l="/";;
--mdadmconf) mdadmconf_l="yes";;
--nomdadmconf) mdadmconf_l="no";;
--lvmconf) lvmconf_l="yes";;
@@ -223,7 +227,9 @@ while (($# > 0)); do
-H|--hostonly) hostonly_l="yes" ;;
--fstab) use_fstab_l="yes" ;;
-h|--help) usage; exit 1 ;;
-i|--include) push include_src "$2"; push include_target "$3"; shift 2;;
-i|--include) push include_src "$2"
push include_target "$3"
shift 2;;
--bzip2) compress_l="bzip2";;
--lzma) compress_l="lzma";;
--xz) compress_l="xz";;
@@ -235,11 +241,12 @@ while (($# > 0)); do
-M|--show-modules)
show_modules_l="yes"
;;
--keep) keep="yes";;
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
*)
if ! [[ $outfile ]]; then
if ! [[ ${outfile+x} ]]; then
outfile=$1
elif [[ $kernel = "unset" ]]; then
elif ! [[ ${kernel+x} ]]; then
kernel=$1
else
usage; exit 1;
@@ -248,7 +255,7 @@ while (($# > 0)); do
esac
shift
done
if ! [[ $kernel ]] || [[ $kernel = "unset" ]]; then
if ! [[ $kernel ]]; then
kernel=$(uname -r)
fi
[[ $outfile ]] || outfile="/boot/initramfs-$kernel.img"
@@ -344,12 +351,14 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
[[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
[[ $do_strip_l ]] && do_strip=$do_strip_l
[[ $prefix_l ]] && prefix=$prefix_l
[[ $prefix = "/" ]] && unset prefix
[[ $hostonly_l ]] && hostonly=$hostonly_l
[[ $use_fstab_l ]] && use_fstab=$use_fstab_l
[[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l
[[ $lvmconf_l ]] && lvmconf=$lvmconf_l
[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
[[ $fw_dir ]] || fw_dir=/lib/firmware
[[ $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
@@ -357,11 +366,12 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
fw_dir=${fw_dir//:/ }
# handle compression options.
[[ $compress ]] || compress="gzip"
case $compress in
bzip2) compress="bzip -9";;
bzip2) compress="bzip2 -9";;
lzma) compress="lzma -9";;
xz) compress="xz --check=crc32 --lzma2=dict=1MiB";;
gzip) type pigz > /dev/null 2>&1 && compress="pigz -9" || \
gzip) command -v pigz > /dev/null 2>&1 && compress="pigz -9" || \
compress="gzip -9";;
esac
if [[ $_no_compress_l = "cat" ]]; then
@@ -370,7 +380,6 @@ fi
[[ $hostonly = yes ]] && hostonly="-h"
[[ $hostonly != "-h" ]] && unset hostonly
[[ $compress ]] || compress="gzip -9"
if [[ -f $dracutbasedir/dracut-functions ]]; then
. $dracutbasedir/dracut-functions
@@ -444,11 +453,11 @@ elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
exit 1
fi
[[ $TMPDIR && ! -w $TMPDIR ]] && unset TMPDIR
readonly initdir=$(mktemp -d -t initramfs.XXXXXX)
readonly TMPDIR=/var/tmp
readonly initdir=$(mktemp --tmpdir=/var/tmp/ -d -t initramfs.XXXXXX)
# clean up after ourselves no matter how we die.
trap 'ret=$?;rm -rf "$initdir";exit $ret;' EXIT
trap 'ret=$?;[[ $keep ]] && echo "Not removing $initdir." >&2 || rm -rf "$initdir";exit $ret;' EXIT
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
@@ -462,37 +471,64 @@ export initdir dracutbasedir dracutmodules drivers \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug
if [[ $kernel_only != yes ]]; then
# Create some directory structure first
for d in bin sbin usr/bin usr/sbin usr/lib etc \
proc sys sysroot tmp dev/pts var/run; do
inst_dir "/$d";
# Create some directory structure first
[[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
[[ -h /lib ]] || mkdir -m 0755 -p "${initdir}${prefix}/lib"
[[ $prefix ]] && ln -sfn "${prefix#/}/lib" "$initdir/lib"
if [[ $prefix ]]; then
for d in bin etc lib "$libdir" sbin tmp usr var; do
ln -sfn "${prefix#/}/${d#/}" "$initdir/$d"
done
fi
if [[ $kernel_only != yes ]]; then
for d in bin etc lib "$libdir" sbin tmp usr var usr/bin usr/sbin; do
[[ -e "${initdir}${prefix}/$d" ]] && continue
if [ -h "/$d" ]; then
inst "/$d" "${prefix}/$d"
else
mkdir -m 0755 -p "${initdir}${prefix}/$d"
fi
done
for d in proc sys sysroot root run run/lock run/initramfs; do
if [ -h "/$d" ]; then
inst "/$d"
else
mkdir -m 0755 -p "$initdir/$d"
fi
done
ln -sfn /run "$initdir/var/run"
ln -sfn /run/lock "$initdir/var/lock"
fi
# check all our modules to see if they should be sourced.
# This builds a list of modules that we will install next.
check_module_dir
modules_loaded=" "
# source our modules.
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
if strstr "$mods_to_load" " $mod "; then
[[ $show_modules = yes ]] && echo "$mod" || \
dinfo "*** Including module: $mod ***"
_d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
if strstr "$mods_to_load" " $_d_mod "; then
[[ $show_modules = yes ]] && echo "$_d_mod" || \
dinfo "*** Including module: $_d_mod ***"
if [[ $kernel_only = yes ]]; then
module_installkernel $mod
module_installkernel $_d_mod
else
module_install $mod
module_install $_d_mod
if [[ $no_kernel != yes ]]; then
module_installkernel $mod
module_installkernel $_d_mod
fi
fi
mods_to_load=${mods_to_load// $mod /}
mods_to_load=${mods_to_load// $_d_mod /}
modules_loaded+="$_d_mod "
fi
done
unset moddir
dinfo "*** Including modules' done ***"
dinfo "*** Including modules done ***"
## final stuff that has to happen
@@ -510,7 +546,21 @@ while pop include_src src && pop include_target tgt; do
else
ddebug "Including directory: $src"
mkdir -p "${initdir}/${tgt}"
cp -a -t "${initdir}/${tgt}" "$src"/*
# check for preexisting symlinks, so we can cope with the
# symlinks to $prefix
for i in "$src"/*; do
[[ -e "$i" || -h "$i" ]] || continue
s=${initdir}/${tgt}/${i#$src/}
if [[ -d "$i" ]]; then
if ! [[ -e "$s" ]]; then
mkdir -m 0755 -p "$s"
chmod --reference="$i" "$s"
fi
cp -a -t "$s" "$i"/*
else
cp -a -t "$s" "$i"
fi
done
fi
fi
done
@@ -522,13 +572,18 @@ while pop install_items items; do
done
unset item
# make sure that library links are correct and up to date
dracut_install /etc/ld.so.conf /etc/ld.so.conf.d/*
if ! ldconfig -r "$initdir"; then
if [[ $UID = 0 ]]; then
derror "ldconfig exited ungracefully"
else
derror "ldconfig might need uid=0 (root) for chroot()"
if [[ $kernel_only != yes ]]; then
# make sure that library links are correct and up to date
for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do
[[ -e $f ]] && dracut_install "$f"
done
if ! ldconfig -r "$initdir"; then
if [[ $UID = 0 ]]; then
derror "ldconfig exited ungracefully"
else
derror "ldconfig might need uid=0 (root) for chroot()"
fi
fi
fi
@@ -560,6 +615,15 @@ type hardlink &>/dev/null && {
hardlink "$initdir" 2>&1
}
if strstr "$modules_loaded" " fips " && command -v prelink >/dev/null; then
for i in $initdir/bin/* \
$initdir/bin/* \
$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 | \
$compress > "$outfile"; ); then
dfatal "dracut: creation of $outfile failed"

View File

@@ -105,7 +105,7 @@ Harald Hoyer &lt;harald@redhat.com&gt;
<refsect1 id='availability'><title>AVAILABILITY</title>
<para>The dracut-catimages command is part of the dracut package and is available from
<ulink url='http://sourceforge.net/apps/trac/dracut/wiki'>http://sourceforge.net/apps/trac/dracut/wiki</ulink></para>
<ulink url='https://dracut.wiki.kernel.org'>https://dracut.wiki.kernel.org</ulink></para>
</refsect1>

View File

@@ -32,9 +32,6 @@ if ! type dinfo >/dev/null 2>&1; then
dlog_init
fi
IF_RTLD=""
IF_dynamic=""
# Generic substring function. If $2 is in $1, return 0.
strstr() { [[ $1 =~ $2 ]]; }
@@ -47,25 +44,25 @@ mksubdirs() { mkdir -m 0755 -p ${1%/*}; }
# $2 = comparision op (gt, ge, eq, le, lt, ne)
# $3 = version b
vercmp() {
local n1=(${1//./ }) op=$2 n2=(${3//./ }) i res
local _n1=(${1//./ }) _op=$2 _n2=(${3//./ }) _i _res
for ((i=0; ; i++))
for ((_i=0; ; _i++))
do
if [[ ! ${n1[i]}${n2[i]} ]]; then res=0
elif ((${n1[i]:-0} > ${n2[i]:-0})); then res=1
elif ((${n1[i]:-0} < ${n2[i]:-0})); then res=2
if [[ ! ${_n1[_i]}${_n2[_i]} ]]; then _res=0
elif ((${_n1[_i]:-0} > ${_n2[_i]:-0})); then _res=1
elif ((${_n1[_i]:-0} < ${_n2[_i]:-0})); then _res=2
else continue
fi
break
done
case $op in
gt) ((res == 1));;
ge) ((res != 2));;
eq) ((res == 0));;
le) ((res != 1));;
lt) ((res == 2));;
ne) ((res != 0));;
case $_op in
gt) ((_res == 1));;
ge) ((_res != 2));;
eq) ((_res == 0));;
le) ((_res != 1));;
lt) ((_res == 2));;
ne) ((_res != 0));;
esac
}
@@ -76,17 +73,19 @@ is_func() {
# Function prints global variables in format name=value line by line.
# $@ = list of global variables' name
print_vars() {
local var value
local _var _value
for var in $@
for _var in $@
do
value=$(eval echo \$$var)
[[ ${value} ]] && echo "${var}=\"${value}\""
_value=$(eval echo \$$_var)
[[ ${_value} ]] && echo "${_var}=\"${_value}\""
done
}
get_fs_env() {
[[ $1 ]] || return
unset ID_FS_TYPE
unset ID_FS_UUID
eval $(udevadm info --query=env --name=$1|egrep 'ID_FS_(TYPE|UUID)=')
[[ $ID_FS_TYPE ]] && return
@@ -118,38 +117,38 @@ get_fs_uuid() (
# finds the major:minor of the block device backing the root filesystem.
find_block_device() {
local x mpt majmin dev fs misc maj min
local _x _mpt _majmin _dev _fs _maj _min
if [[ $use_fstab != yes ]]; then
while read x x majmin x mpt x x fs dev misc; do
[[ $fs = nfs ]] && { echo $dev; return 0;}
[[ $fs = nfs3 ]] && { echo $dev; return 0;}
[[ $fs = nfs4 ]] && { echo $dev; return 0;}
[[ $fs = btrfs ]] && {
ls -nLl "$dev" | {
read x x x x maj min x
maj=${maj//,/}
echo $maj:$min
while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do
[[ $_fs = nfs ]] && { echo $_dev; return 0;}
[[ $_fs = nfs3 ]] && { echo $_dev; return 0;}
[[ $_fs = nfs4 ]] && { echo $_dev; return 0;}
[[ $_fs = btrfs ]] && {
ls -nLl "$_dev" | {
read _x _x _x _x _maj _min _x
_maj=${_maj//,/}
echo $_maj:$_min
} && return 0
}
if [[ $mpt = $1 ]] && [[ ${majmin#0:} = $majmin ]]; then
echo $majmin
if [[ $_mpt = $1 ]] && [[ ${_majmin#0:} = $_majmin ]]; then
echo $_majmin
return 0 # we have a winner!
fi
done < /proc/self/mountinfo
fi
# fall back to /etc/fstab
while read dev mpt fs misc; do
if [[ $mpt = $1 ]]; then
[[ $fs = nfs ]] && { echo $dev; return 0;}
[[ $fs = nfs3 ]] && { echo $dev; return 0;}
[[ $fs = nfs4 ]] && { echo $dev; return 0;}
[[ $dev != ${dev#UUID=} ]] && dev=/dev/disk/by-uuid/${dev#UUID=}
[[ $dev != ${dev#LABEL=} ]] && dev=/dev/disk/by-label/${dev#LABEL=}
[[ -b $dev ]] || return 1 # oops, not a block device.
ls -nLl "$dev" | {
read x x x x maj min x
maj=${maj//,/}
echo $maj:$min
while read _dev _mpt _fs _x; do
if [[ $_mpt = $1 ]]; then
[[ $_fs = nfs ]] && { echo $_dev; return 0;}
[[ $_fs = nfs3 ]] && { echo $_dev; return 0;}
[[ $_fs = nfs4 ]] && { echo $_dev; return 0;}
[[ $_dev != ${_dev#UUID=} ]] && _dev=/dev/disk/by-uuid/${_dev#UUID=}
[[ $_dev != ${_dev#LABEL=} ]] && _dev=/dev/disk/by-label/${_dev#LABEL=}
[[ -b $_dev ]] || return 1 # oops, not a block device.
ls -nLl "$_dev" | {
read _x _x _x _x _maj _min _x
_maj=${_maj//,/}
echo $_maj:$_min
} && return 0
fi
done < /etc/fstab
@@ -164,7 +163,7 @@ find_root_block_device() { find_block_device /; }
# $1 = function to call on every found block device
# $2 = block device in major:minor format
check_block_and_slaves() {
local x
local _x
[[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
"$1" $2 && return
check_vol_slaves "$@" && return 0
@@ -172,15 +171,16 @@ check_block_and_slaves() {
check_block_and_slaves $1 $(cat "/sys/dev/block/$2/../dev") && return 0
fi
[[ -d /sys/dev/block/$2/slaves ]] || return 1
for x in /sys/dev/block/$2/slaves/*/dev; do
[[ -f $x ]] || continue
check_block_and_slaves $1 $(cat "$x") && return 0
for _x in /sys/dev/block/$2/slaves/*/dev; do
[[ -f $_x ]] || continue
check_block_and_slaves $1 $(cat "$_x") && return 0
done
return 1
}
get_numeric_dev() {
ls -lH "$1" | { read a b c d maj min rest; printf "%d:%d" ${maj%%,} $min; }
local _x _maj _min
ls -lH "$1" | { read _x _x _x _x _maj _min _x; printf "%d:%d" ${_maj%%,} $_min; }
}
# ugly workaround for the lvm design
@@ -190,16 +190,17 @@ get_numeric_dev() {
# but you cannot create the logical volume without the volume group.
# And the volume group might be bigger than the devices the LV needs.
check_vol_slaves() {
local _lv _vg _pv
for i in /dev/mapper/*; do
lv=$(get_numeric_dev $i)
if [[ $lv = $2 ]]; then
vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
_lv=$(get_numeric_dev $i)
if [[ $_lv = $2 ]]; then
_vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
# strip space
vg=$(echo $vg)
if [[ $vg ]]; then
for pv in $(lvm vgs --noheadings -o pv_name "$vg" 2>/dev/null)
_vg=$(echo $_vg)
if [[ $_vg ]]; then
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
do
check_block_and_slaves $1 $(get_numeric_dev $pv) && return 0
check_block_and_slaves $1 $(get_numeric_dev $_pv) && return 0
done
fi
fi
@@ -212,27 +213,33 @@ check_vol_slaves() {
# will create ${initdir}/lib64, ${initdir}/lib64/file,
# and a symlink ${initdir}/lib -> lib64.
inst_dir() {
local dir="$1"
[[ -e ${initdir}$dir ]] && return 0
local _dir="$1"
local _file=""
local IFS="/"
local _part
[[ -e ${initdir}$_dir ]] && return 0
# iterate over parent directories
local file=""
local IFS="/"
for part in $dir; do
[[ $part ]] || continue
file="$file/$part"
[[ -e ${initdir}$file ]] && continue
for _part in $_dir; do
[[ $_part ]] || continue
_file="$_file/$_part"
[[ -e ${initdir}$_file ]] && continue
if [[ -L $file ]]; then
if [[ -L $_file ]]; then
# create link as the original
local target=$(readlink "$file")
ln -sfn "$target" "${initdir}$file" || return 1
local target=$(readlink "$_file")
ln -sfn "$target" "${initdir}$_file" || return 1
# resolve relative path and recursively install destination
[[ $target == ${target#/} ]] && target="$(dirname "$file")/$target"
[[ $target == ${target#/} ]] && target="$(dirname "$_file")/$target"
inst_dir "$target"
else
[[ -h ${initdir}$_file ]] && _file=$(readlink "${initdir}$_file")
# create directory
mkdir -m 0755 -p "${initdir}$file" || return 1
mkdir -m 0755 -p "${initdir}$_file" || return 1
if [[ -d "$_file" ]]; then
chmod --reference="$_file" "${initdir}$_file"
chmod u+w "${initdir}$_file"
fi
fi
done
}
@@ -242,19 +249,20 @@ 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
local _src target
[[ -f $1 ]] || return 1
src=$1 target="${2:-$1}"
_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 "${src%/*}/.${src##*/}.hmac" "${target%/*}/.${target##*/}.hmac"
if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then
inst "${_src%/*}/.${_src##*/}.hmac" "${target%/*}/.${target##*/}.hmac"
fi
ddebug "Installing $src"
cp -pfL "$src" "${initdir}$target"
ddebug "Installing $_src"
cp -pfL "$_src" "${initdir}$target"
}
# find symlinks linked to given library file
@@ -286,27 +294,27 @@ 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
if [[ -L $src ]]; then
local _src=$1 _dest=${2:-$1} _lib _reallib _symlink
[[ -e $initdir$_dest ]] && return 0
if [[ -L $_src ]]; then
# install checksum files also
if [[ -e "${src%/*}/.${src##*/}.hmac" ]]; then
inst "${src%/*}/.${src##*/}.hmac" "${dest%/*}/.${dest##*/}.hmac"
if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then
inst "${_src%/*}/.${_src##*/}.hmac" "${_dest%/*}/.${_dest##*/}.hmac"
fi
reallib=$(readlink -f "$src")
lib=${src##*/}
inst_simple "$reallib" "$reallib"
inst_dir "${dest%/*}"
(cd "${initdir}${dest%/*}" && ln -s "$reallib" "$lib")
_reallib=$(readlink -f "$_src")
_lib=${_src##*/}
inst_simple "$_reallib" "$_reallib"
inst_dir "${_dest%/*}"
(cd "${initdir}${_dest%/*}" && ln -sfn "$_reallib" "$_lib")
else
inst_simple "$src" "$dest"
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 ]] && {
ddebug "Creating extra symlink: $symlink"
inst_symlink $symlink
for _symlink in $(rev_lib_symlinks $_src) $(rev_lib_symlinks $_reallib); do
[[ ! -e $initdir$_symlink ]] && {
ddebug "Creating extra symlink: $_symlink"
inst_symlink $_symlink
}
done
}
@@ -314,15 +322,15 @@ inst_library() {
# find a binary. If we were not passed the full path directly,
# search in the usual places to find the binary.
find_binary() {
local binpath="/bin /sbin /usr/bin /usr/sbin" p
local _binpath="/usr/sbin /sbin /usr/bin /bin" _p
if [[ -z ${1##/*} ]]; then
if [[ -x $1 ]] || ldd $1 &>/dev/null; then
echo $1
return 0
fi
fi
for p in $binpath; do
[[ -x $p/$1 ]] && { echo "$p/$1"; return 0; }
for _p in $_binpath; do
[[ -x $_p/$1 ]] && { echo "$_p/$1"; return 0; }
done
return 1
}
@@ -330,105 +338,112 @@ find_binary() {
# Same as above, but specialized to install binary executables.
# Install binary executable, and all shared library dependencies, if any.
inst_binary() {
local bin target
bin=$(find_binary "$1") || return 1
target=${2:-$bin}
inst_symlink $bin $target && return 0
local LDSO NAME IO FILE ADDR I1 n f TLIBDIR
[[ -e $initdir$target ]] && return 0
local _bin _target _f _self _so_regex _lib_regex _tlibdir _base _file _line
_bin=$(find_binary "$1") || return 1
_target=${2:-$_bin}
inst_symlink $_bin $_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[^ ]*)'
[[ $_bin =~ $_so_regex ]] && _self="\t${_bin##*/} => ${_bin} (0x0)\n"
_lib_regex='^(/lib[^/]*).*'
# I love bash!
LC_ALL=C ldd $bin 2>/dev/null | while read line; do
[[ $line = 'not a dynamic executable' ]] && return 1
if [[ $line =~ not\ found ]]; then
dfatal "Missing a shared library required by $bin."
dfatal "Run \"ldd $bin\" to find out what it is."
{ LC_ALL=C ldd $_bin 2>/dev/null; echo -en "$_self"; } | while read _line; do
[[ $_line = 'not a dynamic executable' ]] && return 1
if [[ $_line =~ not\ found ]]; then
dfatal "Missing a shared library required by $_bin."
dfatal "Run \"ldd $_bin\" to find out what it is."
dfatal "dracut cannot create an initrd."
exit 1
fi
so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
[[ $line =~ $so_regex ]] || continue
FILE=${BASH_REMATCH[1]}
[[ -e ${initdir}$FILE ]] && continue
# see if we are loading an optimized version of a shared lib.
lib_regex='^(/lib[^/]*).*'
if [[ $FILE =~ $lib_regex ]]; then
TLIBDIR=${BASH_REMATCH[1]}
BASE=${FILE##*/}
# prefer nosegneg libs, then unoptimized ones.
for f in "$TLIBDIR/i686/nosegneg" "$TLIBDIR"; do
[[ -e $f/$BASE ]] || continue
FILE=$f/$BASE
[[ $_line =~ $_so_regex ]] || continue
_file=${BASH_REMATCH[1]}
[[ -e ${initdir}$_file ]] && continue
# See if we are loading an optimized version of a shared lib.
if [[ $_file =~ $_lib_regex ]]; then
_tlibdir=${BASH_REMATCH[1]}
_base=${_file##*/}
# Prefer nosegneg libs to unoptimized ones.
for _f in "$_tlibdir/i686/nosegneg" "$_tlibdir"; do
[[ -e $_f/$_base ]] || continue
_file=$_f/$_base
break
done
inst_library "$FILE" "$TLIBDIR/$BASE"
IF_dynamic=yes
continue
fi
inst_library "$FILE"
inst_library "$_file" "$_tlibdir/$_base"
else
inst_library "$_file"
fi
done
inst_simple "$bin" "$target"
# Install the binary if it wasn't handled in the above loop.
[[ -z $_self ]] && inst_simple "$_bin" "$_target"
}
# 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 line
read -r -n 80 line <"$1"
local _line _shebang_regex
read -r -n 80 _line <"$1"
# If debug is set, clean unprintable chars to prevent messing up the term
[[ $debug ]] && line=$(echo -n "$line" | tr -c -d '[:print:][:space:]')
shebang_regex='(#! *)(/[^ ]+).*'
[[ $line =~ $shebang_regex ]] || return 1
[[ $debug ]] && _line=$(echo -n "$_line" | tr -c -d '[:print:][:space:]')
_shebang_regex='(#! *)(/[^ ]+).*'
[[ $_line =~ $_shebang_regex ]] || return 1
inst "${BASH_REMATCH[2]}" && inst_simple "$@"
}
# 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
[[ -L $1 ]] || return 1
[[ -L $target ]] && return 0
realsrc=$(readlink -f "$src")
[[ $realsrc = ${realsrc##*/} ]] && realsrc=${src%/*}/$realsrc
inst "$realsrc" && mkdir -m 0755 -p "${target%/*}" && \
ln -s "$realsrc" "$target"
}
# find a udev rule in the usual places.
find_rule() {
[[ -f $1 ]] && { echo "$1"; return 0; }
for r in . /lib/udev/rules.d /etc/udev/rules.d $dracutbasedir/rules.d; do
[[ -f $r/$1 ]] && { echo "$r/$1"; return 0; }
done
return 1
[[ -L $_target ]] && return 0
_realsrc=$(readlink -f "$_src")
[[ $_realsrc = ${_realsrc##*/} ]] && _realsrc=${_src%/*}/$_realsrc
if [[ -d $_realsrc ]]; then
inst_dir "$_realsrc"
else
inst "$_realsrc" && mkdir -m 0755 -p "${_target%/*}"
fi
if [[ -e "${_src}" ]]; then
cp -aP "${_src}" "$_target"
else
ln -sfn "$_realsrc" "$_target"
fi
}
# udev rules always get installed in the same place, so
# create a function to install them to make life simpler.
inst_rules() {
local target=/etc/udev/rules.d rule found
local _target=/etc/udev/rules.d _rule _found
inst_dir "/lib/udev/rules.d"
inst_dir "$target"
for rule in "$@"; do
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"
if [[ -f $r/$_rule ]]; then
_found="$r/$_rule"
inst_simple "$_found"
fi
done
for r in '' ./ $dracutbasedir/rules.d/; do
if [[ -f ${r}$rule ]]; then
found="${r}$rule"
inst_simple "$found" "$target/${found##*/}"
if [[ -f ${r}$_rule ]]; then
_found="${r}$_rule"
inst_simple "$_found" "$_target/${_found##*/}"
fi
done
[[ $found ]] || dinfo "Skipping udev rule: $rule"
[[ $_found ]] || dinfo "Skipping udev rule: $_rule"
done
}
# general purpose installation function
# Same args as above.
inst() {
local _x
case $# in
1) ;;
2) [[ ! $initdir && -d $2 ]] && export initdir=$2
@@ -438,15 +453,15 @@ inst() {
*) dfatal "inst only takes 1 or 2 or 3 arguments"
exit 1;;
esac
for x in inst_symlink inst_script inst_binary inst_simple; do
$x "$@" && return 0
for _x in inst_symlink inst_script inst_binary inst_simple; do
$_x "$@" && return 0
done
return 1
}
[[ $hookdirs ]] || {
hookdirs="cmdline pre-udev pre-trigger netroot initqueue pre-mount"
hookdirs+=" pre-pivot mount emergency"
hookdirs+=" pre-pivot mount emergency emergency-shutdown shutdown"
export hookdirs
}
@@ -466,13 +481,14 @@ inst_hook() {
}
dracut_install() {
local _optional=no
if [[ $1 = '-o' ]]; then
local optional=yes
_optional=yes
shift
fi
while (($# > 0)); do
if ! inst "$1" ; then
if [[ $optional = yes ]]; then
if [[ $_optional = yes ]]; then
dwarn "Skipping program $1 as it cannot be found and is" \
"flagged to be optional"
else
@@ -490,32 +506,32 @@ dracut_install() {
# Function install targets in the same paths inside overlay but decompressed
# and without extensions (.gz, .bz2).
inst_decompress() {
local src dst realsrc realdst cmd
local _src _dst _realsrc _realdst _cmd
for src in $@
for _src in $@
do
case ${src} in
*.gz) cmd='gzip -d' ;;
*.bz2) cmd='bzip2 -d' ;;
case ${_src} in
*.gz) _cmd='gzip -d' ;;
*.bz2) _cmd='bzip2 -d' ;;
*) return 1 ;;
esac
if [[ -L ${src} ]]
if [[ -L ${_src} ]]
then
realsrc="$(readlink -f ${src})" # symlink target with extension
dst="${src%.*}" # symlink without extension
realdst="${realsrc%.*}" # symlink target without extension
mksubdirs "${initdir}/${src}"
_realsrc="$(readlink -f ${_src})" # symlink target with extension
_dst="${_src%.*}" # symlink without extension
_realdst="${_realsrc%.*}" # symlink target without extension
mksubdirs "${initdir}/${_src}"
# Create symlink without extension to target without extension.
ln -s "${realdst}" "${initdir}/${dst}"
ln -sfn "${_realdst}" "${initdir}/${_dst}"
fi
# If the source is symlink we operate on its target.
[[ ${realsrc} ]] && src=${realsrc}
inst ${src}
[[ ${_realsrc} ]] && _src=${_realsrc}
inst ${_src}
# Decompress with chosen tool. We assume that tool changes name e.g.
# from 'name.gz' to 'name'.
${cmd} "${initdir}${src}"
${_cmd} "${initdir}${_src}"
done
}
@@ -523,170 +539,181 @@ inst_decompress() {
# install.
# $@ = list of files
inst_opt_decompress() {
local src
local _src
for src in $@
for _src in $@
do
inst_decompress "${src}" || inst "${src}"
inst_decompress "${_src}" || inst "${_src}"
done
}
module_check() {
local moddir=$(echo ${dracutbasedir}/modules.d/??${1})
[[ -d $moddir ]] || return 1
if [[ ! -f $moddir/module-setup.sh ]]; then
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
[[ -d $_moddir ]] || return 1
if [[ ! -f $_moddir/module-setup.sh ]]; then
# if we do not have a check script, we are unconditionally included
[[ -x $moddir/check ]] || return 0
$moddir/check $hostonly
[[ -x $_moddir/check ]] || return 0
$_moddir/check $hostonly
return $?
else
unset check depends install installkernel
. $moddir/module-setup.sh
. $_moddir/module-setup.sh
is_func check || return 0
check
ret=$?
_ret=$?
unset check depends install installkernel
return $ret
return $_ret
fi
}
module_depends() {
local moddir=$(echo ${dracutbasedir}/modules.d/??${1})
[[ -d $moddir ]] || return 1
if [[ ! -f $moddir/module-setup.sh ]]; then
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
[[ -d $_moddir ]] || return 1
if [[ ! -f $_moddir/module-setup.sh ]]; then
# if we do not have a check script, we have no deps
[[ -x $moddir/check ]] || return 0
$moddir/check -d
[[ -x $_moddir/check ]] || return 0
$_moddir/check -d
return $?
else
unset check depends install installkernel
. $moddir/module-setup.sh
. $_moddir/module-setup.sh
is_func depends || return 0
depends
ret=$?
_ret=$?
unset check depends install installkernel
return $ret
return $_ret
fi
}
module_install() {
local moddir=$(echo ${dracutbasedir}/modules.d/??${1})
[[ -d $moddir ]] || return 1
if [[ ! -f $moddir/module-setup.sh ]]; then
[[ -x $moddir/install ]] && . "$moddir/install"
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
[[ -d $_moddir ]] || return 1
if [[ ! -f $_moddir/module-setup.sh ]]; then
[[ -x $_moddir/install ]] && . "$_moddir/install"
return $?
else
unset check depends install installkernel
. $moddir/module-setup.sh
. $_moddir/module-setup.sh
is_func install || return 0
install
ret=$?
_ret=$?
unset check depends install installkernel
return $ret
return $_ret
fi
}
module_installkernel() {
local moddir=$(echo ${dracutbasedir}/modules.d/??${1})
[[ -d $moddir ]] || return 1
if [[ ! -f $moddir/module-setup.sh ]]; then
[[ -x $moddir/installkernel ]] && . "$moddir/installkernel"
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
[[ -d $_moddir ]] || return 1
if [[ ! -f $_moddir/module-setup.sh ]]; then
[[ -x $_moddir/installkernel ]] && . "$_moddir/installkernel"
return $?
else
unset check depends install installkernel
. $moddir/module-setup.sh
. $_moddir/module-setup.sh
is_func installkernel || return 0
installkernel
ret=$?
_ret=$?
unset check depends install installkernel
return $ret
return $_ret
fi
}
check_module() {
local mod=$1;
local moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local moddep;
local _mod=$1
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
local _moddep
# If we are already scheduled to be loaded, no need to check again.
strstr " $mods_to_load " " $mod " && return 0
strstr " $mods_checked_as_dep " " $mod " && return 1
strstr " $mods_to_load " " $_mod " && return 0
strstr " $mods_checked_as_dep " " $_mod " && return 1
# This should never happen, but...
[[ -d $moddir ]] || return 1
[[ -d $_moddir ]] || return 1
[[ $2 ]] || mods_checked_as_dep+=" $mod "
[[ $2 ]] || mods_checked_as_dep+=" $_mod "
strstr " $omit_dracutmodules " " $mod " && return 1
strstr " $omit_dracutmodules " " $_mod " && return 1
if strstr " $dracutmodules $add_dracutmodules " " $mod "; then
module_check $mod; ret=$?
if strstr " $dracutmodules $add_dracutmodules " " $_mod "; then
module_check $_mod; ret=$?
# explicit module, so also accept ret=255
[[ $ret = 0 || $ret = 255 ]] || return 1
else
# module not in our list
if [[ $dracutmodules = all ]]; then
# check, if we can and should install this module
module_check $mod || return 1
module_check $_mod || return 1
else
# skip this module
return 1
fi
fi
for moddep in $(module_depends $mod); do
for _moddep in $(module_depends $_mod); do
# handle deps as if they were manually added
strstr " $add_dracutmodules " " $moddep " || \
add_dracutmodules+=" $moddep "
strstr " $add_dracutmodules " " $_moddep " || \
add_dracutmodules+=" $_moddep "
# if a module we depend on fail, fail also
check_module $moddep || return 1
check_module $_moddep || return 1
done
strstr " $mods_to_load " " $mod " || \
mods_to_load+=" $mod "
strstr " $mods_to_load " " $_mod " || \
mods_to_load+=" $_mod "
return 0
}
check_module_dir() {
local modcheck;
local mod;
local _modcheck
local _mod
local _moddir
mods_to_load=""
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
local mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
check_module $mod 1
for _moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
_mod=${_moddir##*/}; _mod=${_mod#[0-9][0-9]}
check_module $_mod 1
done
# Report any missing dracut modules, the user has specified
modcheck=$add_dracutmodules
[[ $dracutmodules != all ]] && modcheck="$m $dracutmodules"
for mod in $modcheck; do
strstr "$mods_to_load" "$mod" && continue
strstr "$omit_dracutmodules" "$mod" && continue
derror "Dracut module \"$mod\" cannot be found."
_modcheck=$add_dracutmodules
[[ $dracutmodules != all ]] && _modcheck="$m $dracutmodules"
for _mod in $_modcheck; do
strstr "$mods_to_load" "$_mod" && continue
strstr "$omit_dracutmodules" "$_mod" && continue
derror "Dracut module \"$_mod\" cannot be found."
done
}
# 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
modname=${modname%.ko*}
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 $?
for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
found=''
for fwdir in $fw_dir; do
if [[ -d $fwdir && -f $fwdir/$fw ]]; then
inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
found=yes
for _fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
_found=''
for _fwdir in $fw_dir; do
if [[ -d $_fwdir && -f $_fwdir/$_fw ]]; then
inst_simple "$_fwdir/$_fw" "/lib/firmware/$_fw"
_found=yes
fi
done
if [[ $found != yes ]]; then
dwarn "Possible missing firmware \"${fw}\" for kernel module" \
"\"${mod}.ko\""
if [[ $_found != yes ]]; then
if ! grep -qe "\<${_modname//-/_}\>" /proc/modules; then
dinfo "Possible missing firmware \"${_fw}\" for kernel module" \
"\"${_modname}.ko\""
else
dwarn "Possible missing firmware \"${_fw}\" for kernel module" \
"\"${_modname}.ko\""
fi
fi
done
return 0
@@ -699,18 +726,19 @@ install_kmod_with_fw() {
# $2 = module to get dependencies for
# rest of args = arguments to modprobe
for_each_kmod_dep() {
local func=$1 kmod=$2 cmd modpapth options
local _func=$1 _kmod=$2 _cmd _modpath _options _found=0
shift 2
modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | (
local found=0
while read cmd modpath options; do
[[ $cmd = insmod ]] || continue
$func ${modpath} || exit $?
found=1
modprobe "$@" --ignore-install --show-depends $_kmod 2>"$initdir/modprobe.err" | (
while read _cmd _modpath _options; do
[[ $_cmd = insmod ]] || continue
$_func ${_modpath} || exit $?
_found=1
done
[[ $found -eq 0 ]] && exit 1
[[ $_found -eq 0 ]] && exit 1
exit 0
)
egrep -v 'FATAL: Module .* not found.' "$initdir/modprobe.err" | derror
rm -f "$initdir/modprobe.err"
return $?
}
@@ -723,19 +751,20 @@ for_each_kmod_dep() {
# 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
if ! [[ $hostonly ]]; then
filtercmd='find "$srcmods/kernel/drivers" "$srcmods/extra"'
filtercmd+=' "$srcmods/weak-updates" -name "*.ko" -o -name "*.ko.gz"'
filtercmd+=' 2>/dev/null'
_filtercmd='find "$srcmods/kernel/drivers" "$srcmods/extra"'
_filtercmd+=' "$srcmods/weak-updates" -name "*.ko" -o -name "*.ko.gz"'
_filtercmd+=' 2>/dev/null'
else
filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename '
filtercmd+='-k $kernel 2>/dev/null'
_filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename '
_filtercmd+='-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"
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
@@ -745,52 +774,52 @@ filter_kernel_modules () (
# install kernel modules along with all their dependencies.
instmods() {
[[ $no_kernel = yes ]] && return
local mod mpargs modpath modname cmd moddirname
local ret=0
local _mod _mpargs _moddirname
local _ret=0
while (($# > 0)); do
mod=${1%.ko*}
case $mod in
_mod=${1%.ko*}
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 \
if [[ $_mod = =ata && -f $srcmods/modules.block ]]; then
instmods $_mpargs \
$(egrep 'ata|ahci' "${srcmods}/modules.block")
elif [ -f $srcmods/modules.${mod#=} ]; then
instmods $mpargs $(cat ${srcmods}/modules.${mod#=} )
elif [ -f $srcmods/modules.${_mod#=} ]; then
instmods $_mpargs $(cat ${srcmods}/modules.${_mod#=} )
else
instmods $mpargs $(find "$srcmods" -path "*/${mod#=}/*")
instmods $_mpargs $(find "$srcmods" -path "*/${_mod#=}/*")
fi
;;
--*)
mod=${mod##*/}
mpargs+=" $mod";;
_mod=${_mod##*/}
_mpargs+=" $_mod";;
i2o_scsi) shift; continue;; # Do not load this diagnostic-only module
*) mod=${mod##*/}
*) _mod=${_mod##*/}
# if we are already installed, skip this module and go on
# to the next one.
[[ -f $initdir/$1 ]] && { shift; continue; }
# 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}\>" && {
[[ $hostonly ]] && ! grep -qe "\<${_mod//-/_}\>" /proc/modules \
&& ! echo $add_drivers | grep -qe "\<${_mod}\>" && {
shift; continue
}
# 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/*}
[[ -n ${moddirname} ]] && moddirname="-d ${moddirname}/"
_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}
ret=$((ret+$?))
for_each_kmod_dep install_kmod_with_fw $_mod \
--set-version $kernel ${_moddirname}
((_ret+=$?))
;;
esac
shift
done
return $ret
return $_ret
}

View File

@@ -35,7 +35,7 @@ Harald Hoyer &lt;harald@redhat.com&gt;
<refsect1 id='availability'><title>AVAILABILITY</title>
<para>The dracut-gencmdline command is part of the dracut package and is available from
<ulink url='http://sourceforge.net/apps/trac/dracut/wiki'>http://sourceforge.net/apps/trac/dracut/wiki</ulink></para>
<ulink url='https://dracut.wiki.kernel.org'>https://dracut.wiki.kernel.org</ulink></para>
</refsect1>

View File

@@ -234,6 +234,22 @@ include in the generic initramfs. This parameter can be specified multiple times
<para>do not strip binaries in the initramfs</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--prefix</option>
</term>
<listitem>
<para>prefix initramfs files with /run/initramfs/</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--noprefix</option>
</term>
<listitem>
<para>do not prefix initramfs files with /run/initramfs/ (default)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-h</option>
@@ -435,6 +451,14 @@ TARGET directory in the final initramfs. If SOURCE is a file, it will be install
<para>Print included module's name to standard output during build.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--keep</option>
</term>
<listitem>
<para>Keep the initramfs temporary directory for debugging purposes.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
@@ -507,7 +531,7 @@ set in the configuration files.</para>
<refsect1>
<title>Availability</title>
<para>The dracut command is part of the dracut package and is available from
<ulink url="http://sourceforge.net/apps/trac/dracut/wiki">http://sourceforge.net/apps/trac/dracut/wiki</ulink></para>
<ulink url='https://dracut.wiki.kernel.org'>https://dracut.wiki.kernel.org</ulink></para>
</refsect1>
<refsect1>
<title>See Also</title>

View File

@@ -3,7 +3,9 @@
logfile=/var/log/dracut.log
fileloglvl=6
# Specific list of dracut modules to use
# Exact list of dracut modules to use. Modules not listed here are not going
# to be included. If you only want to add some optional modules use
# add_dracutmodules option instead.
#dracutmodules+=""
# Dracut modules to omit

View File

@@ -1,7 +1,7 @@
# /etc/dracut.conf.d/redhat.conf
# Dracut config file customized for RedHat/Fedora.
# i18n
i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-FONT,FONTACM-FONT_MAP,FONT_UNIMAP"
add_dracutmodules+=" rpmversion "
add_dracutmodules+=" rpmversion shutdown "
stdloglvl=3
prefix=/run/initramfs

View File

@@ -134,7 +134,7 @@ This parameter can be specified multiple times.</para>
<envar>rd.debug</envar>
</term>
<listitem>
<para>set -x for the dracut shell and logs to dmesg, console and <filename>/init.log</filename></para>
<para>set -x for the dracut shell and logs to dmesg, console and <filename>/run/initramfs/init.log</filename></para>
</listitem>
</varlistentry>
<varlistentry>
@@ -169,14 +169,6 @@ This parameter can be specified multiple times.</para>
<para>set udev to loglevel debug</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>rd.timestamp</envar>
</term>
<listitem>
<para>export RDTIMESTAMP environment variable to init, which is set to the uptime of the dracut start.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
@@ -325,7 +317,7 @@ This parameter can be specified multiple times.</para>
<envar>rd.luks.key=</envar><replaceable>&lt;keypath&gt;:&lt;keydev&gt;:&lt;luksdev&gt;</replaceable>
</term>
<listitem>
<para><replaceable>keypath</replaceable> is a path to key file to look for. It&apos;s REQUIRED.</para>
<para><replaceable>keypath</replaceable> is a path to key file to look for. It&apos;s REQUIRED. When <replaceable>keypath</replaceable> ends with '.gpg' it's considered to be key encrypted symmetrically with GPG. You will be prompted for password on boot. GPG support comes with 'crypt-gpg' module which needs to be added explicitly.</para>
<para><replaceable>keydev</replaceable> is a device on which key file resides. It might be kernel name of devices (should start with &quot;/dev/&quot;), UUID (prefixed with &quot;UUID=&quot;) or label (prefix with &quot;LABEL=&quot;). You don&apos;t have to specify full UUID. Just its beginning will suffice, even if its ambiguous. All matching devices will be probed. This parameter is recommended, but not required. If not present, all block devices will be probed, which may significantly increase boot time.</para>
<para>If <replaceable>luksdev</replaceable> is given, the specified key will only be applied for that LUKS device. Possible values are the same as for <replaceable>keydev</replaceable>. Unless you have several LUKS devices, you don&apos;t have to specify this parameter.</para>
<para>The simplest usage is:</para>
@@ -389,6 +381,37 @@ This parameter can be specified multiple times.</para>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
<title>FIPS</title>
<variablelist>
<varlistentry>
<term><envar>rd.fips</envar></term>
<listitem>
<para>enable FIPS</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>boot=<replaceable>&lt;boot device&gt;</replaceable></envar>
</term>
<listitem>
<para>specify the device, where /boot is located.<programlisting>
e.g.
boot=/dev/sda1
boot=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1
boot=UUID=&lt;uuid&gt;
boot=LABEL=&lt;label&gt;</programlisting>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>rd.fips.skipkernel</envar></term>
<listitem>
<para>skip checksum check of the kernel image. Useful, if the kernel image is not in a separate boot partition.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
<title>Network</title>
<variablelist>
@@ -573,7 +596,7 @@ netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target1 </programlisting></par
</varlistentry>
<varlistentry>
<term>
<envar>root=</envar><replaceable>??? </replaceable><envar>rd.iscsi.firmware=1</envar>
<envar>root=</envar><replaceable>??? </replaceable><envar>netroot=iscsi </envar><envar>rd.iscsi.firmware=1</envar>
</term>
<listitem>
<para>will read the iscsi parameter from the BIOS firmware</para>
@@ -700,14 +723,6 @@ rd.znet=ctc,0.0.0600,0.0.0601,0.0.0602,protocol=bar</programlisting></para>
<para><envar>rd.ccw</envar></para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>rdcopystate</envar>
</term>
<listitem>
<para><envar>rd.copystate</envar></para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>rd_DASD_MOD</envar>

View File

@@ -6,17 +6,9 @@
%define with_nbd 0
%endif
%if %{defined gittag}
%define rdist .git%{gittag}%{?dist}
%define dashgittag -%{gittag}
%else
%define rdist %{?dist}
%endif
Name: dracut
Version: 009
%define release_prefix 0%{?rdist}
Release: %{release_prefix}
Version: xxx
Release: xxx
Summary: Initramfs generator using udev
%if 0%{?fedora}
@@ -26,12 +18,13 @@ Group: System Environment/Base
Group: System/Base
%endif
License: GPLv2+
URL: http://apps.sourceforge.net/trac/dracut/wiki
URL: https://dracut.wiki.kernel.org/
# Source can be generated by
# http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=snapshot;h=%{?dashgittag};sf=tgz
Source0: dracut-%{version}%{?dashgittag}.tar.bz2
BuildArch: noarch
# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz
Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2
BuildArch: noarch
BuildRequires: dash bash
%if 0%{?fedora}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%endif
@@ -105,7 +98,7 @@ Requires: rpcbind
%if %{with_nbd}
Requires: nbd
%endif
Requires: net-tools iproute
Requires: iproute
Requires: bridge-utils
%if 0%{?fedora}
@@ -161,17 +154,17 @@ Requires: %{name} = %{version}-%{release}
This package contains tools to assemble the local initrd and host configuration.
%prep
%setup -q -n %{name}-%{version}%{?dashgittag}
%setup -q -n %{name}-%{version}
%build
make WITH_SWITCH_ROOT=0%{?with_switch_root}
make
%install
%if 0%{?fedora}
rm -rf $RPM_BUILD_ROOT
%endif
make install DESTDIR=$RPM_BUILD_ROOT sbindir=/sbin \
sysconfdir=/etc mandir=%{_mandir} WITH_SWITCH_ROOT=0%{?with_switch_root}
sysconfdir=/etc mandir=%{_mandir}
echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/%{_datadir}/dracut/modules.d/10rpmversion/dracut-version
@@ -202,8 +195,8 @@ rm $RPM_BUILD_ROOT/sbin/mkinitrd
rm $RPM_BUILD_ROOT/sbin/lsinitrd
%endif
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d/dracut
install -m 0644 dracut.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/dracut
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
install -m 0644 dracut.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/dracut_log
%clean
rm -rf $RPM_BUILD_ROOT
@@ -212,9 +205,6 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,0755)
%doc README HACKING TODO COPYING AUTHORS NEWS dracut.html dracut.png dracut.svg
/sbin/dracut
%if 0%{?with_switch_root}
/sbin/switch_root
%endif
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999
/sbin/mkinitrd
/sbin/lsinitrd
@@ -228,7 +218,6 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace) /etc/dracut.conf.d/01-dist.conf
%endif
%dir /etc/dracut.conf.d
%config(noreplace) /etc/logrotate.d/dracut
%{_mandir}/man8/dracut.8*
%{_mandir}/man7/dracut.kernel.7*
%{_mandir}/man5/dracut.conf.5*
@@ -248,6 +237,7 @@ rm -rf $RPM_BUILD_ROOT
%{_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
@@ -261,8 +251,8 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/dracut/modules.d/98selinux
%{_datadir}/dracut/modules.d/98syslog
%{_datadir}/dracut/modules.d/99base
# logfile needs no logrotate, because it gets overwritten
# for every dracut run
%{_datadir}/dracut/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

View File

@@ -307,7 +307,7 @@ rd.live.overlay/
<listitem>
<para>With dracut &gt;= 002-11, you can inspect the rd.debug output with:
</para>
<screen># less /init.log
<screen># less /run/initramfs/init.log
# dmesg | less</screen>
</listitem>
</orderedlist>

66
git2spec.pl Executable file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/perl
sub last_tag {
open( GIT, 'git log --pretty=format:%H |');
LINE: while( <GIT> ) {
open( GIT2, "git tag --contains $_ |");
while( <GIT2> ) {
chomp;
last LINE if /..*/;
}
close GIT2;
}
$tag=$_;
close GIT2;
close GIT; # be done
return $tag;
};
sub create_patches {
my $tag=shift;
my $num=0;
open( GIT, 'git format-patch -M -N --no-signature '.$tag.' |');
@lines=<GIT>;
close GIT; # be done
return @lines;
};
use POSIX qw(strftime);
my $datestr = strftime "%Y%m%d", gmtime;
my $tag=shift;
$tag=&last_tag if not defined $tag;
my @patches=&create_patches($tag);
my $num=$#patches + 2;
$tag=~s/[^0-9]+?([0-9]+)/$1/;
my $release="$num.git$datestr";
$release="1" if $num == 1;
while(<>) {
if (/^Version:/) {
print "Version: $tag\n";
}
elsif (/^Release:/) {
print "Release: $release\n";
}
elsif ((/^Source0:/) || (/^Source:/)) {
print $_;
$num=1;
for(@patches) {
print "Patch$num: $_";
$num++;
}
print "\n";
}
elsif (/^%setup/) {
print $_;
$num=1;
for(@patches) {
print "%patch$num -p1\n";
$num++;
}
print "\n";
}
else {
print $_;
}
}

View File

@@ -19,28 +19,31 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ $# -eq 1 || $# -eq 2 ]] || { echo "Usage: $(basename $0) <initramfs file> [<filename>]" ; exit 1 ; }
[[ -f $1 ]] || { echo "$1 does not exist" ; exit 1 ; }
[[ $# -le 2 ]] || { echo "Usage: $(basename $0) [<initramfs file> [<filename>]]" ; exit 1 ; }
image="${1:-/boot/initramfs-$(uname -r).img}"
[[ -f "$image" ]] || { echo "$image does not exist" ; exit 1 ; }
CAT=zcat
FILE_T=$(file $1)
FILE_T=$(file "$image")
if [[ "$FILE_T" =~ ": gzip compressed data" ]]; then
CAT=zcat
elif [[ "$FILE_T" =~ ": xz compressed data" ]]; then
CAT=xzcat
elif [[ "$FILE_T" =~ ": XZ compressed data" ]]; then
CAT=xzcat
elif [[ "$FILE_T" =~ ": data" ]]; then
CAT=lzcat
fi
if [[ $# -eq 2 ]]; then
$CAT $1 | cpio --extract --verbose --quiet --to-stdout ${2#/} 2>/dev/null
$CAT $image | cpio --extract --verbose --quiet --to-stdout ${2#/} 2>/dev/null
exit $?
fi
echo "$1:"
echo "$image:"
echo "========================================================================"
$CAT $1 | cpio --extract --verbose --quiet --to-stdout 'lib/dracut/dracut-*' 2>/dev/null
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'lib/dracut/dracut-*' 2>/dev/null
echo "========================================================================"
$CAT $1 | cpio --extract --verbose --quiet --list
$CAT "$image" | cpio --extract --verbose --quiet --list
echo "========================================================================"

12
modules.d/01fips/fips-boot.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1
elif getarg boot= >/dev/null; then
. /sbin/fips.sh
if mount_boot; then
do_fips || die "FIPS integrity test failed"
fi
fi

11
modules.d/01fips/fips-noboot.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1
elif ! [ -f /tmp/fipsdone ]; then
. /sbin/fips.sh
mount_boot
do_fips || die "FIPS integrity test failed"
fi

View File

@@ -1,55 +1,69 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
do_fips()
mount_boot()
{
FIPSMODULES=$(cat /etc/fipsmodules)
BOOT=$(getarg boot=)
KERNEL=$(uname -r)
case "$boot" in
block:LABEL=*|LABEL=*)
boot="${boot#block:}"
boot=$(getarg boot=)
if [ -n "$boot" ]; then
case "$boot" in
LABEL=*)
boot="$(echo $boot | sed 's,/,\\x2f,g')"
boot="/dev/disk/by-label/${boot#LABEL=}"
bootok=1 ;;
block:UUID=*|UUID=*)
boot="${boot#block:}"
boot="/dev/disk/by-uuid/${root#UUID=}"
bootok=1 ;;
;;
UUID=*)
boot="/dev/disk/by-uuid/${boot#UUID=}"
;;
/dev/*)
bootok=1 ;;
;;
*)
die "You have to specify boot=<boot device> as a boot option for fips=1" ;;
esac
esac
if ! [ -e "$boot" ]; then
udevadm trigger --action=add >/dev/null 2>&1
[ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)
if [ $UDEVVERSION -ge 143 ]; then
udevadm settle --exit-if-exists=$boot
else
udevadm settle --timeout=30
if ! [ -e "$boot" ]; then
udevadm trigger --action=add >/dev/null 2>&1
[ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)
i=0
while ! [ -e $boot ]; do
if [ $UDEVVERSION -ge 143 ]; then
udevadm settle --exit-if-exists=$boot
else
udevadm settle --timeout=30
fi
[ -e $boot ] && break
modprobe scsi_wait_scan && rmmod scsi_wait_scan
[ -e $boot ] && break
sleep 0.5
i=$(($i+1))
[ $i -gt 40 ] && break
done
fi
[ -e "$boot" ] || return 1
mkdir /boot
info "Mounting $boot as /boot"
mount -oro "$boot" /boot || return 1
fi
}
[ -e "$boot" ]
mkdir /boot
info "Mounting $boot as /boot"
mount -oro "$boot" /boot
do_fips()
{
info "Checking integrity of kernel"
newroot=$NEWROOT
KERNEL=$(uname -r)
if ! [ -e "/boot/.vmlinuz-${KERNEL}.hmac" ]; then
warn "/boot/.vmlinuz-${KERNEL}.hmac does not exist"
[ -e "$newroot/boot/.vmlinuz-${KERNEL}.hmac" ] || unset newroot
if ! [ -e "$newroot/boot/.vmlinuz-${KERNEL}.hmac" ]; then
warn "$newroot/boot/.vmlinuz-${KERNEL}.hmac does not exist"
return 1
fi
sha512hmac -c "/boot/.vmlinuz-${KERNEL}.hmac" || return 1
sha512hmac -c "$newroot/boot/.vmlinuz-${KERNEL}.hmac" || return 1
info "Umounting /boot"
umount /boot
FIPSMODULES=$(cat /etc/fipsmodules)
info "Loading and integrity checking all crypto modules"
for module in $FIPSMODULES; do
@@ -62,13 +76,9 @@ do_fips()
rmmod tcrypt
info "All initrd crypto checks done"
> /tmp/fipsdone
umount /boot >/dev/null 2>&1
return 0
}
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1
else
set -e
do_fips || die "FIPS integrity test failed"
set +e
fi

View File

@@ -11,31 +11,39 @@ depends() {
}
installkernel() {
FIPSMODULES="aead aes_generici aes-xts aes-x86_64 ansi_cprng cbc ccm chainiv ctr"
FIPSMODULES="$FIPSMODULES des deflate ecb eseqiv hmac seqiv sha256 sha512"
FIPSMODULES="$FIPSMODULES cryptomgr crypto_null tcrypt"
local _fipsmodules _mod
_fipsmodules="aead aes_generici aes-xts aes-x86_64 ansi_cprng cbc ccm chainiv ctr"
_fipsmodules+=" des deflate ecb eseqiv hmac seqiv sha256 sha512"
_fipsmodules+=" cryptomgr crypto_null tcrypt"
mkdir -p "${initdir}/etc/modprobe.d"
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"
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() {
inst_hook pre-trigger 01 "$moddir/fips.sh"
local _dir
inst_hook pre-trigger 01 "$moddir/fips-boot.sh"
inst_hook pre-pivot 01 "$moddir/fips-noboot.sh"
inst "$moddir/fips.sh" /sbin/fips.sh
dracut_install sha512hmac rmmod insmod mount uname umount
for dir in "$usrlibdir" "$libdir"; do
[[ -e $dir/libsoftokn3.so ]] && \
dracut_install $dir/libsoftokn3.so $dir/libsoftokn3.chk \
$dir/libfreebl3.so $dir/libfreebl3.chk && \
for _dir in "$usrlibdir" "$libdir"; do
[[ -e $_dir/libsoftokn3.so ]] && \
dracut_install $_dir/libsoftokn3.so $_dir/libsoftokn3.chk \
$_dir/libfreebl3.so $_dir/libfreebl3.chk && \
break
done
dracut_install $usrlibdir/hmaccalc/sha512hmac.hmac
if command -v prelink >/dev/null; then
dracut_install prelink
fi
}

View File

@@ -13,18 +13,23 @@ depends() {
}
install() {
inst busybox /sbin/busybox
local _i _progs _path
inst busybox /usr/bin/busybox
# List of shell programs that we use in other official dracut modules, that
# must be supported by the busybox installed on the host system
progs="echo grep usleep [ rmmod insmod mount uname umount setfont kbd_mode stty gzip bzip2 chvt readlink blkid dd losetup tr sed seq ps more cat rm free ping netstat vi ping6 fsck ip hostname basename mknod mkdir pidof sleep chroot ls cp mv dmesg mkfifo less ln modprobe"
_progs="echo grep usleep [ rmmod insmod mount uname umount setfont kbd_mode stty gzip bzip2 chvt readlink blkid dd losetup tr sed seq ps more cat rm free ping netstat vi ping6 fsck ip hostname basename mknod mkdir pidof sleep chroot ls cp mv dmesg mkfifo less ln modprobe"
# FIXME: switch_root should be in the above list, but busybox version hangs
# (using busybox-1.15.1-7.fc14.i686 at the time of writing)
for i in $progs; do
path=$(find_binary "$i")
ln -s /sbin/busybox "$initdir/$path"
for _i in $_progs; do
_path=$(find_binary "$_i")
if [[ $_path != ${_path#/usr} ]]; then
ln -s ../../usr/bin/busybox "$initdir/$_path"
else
ln -s ../usr/bin/busybox "$initdir/$_path"
fi
done
}

View File

@@ -61,7 +61,6 @@ dev_open() {
exec 7>>${dev}
}
dev=/dev/${1#/dev/}
devname=${dev#/dev/}
@@ -70,8 +69,6 @@ devname=${dev#/dev/}
exit 1
}
[ -e /tmp/console_init.${devname} ] && exit 0
dev_open ${dev}
for fd in 6 7; do
@@ -88,4 +85,4 @@ set_font ${dev}
set_keymap
dev_close
>/tmp/console_init.${devname}

View File

@@ -11,6 +11,7 @@ depends() {
}
install() {
[ -x /lib/systemd/systemd-vconsole-setup ] && dracut_install /lib/systemd/systemd-vconsole-setup
KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps
DEFAULT_FONT=LatArCyrHeb-16
I18N_CONF="/etc/locale.conf"

View File

@@ -35,3 +35,10 @@ if [ -f /etc/locale.conf ]; then
export LC_ALL
fi
# FIXME: fix systemd-vconsole-setup
#if [ -x /lib/systemd/systemd-vconsole-setup ]; then
# /lib/systemd/systemd-vconsole-setup
# rm -f /{etc,lib}/udev/rules.d/10-console.rules
# rm -f /lib/udev/console_init
# ln -s /lib/systemd/systemd-vconsole-setup /lib/udev/console_init
#fi

View File

@@ -11,14 +11,16 @@ depends() {
}
install() {
local _line
local _dracut_rpm_version
if [ -e "$moddir/dracut-version" ]; then
dracut_rpm_version=$(cat "$moddir/dracut-version")
inst "$moddir/dracut-version" /lib/dracut/$dracut_rpm_version
_dracut_rpm_version=$(cat "$moddir/dracut-version")
inst "$moddir/dracut-version" /lib/dracut/$_dracut_rpm_version
else
if rpm -qf $(type -P $0) &>/dev/null; then
dracut_rpm_version=$(rpm -qf --qf '%{name}-%{version}-%{release}\n' $(type -P $0) | { ver="";while read line;do ver=$line;done;echo $ver;} )
mkdir -m 0755 -p $initdir/lib $initdir/lib/dracut
echo $dracut_rpm_version > $initdir/lib/dracut/$dracut_rpm_version
_dracut_rpm_version=$(rpm -qf --qf '%{name}-%{version}-%{release}\n' $(type -P $0) | { ver="";while read _line;do ver=$_line;done;echo $ver;} )
mkdir -m 0755 -p $initdir/lib/dracut
echo $_dracut_rpm_version > $initdir/lib/dracut/$_dracut_rpm_version
fi
fi
inst_hook cmdline 01 "$moddir/version.sh"

View File

@@ -44,10 +44,10 @@ setup_interface() {
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
}
PATH=$PATH:/sbin:/usr/sbin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PS4="dhclient.$interface.$$ + "
exec >>/run/initramfs/initlog.pipe 2>>/run/initramfs/initlog.pipe
exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# We already need a set netif here
@@ -74,7 +74,7 @@ case $reason in
echo "$line"
done >/tmp/dhclient.$netif.dhcpopts
echo online > /sys/class/net/$netif/uevent
/sbin/initqueue --onetime --name netroot-$netif /sbin/netroot $netif
initqueue --onetime --name netroot-$netif netroot $netif
;;
*) echo "dhcp: $reason";;
esac

View File

@@ -21,5 +21,5 @@ if [ "$root" = "dhcp" ] || [ "$root" = "dhcp6" ] || [ "$netroot" = "dhcp" ] ; th
# Shut up init error check
[ -z "$root" ] && root="dhcp"
echo '[ -d $NEWROOT/proc -o -e /dev/root ]' > $hookdir/initqueue-finished/dhcp.sh
echo '[ -d $NEWROOT/proc -o -e /dev/root ]' > $hookdir/initqueue/finished/dhcp.sh
fi

View File

@@ -5,13 +5,13 @@
# We don't need to check for ip= errors here, that is handled by the
# cmdline parser script
#
PATH=$PATH:/sbin:/usr/sbin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# Run dhclient
do_dhcp() {
# /sbin/dhclient-script will mark the netif up and generate the online
# dhclient-script will mark the netif up and generate the online
# event for nfsroot
# XXX add -V vendor class and option parsing per kernel
echo "Starting dhcp for interface $netif"
@@ -50,7 +50,7 @@ do_ipv6auto() {
echo online > /sys/class/net/$netif/uevent
/sbin/initqueue --onetime --name netroot-$netif /sbin/netroot $netif
initqueue --onetime --name netroot-$netif netroot $netif
}
# Handle static ip configuration
@@ -77,13 +77,11 @@ do_static() {
fi >> /tmp/net.$netif.resolv.conf
echo online > /sys/class/net/$netif/uevent
/sbin/initqueue --onetime --name netroot-$netif /sbin/netroot $netif
initqueue --onetime --name netroot-$netif netroot $netif
}
PATH=$PATH:/sbin:/usr/sbin
export PS4="ifup.$1.$$ + "
exec >>/run/initramfs/initlog.pipe 2>>/run/initramfs/initlog.pipe
exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# Huh? No $1?
@@ -181,7 +179,7 @@ fi
# start bridge if necessary
if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
if [ "$ethname" = "$bondname" ] ; then
DO_BOND_SETUP=yes /sbin/ifup $bondname
DO_BOND_SETUP=yes ifup $bondname
else
ip link set $ethname up
fi

View File

@@ -3,11 +3,12 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _program
. $dracutfunctions
for program in ip arping dhclient ; do
if ! type -P $program >/dev/null; then
derror "Could not find program \"$program\" required by network."
for _program in ip arping dhclient ; do
if ! type -P $_program >/dev/null; then
derror "Could not find program \"$_program\" required by network."
return 1
fi
done
@@ -24,11 +25,11 @@ installkernel() {
# Include wired net drivers, excluding wireless
net_module_test() {
local net_drivers='eth_type_trans|register_virtio_device'
local unwanted_drivers='/(wireless|isdn|uwb)/'
egrep -q $net_drivers "$1" && \
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 ]]
[[ ! $1 =~ $_unwanted_drivers ]]
}
instmods $(filter_kernel_modules net_module_test)
@@ -42,6 +43,7 @@ installkernel() {
}
install() {
local _arch _i _dir
dracut_install ip arping tr dhclient
dracut_install -o brctl ifenslave
inst "$moddir/ifup" "/sbin/ifup"
@@ -57,12 +59,12 @@ install() {
inst_hook cmdline 99 "$moddir/parse-ifname.sh"
inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh"
arch=$(uname -m)
_arch=$(uname -m)
for dir in "$usrlibdir/tls/$arch" "$usrlibdir/tls" "$usrlibdir/$arch" \
for _dir in "$usrlibdir/tls/$_arch" "$usrlibdir/tls" "$usrlibdir/$_arch" \
"$usrlibdir" "$libdir"; do
for i in "$dir"/libnss_dns.so.* "$dir"/libnss_mdns4_minimal.so.*; do
[ -e "$i" ] && dracut_install "$i"
for _i in "$_dir"/libnss_dns.so.* "$_dir"/libnss_mdns4_minimal.so.*; do
[ -e "$_i" ] && dracut_install "$_i"
done
done

View File

@@ -40,12 +40,12 @@ fix_bootif() {
# If we have to handle multiple interfaces, handle only them.
elif [ -n "$IFACES" ] ; then
for iface in $IFACES ; do
printf 'ACTION=="add", SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
done
# Default: We don't know the interface to use, handle all
else
printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n'
printf 'SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n'
fi
} > /etc/udev/rules.d/60-net.rules

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
PATH=$PATH:/sbin:/usr/sbin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
@@ -65,7 +65,7 @@ fi
handler=${netroot%%:*}
handler=${handler%%4}
handler="/sbin/${handler}root"
handler=$(command -v ${handler}root)
if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
die "No handler for netroot type '$netroot'"
fi

View File

@@ -52,17 +52,26 @@ if [ -n "$NEEDBOOTDEV" ] ; then
fi
if [ "ibft" = "$(getarg ip=)" ]; then
modprobe ibft
modprobe iscsi_ibft
num=0
(
for iface in /sys/firmware/ibft/ethernet*; do
[ -e ${iface}/mac ] || continue
ifname_mac=$(read a < ${iface}/mac; echo $a)
[ -z "$ifname_mac" ] || continue
ifname_if=ibft$num
num=$(( $num + 1 ))
echo "ifname=$ifname_if:$ifname_mac"
dev=$ifname_if
[ -z "$ifname_mac" ] && continue
unset dev
for ifname in $(getargs ifname=); do
if strstr "$ifname" "$ifname_mac"; then
dev=${ifname%%:*}
break
fi
done
if [ -z "$dev" ]; then
ifname_if=ibft$num
num=$(( $num + 1 ))
echo "ifname=$ifname_if:$ifname_mac"
dev=$ifname_if
fi
dhcp=$(read a < ${iface}/dhcp; echo $a)
if [ -n "$dhcp" ]; then

View File

@@ -17,7 +17,7 @@ if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
fi
mkdir -p /tmp/ifcfg/
mkdir -m 0755 -p /tmp/ifcfg/
for netif in $IFACES ; do
# bridge?
@@ -42,7 +42,7 @@ for netif in $IFACES ; do
else
echo "BOOTPROTO=none"
# If we've booted with static ip= lines, the override file is there
. /tmp/net.$netif.override
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
echo "IPADDR=$ip"
echo "NETMASK=$mask"
[ -n "$gw" ] && echo "GATEWAY=$gw"
@@ -134,9 +134,11 @@ for netif in $IFACES ; do
done
# Pass network opts
mkdir -p /run/initramfs
[ -d /run/initramfs ] || mkdir -m 0755 -p /run/initramfs
cp /tmp/net.* /run/initramfs/ >/dev/null 2>&1
mkdir -p /run/initramfs/state/etc/sysconfig/network-scripts/
for i in /run/initramfs/state /run/initramfs/state/etc/ /run/initramfs/state/etc/sysconfig /run/initramfs/state/etc/sysconfig/network-scripts; do
[ -d $i ] || mkdir -m 0755 -p $i
done
cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/ >/dev/null 2>&1
echo "files /etc/sysconfig/network-scripts" > /run/initramfs/rwtab
cp -a /tmp/ifcfg/* /run/initramfs/state/etc/sysconfig/network-scripts/ >/dev/null 2>&1
cp -a -t /run/initramfs/state/etc/sysconfig/network-scripts/ /tmp/ifcfg/* >/dev/null 2>&1

View File

@@ -9,8 +9,9 @@ if getargbool 1 rd.splash -n rd_NO_SPLASH; then
info "Starting Gentoo Splash"
/lib/udev/console_init tty0
[ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0
CDROOT=0
. /lib/gensplash-lib.sh
splash init
[ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0
fi

View File

@@ -13,55 +13,57 @@ depends() {
}
install() {
local _opts
local _splash_theme
local _splash_res
call_splash_geninitramfs() {
local out ret
local _out _ret
out=$(splash_geninitramfs -c "$1" ${@:2} 2>&1)
ret=$?
_out=$(splash_geninitramfs -c "$1" ${@:2} 2>&1)
_ret=$?
if [[ ${out} ]]; then
if [[ ${_out} ]]; then
local IFS='
'
for line in ${out}; do
for line in ${_out}; do
if [[ ${line} =~ ^Warning ]]; then
dwarn "${line}"
else
derror "${line}"
(( ret == 0 )) && ret=1
(( $_ret == 0 )) && _ret=1
fi
done
fi
return ${ret}
return ${_ret}
}
type -P splash_geninitramfs >/dev/null || return 1
opts=''
_opts=''
if [[ ${DRACUT_GENSPLASH_THEME} ]]; then
# Variables from the environment
# They're supposed to be set up by e.g. Genkernel in basis of cmdline args.
# If user set them he/she would expect to be included only given theme
# rather then all even if we're building generic initramfs.
SPLASH_THEME=${DRACUT_GENSPLASH_THEME}
SPLASH_RES=${DRACUT_GENSPLASH_RES}
_splash_theme=${DRACUT_GENSPLASH_THEME}
_splash_res=${DRACUT_GENSPLASH_RES}
elif [[ ${hostonly} ]]; then
# Settings from config only in hostonly
[[ -e /etc/conf.d/splash ]] && source /etc/conf.d/splash
[[ ! ${SPLASH_THEME} ]] && SPLASH_THEME=default
[[ ${SPLASH_RES} ]] && opts+=" -r ${SPLASH_RES}"
[[ ! ${_splash_theme} ]] && _splash_theme=default
[[ ${_splash_res} ]] && _opts+=" -r ${_splash_res}"
else
# generic
SPLASH_THEME=--all
_splash_theme=--all
fi
dinfo "Installing Gentoo Splash (using the ${SPLASH_THEME} theme)"
dinfo "Installing Gentoo Splash (using the ${_splash_theme} theme)"
pushd "${initdir}" >/dev/null
mv dev dev.old
call_splash_geninitramfs "${initdir}" ${opts} ${SPLASH_THEME} || {
call_splash_geninitramfs "${initdir}" ${_opts} ${_splash_theme} || {
derror "Could not build splash"
return 1
}

View File

@@ -11,9 +11,10 @@ depends() {
}
installkernel() {
local _modname
# Include KMS capable drm drivers
for modname in $(find "$srcmods/kernel/drivers/gpu/drm" "$srcmods/extra" -name '*.ko' 2>/dev/null); do
grep -q drm_crtc_init $modname && instmods $modname
for _modname in $(find "$srcmods/kernel/drivers/gpu/drm" "$srcmods/extra" -name '*.ko' 2>/dev/null); do
grep -q drm_crtc_init $_modname && instmods $_modname
done
}

View File

@@ -9,7 +9,7 @@ dracut_install /bin/plymouth \
"${PLYMOUTH_LOGO_FILE}" \
/etc/system-release
mkdir -p "${initdir}/usr/share/plymouth"
mkdir -m 0755 -p "${initdir}/usr/share/plymouth"
if [[ $hostonly ]]; then
dracut_install "${usrlibdir}/plymouth/text.so" \
@@ -34,7 +34,7 @@ else
for x in /usr/share/plymouth/themes/{text,details}/* ; do
[[ -f "$x" ]] || continue
THEME_DIR=$(dirname "$x")
mkdir -p "${initdir}/$THEME_DIR"
mkdir -m 0755 -p "${initdir}/$THEME_DIR"
dracut_install "$x"
done
for x in "${usrlibdir}"/plymouth/{text,details}.so ; do

View File

@@ -17,8 +17,10 @@ if getargbool 1 rd.plymouth -n rd_NO_PLYMOUTH; then
[ -e /dev/fb ] || ln -s fb0 /dev/fb
info "Starting plymouth daemon"
[ -x /bin/plymouthd ] && /bin/plymouthd --attach-to-session
>/run/initramfs/plymouth
/lib/udev/console_init tty0
mkdir -m 0755 /run/plymouth
[ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0
[ -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
[ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0
fi

View File

@@ -23,11 +23,12 @@ depends() {
}
installkernel() {
for i in \
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
modinfo -k $kernel $_i >/dev/null 2>&1 && instmods $_i
done
}

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _rootdev
# if we don't have btrfs installed on the host system,
# no point in trying to support it in the initramfs.
type -P btrfs >/dev/null || return 1
@@ -13,9 +14,9 @@ check() {
is_btrfs() { get_fs_type /dev/block/$1 | grep -q btrfs; }
if [[ $hostonly ]]; then
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
is_btrfs "$rootdev" || return 1
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
is_btrfs "$_rootdev" || return 1
fi
fi

View File

@@ -2,7 +2,79 @@
# -*- 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
command -v getarg >/dev/null || . /lib/dracut-lib.sh
# ask_for_password
#
# Wraps around plymouth ask-for-password and adds fallback to tty password ask
# if plymouth is not present.
#
# --cmd command
# Command to execute. Required.
# --prompt prompt
# Password prompt. Note that function already adds ':' at the end.
# Recommended.
# --tries n
# How many times repeat command on its failure. Default is 3.
# --ply-[cmd|prompt|tries]
# Command/prompt/tries specific for plymouth password ask only.
# --tty-[cmd|prompt|tries]
# Command/prompt/tries specific for tty password ask only.
# --tty-echo-off
# Turn off input echo before tty command is executed and turn on after.
# It's useful when password is read from stdin.
ask_for_password() {
local cmd; local prompt; local tries=3
local ply_cmd; local ply_prompt; local ply_tries=3
local tty_cmd; local tty_prompt; local tty_tries=3
local ret
while [ $# -gt 0 ]; do
case "$1" in
--cmd) ply_cmd="$2"; tty_cmd="$2" shift;;
--ply-cmd) ply_cmd="$2"; shift;;
--tty-cmd) tty_cmd="$2"; shift;;
--prompt) ply_prompt="$2"; tty_prompt="$2" shift;;
--ply-prompt) ply_prompt="$2"; shift;;
--tty-prompt) tty_prompt="$2"; shift;;
--tries) ply_tries="$2"; tty_tries="$2"; shift;;
--ply-tries) ply_tries="$2"; shift;;
--tty-tries) tty_tries="$2"; shift;;
--tty-echo-off) tty_echo_off=yes;;
esac
shift
done
{ flock -s 9;
# Prompt for password with plymouth, if installed and running.
if [ -x /bin/plymouth ]; then
/bin/plymouth ask-for-password \
--prompt "$ply_prompt" --number-of-tries=$ply_tries \
--command="$ply_cmd"
ret=$?
else
if [ "$tty_echo_off" = yes ]; then
stty_orig="$(stty -g)"
stty -echo
fi
local i=1
while [ $i -le $tty_tries ]; do
[ -n "$tty_prompt" ] && \
printf "$tty_prompt [$i/$tty_tries]:" >&2
eval "$tty_cmd" && ret=0 && break
ret=$?
i=$(($i+1))
[ -n "$tty_prompt" ] && printf '\n' >&2
done
[ "$tty_echo_off" = yes ] && stty $stty_orig
fi
} 9>/.console_lock
[ $ret -ne 0 ] && echo "Wrong password" >&2
return $ret
}
# Try to mount specified device (by path, by UUID or by label) and check
# the path with 'test'.
@@ -118,3 +190,33 @@ getkey() {
return 1
}
# readkey keypath keydev device
#
# Mounts <keydev>, reads key from file <keypath>, optionally processes it (e.g.
# if encrypted with GPG) and prints to standard output which is supposed to be
# read by cryptsetup. <device> is just passed to helper function for
# informational purpose.
readkey() {
local keypath="$1"
local keydev="$2"
local device="$3"
local mntp=$(mkuniqdir /mnt keydev)
mount -r "$keydev" "$mntp" || die 'Mounting rem. dev. failed!'
case "${keypath##*.}" in
gpg)
if [ -f /lib/dracut-crypt-gpg-lib.sh ]; then
. /lib/dracut-crypt-gpg-lib.sh
gpg_decrypt "$mntp" "$keypath" "$keydev" "$device"
else
die "No GPG support to decrypt '$keypath' on '$keydev'."
fi
;;
*) cat "$mntp/$keypath" ;;
esac
umount "$mntp"
rmdir "$mntp"
}

View File

@@ -2,8 +2,11 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
NEWROOT=${NEWROOT:-"/sysroot"}
# do not ask, if we already have root
[ -f /sysroot/proc ] && exit 0
[ -f $NEWROOT/proc ] && exit 0
# check if destination already exists
[ -b /dev/mapper/$2 ] && exit 0
@@ -66,45 +69,25 @@ if [ -n "$(getarg rd.luks.key)" ]; then
keypath="${tmp#*:}"
else
info "No key found for $device. Will try later."
/sbin/initqueue --unique --onetime --settled \
initqueue --unique --onetime --settled \
--name cryptroot-ask-$luksname \
/sbin/cryptroot-ask "$@"
$(command -v cryptroot-ask) "$@"
exit 0
fi
unset tmp
mntp=$(mkuniqdir /mnt keydev)
mount -r "$keydev" "$mntp" || die 'Mounting rem. dev. failed!'
cryptsetup -d "$mntp/$keypath" luksOpen "$device" "$luksname"
umount "$mntp"
rmdir "$mntp"
unset mntp keypath keydev
info "Using '$keypath' on '$keydev'"
readkey "$keypath" "$keydev" "$device" \
| cryptsetup -d - luksOpen "$device" "$luksname"
unset keypath keydev
else
# Prompt for password with plymouth, if installed and running.
if [ -x /bin/plymouth ] && /bin/plymouth --has-active-vt; then
prompt="Password [$device ($luksname)]:"
if [ ${#luksname} -gt 8 ]; then
sluksname=${sluksname##luks-}
sluksname=${luksname%%${luksname##????????}}
prompt="Password for $device ($sluksname...)"
fi
# flock against other interactive activities
{ flock -s 9;
/bin/plymouth ask-for-password \
--prompt "$prompt" --number-of-tries=5 \
--command="/sbin/cryptsetup luksOpen -T1 $device $luksname"
} 9>/.console.lock
unset sluksname prompt
else
# flock against other interactive activities
{ flock -s 9;
echo "$device ($luksname) is password protected"
cryptsetup luksOpen -T5 $device $luksname
} 9>/.console.lock
fi
luks_open="$(command -v cryptsetup) luksOpen"
ask_for_password --ply-tries 5 \
--ply-cmd "$luks_open -T1 $device $luksname" \
--ply-prompt "Password ($device)" \
--tty-tries 1 \
--tty-cmd "$luks_open -T5 $device $luksname"
unset luks_open
fi
unset device luksname

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _rootdev
# if cryptsetup is not installed, then we cannot support encrypted devices.
type -P cryptsetup >/dev/null || return 1
@@ -11,11 +12,11 @@ check() {
is_crypt() { [[ $(get_fs_type /dev/block/$1) = crypto_LUKS ]]; }
[[ $hostonly ]] && {
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_crypt "$rootdev" || return 1
check_block_and_slaves is_crypt "$_rootdev" || return 1
else
# root is not on a block device, use the shotgun approach
blkid | grep -q crypto\?_LUKS || return 1
@@ -35,9 +36,7 @@ installkernel() {
}
install() {
inst cryptsetup
inst rmdir
inst readlink
dracut_install cryptsetup rmdir readlink umount
inst "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
inst "$moddir"/probe-keydev.sh /sbin/probe-keydev
inst_hook cmdline 10 "$moddir/parse-keydev.sh"

View File

@@ -8,7 +8,7 @@ else
{
echo 'SUBSYSTEM!="block", GOTO="luks_end"'
echo 'ACTION!="add|change", GOTO="luks_end"'
} > /etc/udev/rules.d/70-luks.rules
} > /etc/udev/rules.d/70-luks.rules.new
LUKS=$(getargs rd.luks.uuid rd_LUKS_UUID)
@@ -16,26 +16,28 @@ else
for luksid in $LUKS; do
luksid=${luksid##luks-}
{
printf 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
printf 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
printf 'RUN+="/sbin/initqueue --unique --onetime '
printf -- '--name cryptroot-ask-%%k /sbin/cryptroot-ask '
printf '$env{DEVNAME} luks-$env{ID_FS_UUID}"\n'
} >> /etc/udev/rules.d/70-luks.rules
printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
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'
} >> /etc/udev/rules.d/70-luks.rules.new
printf '[ -e /dev/disk/by-uuid/*%s* ] || exit 1\n' $luksid \
printf -- '[ -e /dev/disk/by-uuid/*%s* ]\n' $luksid \
>> $hookdir/initqueue/finished/90-crypt.sh
{
printf '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid
printf 'warn "crypto LUKS UUID "%s" not found"\n' $luksid
printf -- '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid
printf -- 'warn "crypto LUKS UUID "%s" not found"\n' $luksid
} >> $hookdir/emergency/90-crypt.sh
done
else
echo 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue' \
'--unique --onetime --name cryptroot-ask-%k' \
'/sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"' \
>> /etc/udev/rules.d/70-luks.rules
{
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)
} >> /etc/udev/rules.d/70-luks.rules.new
fi
echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules
echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules.new
mv /etc/udev/rules.d/70-luks.rules.new /etc/udev/rules.d/70-luks.rules
fi

View File

@@ -28,10 +28,10 @@ if getargbool 1 rd.luks -n rd_NO_LUKS && \
fi
{
printf 'RUN+="/sbin/initqueue --unique --onetime '
printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
printf -- '--name probe-keydev-%%k '
printf '/sbin/probe-keydev /dev/%%k %s %s"\n' \
"${keypath}" "${luksdev}"
printf -- '%s /dev/%%k %s %s"\n' \
$(command -v probe-keydev) "${keypath}" "${luksdev}"
} >&7
done
unset arg keypath keydev luksdev

View File

@@ -0,0 +1,5 @@
SUBSYSTEM!="block", GOTO="dm_end"
KERNEL!="dm-[0-9]*", GOTO="dm_end"
ACTION!="add|change", GOTO="dm_end"
OPTIONS+="db_persist"
LABEL="dm_end"

View File

@@ -0,0 +1,2 @@
echo "Disassembling device-mapper devices"
dmsetup -v remove_all

View File

@@ -25,5 +25,8 @@ install() {
# 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
inst_rules "$moddir/11-dm.rules"
inst_hook shutdown 30 "$moddir/dm-shutdown.sh"
}

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _rootdev
# if we don't have dmraid installed on the host system, no point
# in trying to support it in the initramfs.
type -P dmraid >/dev/null || return 1
@@ -14,11 +15,11 @@ check() {
grep -q _raid_member; }
[[ $hostonly ]] && {
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_dmraid "$rootdev" || return 1
check_block_and_slaves is_dmraid "$_rootdev" || return 1
else
# root is not on a block device, use the shotgun approach
dmraid -r | grep -q ok || return 1
@@ -34,12 +35,13 @@ depends() {
}
install() {
local _i
dracut_install dmraid partx kpartx
inst dmeventd
for i in {"$libdir","$usrlibdir"}/libdmraid-events*.so; do
[ -e "$i" ] && dracut_install "$i"
for _i in {"$libdir","$usrlibdir"}/libdmraid-events*.so; do
[ -e "$_i" ] && dracut_install "$_i"
done
inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules

View File

@@ -7,7 +7,7 @@ if ! getargbool 1 rd.dm -n rd_NO_DM || getarg nodmraid; then
udevproperty rd_NO_DM=1
fi
if [ ! -x /sbin/mdadm ] || ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM || getarg noiswmd; then
if ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM || getarg noiswmd; then
info "rd.md.imsm=0: no MD RAID for imsm/isw raids"
udevproperty rd_NO_MDIMSM=1
fi

View File

@@ -8,7 +8,7 @@ case "$root" in
${root#live:/dev/}
printf 'SYMLINK=="%s", SYMLINK+="live"\n' \
${root#live:/dev/}
} >> /dev/.udev/rules.d/99-live-mount.rules
} >> $UDEVRULESD/99-live-mount.rules
{
printf 'KERNEL=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root $env{DEVNAME}"\n' \
${root#live:/dev/}

View File

@@ -5,7 +5,7 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
[ -f /tmp/root.info ] && . /tmp/root.info
PATH=$PATH:/sbin:/usr/sbin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
if getargbool 0 rd.live.debug -y rdlivedebug; then
exec > /tmp/liveroot.$$.out
@@ -25,25 +25,26 @@ getargbool 0 rd.live.overlay.reset -y reset_overlay && reset_overlay="yes"
getargbool 0 rd.live.overlay.readonly -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
overlay=$(getarg rd.live.overlay overlay)
# FIXME: we need to be able to hide the plymouth splash for the check really
[ -e $livedev ] && fs=$(blkid -s TYPE -o value $livedev)
if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
check="yes"
fi
getarg rd.live.check check || check=""
if [ -n "$check" ]; then
[ -x /bin/plymouth ] && /bin/plymouth --hide-splash
checkisomd5 --verbose $livedev || :
if [ $? -ne 0 ]; then
die "CD check failed!"
exit 1
fi
[ -x /bin/plymouth ] && /bin/plymouth --show-splash
fi
getarg ro && liverw=ro
getarg rw && liverw=rw
[ -z "$liverw" ] && liverw=ro
# mount the backing of the live image first
mkdir -p /run/initramfs/live
mkdir -m 0755 -p /run/initramfs/live
if [ -f $livedev ]; then
# no mount needed - we've already got the LiveOS image in initramfs
case $livedev in
@@ -84,16 +85,16 @@ do_live_overlay() {
# need to know where to look for the overlay
setup=""
if [ -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then
mkdir /overlayfs
mount -n -t auto $devspec /overlayfs || :
if [ -f /overlayfs$pathspec -a -w /overlayfs$pathspec ]; then
losetup $OVERLAY_LOOPDEV /overlayfs$pathspec
mkdir -m 0755 /run/initramfs/overlayfs
mount -n -t auto $devspec /run/initramfs/overlayfs || :
if [ -f /run/initramfs/overlayfs$pathspec -a -w /run/initramfs/overlayfs$pathspec ]; then
losetup $OVERLAY_LOOPDEV /run/initramfs/overlayfs$pathspec
if [ -n "$reset_overlay" ]; then
dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1 2>/dev/null
fi
setup="yes"
fi
umount -l /overlayfs || :
umount -l /run/initramfs/overlayfs || :
fi
if [ -z "$setup" ]; then
@@ -125,11 +126,11 @@ if [ -n "$OSMINSQFS" ]; then
dd if=$OSMINSQFS of=/osmin.img 2> /dev/null
OSMIN_SQUASHED_LOOPDEV=$( losetup -f )
losetup -r $OSMIN_SQUASHED_LOOPDEV /osmin.img
mkdir -p /squashfs.osmin
mount -n -t squashfs -o ro $OSMIN_SQUASHED_LOOPDEV /squashfs.osmin
mkdir -m 0755 -p /run/initramfs/squashfs.osmin
mount -n -t squashfs -o ro $OSMIN_SQUASHED_LOOPDEV /run/initramfs/squashfs.osmin
OSMIN_LOOPDEV=$( losetup -f )
losetup -r $OSMIN_LOOPDEV /squashfs.osmin/osmin
umount -l /squashfs.osmin
losetup -r $OSMIN_LOOPDEV /run/initramfs/squashfs.osmin/osmin
umount -l /run/initramfs/squashfs.osmin
fi
# we might have an embedded fs image to use as rootfs (uncompressed live)
@@ -164,17 +165,17 @@ if [ -e "$SQUASHED" ] ; then
SQUASHED_LOOPDEV=$( losetup -f )
losetup -r $SQUASHED_LOOPDEV $SQUASHED
mkdir -p /squashfs
mount -n -t squashfs -o ro $SQUASHED_LOOPDEV /squashfs
mkdir -m 0755 -p /run/initramfs/squashfs
mount -n -t squashfs -o ro $SQUASHED_LOOPDEV /run/initramfs/squashfs
BASE_LOOPDEV=$( losetup -f )
if [ -f /squashfs/LiveOS/ext3fs.img ]; then
losetup -r $BASE_LOOPDEV /squashfs/LiveOS/ext3fs.img
elif [ -f /squashfs/LiveOS/rootfs.img ]; then
losetup -r $BASE_LOOPDEV /squashfs/LiveOS/rootfs.img
if [ -f /run/initramfs/squashfs/LiveOS/ext3fs.img ]; then
losetup -r $BASE_LOOPDEV /run/initramfs/squashfs/LiveOS/ext3fs.img
elif [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then
losetup -r $BASE_LOOPDEV /run/initramfs/squashfs/LiveOS/rootfs.img
fi
umount -l /squashfs
umount -l /run/initramfs/squashfs
do_live_from_base_loop
fi

View File

@@ -27,12 +27,7 @@ install() {
inst losetup
inst grep
# eject might be a symlink to consolehelper
if [ -L /usr/bin/eject ]; then
dracut_install /usr/sbin/eject
else
inst eject
fi
dracut_install eject
inst blockdev
type -P checkisomd5 >/dev/null && inst checkisomd5

View File

@@ -2,11 +2,13 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
for p in $(getargs rd.driver.post rdinsmodpost=); do
. /lib/dracut-lib.sh
for modlist in $(getargs rd.driver.post rdinsmodpost=); do
(
IFS=,
for p in $i; do
modprobe $p
for m in $modlist; do
modprobe $m
done
)
done

View File

@@ -42,9 +42,19 @@ installkernel() {
}
install() {
local _f
[ -f /etc/modprobe.conf ] && dracut_install /etc/modprobe.conf
dracut_install $(find /etc/modprobe.d/ -type f -name '*.conf')
inst_hook cmdline 01 "$moddir/parse-kernel.sh"
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
inst "$srcmods/modules.builtin.bin" "/lib/modules/$kernel/modules.builtin.bin"
local f
for _f in modules.builtin.bin modules.builtin; do
[[ $srcmods/$_f ]] && inst "$srcmods/$_f" "/lib/modules/$kernel/$_f" \
&& break
done || {
dfatal "No modules.builtin.bin and modules.builtin found!"
return 1
}
}

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
for p in $(getargs rd.driver.pre rdloaddriver=); do
for i in $(getargs rd.driver.pre rdloaddriver=); do
(
IFS=,
for p in $i; do
@@ -11,7 +11,7 @@ for p in $(getargs rd.driver.pre rdloaddriver=); do
)
done
for p in $(getargs rd.driver.blacklist rdblacklist=); do
for i in $(getargs rd.driver.blacklist rdblacklist=); do
(
IFS=,
for p in $i; do
@@ -25,5 +25,5 @@ for p in $(getargs rd.driver.post rdinsmodpost=); do
_do_insmodpost=1
done
[ -n "$_do_insmodpost" ] && /sbin/initqueue --settled --unique --onetime /sbin/insmodpost.sh
[ -n "$_do_insmodpost" ] && initqueue --settled --unique --onetime insmodpost.sh
unset _do_insmodpost

View File

@@ -11,7 +11,7 @@ LVS=$(getargs rd.lvm.lv rd_LVM_LV=)
SNAPSHOT=$(getargs rd.lvm.snapshot rd_LVM_SNAPSHOT=)
SNAPSIZE=$(getargs rd.lvm.snapsize rd_LVM_SNAPSIZE=)
[ -d /etc/lvm ] || mkdir -p /etc/lvm
[ -d /etc/lvm ] || mkdir -m 0755 -p /etc/lvm
# build a list of devices to scan
lvmdevs=$(
for f in /tmp/.lvm_scan-*; do
@@ -120,7 +120,5 @@ fi
if [ "$lvmwritten" ]; then
rm -f /etc/lvm/lvm.conf
ln -s /sbin/lvm-cleanup $hookdir/pre-pivot/30-lvm-cleanup.sh 2>/dev/null
ln -s /sbin/lvm-cleanup $hookdir/pre-pivot/31-lvm-cleanup.sh 2>/dev/null
fi
unset lvmwritten

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _rootdev
# No point trying to support lvm if the binaries are missing
type -P lvm >/dev/null || return 1
@@ -12,11 +13,11 @@ check() {
is_lvm() { [[ $(get_fs_type /dev/block/$1) = LVM2_member ]]; }
[[ $hostonly ]] && {
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_lvm "$rootdev" || return 1
check_block_and_slaves is_lvm "$_rootdev" || return 1
else
# root is not on a block device, use the shotgun approach
blkid | grep -q LVM2_member || return 1
@@ -33,6 +34,7 @@ depends() {
}
install() {
local _i
inst lvm
inst_rules "$moddir/64-lvm.rules"
@@ -54,8 +56,8 @@ install() {
inst "$moddir/lvm_scan.sh" /sbin/lvm_scan
inst_hook cmdline 30 "$moddir/parse-lvm.sh"
for i in {"$libdir","$usrlibdir"}/libdevmapper-event-lvm*.so; do
[ -e "$i" ] && dracut_install "$i"
for _i in {"$libdir","$usrlibdir"}/libdevmapper-event-lvm*.so; do
[ -e "$_i" ] && dracut_install "$_i"
done
}

View File

@@ -10,7 +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" ] || exit 1\n' $dev \
printf '[ -e "/dev/%s" ]\n' $dev \
>> $hookdir/initqueue/finished/lvm.sh
{
printf '[ -e "/dev/%s" ] || ' $dev

View File

@@ -0,0 +1,2 @@
echo "Disassembling mdraid devices."
mdadm -v --stop --scan

View File

@@ -4,4 +4,4 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
info "Autoassembling MD Raid"
/sbin/mdadm -As --auto=yes --run 2>&1 | vinfo
mdadm -As --auto=yes --run 2>&1 | vinfo

View File

@@ -7,6 +7,6 @@ md=$1
udevadm control --stop-exec-queue
# and activate any containers
mdadm -IR $md 2>&1 | vinfo
ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null
ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
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,5 +2,5 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# save state dir for mdmon/mdadm for the real root
mkdir -m 0755 /run/mdadm
[ -d /run/mdadm ] || mkdir -m 0755 /run/mdadm
# backward compat link

View File

@@ -21,6 +21,6 @@ for md in /dev/md[0-9]* /dev/md/*; do
done
unset udevinfo
ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null
ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
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

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _rootdev
# No mdadm? No mdraid support.
type -P mdadm >/dev/null || return 1
@@ -12,11 +13,11 @@ check() {
is_mdraid() { [[ -d "/sys/dev/block/$1/md" ]]; }
[[ $hostonly ]] && {
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_mdraid "$rootdev" || return 1
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
@@ -76,5 +77,6 @@ install() {
inst "$moddir/md_finished.sh" /sbin/md_finished.sh
inst_hook pre-trigger 30 "$moddir/parse-md.sh"
inst "$moddir/mdraid-cleanup.sh" /sbin/mdraid-cleanup
inst_hook shutdown 30 "$moddir/md-shutdown.sh"
}

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _rootdev
# if there's no multipath binary, no go.
type -P multipath >/dev/null || return 1
@@ -16,9 +17,9 @@ check() {
}
if [[ $hostonly ]]; then
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
check_block_and_slaves is_mpath "$rootdev" && return 0
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
check_block_and_slaves is_mpath "$_rootdev" && return 0
fi
return 1
fi
@@ -41,7 +42,8 @@ installkernel() {
}
install() {
for f in \
local _f
for _f in \
/sbin/dmsetup \
/sbin/kpartx \
/sbin/mpath_wait \
@@ -53,7 +55,7 @@ install() {
/etc/multipath.conf \
/etc/multipath/* \
"$libdir"/libmultipath* "$libdir"/multipath/*; do
[ -e "$f" ] && inst "$f"
[ -e "$_f" ] && inst "$_f"
done
inst_hook pre-trigger 02 "$moddir/multipathd.sh"

View File

@@ -0,0 +1,33 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=4 sw=4 sts=0 et filetype=sh
command -v ask_for_password >/dev/null || . /lib/dracut-crypt-lib.sh
# gpg_decrypt mnt_point keypath keydev device
#
# Decrypts encrypted symmetrically key to standard output.
#
# mnt_point - mount point where <keydev> is already mounted
# keypath - GPG encrypted key path relative to <mnt_point>
# keydev - device on which key resides; only to display in prompt
# device - device to be opened by cryptsetup; only to display in prompt
gpg_decrypt() {
local mntp="$1"
local keypath="$2"
local keydev="$3"
local device="$4"
local gpghome=/tmp/gnupg
local opts="--homedir $gpghome --no-mdc-warning --skip-verify --quiet"
opts="$opts --logger-file /dev/null --batch --no-tty --passphrase-fd 0"
mkdir -m 0700 -p "$gpghome"
ask_for_password \
--cmd "gpg $opts --decrypt $mntp/$keypath" \
--prompt "Password ($keypath on $keydev for $device)" \
--tries 3 --tty-echo-off
rm -rf -- "$gpghome"
}

View File

@@ -0,0 +1,19 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# GPG support is optional
check() {
type -P gpg >/dev/null || return 1
return 255
}
depends() {
echo crypt
}
install() {
dracut_install gpg
inst "$moddir/crypt-gpg-lib.sh" "/lib/dracut-crypt-gpg-lib.sh"
}

View File

@@ -3,8 +3,8 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
arch=$(uname -m)
[ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
local _arch=$(uname -m)
[ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
return 0
}

View File

@@ -3,8 +3,8 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
arch=$(uname -m)
[ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
local _arch=$(uname -m)
[ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
return 0
}

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[ -d /etc/modprobe.d ] || mkdir /etc/modprobe.d
[ -d /etc/modprobe.d ] || mkdir -m 0755 -p /etc/modprobe.d
dasd_arg=$(getarg rd.dasd_mod.dasd rd_DASD_MOD=)
if [ -n "$dasd_arg" ]; then

25
modules.d/95fcoe/fcoe-edd.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
dcb=$1
if ! [ -d /sys/firmware/edd ]; then
modprobe edd
while ! [ -d /sys/firmware/edd ]; do sleep 0.1; done
fi
for disk in /sys/firmware/edd/int13_*; do
[ -d $disk ] || continue
for nic in ${disk}/pci_dev/net/*; do
[ -d $nic ] || continue
if [ -e ${nic}/address ]; then
fcoe_interface=${nic##*/}
if ! [ -e "/tmp/.fcoe-$fcoe_interface" ]; then
/sbin/fcoe-up $fcoe_interface $dcb
> "/tmp/.fcoe-$fcoe_interface"
fi
fi
done
done
modprobe -r edd

View File

@@ -3,24 +3,24 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
#
# We get called like this:
# /sbin/fcoe-up <network-device> <dcb|nodcb>
# fcoe-up <network-device> <dcb|nodcb>
#
# Note currently only nodcb is supported, the dcb option is reserved for
# future use.
PATH=$PATH:/sbin:/usr/sbin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# Huh? Missing arguments ??
[ -z "$1" -o -z "$2" ] && exit 1
export PS4="fcoe-up.$1.$$ + "
exec >>/run/initramfs/initlog.pipe 2>>/run/initramfs/initlog.pipe
exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
netif=$1
dcb=$2
/sbin/ip link set "$netif" up
ip link set "$netif" up
wait_for_if_up "$netif"
if [ "$dcb" = "dcb" ]; then

View File

@@ -26,11 +26,11 @@ install() {
inst fipvlan
inst lldpad
mkdir -p "$initdir/var/lib/lldpad"
mkdir -m 0755 -p "$initdir/var/lib/lldpad"
inst "$moddir/fcoe-up" "/sbin/fcoe-up"
inst "$moddir/fcoe-edd.sh" "/sbin/fcoe-edd"
inst "$moddir/fcoe-genrules.sh" "/sbin/fcoe-genrules.sh"
inst_hook pre-udev 60 "$moddir/fcoe-genrules.sh"
inst_hook cmdline 99 "$moddir/parse-fcoe.sh"
}

View File

@@ -51,20 +51,7 @@ if [ "$fcoe_interface" = "edd" ]; then
if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ] ; then
warn "Invalid FCoE DCB option: $fcoe_dcb"
fi
[ -d /sys/firmware/edd ] || modprobe edd
# parse edd interfaces
for disk in /sys/firmware/edd/int13_*; do
[ -d $disk ] || continue
for nic in ${disk}/pci_dev/net/*; do
[ -d $nic ] || continue
if [ -e ${nic}/address ]; then
unset fcoe_mac
unset fcoe_interface
fcoe_mac=$(cat ${nic}/address)
[ -n "$fcoe_mac" ] && source /sbin/fcoe-genrules.sh
fi
done
done
/sbin/initqueue --settled --unique /sbin/fcoe-edd $fcoe_dcb
else
for fcoe in $(getargs fcoe=); do
unset fcoe_mac
@@ -73,6 +60,6 @@ else
if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ] ; then
warn "Invalid FCoE DCB option: $fcoe_dcb"
fi
source /sbin/fcoe-genrules.sh
. $(command -v fcoe-genrules.sh)
done
fi

View File

@@ -12,5 +12,7 @@ depends() {
install() {
dracut_install /etc/fstab.sys
dracut_install /sbin/fsck*
type -P e2fsck >/dev/null && dracut_install e2fsck
inst_hook pre-pivot 00 "$moddir/mount-sys.sh"
}

View File

@@ -2,14 +2,25 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
fstab_mount(){
local dev mp type opts rest
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
fstab_mount() {
local _dev _mp _fs _opts _dump _pass _rest
test -e "$1" || return 1
info "Mounting from $1"
while read dev mp type opts rest; do
[ -z "${dev%%#*}" ]&& continue # Skip comment lines
mount -v -t $type -o $opts $dev $NEWROOT/$mp
done < $1 | vinfo
while read _dev _mp _fs _opts _dump _pass _rest; do
[ -z "${_dev%%#*}" ] && continue # Skip comment lines
if [ ! -e "$_dev" ]; then
warn "Device $_dev doesn't exist, skipping mount."
continue
fi
if [ "$_pass" -gt 0 ] && ! strstr "$_opts" _netdev; then
wrap_fsck "$_dev"
fi
_fs=$(det_fs "$_dev" "$_fs" /etc/fstab.sys)
info "Mounting $_dev"
mount -v -t $_fs -o $_opts $_dev $NEWROOT/$_mp 2>&1 | vinfo
done < $1
return 0
}

View File

@@ -10,7 +10,7 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
PATH=$PATH:/sbin:/usr/sbin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# Huh? Empty $1?
[ -z "$1" ] && exit 1

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _rootdev
# If our prerequisites are not met, fail anyways.
type -P iscsistart hostname iscsi-iname >/dev/null || return 1
@@ -23,11 +24,11 @@ check() {
)
[[ $hostonly ]] && {
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_iscsi "$rootdev" || return 1
check_block_and_slaves is_iscsi "$_rootdev" || return 1
else
return 1
fi
@@ -40,7 +41,12 @@ depends() {
}
installkernel() {
instmods iscsi_tcp crc32c iscsi_ibft
instmods iscsi_tcp iscsi_ibft crc32c
iscsi_module_test() {
local _iscsifuncs='iscsi_register_transport'
fgrep -q "$_iscsifuncs" "$1"
}
instmods $(filter_kernel_modules iscsi_module_test)
}
install() {

View File

@@ -8,7 +8,7 @@ NEWROOT=${NEWROOT:-"/sysroot"}
for disk in /dev/disk/by-path/*-iscsi-*-$iscsi_lun; do
if mount -t ${fstype:-auto} -o "$rflags" $disk $NEWROOT; then
if [ ! -d /sysroot/proc ]; then
if [ ! -d $NEWROOT/proc ]; then
umount $disk
continue
fi

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _rootdev
# If our prerequisites are not met, fail.
type -P nbd-client >/dev/null || return 1
@@ -12,9 +13,9 @@ check() {
is_nbd() { [[ -b /dev/block/$1 && $1 == 43:* ]] ;}
. $dracutfunctions
rootdev=$(find_root_block_device)
[[ -b /dev/block/$rootdev ]] || return 1
check_block_and_slaves is_nbd "$rootdev" || return 1
_rootdev=$(find_root_block_device)
[[ -b /dev/block/$_rootdev ]] || return 1
check_block_and_slaves is_nbd "$_rootdev" || return 1
}
return 0

View File

@@ -4,7 +4,7 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
PATH=$PATH:/sbin:/usr/sbin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# Huh? Empty $1?
[ -z "$1" ] && exit 1

View File

@@ -23,6 +23,8 @@ installkernel() {
}
install() {
local _i
local _nsslibs
type -P portmap >/dev/null && dracut_install portmap
type -P rpcbind >/dev/null && dracut_install rpcbind
@@ -33,25 +35,25 @@ install() {
dracut_install rpc.idmapd /etc/idmapd.conf
dracut_install sed
for i in {"$libdir","$usrlibdir"}/libnfsidmap_nsswitch.so* \
for _i in {"$libdir","$usrlibdir"}/libnfsidmap_nsswitch.so* \
{"$libdir","$usrlibdir"}/libnfsidmap/*.so \
{"$libdir","$usrlibdir"}/libnfsidmap*.so*; do
[ -e "$i" ] && dracut_install "$i"
[ -e "$_i" ] && dracut_install "$_i"
done
nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
nsslibs=${nsslibs#|}
nsslibs=${nsslibs%|}
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
dracut_install $(for i in $(ls {/usr,}$libdir/libnss*.so 2>/dev/null); do echo $i;done | egrep "$nsslibs")
dracut_install $(for _i in $(ls {/usr,}$libdir/libnss*.so 2>/dev/null); do echo $_i;done | egrep "$_nsslibs")
inst_hook cmdline 90 "$moddir/parse-nfsroot.sh"
inst_hook pre-pivot 99 "$moddir/nfsroot-cleanup.sh"
inst "$moddir/nfsroot" "/sbin/nfsroot"
mkdir -p "$initdir/var/lib/nfs/rpc_pipefs"
mkdir -p "$initdir/var/lib/rpcbind"
mkdir -p "$initdir/var/lib/nfs/statd/sm"
mkdir -m 0755 -p "$initdir/var/lib/nfs/rpc_pipefs"
mkdir -m 0755 -p "$initdir/var/lib/rpcbind"
mkdir -m 0755 -p "$initdir/var/lib/nfs/statd/sm"
# Rather than copy the passwd file in, just set a user for rpcbind
# We'll save the state and restart the daemon from the root anyway
@@ -61,9 +63,11 @@ install() {
egrep '^rpc:' /etc/passwd >> "$initdir/etc/passwd"
egrep '^rpcuser:' /etc/passwd >> "$initdir/etc/passwd"
#type -P nologin >/dev/null && dracut_install nologin
egrep '^rpc:' /etc/group >> "$initdir/etc/group"
# rpc user needs to be able to write to this directory to save the warmstart
# file
chmod 777 "$initdir/var/lib/rpcbind"
chmod 770 "$initdir/var/lib/rpcbind"
chown rpc.rpc "$initdir/var/lib/rpcbind"
}

View File

@@ -4,7 +4,7 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
PATH=$PATH:/sbin:/usr/sbin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# Huh? Empty $1?
[ -z "$1" ] && exit 1
@@ -86,10 +86,13 @@ options=${options:+$options,}$nfsrw
# Start rpcbind or rpcbind
# FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why?
[ -x /sbin/portmap ] && [ -z "$(pidof portmap)" ] && portmap
[ -x /sbin/rpcbind ] && [ -z "$(pidof rpcbind)" ] && rpcbind
command -v portmap >/dev/null && [ -z "$(pidof portmap)" ] && portmap
command -v rpcbind >/dev/null && [ -z "$(pidof rpcbind)" ] && rpcbind
if [ "$nfs" = "nfs4" ]; then
[ ! -d /var/lib/nfs/rpc_pipefs/nfs ] && \
mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
# Start rpc.statd as mount won't let us use locks on a NFSv4
# filesystem without talking to it. NFSv4 does locks internally,
# rpc.lockd isn't needed

View File

@@ -16,7 +16,8 @@ pid=$(pidof rpcbind)
if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then
# try to create the destination directory
[ -d $NEWROOT/$rpcpipefspath ] || mkdir -p $NEWROOT/$rpcpipefspath 2>/dev/null
[ -d $NEWROOT/$rpcpipefspath ] || \
mkdir -m 0755 -p $NEWROOT/$rpcpipefspath 2>/dev/null
if [ -d $NEWROOT/$rpcpipefspath ]; then
mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/$rpcpipefspath

View File

@@ -3,11 +3,12 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
install() {
local _bin
# Optional uswsusp support
for bin in /usr/sbin/resume /usr/lib/suspend/resume
for _bin in /usr/sbin/resume /usr/lib/suspend/resume
do
[[ -x "${bin}" ]] && {
inst "${bin}" /usr/sbin/resume
[[ -x "${_bin}" ]] && {
inst "${_bin}" /usr/sbin/resume
[[ -f /etc/suspend.conf ]] && inst /etc/suspend.conf
break
}

View File

@@ -2,6 +2,8 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
[ -s /.resume -a -b "$resume" ] && {
# First try user level resume; it offers splash etc
case "$splash" in
@@ -12,7 +14,7 @@
a_splash="-P splash=n"
;;
esac
[ -x /usr/sbin/resume ] && /usr/sbin/resume $a_splash "$resume"
[ -x $(command -v resume) ] && command resume $a_splash "$resume"
# parsing the output of ls is Bad, but until there is a better way...
ls -lH "$resume" | (

View File

@@ -11,7 +11,7 @@ if [ "${root%%:*}" = "block" ]; then
} >> $UDEVRULESD/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
"${root#block:}" "${root#block:}" > $hookdir/initqueue/settled/blocksymlink.sh
echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/block.sh
fi

View File

@@ -26,8 +26,10 @@ filter_rootopts() {
}
if [ -n "$root" -a -z "${root%%block:*}" ]; then
mount -t ${fstype:-auto} -o "$rflags",ro "${root#block:}" "$NEWROOT" \
&& ROOTFS_MOUNTED=yes
# sanity - determine/fix fstype
rootfs=$(det_fs "${root#block:}" "$fstype" "cmdline")
mount -t ${rootfs} -o "$rflags",ro "${root#block:}" "$NEWROOT"
READONLY=
fsckoptions=
@@ -67,11 +69,10 @@ if [ -n "$root" -a -z "${root%%block:*}" ]; then
fsckoptions="$AUTOFSCK_OPT $fsckoptions"
fi
if ! strstr " $fsckoptions" " -y"; then
if ! strstr " $fsckoptions" " -y" && strstr "$rootfs" ext; then
fsckoptions="-a $fsckoptions"
fi
rootfs=${fstype:-auto}
rootopts=
if getargbool 1 rd.fstab -n rd_NO_FSTAB \
&& ! getarg rootflags \
@@ -86,7 +87,8 @@ if [ -n "$root" -a -z "${root%%block:*}" ]; then
[ "${dev%%#*}" != "$dev" ] && continue
if [ "$mp" = "/" ]; then
rootfs=$fs
# sanity - determine/fix fstype
rootfs=$(det_fs "${root#block:}" "$fs" "$NEWROOT/etc/fstab")
rootopts=$opts
break
fi
@@ -96,41 +98,14 @@ if [ -n "$root" -a -z "${root%%block:*}" ]; then
fi
umount "$NEWROOT"
if [ "$rootfs" = "auto" ]; then
rootfs=$(udevadm info --query=env --name=${root#block:} | \
while read line; do
if strstr $line ID_FS_TYPE; then
eval $line
echo $ID_FS_TYPE
break
fi
done)
rootfs=${rootfs:-auto}
fi
# backslashes are treated as escape character in fstab
esc_root=$(echo ${root#block:} | sed 's,\\,\\\\,g')
printf '%s %s %s %s,%s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" "$rootopts" > /etc/fstab
if [ -z "$fastboot" -a "$READONLY" != "yes" ]; then
info "Checking filesystems"
info fsck -T -t noopts=_netdev -A $fsckoptions
out=$(fsck -T -t noopts=_netdev -A $fsckoptions)
export RD_ROOTFS_FSCK=$?
echo $RD_ROOTFS_FSCK > /run/initramfs/root-fsck
# A return of 4 or higher means there were serious problems.
if [ $RD_ROOTFS_FSCK -gt 3 ]; then
warn $out
warn "fsck returned with error code $RD_ROOTFS_FSCK"
warn "*** An error occurred during the file system check."
warn "*** Dropping you to a shell; the system will retry"
warn "*** to mount the system, when you leave the shell."
emergency_shell -n "(Repair filesystem)"
else
echo $out|vinfo
[ $RD_ROOTFS_FSCK -gt 0 ] && warn "fsck returned with $RD_ROOTFS_FSCK"
fi
if [ -x "/sbin/fsck.$rootfs" -a -z "$fastboot" -a "$READONLY" != "yes" ] && ! strstr "${rflags},${rootopts}" _netdev; then
wrap_fsck "${root#block:}" "$fsckoptions"
echo $? >/run/initramfs/root-fsck
fi
info "Remounting ${root#block:} with -o ${rflags},${rootopts}"

View File

@@ -3,12 +3,13 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
install() {
local _terminfodir
# terminfo bits make things work better if you fall into interactive mode
for TERMINFODIR in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -d ${TERMINFODIR} ] && break
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -d ${_terminfodir} ] && break
done
[ -d ${TERMINFODIR} ] && \
dracut_install $(find ${TERMINFODIR} -type f)
[ -d ${_terminfodir} ] && \
dracut_install $(find ${_terminfodir} -type f)
}

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
install() {
local _i
# 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
@@ -21,6 +22,10 @@ install() {
inst_rules 50-firmware.rules
dracut_install cat uname
inst_dir /run/udev
inst_dir /run/udev/rules.d
if [ ! -x /lib/udev/vol_id ]; then
dracut_install blkid
inst_rules "$moddir/59-persistent-storage.rules"
@@ -29,7 +34,7 @@ install() {
fi
inst_rules "$moddir/61-persistent-storage.rules"
for i in \
for _i in \
ata_id \
cdrom_id \
create_floppy_devices \
@@ -47,14 +52,14 @@ install() {
pcmcia-socket-startup \
pcmcia-check-broken-cis \
; do
[ -e /lib/udev/$i ] && dracut_install /lib/udev/$i
[ -e /lib/udev/$_i ] && dracut_install /lib/udev/$_i
done
[ -f /etc/arch-release ] && \
inst "$moddir/load-modules.sh" /lib/udev/load-modules.sh
for i in {"$libdir","$usrlibdir"}/libnss_files*; do
[ -e "$i" ] && dracut_install "$i"
for _i in {"$libdir","$usrlibdir"}/libnss_files*; do
[ -e "$_i" ] && dracut_install "$_i"
done
}

View File

@@ -21,7 +21,7 @@
# echo 0x5022000000000000 > /sys/bus/ccw/drivers/zfcp/0.0.4000/0x5005076300c213e9/unit_add
CONFIG=/etc/zfcp.conf
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
if [ -f "$CONFIG" ]; then
if [ ! -d /sys/bus/ccw/drivers/zfcp ]; then

View File

@@ -27,11 +27,11 @@ rd_load_policy()
# load_policy does mount /proc and /selinux in
# libselinux,selinux_init_load_policy()
if [ -x "$NEWROOT/sbin/load_policy" ]; then
out=$(chroot "$NEWROOT" /sbin/load_policy -i 2>&1)
out=$(LANG=C chroot "$NEWROOT" /sbin/load_policy -i 2>&1)
ret=$?
info $out
else
out=$(chroot "$NEWROOT" /usr/sbin/load_policy -i 2>&1)
out=$(LANG=C chroot "$NEWROOT" /usr/sbin/load_policy -i 2>&1)
ret=$?
info $out
fi
@@ -44,7 +44,7 @@ rd_load_policy()
# If machine requires a relabel, force to permissive mode
[ -e "$NEWROOT"/.autorelabel ] && ( echo 0 > "$NEWROOT"/selinux/enforce )
mount --bind /dev "$NEWROOT/dev"
chroot "$NEWROOT" /sbin/restorecon -R /dev
LANG=C chroot "$NEWROOT" /sbin/restorecon -R /dev
return 0
fi

View File

@@ -12,30 +12,32 @@ depends() {
}
install() {
local _i
local _installs
if type -P rsyslogd >/dev/null; then
installs="rsyslogd"
for i in {"$libdir","$usrlibdir"}/rsyslog/lmnet.so \
_installs="rsyslogd"
for _i in {"$libdir","$usrlibdir"}/rsyslog/lmnet.so \
{"$libdir","$usrlibdir"}/rsyslog/imklog.so \
{"$libdir","$usrlibdir"}/rsyslog/imuxsock.so ; do
[ -e "$i" ] && installs="$installs $i"
[ -e "$_i" ] && _installs="$_installs $_i"
done
elif type -P syslogd >/dev/null; then
installs="syslogd"
_installs="syslogd"
elif type -P syslog-ng >/dev/null; then
installs="syslog-ng"
_installs="syslog-ng"
else
derror "Could not find any syslog binary although the syslogmodule" \
"is selected to be installed. Please check."
fi
if [ -n "$installs" ]; then
if [ -n "$_installs" ]; then
dracut_install cat
dracut_install $installs
dracut_install $_installs
inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh"
inst_hook pre-udev 61 "$moddir/syslog-genrules.sh"
inst_hook pre-pivot 99 "$moddir/syslog-cleanup.sh"
inst_simple "$moddir/rsyslogd-start.sh" /sbin/rsyslogd-start
inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop
mkdir -p ${initdir}/etc/templates
mkdir -m 0755 -p ${initdir}/etc/templates
inst_simple "${moddir}/rsyslog.conf" /etc/templates
fi
}

View File

@@ -31,5 +31,5 @@ read conf < /tmp/syslog.conf
template=/etc/templates/rsyslog.conf
if [ -n "$server" ]; then
rsyslog_config "$server" "$template" "$filters" > $conf
/sbin/rsyslogd -c3
rsyslogd -c3
fi

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