Commit Graph

194 Commits (2b1b3bcdcb0ddaa18337f18da515adb6284df0ab)

Author SHA1 Message Date
Kairui Song a0d9ad6f70 dracut.sh: record the actual hostonly modules for hostonly mode
Previous in commit 7047294, dracut will include the loaded kernel module
list in initramfs, so other tools could check if the loaded kernel
module is changed and rebuild the host only initramfs in case some
module required to boot the machine is missing due to host only install.

It's better to use modalias list generated by dracut-install, that
list includes the device modalias list combined with current loaded
kernel module list. In this way, if any kernel module is yet to be
loaded when the initramfs is built, or got unloaded by accident the
module list will not change. This make the list more stable over
initramfs builds.

Signed-off-by: Kairui Song <kasong@redhat.com>
2019-07-19 15:38:13 +02:00
Lukas Nykryn a762dedb60 dracut-functions: fix the word splitting 2018-08-09 13:13:52 +02:00
Kairui Song 7047294617 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
2018-07-18 11:50:18 +02:00
Harald Hoyer e64dafd1f2 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
2018-02-19 09:05:01 +01:00
Martin Wilck b6054b5de6 Give --persistent_policy precedence over /dev/mapper names
There is currently no way to override dracut's preference for
/dev/mapper device names. But using these is problematic in
different scenarios: For example, if a user has a multipath-
enabled system but wants to disable multipath, or if the
names of multipath maps change because of configuration changes
(e.g. toggling user_friendly_names in /etc/multipath.conf).

This patch makes dracut prefer the user-specified
--persistent_policy names over /dev/mapper names.

It might be worthwhile to discuss why dracut prefers /dev/mapper
of /dev/disk/by-uuid at all. This preference was introduced
in 9037b63e with the argument "dm devices maintain /dev/mapper/* as
persistent names", but that's wrong for the scenarios mentioned
above, and is not a compelling reason for preferring /dev/mapper
over /dev/disk/by-uuid.

References: bsc#908143

Signed-off-by: Martin Wilck <mwilck@suse.de>
2018-01-17 12:05:44 +01:00
Harald Hoyer 9ed6eb741f 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.
2018-01-15 15:47:17 +01:00
Daniel Molkentin 19453dc874 Simplify microcode lookup for for AMD CPUs
Suggested by Tom Lendacky <thomas.lendacky@amd.com>
2017-12-14 12:25:50 +01:00
Daniel Molkentin 215fe58324 Support Microcode Updates for AMD CPU Family 0x17
Original-Patch-By: Tom Lendacky <thomas.lendacky@amd.com>
2017-12-13 01:42:52 +01:00
Pingfan Liu e6199960d9 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>
2017-12-04 11:04:53 +01:00
jonathan-teh af6eee79e3 Add early microcode support for AMD family 16h 2017-07-29 00:19:19 +01:00
Harald Hoyer c7c8c4981a dracut-functions.sh: catch all lvm slaves
add check_vol_slaves_all to be used in check_block_and_slaves_all

otherwise only the first lvm VG member would be processed

(cherry picked from commit 7a7b8c1740)
2016-08-19 15:49:33 +02:00
Harald Hoyer 9e19c0512d Revert "network: remove awk call and replace it with a shell function"
This reverts commit 71867b665c.

