Compare commits

..

65 Commits

Author SHA1 Message Date
Lukas Nykryn
6b82776107 net-lib: check if addr exists before checking for dad state
Before we check if dad is done we should first make sure,
that there is a link local address where we do the check.

Due to this issue, on ipv6 only setups sometimes dhclient started
asking for ip address, before the link local address was present
and failed immediately.
2019-10-29 14:47:26 +01:00
Harald Hoyer
57c3103a69 dracut.sh: quote sync file argument 2019-10-22 12:26:15 +02:00
Ankit Kumar
1126a69746 Sync initramfs after creation
If we trigger crash just after creating initramfs, sometimes it is
observed that initramfs is not written to disk causing the subsequent
boot to fail. A sync should resolve this.

Signed-off-by: Ankit Kumar <ankit@linux.vnet.ibm.com>
2019-10-22 12:24:46 +02:00
Lukas Nykryn
6193b3a6e2 rootfs-generator: don't set JobRunningTimeoutSec
We don't have that in rhel7 systemd
2019-08-29 09:40:09 +02:00
Harald Hoyer
e8a7c2a152 network: skip already enslaved interfaces 2019-06-19 14:42:52 +02:00
Lukas Nykryn
65623826c1 fips: split loading the crypto modules and checking the kernel
In e54ab383 we moved the fips script to a later pahse of boot, since
the /boot might not be available early on.

The problem is that systemd-cryptsetup* services could be run now
started before the do_fips is executed and need the crypto modules
to decrypted the devices.

So let's split the do_fips and load the module before udev does the
trigger.
2019-05-14 10:10:33 +02:00
Lukas Nykryn
e42ab58a70 rootfs-generator: rebase to upstream version
Resolves: #1640866
2019-04-25 10:11:58 +02:00
Lukas Nykryn
937b808a0d 95iscsi/iscsiroot: synchronously wait until iscsistart finishes 2019-04-01 17:25:05 +02:00
Renaud Métrich
2ee1e96e1a fips: removed false-positive 'FATAL: Module xxx not found' error message when kernel provides a generic algo for module
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>

Cherry-picked from: 01ffcf342a
Resolves: #1649743
2019-03-27 17:54:57 +01:00
Kairui Song
c6ccef8827 fips: ensure fs module for /boot is installed
When using dracut with  --hostonly and --no-hostonly-default-device,
/boot will be inaccessible as dracut will most fs modules unless
specified. But FIPS require /boot to be accessible, and it will try
to mount it on boot. It will fail if corresponding fs module is missing.

For most case /boot will be a simple partition, include the fs module
will be enough for FIPS to mount it. For other cases users have to pass
extra parameters by themselves.

Suggested-by: Kenneth Dsouza <kdsouza@redhat.com>
Signed-off-by: Kairui Song <kasong@redhat.com>

Cherry-picked from: 8365177644
Resolves: #1672817
2019-03-27 17:51:07 +01:00
Renaud Métrich
97dd467e8e iscsi: always popd, even if there is no iscsi device
Cherry-picked from: 33cfad0b8f
Resolves: #1684474
2019-03-27 17:47:42 +01:00
Renaud Métrich
fc87cf0e7e Harden dracut against BASH_ENV environment variable
When dracut silently produces a broken initramfs, then the system will
likely not boot and this can be very problematic. Typical use case is
after the kernel has been updated.

It appears that dracut is not protected against the BASH_ENV variable,
causing various scripts called by dracut to possibly fail or provide
wrong output (e.g. "ldd" is one of these).
Having a broken output for "ldd" makes the generated initramfs be not
usable, typically because vital binaries will be missing (e.g.
"awk", "udevadm", ...).

Note: because the shebang line cannot contain more than one argument,
the '--norc' option had to be removed. IMHO, it was useless anyway.

Signed-off-by: Renaud Métrich <rmetrich@redhat.com>

Cherry-picked from: c1c78f8a91
Resolves: #1588483
2019-02-25 10:49:10 +01:00
Renaud Métrich
75d6e4366a fips: check fips integrity just before mounting local filesystems in /sysroot
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>

Cherry-picked from: e54ab383f7
Resolves: #1640981
2019-02-25 10:44:50 +01:00
Ondrej Dubaj
d76ccd07bc added make rpm/srpm options 2019-02-12 13:40:19 +01:00
Kairui Song
e5c337c3b3 kernel-modules: add nfit
To support pmem devices, nfit module is required

Cherry-picked from: 09ba1b289f
Resolves: #1288619
2018-09-27 15:26:09 +02:00
Lukas Nykryn
e4034dcae3 dracut-functions: fix the word splitting
Cherry-picked from: dc4f0a40f8fbea23ccd1e0fcde48d5c6f7996021
Resolves: #1607744
2018-08-09 12:17:50 +02:00
Harald Hoyer
da6411f59c dracut.spec: remove 90multipath-hostonly
Cherry-picked from: ca77afdeb3
Resolves: #1599592
2018-07-30 14:49:39 +02:00
Lukas Nykryn
af97814e42 Revert "add 90multipath-hostonly module"
This reverts commit 6ef3173e86.

Cherry-picked from: 35e86ac117
Resolves: #1599592
2018-07-30 13:55:57 +02:00
Kairui Song
ecd196732f Introduce tri-state hostonly mode
Add a new option --hostonly-mode which accept an <mode> parameter, so we have a tri-state hostonly mode:

    * generic: by passing "--no-hostonly" or not passing anything.
               "--hostonly-mode" has no effect in such case.
    * sloppy: by passing "--hostonly --hostonly-mode sloppy". This
              is also the default mode when only "--hostonly" is given.
    * strict: by passing "--hostonly --hostonly-mode strict".

Sloppy mode is the original hostonly mode, the new introduced strict
mode will allow modules to ignore more drivers or do some extra job to
save memory and disk space, while making the image less portable.

Also introduced a helper function "optional_hostonly" to make it
easier for modules to leverage new hostonly mode.

To force install modules only in sloppy hostonly mode, use the form:

hostonly="$(optional_hostonly)" instmods <modules>

Signed-off-by: Kairui Song <kasong@redhat.com>

Cherry-picked from: a695250ec7
Resolves: #1599592
2018-07-30 13:55:57 +02:00
Christian Rodrigues
5f381a151f Correct paths for openSUSE
openSUSE has things stored in different places, so fixup the
paths here.

Signed-off-by: Christian Rodrigues <crrodriguez@opensuse.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>

Cherry-picked from: b52cfbea
Resolves: #1608491
2018-07-30 13:55:57 +02:00
Kairui Song
8df75b1573 Record loaded kernel modules when hostonly mode is enabled
A hostonly image will not include every possibly required kernel module,
so if any hardware or configuration changed, the image may fail to boot.

One way to know if there are any hardware change or configuration change
that will require an image rebuild or not is to check the loaded kernel
module list. If the loaded kernel module list differs from last build
time, then the image may require to be rebuilt.

This commit will let dracut record the loaded kernel module list when
the image is being built, so other tools or services can compare this
list with currently loaded kernel modules to decide if dracut should be
called to rebuild the image.

To retrieve the loaded kernel modules list when an image is built, use
lsinitrd command:

lsinitrd $image -f */lib/dracut/loaded-kernel-modules.txt

Cherry-picked from: 7047294617
Resolves: #1607744
2018-07-30 13:55:47 +02:00
Lukas Nykryn
013030d947 40network/dhclient.conf: rename classless-routes to classless-static-routes
We tell dhclient to name 121 option "classless-routes",
but in dhclient-script we parse classless_static_routes.
So either have to change the configuration or the script.

And since dhclient uses by default classless_static_routes,
let's change the configuration

Cherry-picked from: 62b7920ed
Resolves: #1453907
2018-06-21 15:21:50 +02:00
Xunlei Pang
f055e5126f fcoe: handle CNAs with DCB firmware support
Some Combined Network Adapters(CNAs) implement DCB protocol
in firmware, it is recommended that do not run software-based
DCB or LLDP on CNAs that implement DCB, but we have to start
the lldpad service anyway(there might be other software DCB).

If the network interface provides hardware DCB/DCBX capabilities,
the field DCB_REQUIRED in "/etc/fcoe/cfg-xxx" is expected to
be set to "no".

We met an issue on "QLogic BCM57810" with DCB firmware support,
and found dracut still generated "fcoe=<mac>:dcb" which caused
kdump boot failure when using that fcoe dump target.

This patch parses /etc/fcoe/cfg-xxx to detect DCB_REQUIRED="no",
and force "nodcb" if it is the case.

Also improved some coding style in passing.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>

Cherry-picked from: 795256bbb
Resolves: #1442663
2018-06-20 12:04:47 +02:00
Harald Hoyer
c9e0ee2c91 mdraid: wait for rd.md.uuid specified devices to be assembled
This patch uses wait_for_dev "/dev/disk/by-id/md-uuid-${uuid}" for the
specified uuids.

On timeout only md devices are force started which are specified by
uuid, or all, if rd.auto was specified.

Fixes https://github.com/dracutdevs/dracut/issues/227

Cherry-picked from: 3cea0658
Resolves: #1451660
2018-06-20 11:13:33 +02:00
NeilBrown
f421aa0f16 mdraid/mdraid_start.sh: tell mainloop if we make progress.
mdraid_start is a number of scripts which run after a timeout.
If it makes progress, it should tell the main loop so that it
knows that it is worth waiting a bit longer.

So in that case, create the initqueue/work file which the main loop
checks for.

Signed-off-by: NeilBrown <neilb@suse.de>

Cherry-picked from: 3b82ac16
Resolves: #1451660
2018-06-20 11:13:24 +02:00
Thomas Renninger
125bb747c3 dracut: Introduce --force-drivers parameter and force_drivers=+ config option
Which will not only add listed drivers, but also enforce that they are
tried to be loaded at early boot time.

This is needed if drivers which are not autoloaded (e.g. loop and a lot
others) shall get loaded via initramfs.