network needs posix shell
2016-06-07 14:27:35 +02:00
Harald Hoyer 71867b665c network: remove awk call and replace it with a shell function
changes commit 4fa5c235a7
2016-06-07 11:15:07 +02:00
Harald Hoyer 1901500187 move ln_r() to dracut-init.sh 2016-05-25 15:07:08 +02:00
Harald Hoyer 2fd8588da5 dracut-functions.sh:fix check_vol_slaves() volume group name stripping
commit 466a59984a removed whitespace
stripping from lvm volume group names.
2016-01-18 17:01:15 +01:00
Harald Hoyer 561eb42f39 reduce dracut-functions.sh and add to dracut-init.sh
move all dracut specific functions to dracut-init.sh
2015-11-13 13:06:01 +01:00
Harald Hoyer eed08b6988 Merge branch 'master' of github.com:haraldh/dracut 2015-09-07 15:13:04 +02:00
Harald Hoyer ea877ac6cc dracut-functions.sh: fixed dracutbasedir, when sourced directly 2015-09-03 12:31:34 +02:00
Lidong Zhong 9918afd244 dracut-functions.sh: remove duplicate declaratio of local variable 2015-08-24 18:03:02 +08:00
Harald Hoyer 32de4eb5d3 dracut-functions.sh: simplify some for loops
continue early, if condition is not met
2015-07-09 15:36:25 +02:00
Harald Hoyer 3721635b2c guard ${arrays[@]} with "" 2015-07-09 15:36:25 +02:00
Harald Hoyer 1cadc26fd4 Add all btrfs devices
We have to find them with "btrfs usage", which is cumbersome.
2015-07-09 15:36:25 +02:00
Harald Hoyer 777f2db037 splitup dracut-init.sh from dracut-functions.sh
other tools want to source dracut-functions.sh without any mkdir side
effects.
2015-07-02 16:04:05 +02:00
Harald Hoyer 1339095dba dracut-functions.sh: only honor the first [0-9]+<module> dir
If multiple directories with different numbers exist, only honor the
first one.
2015-06-09 15:05:32 +02:00
Harald Hoyer 27c9d1f20f Merge remote-tracking branch 'github/master' 2015-05-18 13:28:00 +02:00
Harald Hoyer 6d58fa27a4 change "while read x" to cope with EOF without newline
while read x || [ -n "$x" ]

should do the trick
2015-04-28 11:39:15 +02:00
Lukas Nykryn b0b60c8e05 dracut-functions: use [[ ]] with -n and no quotes 2015-04-27 11:40:54 +02:00
Lubomir Rintel c59779cf93 dracut-functions.sh: avoid tokenizing ldconfig output with 'read'
The space does not separate the elements reliably, spaces can be
embedded in parenthesized expressions too:

  libgmpxx.so.4 (libc6, hwcap: 0x0000000004000000) => /lib/sse2/libgmpxx.so.4
  libgmp.so.10 (libc6, hwcap: 0x0000000004000000) => /lib/sse2/libgmp.so.10

This results in dracut creating '0x0000000004000000' and '=>'
directories in the initramfs image.
2015-01-08 15:34:03 +01:00
Harald Hoyer bea41b898a dracut-functions.sh: for module handling, strip all ".ko*"
Just strip anything after ".ko" including ".ko", otherwise compressed
modules are not stripped, if they end on e.g. ".ko.gz"
2014-12-17 11:22:46 +01:00
Thomas Renninger 8d40852e8c dracut: Do not stop installing drivers if one fails
--add-drivers and --filesystems kernel drivers are added via:
instmods -c
The check option makes the function return if one driver could not get
installed without trying to install further drivers which is bad.

The user is still informed ($_silent is by default no), but all modules
passed to instmods are tried to be loaded, even if one fails.

Signed-off-by: Thomas Renninger <trenn@suse.de>
2014-12-16 13:29:36 +01:00
Hannes Reinecke 3ae60e559f Handle module alias properly
Some modules (like ext4) provide aliases by which the modules
can be accessed, too. But when using aliases directly dracut
fails to include the correct module. So translate the alias
into the correct module name before checking the module.

References: bnc#886839

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2014-12-16 13:29:36 +01:00
Hannes Reinecke 3244bf5981 Do not call 'lvm' for non-LVM device-mapper devices
If a device-mapper device is not created by LVM it's pointless
to call any 'lvm' programs got extract details; they'll be
failing anyway. So check the UUID before calling 'lvm'.
This speeds up initrd creation and avoids I/O errors on
multipath devices.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2014-12-16 13:29:36 +01:00
Harald Hoyer 26d14fb3d3 dracut-functions.sh: check if dinfo is a function
If "dinfo" is an executable, dracut-logger.sh would never be sourced.

See: https://bugzilla.redhat.com/show_bug.cgi?id=1167082
2014-11-24 15:17:45 +01:00
Harald Hoyer 2f0f1b0bbc dracut-functions.sh: fixup for 34a1ec6 for non-local mode 2014-10-29 13:39:28 +01:00
Stefan Reimer 972d6b44ba Fix location of dracut-install for local mode 2014-10-28 17:58:56 -07:00
Harald Hoyer ab2f95e45e dracut: fixed module dependency handling
Fail for "--modules" and "--force-add" dracut modules, if they or their
dependencies cannot be included.
2014-10-24 13:19:58 +02:00
Harald Hoyer a49cac2e65 dracut-functions.sh: exit for missing --force-add or --add dracut modules
Better exit with fail early, so there is no surprise on reboot.
2014-09-12 10:19:28 +02:00
Harald Hoyer 37383f7123 add "--loginstall <DIR>" and loginstall="<DIR>" options
loginstall specifies a directory, in which dracut-install records all
files, which were installed from the host system to the initramfs.