Cherry-picked from: cea907f6bf
Resolves: #1577626
2018-06-20 10:55:59 +02:00
Derek Higgins
903d6fc2fc Skip iscsi attachment if no info
If no iscsi session information can be retrieved from the firmware
then skip the iscsi attachment and allow the boot process to continue.
Ensure the timeout scripts don't hit their timeout waiting for
/tmp/iscsistarted-firmware to be created.
This will allow a common image to be used for servers with both a
local and iscsi root with rd.iscsi.firmware set.

Cherry-picked from: 9408a2ac33
Resolves: #1513397
2018-06-20 10:53:44 +02:00
Fabian Vogt
249dcc61ea Fix loading of modules in modules-load.d
With hostonly enabled, only modules that are currently
loaded are included in the initrd. Modules which are
explicitly listed in modules-load.d do not need to
be filtered that way. Fix for boo#962224.

Cherry-picked from: 9fd3e045d
Resolves: #1547730
2018-06-20 10:23:22 +02:00
Pingfan Liu
26273649dc 40network: introduce ip=either6 option
In kdump, if dump-target is ssh on ipv6, we need to sync until ipv6 addr
is ready. Currently ip=auto6/dhcp6 provides such function. But in 1st kernel,
it is hard to know whether the ipv6 addr is got by dhcpv6 or SLAAC.
E.g ifcfg-eth* contains DHCPV6C=yes direction, but there is no dhcpv6
server in the network, and then after the system is up, the user
echo 1 > /proc/sys/net/ipv6/conf/eth0/autoconf && accept_ra by manual
to obtain a ipv6 addr. Or vice.
So this patch suggests to make dhcpv6 as auto6 fallback

Signed-off-by: Pingfan Liu <piliu@redhat.com>

Cherry-picked from: 67354ee
Resolves: #1582398
2018-06-14 13:41:09 +02:00
Harald Hoyer
15384bcedb dracut-functions.sh:check_vol_slaves() speedup LV -> VG name
Instead of trying all /dev/mapper/* devices to match the maj:min, and
get the VG name with "lvm lvs", use the dm/name from /sys and dmsetup
splitname.

This should speedup execution with lots of LVs.

Cherry-picked from: 9ed6eb741
Resolves: #1531503
2018-06-14 10:29:19 +02:00
Harald Hoyer
dd235965dd dracut-function.sh:check_block_and_slaves() check for block devices
Some nvme have char parents, so check if the "slave" is a block dev.

Fixes https://github.com/dracutdevs/dracut/issues/373

Cherry-picked from: e64dafd1f2
Resolves: #1549498
2018-06-11 12:37:37 +02:00
Lukas Nykryn
388c771a28 net-lib: bump carrier timeout to 15
df95b10 caused that dracut now waits only 5 seconds for carrier.
Let's bump this in downstream to avoid regressions in minor versions.

RHEL-only
Resolves: #1401811
2018-06-11 12:30:07 +02:00
Lukas Nykryn
f264cfbe8a dracut.sh: workaround broken read from /proc/modules
RHEL-only (upstream is using libkmod)
Resolves: #1578222
2018-06-11 12:17:20 +02:00
Lukas Nykryn
de688a407c 90lvm: always add dm-snapshot
Resolves: #1546577
2018-02-19 16:09:53 +01:00
Alexander Tsoy
58a5434f75 base/dracut-lib.sh:dev_unit_name() guard against $dev beginning with "-"
crypt/parse-crypt.sh generate initqueue job which always call
dev_unit_name() with an argument beginning with "-". This results
in the following error:

dracut-initqueue[307]: + systemd-escape -p -cfb4aa43-2f02-4c6b-a313-60ea99288087
dracut-initqueue[307]: systemd-escape: invalid option -- 'c'

Cherry-picked from: c41df7e1
Resolves: #1306640
2018-02-01 14:04:41 +01:00
Alexander Tsoy
9dfcc5f066 base/dracut-lib.sh: remove bashism
Cherry-picked from: 13efce5d
Resolves: #1306640
2018-02-01 14:04:41 +01:00
Thorsten Behrens
014a78261d Align dev_unit_name() with systemd's function.
Add more corner cases from systemd's
unit_name_from_path_instance() C function.

Signed-off-by: Thorsten Behrens <tbehrens@suse.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>

Cherry-picked from: e3eec4b8
Resolves: #1306640
2018-02-01 14:04:41 +01:00
Harald Hoyer
e8ffd4b3d4 dracut-lib.sh:dev_unit_name(): use systemd-escape, if available
Cherry-picked from: 85752f0f
Resolves: #1306640
2018-02-01 14:04:41 +01:00
Lukas Nykryn
19da2dda22 90dmsquash-live-ntfs: fix depends()
Dependencies should not include module number.

Cherry-picked from: f3e09bf1cb
Resolves: #1449410
2018-02-01 12:48:55 +01:00
Lukas Nykryn
5aadb10791 90dmsquash-live: we don't have find_binary inside initramdisk
Cherry-picked from: c42c387cca
Resolves: #1449410
2018-02-01 12:48:05 +01:00
Erwan Velu
7812b7a7b0 dracut: Ajusting variables name for --include
When reading the --include part of the script, we had the following
issues to make the code easy to read:
- src & tgt were extract for the original options
- i variable was a file or a directory from src
- s variable was the directory name in case $i was a directory

"s" sounds very close to "src" while "s" is on the "tgt" side. Very
confusing.

"s" was defined before the "if it's a directory" statement while it's
only used inside the "if".

"i" was commit from the "src" but wasn't really explicit.

Having some lines mixing "i" and "s" takes a little time to get read
properly.

This patch offer the following changes:
- "i" is renamed to "objectname" as we don't know if its a file or a
  directory

- "s" is renamed to "object_destdir" as the object name becomes a
  directory on the destdir

- "object_destdir" (former "s") is moved inside the "if" statement as it's
  only used here

- tgt is finally renamed to "target" to be more explicit. We are not all
  native english ;o)

My 2 (semantic) cents,

Cherry-picked from: c9364f6ea2
Resolves: #1489882
2018-01-11 16:11:08 +01:00
Lukas Nykryn
69a889ee67 01fips: Properly fix creating path to .hmac of kernel based on BOOT_IMAGE
8f5c5 broke the case where BOOT_IMAGE is not set at all.
This code should handle following:
1) BOOT_IMAGE not set
2) BOOT_IMAGE set to something unrelated (s390)
3) BOOT_IMAGE=vmlinuz-4.14.7-300.fc27.x86_64
4) BOOT_IMAGE=/vmlinuz-4.14.7-300.fc27.x86_64
5) BOOT_IMAGE=/boot/vmlinuz-4.14.7-300.fc27.x86_64
6) BOOT_IMAGE=subdir/vmlinuz-4.14.7-300.fc27.x86_64
7) BOOT_IMAGE=/subdir/vmlinuz-4.14.7-300.fc27.x86_64
8) BOOT_IMAGE=/boot/subdir/vmlinuz-4.14.7-300.fc27.x86_64

https://bugzilla.redhat.com/show_bug.cgi?id=1415032

Cherry-picked from: d818986db4
Resolves: #1415032
2018-01-03 10:57:10 +01:00
Lukas Nykryn
9b1d79993d 01fips: Fix creating path to .hmac of kernel based on BOOT_IMAGE
Old code did not work for two most common use-cases.
On most machines BOOT_IMAGE is set to something like
/vmlinuz-4.11.3-202.fc25.x86_64. So if we just add prefix "/boot/."
it won't work. Also on machines without /boot on separate partition
BOOT_IMAGE already has the /boot/ prefix (/boot/vmlinuz-3.10.0-799.el7.x86_64).
So let's strip it in such case.

https://bugzilla.redhat.com/show_bug.cgi?id=1415032

Cherry-picked from: 8f5c564cb3
Resolves: #1415032
2017-12-18 16:13:37 +01:00
Daniel Molkentin
a0e7bc11c8 Simplify microcode lookup for for AMD CPUs
Suggested by Tom Lendacky <thomas.lendacky@amd.com>

Cherry-picked from: 19453dc874
Resolves: #1476039
2017-12-18 09:52:39 +01:00
Daniel Molkentin
f93c34935f Support Microcode Updates for AMD CPU Family 0x17
Original-Patch-By: Tom Lendacky <thomas.lendacky@amd.com>

Cherry-picked from: 215fe58324
Resolves: #1476039
2017-12-18 09:52:34 +01:00
Harald Hoyer
e076279d38 dracut.sh: remove quotes from install_items and install_optional_items
Unfortunately these are lists with whitespaces.

Cherry-picked from: 3c00189988
Resolves: #1520721
2017-12-13 16:41:45 +01:00
Pingfan Liu
43d6b9d008 dracut.sh: for_each_host_xx() function should indicate the empty case
The caller of "for_each_host_xx func" needs to tell three cases:
func success/ fail / not be called.
E.g, in kdump case, host_devs can be empty, and we want to know it.

Signed-off-by: Pingfan Liu <piliu@redhat.com>

Cherry-picked from: e6199960d9
Resolves: #1520721
2017-12-08 14:54:15 +01:00
Harald Hoyer
69b5de6251 guard ${arrays[@]} with ""
Cherry-picked from: 3721635b2c
Resolves: #1520721
2017-12-08 14:54:02 +01:00
Harald Hoyer
0259f1c246 network/ifup: don't arping for point-to-point connections
https://bugzilla.redhat.com/show_bug.cgi?id=1477339

Cherry-picked from: 5abd692fe4
Resolves: #1477339
2017-11-03 14:10:54 +01:00
Javier Martinez Canillas
240c2fea10 network: Only bring up wired network interfaces
The dracut network module is only supposed to be used for wired interfaces
but if driver modules for wireless devices are wrongly copied, these will
be loaded and the available interfaces brought up.

If the rd.neednet=1 command line parameter is used, dhclient will attempt
to request an IP address for the interfaces and these requests will fail.

But other dracut modules that depend on the network to be settled, will
have to wait for the DHCP requests to timeout. Which can be a lot of time
since the dhclient default timeout value is 60 seconds.

Instead of trying to blacklist all possible kernel modules for wireless
devices, only bring up network interfaces if these are for wired devices.

Suggested-by: Harald Hoyer <harald@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Cherry-picked from: 1792759721
Resolves: #1480246
2017-11-03 14:03:43 +01:00
Harald Hoyer
75bf5df420 dracut.sh: source dracut-version.sh earlier than dracut-functions.sh
Otherwise dracut-logger.sh outputs an empty version on journal testing.

Aug 20 10:15:49 lenovo dracut[11144]: dracut-
Aug 20 10:15:49 lenovo dracut[11148]: Executing: /sbin/dracut

Cherry-picked from: e27ecc9ae8
Resolves: #1490777
2017-11-03 14:01:42 +01:00
Robert LeBlanc
50c3405ce0 Fix MTU on bond interface.
The MTU is only being set on the slave devices and the MTU of the
bonding master is not being updated. This updates the bonding master and
also changes the MTU on the slaves as expected.

Signed-Off-By: Robert LeBlanc <robert@leblancnet.us>

Cherry-picked from: d0eabcab43
Resolves: #1494265
2017-11-03 13:39:32 +01:00
Imran Haider
50d75a50fb add 'mtu' parameter for bond options
Signed-off-by: Imran Haider <imran1008@gmail.com>

Cherry-picked from: 292548be6e
Resolves: #1494265
2017-11-03 13:39:28 +01:00
Chad Dupuis
3d1c9a76e7 fcoe: Allow more time for the bnx2x link negotiation before brining up fcoe interfaces.
bnx2x can take no longer than 3 seconds to initialize the link in some setups
which can cause fipvlan to fail and thus the fcoe interface(s) won't be
created.

Add another 10 seconds to give the link enough time to initialize.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>

Cherry-picked from: 3966a1e1ee
Resolves: #1378910
2017-11-03 13:30:53 +01:00
Bryn M. Reeves
0fe8ed5ccb lvm_scan.sh: use -K when calling lvchange
The --ignoreactivationskip/-K switch was added to LVM2 in 2.02.99
(July 2013) and is used to control the activation of volumes with
the activation skip flag set: without -K these volumes will be
ignored when 'lvchange -ay $LV' is issued.

This prevents an LVM2 thin-privisioned snapshot from being used
as the root device when booting with rd.lvm.lv=vg/lv since the
activation skip flag is set for these snapshots by default (the
legacy non-thinp snapshots do not set this flag and can already
be activated and used as a root device by specifying appropriate
values for rd.lvm.lv).

This is only used in the rd.lvm.lv case since in that situation
we are activating one or more named LVs specified by the user:
the flag is not given when calling 'vgchange' since this may
cause many unwanted volumes to be activated during early user
space. Users wishing to use a specific snapshot volume should
specify it with 'rd.lvm.lv'.

Cherry-picked from: cc4e507322
Resolves: #1489841
2017-11-03 13:16:57 +01:00
Yu Watanabe
fe89c8f9df spec: add missing modules
Cherry-picked from: ad3b209d40
Resolves: #1457311
2017-11-02 13:10:13 +01:00
Harald Hoyer
6ef3173e86 add 90multipath-hostonly module
hardcoding the wwid of the drives in the initramfs causes problems
when the drives are cloned to a system with the same hardware, but
different disk wwid's

https://bugzilla.redhat.com/show_bug.cgi?id=1457311

Cherry-picked from: 5ce7cc7337
Resolves: #1457311
2017-11-02 13:07:43 +01:00
Robert Scheck
015d5aee92 Add NTFS support to 90dmsquash-live module
Support booting from USB media with NTFS filesystem (optionally),
which removes the FAT32 related 4 GB file size limit for LiveOS/
squashfs.img (and any other file on the same USB media).

Backports 37437cac8a from dracut 046
2017-11-02 13:06:22 +01:00
Lukas Nykryn
0489607bf6 dracut.sh: gather host_modalias when "--no-hostonly-default-device" is set
rhel-only
Related: #1483838
2017-10-27 14:36:26 +02:00
Lukas Nykryn
e2afcc958b rootfs-block/module-setup.sh: check root_dev in cmdline_rootfs()
In case of "--no-hostonly-default-device", we do not need
the root device, thus add this check.

Reimplementation of upstream commit 5634a31156

Resolves: #1483838
2017-10-26 13:50:17 +02:00
Xunlei Pang
0e842c4b8b dracut.sh: introduce "--no-hostonly-default-device" argument
Kdump doesn't need default host devices like root, swap, fstab, etc,
we only care about the dump target which can be added via "--mount"
or "--add-device". We met several issues that kdump kernel failed
due to one of those host devices added by dracut, additionally, the
needless devices(e.g. LVM) consume some appreciable amount of memory
which is more likely to cause OOM under memory-limited kdump.

So this patch introduced "--no-hostonly-default-device" to avoid
adding those default devices as host_devs.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>

Cherry-picked from: 37f2fe55d
Resolves: #1483838
2017-10-26 12:25:37 +02:00
Harald Hoyer
063d6acb7b 10i18n/parse-i18n.sh: parse rd.vconsole and rd.locale
and removed systemd part, because parse-i18n.sh is not even installed in
systemd driven initramfs images.

Cherry-picked from: 6c8fc6e377
Resolves: #1479325
2017-09-20 14:56:41 +02:00
Harald Hoyer
8131fd3c11 dracut.cmdline: remove extra ":" from ip= doc
Cherry-picked from: 0a7d7f6310
Resolves: #1469997
2017-09-20 14:44:26 +02:00
Harald Hoyer
744afe7531 Try BOOT_IMAGE and fallback to vmlinuz-${KERNEL}
On s390 BOOT_IMAGE only denotes the number of the boot record that
was selected in the bootloader and not the path to the kernel image.

Also only bail out, if the kernel hmac checking relies on that path.

Cherry-picked from: 3d875f77f3
Resolves: #1415032
2017-09-20 10:34:17 +02:00
Harald Hoyer
17092b128c fips: honor $BOOT_IMAGE variable for HMAC check of the kernel
https://bugzilla.redhat.com/show_bug.cgi?id=1415032

Cherry-picked from: 4693daa5fa
Resolves: #1415032
2017-09-20 10:34:07 +02:00
39 changed files with 583 additions and 211 deletions

View File

@@ -1,6 +1,6 @@
-include dracut-version.sh
VERSION = $(shell [ -d .git ] && git describe --abbrev=0 --tags 2>/dev/null || echo $(DRACUT_VERSION))
VERSION = $(shell [ -d .git ] && git describe --abbrev=0 2>/dev/null || echo $(DRACUT_VERSION))
GITVERSION = $(shell [ -d .git ] && { v=$$(git describe --tags 2>/dev/null); [ $${v\#*-} != $$v ] && echo -$${v\#*-}; } )
-include Makefile.inc
@@ -39,7 +39,7 @@ man8pages = dracut.8 \
manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
.PHONY: install clean archive rpm testimage test all check AUTHORS doc dracut-version.sh
.PHONY: install clean archive rpm srpm testimage test all check AUTHORS doc dracut-version.sh
all: dracut-version.sh dracut.pc dracut-install skipcpio/skipcpio
@@ -202,6 +202,16 @@ rpm: dracut-$(VERSION).tar.bz2 syncheck
--define "_rpmdir $$PWD" -ba dracut.spec; ) && \
( mv "$$rpmbuild"/$$(arch)/*.rpm $(DESTDIR).; mv "$$rpmbuild"/*.src.rpm $(DESTDIR).;rm -fr -- "$$rpmbuild"; ls $(DESTDIR)*.rpm )
srpm: dracut-$(VERSION).tar.bz2 syncheck
rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
cp dracut-$(VERSION).tar.bz2 "$$rpmbuild"; \
LC_MESSAGES=C $$src/git2spec.pl $(VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
(cd "$$rpmbuild"; \
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
--define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
--define "_rpmdir $$PWD" -bs dracut.spec; ) && \
( mv "$$rpmbuild"/*.src.rpm $(DESTDIR).; rm -fr -- "$$rpmbuild"; ls $(DESTDIR)*.rpm )
syncheck:
@ret=0;for i in dracut-initramfs-restore.sh modules.d/*/*.sh; do \
[ "$${i##*/}" = "module-setup.sh" ] && continue; \

View File

@@ -593,7 +593,8 @@ for_each_host_dev_fs()
local _dev
local _ret=1
[[ "${!host_fs_types[@]}" ]] || return 0
[[ "${#host_fs_types[@]}" ]] || return 2
for _dev in "${!host_fs_types[@]}"; do
$_func "$_dev" "${host_fs_types[$_dev]}" && _ret=0
@@ -615,13 +616,14 @@ check_block_and_slaves() {
[[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
if ! lvm_internal_dev $2; then "$1" $2 && return; fi
check_vol_slaves "$@" && return 0
if [[ -f /sys/dev/block/$2/../dev ]]; then
if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
check_block_and_slaves $1 $(<"/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 $(<"$_x") && return 0
for _x in /sys/dev/block/$2/slaves/*; do
[[ -f $_x/dev ]] || continue
[[ $_x/subsystem -ef /sys/class/block ]] || continue
check_block_and_slaves $1 $(<"$_x/dev") && return 0
done
return 1
}
@@ -633,13 +635,14 @@ check_block_and_slaves_all() {
_ret=0
fi
check_vol_slaves_all "$@" && return 0
if [[ -f /sys/dev/block/$2/../dev ]]; then
if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=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_all $1 $(<"$_x") && _ret=0
for _x in /sys/dev/block/$2/slaves/*; do
[[ -f $_x/dev ]] || continue
[[ $_x/subsystem -ef /sys/class/block ]] || continue
check_block_and_slaves_all $1 $(<"$_x/dev") && _ret=0
done
return $_ret
}
@@ -652,9 +655,9 @@ for_each_host_dev_and_slaves_all()
local _dev
local _ret=1
[[ "${host_devs[@]}" ]] || return 0
[[ "${host_devs[@]}" ]] || return 2
for _dev in ${host_devs[@]}; do
for _dev in "${host_devs[@]}"; do
[[ -b "$_dev" ]] || continue
if check_block_and_slaves_all $_func $(get_maj_min $_dev); then
_ret=0
@@ -668,9 +671,9 @@ for_each_host_dev_and_slaves()
local _func="$1"
local _dev
[[ "${host_devs[@]}" ]] || return 0
[[ "${host_devs[@]}" ]] || return 2
for _dev in ${host_devs[@]}; do
for _dev in "${host_devs[@]}"; do
[[ -b "$_dev" ]] || continue
check_block_and_slaves $_func $(get_maj_min $_dev) && return 0
done
@@ -684,43 +687,39 @@ for_each_host_dev_and_slaves()
# 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
[[ $i == /dev/mapper/control ]] && continue
_lv=$(get_maj_min $i)
if [[ $_lv = $2 ]]; then
_vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
# strip space
_vg="${_vg//[[:space:]]/}"
if [[ $_vg ]]; then
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
do
check_block_and_slaves $1 $(get_maj_min $_pv) && return 0
done
fi
fi
done
local _lv _vg _pv _dm _majmin
_majmin="$2"
_lv="/dev/block/$_majmin"
_dm=/sys/dev/block/$_majmin/dm
[[ -f $_dm/uuid && $(<$_dm/uuid) =~ LVM-* ]] || return 1
_vg=$(dmsetup splitname --noheadings -o vg_name $(<"$_dm/name") )
# strip space
_vg="${_vg//[[:space:]]/}"
if [[ $_vg ]]; then
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
do
check_block_and_slaves $1 $(get_maj_min $_pv) && return 0
done
fi
return 1
}
check_vol_slaves_all() {
local _lv _vg _pv
for i in /dev/mapper/*; do
[[ $i == /dev/mapper/control ]] && continue
_lv=$(get_maj_min $i)
if [[ $_lv = $2 ]]; then
_vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
# strip space
_vg="${_vg//[[:space:]]/}"
if [[ $_vg ]]; then
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
do
check_block_and_slaves_all $1 $(get_maj_min $_pv)
done
return 0
fi
fi
done
local _lv _vg _pv _majmin
_majmin="$2"
_lv="/dev/block/$_majmin"
_dm="/sys/dev/block/$_majmin/dm"
[[ -f $_dm/uuid && $(<$_dm/uuid) =~ LVM-* ]] || return 1
_vg=$(dmsetup splitname --noheadings -o vg_name $(<"$_dm/name") )
# strip space
_vg="${_vg//[[:space:]]/}"
if [[ $_vg ]]; then
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
do
check_block_and_slaves_all $1 $(get_maj_min $_pv)
done
return 0
fi
return 1
}
@@ -1241,7 +1240,7 @@ check_mount() {
local _ret
local _moddep
[ "${#host_fs_types[*]}" -le 0 ] && return 1
[ "${#host_fs_types[@]}" -le 0 ] && return 1
# If we are already scheduled to be loaded, no need to check again.
[[ " $mods_to_load " == *\ $_mod\ * ]] && return 0
@@ -1737,9 +1736,8 @@ get_ucode_file ()
local stepping=`grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //`
if [[ "$(get_cpu_vendor)" == "AMD" ]]; then
# If family greater or equal than 0x15
if [[ $family -ge 21 ]]; then
printf "microcode_amd_fam15h.bin"
printf "microcode_amd_fam%xh.bin" $family
else
printf "microcode_amd.bin"
fi
@@ -1750,6 +1748,17 @@ get_ucode_file ()
fi
}
# Get currently loaded modules
# sorted, and delimited by newline
get_loaded_kernel_modules ()
{
local modules=( )
while read _module _size _used _used_by; do
modules+=( "$_module" )
done <<< "$(lsmod | sed -n '1!p')"
printf '%s\n' "${modules[@]}" | sort
}
# Not every device in /dev/mapper should be examined.
# If it is an LVM device, touch only devices which have /dev/VG/LV symlink.
lvm_internal_dev() {
@@ -1761,3 +1770,14 @@ lvm_internal_dev() {
[[ ${DM_LV_LAYER} ]] || [[ ! -L /dev/${DM_VG_NAME}/${DM_LV_NAME} ]]
}
# Use with form hostonly="$(optional_hostonly)" inst_xxxx <args>
# If hosotnly mode is set to "strict", hostonly restrictions will still
# be applied, else will ignore hostonly mode and try to install all
# given modules.
optional_hostonly() {
if [[ $hostonly_mode = "strict" ]]; then
printf -- "$hostonly"
else
printf ""
fi
}

View File

@@ -136,6 +136,19 @@ example:
----
===============================
**--force-drivers** _<list of kernel modules>_::
See add-drivers above. But in this case it is ensured that the drivers
are tried to be loaded early via modprobe.
+
[NOTE]
===============================
If [LIST] has multiple arguments, then you have to put these in quotes. For
example:
----
# dracut --force-drivers "kmodule1 kmodule2" ...
----
===============================
**--omit-drivers** _<list of kernel modules>_::
specify a space-separated list of kernel modules not to add to the
initramfs.
@@ -306,6 +319,10 @@ provide a valid _/etc/fstab_.
**--no-hostonly-cmdline**:
Do not store kernel command line arguments needed in the initramfs
**--no-hostonly-default-device**:
Do not generate implicit host devices like root, swap, fstab, etc.
Use "--mount" or "--add-device" to explicitly add devices as needed.
**--hostonly-i18n**:
Install only needed keyboard and font files according to the host configuration (default).

View File

@@ -449,7 +449,7 @@ USB Android phone::
* enp0s29u1u2
=====================
**ip=**__{dhcp|on|any|dhcp6|auto6}__::
**ip=**__{dhcp|on|any|dhcp6|auto6|either6}__::
dhcp|on|any::: get ip from dhcp server from all interfaces. If root=dhcp,
loop sequentially through all interfaces (eth0, eth1, ...) and use the first
with a valid DHCP root-path.
@@ -458,6 +458,8 @@ USB Android phone::
dhcp6::: IPv6 DHCP
either6::: if auto6 fails, then dhcp6
**ip=**__<interface>__:__{dhcp|on|any|dhcp6|auto6}__[:[__<mtu>__][:__<macaddr>__]]::
This parameter can be specified multiple times.
+
@@ -469,7 +471,7 @@ cannot be used in conjunction with the **ifname** argument for the
same <interface>.
=====================
**ip=**__<client-IP>__:[__<peer>__]:__<gateway-IP>__:__<netmask>__:__<client_hostname>__:__<interface>__:__{none|off|dhcp|on|any|dhcp6|auto6|ibft}__:[:[__<mtu>__][:__<macaddr>__]]::
**ip=**__<client-IP>__:[__<peer>__]:__<gateway-IP>__:__<netmask>__:__<client_hostname>__:__<interface>__:__{none|off|dhcp|on|any|dhcp6|auto6|ibft}__[:[__<mtu>__][:__<macaddr>__]]::
explicit network configuration. If you want do define a IPv6 address, put it
in brackets (e.g. [2001:DB8::1]). This parameter can be specified multiple
times. __<peer>__ is optional and is the address of the remote endpoint

View File

@@ -54,6 +54,10 @@ Space-separated lists have to have a leading and trailing space!
Specify a space-separated list of kernel modules to add to the initramfs.
The kernel modules have to be specified without the ".ko" suffix.
*force_drivers+=*" __<list of kernel modules>__ "::
See add_drivers above. But in this case it is ensured that the drivers
are tried to be loaded early via modprobe.
*omit_drivers+=*" __<kernel modules>__ "::
Specify a space-separated list of kernel modules not to add to the
initramfs. The kernel modules have to be specified without the ".ko" suffix.

139
dracut.sh
View File

@@ -23,6 +23,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
unset BASH_ENV
# store for logging
dracut_args=( "$@" )
@@ -81,6 +83,10 @@ Creates initial ramdisk images for preloading modules
exclusively include in the initramfs.
--add-drivers [LIST] Specify a space-separated list of kernel
modules to add to the initramfs.
--force-drivers [LIST] Specify a space-separated list of kernel
modules to add to the initramfs and make sure they
are tried to be loaded via modprobe same as passing
rd.driver.pre=DRIVER kernel parameter.
--omit-drivers [LIST] Specify a space-separated list of kernel
modules not to add to the initramfs.
--filesystems [LIST] Specify a space-separated list of kernel filesystem
@@ -137,10 +143,29 @@ Creates initial ramdisk images for preloading modules
-H, --hostonly Host-Only mode: Install only what is needed for
booting the local host instead of a generic host.
-N, --no-hostonly Disables Host-Only mode
--hostonly-mode <mode>
Specify the hostonly mode to use. <mode> could be
one of "sloppy" or "strict". "sloppy" mode is used
by default.
In "sloppy" hostonly mode, extra drivers and modules
will be installed, so minor hardware change won't make
the image unbootable (eg. changed keyboard), and the
image is still portable among similar hosts.
With "strict" mode enabled, anything not necessary
for booting the local host in its current state will
not be included, and modules may do some extra job
to save more space. Minor change of hardware or
environment could make the image unbootable.
DO NOT use "strict" mode unless you know what you
are doing.
--hostonly-cmdline Store kernel command line arguments needed
in the initramfs
--no-hostonly-cmdline Do not store kernel command line arguments needed
in the initramfs
--no-hostonly-default-device
Do not generate implicit host devices like root,
swap, fstab, etc. Use "--mount" or "--add-device"
to explicitly add devices as needed.
--hostonly-i18n Install only needed keyboard and font files according
to the host configuration (default).
--no-hostonly-i18n Install all keyboard and font files available.
@@ -304,6 +329,7 @@ rearrange_params()
--long add: \
--long force-add: \
--long add-drivers: \
--long force-drivers: \
--long omit-drivers: \
--long modules: \
--long omit: \
@@ -355,8 +381,10 @@ rearrange_params()
--long host-only \
--long no-hostonly \
--long no-host-only \
--long hostonly-mode: \
--long hostonly-cmdline \
--long no-hostonly-cmdline \
--long no-hostonly-default-device \
--long persistent-policy: \
--long fstab \
--long help \
@@ -471,6 +499,7 @@ while :; do
-a|--add) push add_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--force-add) push force_add_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--add-drivers) push add_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--force-drivers) push force_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--omit-drivers) push omit_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
-m|--modules) push dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
-o|--omit) push omit_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
@@ -537,6 +566,8 @@ while :; do
hostonly_l="yes" ;;
-N|--no-hostonly|--no-host-only)
hostonly_l="no" ;;
--hostonly-mode)
hostonly_mode_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--hostonly-cmdline)
hostonly_cmdline_l="yes" ;;
--hostonly-i18n)
@@ -545,6 +576,8 @@ while :; do
i18n_install_all_l="yes" ;;
--no-hostonly-cmdline)
hostonly_cmdline_l="no" ;;
--no-hostonly-default-device)
hostonly_default_device="no" ;;
--persistent-policy)
persistent_policy_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--fstab) use_fstab_l="yes" ;;
@@ -790,13 +823,14 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
[[ $prefix = "/" ]] && unset prefix
[[ $hostonly_l ]] && hostonly=$hostonly_l
[[ $hostonly_cmdline_l ]] && hostonly_cmdline=$hostonly_cmdline_l
[[ $hostonly_mode_l ]] && hostonly_mode=$hostonly_mode_l
[[ $i18n_install_all_l ]] && i18n_install_all=$i18n_install_all_l
[[ $persistent_policy_l ]] && persistent_policy=$persistent_policy_l
[[ $use_fstab_l ]] && use_fstab=$use_fstab_l
[[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l
[[ $lvmconf_l ]] && lvmconf=$lvmconf_l
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
[[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware"
[[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware /lib/firmware/$kernel"
[[ $tmpdir_l ]] && tmpdir="$tmpdir_l"
[[ $tmpdir ]] || tmpdir=/var/tmp
[[ $INITRD_COMPRESS ]] && compress=$INITRD_COMPRESS
@@ -827,6 +861,21 @@ fi
[[ $hostonly = yes ]] && hostonly="-h"
[[ $hostonly != "-h" ]] && unset hostonly
case $hostonly_mode in
'')
[[ $hostonly ]] && hostonly_mode="sloppy" ;;
sloppy|strict)
if [[ ! $hostonly ]]; then
unset hostonly_mode
fi
;;
*)
printf "%s\n" "dracut: Invalid hostonly mode '$hostonly_mode'." >&2
exit 1
esac
readonly TMPDIR="$tmpdir"
readonly DRACUT_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t dracut.XXXXXX)"
[ -d "$DRACUT_TMPDIR" ] || {
@@ -857,6 +906,10 @@ if [[ $print_cmdline ]]; then
kmsgloglvl=0
fi
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
. $dracutbasedir/dracut-version.sh
fi
if [[ -f $dracutbasedir/dracut-init.sh ]]; then
. $dracutbasedir/dracut-init.sh
else
@@ -875,10 +928,6 @@ if ! [[ $print_cmdline ]]; then
rm -fr -- ${initdir}/*
fi
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
. $dracutbasedir/dracut-version.sh
fi
# Verify bash version, current minimum is 3.1
if (( BASH_VERSINFO[0] < 4 )); then
dfatal 'You need at least Bash 4 to use dracut, sorry.'
@@ -921,6 +970,13 @@ if (( ${#add_drivers_l[@]} )); then
fi
add_drivers=${add_drivers/-/_}
if (( ${#force_drivers_l[@]} )); then
while pop force_drivers_l val; do
force_drivers+=" $val "
done
fi
force_drivers=${force_drivers/-/_}
if (( ${#omit_drivers_l[@]} )); then
while pop omit_drivers_l val; do
omit_drivers+=" $val "
@@ -937,6 +993,7 @@ fi
omit_drivers_corrected=""
for d in $omit_drivers; do
[[ " $drivers $add_drivers " == *\ $d\ * ]] && continue
[[ " $drivers $force_drivers " == *\ $d\ * ]] && continue
omit_drivers_corrected+="$d|"
done
omit_drivers="${omit_drivers_corrected%|}"
@@ -1039,7 +1096,7 @@ if (( ${#add_device_l[@]} )); then
done
fi
if [[ $hostonly ]]; then
if [[ $hostonly ]] && [[ "$hostonly_default_device" != "no" ]]; then
# in hostonly mode, determine all devices, which have to be accessed
# and examine them for filesystem types
@@ -1114,8 +1171,10 @@ if [[ $hostonly ]]; then
[[ -b $_dev ]] && push host_devs "$_dev"
done < /etc/fstab
fi
fi
if [[ $hostonly ]]; then
# record all host modaliases
declare -A host_modalias
find /sys/devices/ -name uevent -print > "$initdir/.modalias"
@@ -1136,10 +1195,23 @@ if [[ $hostonly ]]; then
# check /proc/modules
declare -A host_modules
while read m rest; do
[ -z "$m" ] && continue
host_modules["$m"]=1
done </proc/modules
declare new_module_found=1
declare tmpmodules=$(mktemp --tmpdir="$TMPDIR/" -t proc_modules.XXXXXX)
while [[ $new_module_found ]]; do
new_module_found=
sleep 0.1
#reading from procfs can be broken, so copy the file elsewhere
cp -f /proc/modules "$tmpmodules"
while read m rest; do
[ -z "$m" ] && continue
[[ ${host_modules["$m"]} ]] && continue
host_modules["$m"]=1
new_module_found=1
done < "$tmpmodules"
done
rm "$tmpmodules"
unset new_module_found
unset tmpmodules
fi
unset m
@@ -1162,7 +1234,7 @@ _get_fs_type() {
return 1
}
for dev in ${host_devs[@]}; do
for dev in "${host_devs[@]}"; do
_get_fs_type "$dev"
check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
done
@@ -1359,6 +1431,9 @@ dinfo "*** Including modules done ***"
## final stuff that has to happen
if [[ $no_kernel != yes ]]; then
if [[ $hostonly ]]; then
echo "$(get_loaded_kernel_modules)" > $initdir/lib/dracut/loaded-kernel-modules.txt
fi
if [[ $drivers ]]; then
hostonly='' instmods $drivers
@@ -1367,6 +1442,13 @@ if [[ $no_kernel != yes ]]; then
if [[ $add_drivers ]]; then
hostonly='' instmods -c $add_drivers
fi
if [[ $force_drivers ]]; then
hostonly='' instmods -c $force_drivers
rm -f $initdir/etc/cmdline.d/20-force_driver.conf
for mod in $force_drivers; do
echo "rd.driver.pre=$mod" >>$initdir/etc/cmdline.d/20-force_drivers.conf
done
fi
if [[ $filesystems ]]; then
hostonly='' instmods -c $filesystems
fi
@@ -1424,26 +1506,29 @@ if [[ $kernel_only != yes ]]; then
fi
fi
while pop include_src src && pop include_target tgt; do
if [[ $src && $tgt ]]; then
while pop include_src src && pop include_target target; do
if [[ $src && $target ]]; then
if [[ -f $src ]]; then
inst $src $tgt
inst $src $target
else
ddebug "Including directory: $src"
mkdir -p "${initdir}/${tgt}"
destdir="${initdir}/${target}"
mkdir -p "$destdir"
# 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"
# Objectname is a file or a directory
for objectname in "$src"/*; do
[[ -e "$objectname" || -h "$objectname" ]] || continue
if [[ -d "$objectname" ]]; then
# objectname is a directory, let's compute the final directory name
object_destdir=${destdir}/${objectname#$src/}
if ! [[ -e "$object_destdir" ]]; then
mkdir -m 0755 -p "$object_destdir"
chmod --reference="$objectname" "$object_destdir"
fi
cp --reflink=auto --sparse=auto -fa -t "$s" "$i"/*
cp --reflink=auto --sparse=auto -fa -t "$object_destdir" "$objectname"/*
else
cp --reflink=auto --sparse=auto -fa -t "$s" "$i"
cp --reflink=auto --sparse=auto -fa -t "$destdir" "$objectname"
fi
done
fi
@@ -1619,4 +1704,10 @@ else
exit 1
fi
if ! sync "$outfile" 2> /dev/null; then
dinfo "dracut: sync operartion on newly created initramfs $outfile failed"
exit 1
fi
exit 0

View File

@@ -346,6 +346,7 @@ rm -rf -- $RPM_BUILD_ROOT
%{dracutlibdir}/modules.d/90dm
%{dracutlibdir}/modules.d/90dmraid
%{dracutlibdir}/modules.d/90dmsquash-live
%{dracutlibdir}/modules.d/90dmsquash-live-ntfs
%{dracutlibdir}/modules.d/90kernel-modules
%{dracutlibdir}/modules.d/90lvm
%{dracutlibdir}/modules.d/90mdraid

View File

@@ -113,7 +113,7 @@ fi
extract_files()
{
(( ${#filenames[@]} == 1 )) && nofileinfo=1
for f in ${!filenames[@]}; do
for f in "${!filenames[@]}"; do
[[ $nofileinfo ]] || echo "initramfs:/$f"
[[ $nofileinfo ]] || echo "========================================================================"
$CAT $image 2>/dev/null | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null

View File

@@ -0,0 +1,8 @@
#!/bin/sh
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
else
. /sbin/fips.sh
fips_load_crypto || die "FIPS integrity test failed"
fi

View File

@@ -71,6 +71,34 @@ do_rhevh_check()
return 0
}
fips_load_crypto()
{
FIPSMODULES=$(cat /etc/fipsmodules)
info "Loading and integrity checking all crypto modules"
mv /etc/modprobe.d/fips.conf /etc/modprobe.d/fips.conf.bak
for _module in $FIPSMODULES; do
if [ "$_module" != "tcrypt" ]; then
if ! modprobe "${_module}" 2>/tmp/fips.modprobe_err; then
# check if kernel provides generic algo
_found=0
while read _k _s _v; do
[ "$_k" != "name" -a "$_k" != "driver" ] && continue
[ "$_v" != "$_module" ] && [ "crypto-$_v" != "$_module" ] && continue
_found=1
break
done </proc/crypto
[ "$_found" = "0" ] && cat /tmp/fips.modprobe_err >&2 && return 1
fi
fi
done
mv /etc/modprobe.d/fips.conf.bak /etc/modprobe.d/fips.conf
info "Self testing crypto algorithms"
modprobe tcrypt || return 1
rmmod tcrypt
}
do_fips()
{
local _v
@@ -80,43 +108,36 @@ do_fips()
KERNEL=$(uname -r)
if ! [ -e "/boot/.vmlinuz-${KERNEL}.hmac" ]; then
warn "/boot/.vmlinuz-${KERNEL}.hmac does not exist"
return 1
fi
FIPSMODULES=$(cat /etc/fipsmodules)
info "Loading and integrity checking all crypto modules"
mv /etc/modprobe.d/fips.conf /etc/modprobe.d/fips.conf.bak
for _module in $FIPSMODULES; do
if [ "$_module" != "tcrypt" ]; then
if ! modprobe "${_module}"; then
# check if kernel provides generic algo
_found=0
while read _k _s _v; do
[ "$_k" != "name" -a "$_k" != "driver" ] && continue
[ "$_v" != "$_module" ] && [ "crypto-$_v" != "$_module" ] && continue
_found=1
break
done </proc/crypto
[ "$_found" = "0" ] && return 1
fi
fi
done
mv /etc/modprobe.d/fips.conf.bak /etc/modprobe.d/fips.conf
info "Self testing crypto algorithms"
modprobe tcrypt || return 1
rmmod tcrypt
info "Checking integrity of kernel"
if [ -e "/run/initramfs/live/vmlinuz0" ]; then
do_rhevh_check /run/initramfs/live/vmlinuz0 || return 1
elif [ -e "/run/initramfs/live/isolinux/vmlinuz0" ]; then
do_rhevh_check /run/initramfs/live/isolinux/vmlinuz0 || return 1
else
sha512hmac -c "/boot/.vmlinuz-${KERNEL}.hmac" || return 1
BOOT_IMAGE="$(getarg BOOT_IMAGE)"
BOOT_IMAGE_NAME="${BOOT_IMAGE##*/}"
BOOT_IMAGE_PATH="${BOOT_IMAGE%${BOOT_IMAGE_NAME}}"
if [ -z "$BOOT_IMAGE_NAME" ]; then
BOOT_IMAGE_NAME="vmlinuz-${KERNEL}"
elif ! [ -e "/boot/${BOOT_IMAGE_PATH}/${BOOT_IMAGE}" ]; then
#if /boot is not a separate partition BOOT_IMAGE might start with /boot
BOOT_IMAGE_PATH=${BOOT_IMAGE_PATH#"/boot"}
#on some achitectures BOOT_IMAGE does not contain path to kernel
#so if we can't find anything, let's treat it in the same way as if it was empty
if ! [ -e "/boot/${BOOT_IMAGE_PATH}/${BOOT_IMAGE_NAME}" ]; then
BOOT_IMAGE_NAME="vmlinuz-${KERNEL}"
BOOT_IMAGE_PATH=""
fi
fi
BOOT_IMAGE_HMAC="/boot/${BOOT_IMAGE_PATH}.${BOOT_IMAGE_NAME}.hmac"
if ! [ -e "${BOOT_IMAGE_HMAC}" ]; then
warn "${BOOT_IMAGE_HMAC} does not exist"
return 1
fi
sha512hmac -c "${BOOT_IMAGE_HMAC}" || return 1
fi
info "All initrd crypto checks done"

View File

@@ -11,7 +11,7 @@ depends() {
}
installkernel() {
local _fipsmodules _mod i
local _fipsmodules _mod i _bootfstype
if [[ -f "${srcmods}/modules.fips" ]]; then
_fipsmodules="$(cat "${srcmods}/modules.fips")"
@@ -36,12 +36,23 @@ installkernel() {
done
fi
done
# with hostonly_default_device fs module for /boot is not installed by default
if [[ $hostonly ]] && [[ "$hostonly_default_device" == "no" ]]; then
_bootfstype=$(find_mp_fstype /boot)
if [[ -n "$_bootfstype" ]]; then
hostonly='' instmods $_bootfstype
else
dwarning "Can't determine fs type for /boot, FIPS check may fail."
fi
fi
}
install() {
local _dir
inst_hook pre-trigger 01 "$moddir/fips-boot.sh"
inst_hook pre-mount 01 "$moddir/fips-boot.sh"
inst_hook pre-pivot 01 "$moddir/fips-noboot.sh"
inst_hook pre-udev 01 "$moddir/fips-load-crypto.sh"
inst_script "$moddir/fips.sh" /sbin/fips.sh
inst_multiple sha512hmac rmmod insmod mount uname umount fipscheck

View File

@@ -19,24 +19,18 @@ inst_key_val() {
unset _value
}
inst_key_val '' /etc/vconsole.conf vconsole.keymap KEYMAP -d KEYTABLE
inst_key_val '' /etc/vconsole.conf vconsole.font FONT -d SYSFONT
inst_key_val '' /etc/vconsole.conf vconsole.font.map FONT_MAP -d CONTRANS
inst_key_val '' /etc/vconsole.conf vconsole.font.unimap FONT_UNIMAP -d UNIMAP
inst_key_val 1 /etc/vconsole.conf vconsole.font.unicode UNICODE vconsole.unicode
inst_key_val '' /etc/vconsole.conf vconsole.keymap.ext EXT_KEYMAP
inst_key_val '' /etc/vconsole.conf rd.vconsole.keymap vconsole.keymap KEYMAP -d KEYTABLE
inst_key_val '' /etc/vconsole.conf rd.vconsole.font vconsole.font FONT -d SYSFONT
inst_key_val '' /etc/vconsole.conf rd.vconsole.font.map vconsole.font.map FONT_MAP -d CONTRANS
inst_key_val '' /etc/vconsole.conf rd.vconsole.font.unimap vconsole.font.unimap FONT_UNIMAP -d UNIMAP
inst_key_val 1 /etc/vconsole.conf rd.vconsole.font.unicode vconsole.font.unicode UNICODE vconsole.unicode
inst_key_val '' /etc/vconsole.conf rd.vconsole.keymap.ext vconsole.keymap.ext EXT_KEYMAP
inst_key_val '' /etc/locale.conf locale.LANG LANG
inst_key_val '' /etc/locale.conf locale.LC_ALL LC_ALL
inst_key_val '' /etc/locale.conf rd.locale.LANG locale.LANG LANG
inst_key_val '' /etc/locale.conf rd.locale.LC_ALL locale.LC_ALL LC_ALL
if [ -f /etc/locale.conf ]; then
. /etc/locale.conf
export LANG
export LC_ALL
fi
if [ -n "$DRACUT_SYSTEMD" ]; then
rm -f -- /etc/udev/rules.d/10-console.rules
rm -f -- /lib/udev/rules.d/10-console.rules
rm -f -- /lib/udev/console_init
fi

View File

@@ -1,6 +1,6 @@
option classless-routes code 121 = array of unsigned integer 8;
option classless-static-routes code 121 = array of unsigned integer 8;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
root-path, interface-mtu, classless-routes;
root-path, interface-mtu, classless-static-routes;

View File

@@ -76,6 +76,7 @@ load_ipv6() {
}
do_ipv6auto() {
local ret
load_ipv6
echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
@@ -84,10 +85,11 @@ do_ipv6auto() {
[ -n "$macaddr" ] && ip link set address $macaddr dev $netif
[ -n "$mtu" ] && ip link set mtu $mtu dev $netif
wait_for_ipv6_auto $netif
ret=$?
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
return 0
return $ret
}
# Handle static ip configuration
@@ -118,9 +120,11 @@ do_static() {
ip addr add $ip/$mask ${srv:+peer $srv} dev $netif
wait_for_ipv6_dad $netif
else
if ! arping -f -q -D -c 2 -I $netif $ip; then
warn "Duplicate address detected for $ip for interface $netif."
return 1
if [ -z "$srv" ]; then
if ! arping -f -q -D -c 2 -I $netif $ip; then
warn "Duplicate address detected for $ip for interface $netif."
return 1
fi
fi
ip -4 addr flush dev $netif
ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif
@@ -249,6 +253,9 @@ if [ -z "$NO_BOND_MASTER" ]; then
linkup $slave
done
# Set mtu on bond master
[ -n "$bondmtu" ] && ip link set mtu $bondmtu dev $bondname
# add the bits to setup the needed post enslavement parameters
for arg in $bondoptions ; do
key=${arg%%=*};
@@ -370,10 +377,13 @@ for p in $(getargs ip=); do
esac
# If this option isn't directed at our interface, skip it
[ -n "$dev" ] && [ "$dev" != "$netif" ] && \
[ "$use_bridge" != 'true' ] && \
[ "$use_vlan" != 'true' ] && continue
if [ -n "$dev" ]; then
[ "$dev" != "$netif" ] && \
[ "$use_bridge" != 'true' ] && \
[ "$use_vlan" != 'true' ] && continue
else
iface_is_enslaved "$netif" && continue
fi
# Store config for later use
for i in ip srv gw mask hostname macaddr mtu dns1 dns2; do
eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
@@ -388,6 +398,8 @@ for p in $(getargs ip=); do
do_dhcp -6 ;;
auto6)
do_ipv6auto ;;
either6)
do_ipv6auto || do_dhcp -6 ;;
*)
do_static ;;
esac

View File

@@ -102,7 +102,7 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
# Default: We don't know the interface to use, handle all
# Fixme: waiting for the interface as well.
else
cond='ACTION=="add", SUBSYSTEM=="net"'
cond='ACTION=="add", SUBSYSTEM=="net", ENV{DEVTYPE}!="wlan|wwan"'
# if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules
fi

View File

@@ -445,7 +445,7 @@ ip_to_var() {
fi
if [ $# -eq 1 ]; then
# format: ip={dhcp|on|any|dhcp6|auto6}
# format: ip={dhcp|on|any|dhcp6|auto6|either6}
# or
# ip=<ipv4-address> means anaconda-style static config argument cluster
autoconf="$1"
@@ -472,7 +472,7 @@ ip_to_var() {
return 0
fi
if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" ]; then
if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" -o "$2" = "either6" ]; then
# format: ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]]
[ -n "$1" ] && dev="$1"
[ -n "$2" ] && autoconf="$2"
@@ -645,6 +645,7 @@ wait_for_ipv6_dad_link() {
timeout=$(($timeout*10))
while [ $cnt -lt $timeout ]; do
[ -n "$(ip -6 addr show dev "$1" scope link)" ] \
[ -z "$(ip -6 addr show dev "$1" scope link tentative)" ] \
&& return 0
[ -n "$(ip -6 addr show dev "$1" scope link dadfailed)" ] \
@@ -662,6 +663,7 @@ wait_for_ipv6_dad() {
timeout=$(($timeout*10))
while [ $cnt -lt $timeout ]; do
[ -n "$(ip -6 addr show dev "$1")" ] \
[ -z "$(ip -6 addr show dev "$1" tentative)" ] \
&& return 0
[ -n "$(ip -6 addr show dev "$1" dadfailed)" ] \
@@ -706,7 +708,7 @@ iface_has_carrier() {
interface="/sys/class/net/$interface"
[ -d "$interface" ] || return 2
local timeout="$(getargs rd.net.timeout.carrier=)"
timeout=${timeout:-5}
timeout=${timeout:-15}
timeout=$(($timeout*10))
linkup "$1"
@@ -731,6 +733,13 @@ iface_has_link() {
iface_has_carrier "$@"
}
iface_is_enslaved() {
local _li
_li=$(ip -o link show dev $1)
strstr "$li" " master " || return 1
return 0
}
find_iface_with_link() {
local iface_path="" iface=""
for iface_path in /sys/class/net/*; do

View File

@@ -1,7 +1,7 @@
#!/bin/sh
#
# Format:
# bond=<bondname>[:<bondslaves>:[:<options>]]
# bond=<bondname>[:<bondslaves>:[:<options>[:<mtu>]]]
#
# bondslaves is a comma-separated list of physical (ethernet) interfaces
# options is a comma-separated list on bonding options (modinfo bonding for details) in format compatible with initscripts
@@ -9,6 +9,8 @@
#
# bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr
#
# if the mtu is specified, it will be set on the bond master
#
# We translate list of slaves to space-separated here to mwke it easier to loop over them in ifup
# Ditto for bonding options
@@ -25,15 +27,17 @@ parsebond() {
1) bondname=$1; bondslaves="eth0 eth1" ;;
2) bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;;
3) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;;
4) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " "); bondmtu=$4;;
*) die "bond= requires zero to four parameters" ;;
esac
}
# Parse bond for bondname, bondslaves, bondmode and bondoptions
# Parse bond for bondname, bondslaves, bondmode, bondoptions and bondmtu
for bond in $(getargs bond=); do
unset bondname
unset bondslaves
unset bondoptions
unset bondmtu
if [ "$bond" != "bond" ]; then
parsebond "$bond"
fi
@@ -47,4 +51,5 @@ for bond in $(getargs bond=); do
echo "bondname=$bondname" > /tmp/bond.${bondname}.info
echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info
echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info
echo "bondmtu=\"$bondmtu\"" >> /tmp/bond.${bondname}.info
done

View File

@@ -78,6 +78,7 @@ for p in $(getargs ip=); do
die "Sorry, automatic calculation of netmask is not yet supported"
;;
auto6);;
either6);;
dhcp|dhcp6|on|any) \
#[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
# die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"

View File

@@ -9,7 +9,7 @@ check() {
require_binaries btrfs || return 1
[[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in ${host_fs_types[@]}; do
for fs in "${host_fs_types[@]}"; do
[[ "$fs" == "btrfs" ]] && return 0
done
return 255

View File

@@ -0,0 +1,22 @@
#!/bin/bash
command -v
check() {
require_binaries ntfs-3g || return 1
return 255
}
depends() {
echo dmsquash-live
return 0
}
install() {
inst_multiple fusermount ulockmgr_server mount.fuse ntfs-3g
dracut_need_initqueue
}
installkernel() {
hostonly='' instmods fuse
}

View File

@@ -79,7 +79,20 @@ if [ -f $livedev ]; then
esac
[ -e /sys/fs/$fstype ] || modprobe $fstype
else
mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live
if [ "$(blkid -o value -s TYPE $livedev)" != "ntfs" ]; then
mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live
else
# Symlinking /usr/bin/ntfs-3g as /sbin/mount.ntfs seems to boot
# at the first glance, but ends with lots and lots of squashfs
# errors, because systemd attempts to kill the ntfs-3g process?!
if [ -x "/usr/bin/ntfs-3g" ]; then
( exec -a @ntfs-3g ntfs-3g -o ${liverw:-ro} $livedev /run/initramfs/live ) | vwarn
else
die "Failed to mount block device of live image: Missing NTFS support"
exit 1
fi
fi
if [ "$?" != "0" ]; then
die "Failed to mount block device of live image"
exit 1

View File

@@ -45,7 +45,7 @@ installkernel() {
instmods yenta_socket scsi_dh_rdac scsi_dh_emc scsi_dh_alua \
atkbd i8042 usbhid firewire-ohci pcmcia hv-vmbus \
atkbd i8042 usbhid firewire-ohci pcmcia usb_storage \
nvme hv-vmbus sdhci_acpi
nvme hv-vmbus sdhci_acpi nfit
instmods \
"=drivers/hid" \
@@ -83,7 +83,7 @@ installkernel() {
instmods '=fs'
fi
else
for i in $(host_fs_all); do
for i in "${host_fs_types[@]}"; do
hostonly='' instmods $i
done
fi

View File

@@ -109,9 +109,9 @@ if [ -n "$LVS" ] ; then
lvm lvscan --ignorelockingfailure 2>&1 | vinfo
for LV in $LVS; do
if [ -z "$sysinit" ]; then
lvm lvchange --yes -ay --ignorelockingfailure $nopoll --ignoremonitoring $LV 2>&1 | vinfo
lvm lvchange --yes -K -ay --ignorelockingfailure $nopoll --ignoremonitoring $LV 2>&1 | vinfo
else
lvm lvchange --yes -ay $sysinit $LV 2>&1 | vinfo
lvm lvchange --yes -K -ay $sysinit $LV 2>&1 | vinfo
fi
done
fi

View File

@@ -43,7 +43,7 @@ cmdline() {
}
installkernel() {
instmods dm-snapshot
hostonly='' instmods dm-snapshot
}
# called by dracut

View File

@@ -2,34 +2,69 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
_md_force_run() {
type getargs >/dev/null 2>&1 || . /lib/dracut-lib.sh
_md_start() {
local _udevinfo
local _path_s
local _path_d
local _md="$1"
local _offroot="$2"
_udevinfo="$(udevadm info --query=env --name="${_md}")"
strstr "$_udevinfo" "MD_LEVEL=container" && continue
strstr "$_udevinfo" "DEVTYPE=partition" && continue
_path_s="/sys/$(udevadm info -q path -n "${_md}")/md/array_state"
[ ! -r "$_path_s" ] && continue
# inactive ?
[ "$(cat "$_path_s")" != "inactive" ] && continue
mdadm $_offroot -R "${_md}" 2>&1 | vinfo
# still inactive ?
[ "$(cat "$_path_s")" = "inactive" ] && continue
_path_d="${_path_s%/*}/degraded"
[ ! -r "$_path_d" ] && continue
> $hookdir/initqueue/work
}
_md_force_run() {
local _offroot
local _md
local _UUID
local _MD_UUID=$(getargs rd.md.uuid -d rd_MD_UUID=)
[ -n "$_MD_UUID" ] || getargbool 0 rd.auto || return
_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
# try to force-run anything not running yet
for md in /dev/md[0-9_]*; do
[ -b "$md" ] || continue
_udevinfo="$(udevadm info --query=env --name="$md")"
strstr "$_udevinfo" "MD_LEVEL=container" && continue
strstr "$_udevinfo" "DEVTYPE=partition" && continue
_path_s="/sys/$(udevadm info -q path -n "$md")/md/array_state"
[ ! -r "$_path_s" ] && continue
if [ -n "$_MD_UUID" ]; then
for _md in /dev/md[0-9_]*; do
[ -b "$_md" ] || continue
_UUID=$(
/sbin/mdadm -D --export "$_md" \
| while read line || [ -n "$line" ]; do
str_starts "$line" "MD_UUID=" || continue
printf "%s" "${line#MD_UUID=}"
done
)
# inactive ?
[ "$(cat "$_path_s")" != "inactive" ] && continue
[ -z "$_UUID" ] && continue
mdadm $_offroot -R "$md" 2>&1 | vinfo
# check if we should handle this device
strstr " $_MD_UUID " " $_UUID " || continue
# still inactive ?
[ "$(cat "$_path_s")" = "inactive" ] && continue
_path_d="${_path_s%/*}/degraded"
[ ! -r "$_path_d" ] && continue
done
_md_start "${_md}" "${_offroot}"
done
else
# try to force-run anything not running yet
for _md in /dev/md[0-9_]*; do
[ -b "$_md" ] || continue
_md_start "${_md}" "${_offroot}"
done
fi
}
_md_force_run

View File

@@ -26,6 +26,9 @@ else
done < "${f}" > "${f}.new"
mv "${f}.new" "$f"
done
for uuid in $MD_UUID; do
wait_for_dev "/dev/disk/by-id/md-uuid-${uuid}"
done
fi
fi

View File

@@ -105,7 +105,7 @@ install() {
/etc/multipath.conf \
/etc/multipath/*
[[ $hostonly ]] && {
[[ $hostonly ]] && [[ $hostonly_mode = "strict" ]] && {
for_each_host_dev_and_slaves_all add_hostonly_mpath_conf
[ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf
}

View File

@@ -7,7 +7,7 @@ check() {
require_binaries mount.cifs || return 1
[[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in ${host_fs_types[@]}; do
for fs in "${host_fs_types[@]}"; do
[[ "$fs" == "cifs" ]] && return 0
done
return 255

View File

@@ -87,8 +87,8 @@ elif [ "$netdriver" = "bnx2x" ]; then
# If driver is bnx2x, do not use /sys/module/fcoe/parameters/create but fipvlan
modprobe 8021q
udevadm settle --timeout=30
# Sleep for 3 s to allow dcb negotiation
sleep 3
# Sleep for 13 s to allow dcb negotiation
sleep 13
fipvlan "$netif" -c -s
else
vlan="no"

View File

@@ -51,16 +51,30 @@ cmdline() {
read mac < ${i}/address
s=$(dcbtool gc ${i##*/} dcb | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
if [ -z "$s" ] ; then
p=$(get_vlan_parent ${i})
if [ "$p" ] ; then
s=$(dcbtool gc ${p} dcb | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
fi
p=$(get_vlan_parent ${i})
if [ "$p" ] ; then
s=$(dcbtool gc ${p} dcb | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
fi
fi
if [ "$s" = "on" ] ; then
dcb="dcb"
dcb="dcb"
else
dcb="nodcb"
dcb="nodcb"
fi
# Some Combined Network Adapters(CNAs) implement DCB in firmware.
# Do not run software-based DCB or LLDP on CNAs that implement DCB.
# If the network interface provides hardware DCB/DCBX capabilities,
# DCB_REQUIRED in "/etc/fcoe/cfg-xxx" is expected to set to "no".
#
# Force "nodcb" if there's any DCB_REQUIRED="no"(child or vlan parent).
grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${i##*/} &>/dev/null
[ $? -eq 0 ] && dcb="nodcb"
if [ "$p" ] ; then
grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${p} &>/dev/null
[ $? -eq 0 ] && dcb="nodcb"
fi
echo "fcoe=${mac}:${dcb}"
done
}

View File

@@ -46,8 +46,9 @@ fi
handle_firmware()
{
if ! iscsistart -f; then
warn "iscistart: Could not get list of targets from firmware."
return 1
warn "iscistart: Could not get list of targets from firmware. Skipping."
echo 'skipped' > "/tmp/iscsistarted-firmware"
return 0
fi
for p in $(getargs rd.iscsi.param -d iscsi_param); do
@@ -196,6 +197,11 @@ handle_netroot()
${iscsi_netdev_name:+--param "iface.net_ifacename=$iscsi_netdev_name"} \
${iscsi_param} >/dev/null 2>&1 \
&& { > $hookdir/initqueue/work ; }
while : ; do
status=$(systemctl is-active "$netroot_enc" 2>/dev/null)
[ "$status" != "activating" ] && break
sleep 1
done
else
systemctl --no-block restart "$netroot_enc" >/dev/null 2>&1 \
&& { > $hookdir/initqueue/work ; }

View File

@@ -23,8 +23,10 @@ check() {
[[ $hostonly ]] || [[ $mount_needs ]] && {
pushd . >/dev/null
for_each_host_dev_and_slaves is_iscsi || return 255
for_each_host_dev_and_slaves is_iscsi
local _is_iscsi=$?
popd >/dev/null
[[ $_is_iscsi == 0 ]] || return 255
}
return 0
}

View File

@@ -8,7 +8,7 @@ check() {
require_binaries rpc.statd mount.nfs mount.nfs4 umount || return 1
[[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in ${host_fs_types[@]}; do
for fs in "${host_fs_types[@]}"; do
[[ "$fs" == "nfs" ]] && return 0
[[ "$fs" == "nfs3" ]] && return 0
[[ "$fs" == "nfs4" ]] && return 0

View File

@@ -32,7 +32,7 @@ cmdline_journal() {
cmdline() {
local dev=/dev/block/$(find_root_block_device)
if [ -e $dev ]; then
if [ -e $dev ] && [ -n "$root_dev" ] ; then
printf " root=%s" "$(shorten_persistent_dev "$(get_persistent_dev "$dev")")"
printf " rootflags=%s" "$(find_mp_fsopts /)"
printf " rootfstype=%s" "$(find_mp_fstype /)"

View File

@@ -4,7 +4,7 @@
check() {
[[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in ${host_fs_types[@]}; do
for fs in "${host_fs_types[@]}"; do
[[ "$fs" == "9p" ]] && return 0
done
return 255

View File

@@ -166,7 +166,7 @@ install() {
}
_mods=$(modules_load_get /usr/lib/modules-load.d)
[[ $_mods ]] && instmods $_mods
[[ $_mods ]] && hostonly='' instmods $_mods
if [[ $hostonly ]]; then
inst_multiple -o \
@@ -181,7 +181,7 @@ install() {
/etc/sysctl.conf
_mods=$(modules_load_get /etc/modules-load.d)
[[ $_mods ]] && instmods $_mods
[[ $_mods ]] && hostonly='' instmods $_mods
fi
if ! [[ -e "$initdir/etc/machine-id" ]]; then

View File

@@ -1,6 +1,4 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
@@ -10,32 +8,80 @@ generator_wait_for_dev()
local _timeout
_name="$(str_replace "$1" '/' '\x2f')"
_timeout=$(getarg rd.timeout)
_timeout=${_timeout:-0}
[ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
if ! [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ]; then
printf '[ -e "%s" ]\n' $1 \
>> "$hookdir/initqueue/finished/devexists-${_name}.sh"
{
printf '[ -e "%s" ] || ' $1
printf 'warn "\"%s\" does not exist"\n' $1
} >> "$hookdir/emergency/80-${_name}.sh"
_name=$(dev_unit_name "$1")
if ! [ -L /run/systemd/generator/initrd.target.wants/${_name}.device ]; then
[ -d /run/systemd/generator/initrd.target.wants ] || mkdir -p /run/systemd/generator/initrd.target.wants
ln -s ../${_name}.device /run/systemd/generator/initrd.target.wants/${_name}.device
printf '[ -e "%s" ]\n' $1 \
>> "$hookdir/initqueue/finished/devexists-${_name}.sh"
{
printf '[ -e "%s" ] || ' $1
printf 'warn "\"%s\" does not exist"\n' $1
} >> "$hookdir/emergency/80-${_name}.sh"
fi
if ! [ -f /run/systemd/generator/${_name}.device.d/timeout.conf ]; then
_timeout=$(getarg rd.device.timeout || printf "0")
mkdir -p /run/systemd/generator/${_name}.device.d
_name=$(dev_unit_name "$1")
if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/${_name}.device ]; then
[ -d "$GENERATOR_DIR"/initrd.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd.target.wants
ln -s ../${_name}.device "$GENERATOR_DIR"/initrd.target.wants/${_name}.device
fi
if ! [ -f "$GENERATOR_DIR"/${_name}.device.d/timeout.conf ]; then
mkdir -p "$GENERATOR_DIR"/${_name}.device.d
{
echo "[Unit]"
echo "JobTimeoutSec=$_timeout"
} > /run/systemd/generator/${_name}.device.d/timeout.conf
} > "$GENERATOR_DIR"/${_name}.device.d/timeout.conf
fi
}
generator_mount_rootfs()
{
local _type=$2
local _flags=$3
local _name
[ -z "$1" ] && return 0
_name=$(dev_unit_name "$1")
[ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
if ! [ -f "$GENERATOR_DIR"/sysroot.mount ]; then
{
echo "[Unit]"
echo "Before=initrd-root-fs.target"
echo "Requires=systemd-fsck@${_name}.service"
echo "After=systemd-fsck@${_name}.service"
echo "[Mount]"
echo "Where=/sysroot"
echo "What=$1"
echo "Options=${_flags}"
echo "Type=${_type}"
} > "$GENERATOR_DIR"/sysroot.mount
fi
if ! [ -L "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount ]; then
[ -d "$GENERATOR_DIR"/initrd-root-fs.target.requires ] || mkdir -p "$GENERATOR_DIR"/initrd-root-fs.target.requires
ln -s ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount
fi
}
generator_fsck_after_pre_mount()
{
local _name
[ -z "$1" ] && return 0
_name=$(dev_unit_name "$1")
[ -d /run/systemd/generator/systemd-fsck@${_name}.service.d ] || mkdir -p /run/systemd/generator/systemd-fsck@${_name}.service.d
if ! [ -f /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf ]; then
{
echo "[Unit]"
echo "After=dracut-pre-mount.service"
} > /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf
fi
}
root=$(getarg root=)
case "$root" in
block:LABEL=*|LABEL=*)
@@ -62,6 +108,12 @@ case "$root" in
rootok=1 ;;
esac
[ "${root%%:*}" = "block" ] && generator_wait_for_dev "${root#block:}"
GENERATOR_DIR="$1"
if [ "$rootok" = "1" ]; then
generator_wait_for_dev "${root#block:}" "$RDRETRY"
generator_fsck_after_pre_mount "${root#block:}"
strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
fi
exit 0

View File

@@ -868,13 +868,32 @@ wait_for_mount()
} >> "$hookdir/emergency/90-${_name}.sh"
}
# get a systemd-compatible unit name from a path
# (mimicks unit_name_from_path_instance())
dev_unit_name()
{
_name="${1%%/}"
_name="${_name##/}"
_name="$(str_replace "$_name" '-' '\x2d')"
_name="$(str_replace "$_name" '/' '-')"
echo "$_name"
local dev="$1"
if command -v systemd-escape >/dev/null; then
systemd-escape -p -- "$dev"
return
fi
if [ "$dev" = "/" -o -z "$dev" ]; then
printf -- "-"
exit 0
fi
dev="${1%%/}"
dev="${dev##/}"
dev="$(str_replace "$dev" '\' '\x5c')"
dev="$(str_replace "$dev" '-' '\x2d')"
if [ "${dev##.}" != "$dev" ]; then
dev="\x2e${dev##.}"
fi
dev="$(str_replace "$dev" '/' '-')"
printf -- "%s" "$dev"
}
# wait_for_dev <dev>

View File

@@ -103,13 +103,13 @@ install() {
. "$moddir/dracut-lib.sh"
for _dev in ${host_devs[@]}; do
for _dev in "${host_devs[@]}"; do
[[ "$_dev" == "$root_dev" ]] && continue
# We only actually wait for real devs - swap is only needed
# for resume and udev rules generated when parsing resume=
# argument take care of the waiting for us
for _dev2 in ${swap_devs[@]}; do
for _dev2 in "${swap_devs[@]}"; do
[[ "$_dev" == "$_dev2" ]] && continue 2
done