Use case is e.g. to create a list of packages to watch for updates, to
maybe trigger a recreation of the initramfs.
2014-09-11 16:42:36 +02:00
Harald Hoyer 967cc19ab1 remove all vim and emacs code format comments 2014-08-29 13:38:47 +02:00
Harald Hoyer 8e3f653749 Check kernel config for early microcode and ACPI override
Disable early microcode and ACPI override, if the kernel does not
support it.
2014-08-20 10:13:55 +02:00
Harald Hoyer 9efb74a32d dracut-functions.sh:get_persistent_dev(): use printf, instead of echo 2014-08-15 12:36:04 +02:00
WANG Chao a628b7caf5 dracut-functions: get_persistent_dev() fall back to the original name
In case of raw disk/partition, ex. /dev/vda1, which doesn't contain any
filesystem on it. get_persistent_dev() would return empty. Now fix it to
return its original name, /dev/vda1 in above case. So that we don't have
to check its return string every time.

Signed-off-by: WANG Chao <chaowang@redhat.com>
2014-08-15 12:35:01 +02:00
Harald Hoyer 4ef45f13f4 dracut-functions.sh: fix inst*() functions for "-H" handling
because some inst*() functions check the existance of the source files
and do not know about the "-H" option, some failed to install the
hostonly files.
2014-07-21 16:59:49 +02:00
Harald Hoyer 5ea0be0a8c dracut-functions.sh: speed up ldconfig_paths() 2014-07-08 12:54:21 +02:00
Harald Hoyer 26cd262a6a install: add -H flag for install
inst* functions and dracut-install now accept the "-H" flag, which
logs all installed files to /lib/dracut/hostonly-files. This is used
to remove those files, if rd.hostonly is given on the kernel command line.
2014-06-25 11:42:53 +02:00
Harald Hoyer 0fa5dbedc5 dracut-functions.sh:require_binaries() clarify message
The info message written by require_binaries() was a bit frighten to
users. So just be a little bit more verbose.

If you have ideas on how to improve the message for these "soft"
dependency modules, please submit patches.
2014-05-20 13:23:43 +02:00
Harald Hoyer 7a94a4326f dracut-functions.sh:print_vars() fix for values with spaces
for a variable with spaces, e.g.:
EXT_KEYMAPS='backspace keypad euro2'

The following would occur:
print_vars: eval printf -v _value %s '$EXT_KEYMAPS'
print_vars: printf -v _value %s backspace keypad euro2
print_vars: [[ -n backspacekeypadeuro2 ]]
print_vars: printf '%s=\"%s\"\n' EXT_KEYMAPS backspacekeypadeuro2

Thanks to Sebastian Köln for the fix!
2014-05-20 11:31:16 +02:00
Chapman Flack 2c19a5fa78 Specify strstr tightly, add strglob/strglobin.
By convention, strstr should be a literal string match. Previously, it
would match as a glob pattern. Some code used that, so add new
functions strglob and strglobin to do what that code expects, and
specify them tightly too. strglob tests whether the glob pattern
matches the entire string (the name strglob is also used in the yorick
language, and that's what it does there), while strglobin tests whether
the glob pattern matches anywhere in the string.

Also tightens str_starts, str_ends, and str_replace to deal with
literal strings only. In a quick grep I did not find code that depended
on these functions matching globs.

Changes the call sites where strstr was used with glob patterns to use
strglobin or strglob as the intention seemed to be (or, in one case,
strstr with the * removed as it did not affect the result anyway).
2014-04-07 10:49:07 +02:00
Harald Hoyer 83a3cba777 dracut-functions.sh: degrade info about missing binaries to info 2014-03-05 12:23:49 +01:00
Harald Hoyer e8a7c9bc93 dracut-functions.sh:find_kernel_modules_by_path() fixed updates search
"updates/*" path does not start with "/"
2014-02-17 13:29:42 +01:00