Commit Graph

209 Commits (b80ee080937ce364f7324c297f23e40af6d88892)

Author SHA1 Message Date
Kairui Song 122657b2fe fix(dracut-functions): word splitting issue for sed in get_ucode_file
This unquated regex could be splitted into two arguments and sed will
not work. I've see giving error of wrong arguments being used on my
desktop.

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-04-12 09:17:18 +02:00
Harald Hoyer 2b5ddc7722 fix: shellcheck for dracut*.sh 2021-03-29 09:54:52 +02:00
Harald Hoyer 75d758e8f1 style: shfmt -s reformat
reproducible with:

```
$ shfmt_version=3.0.1
$ wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O shfmt
$ chmod u+x shfmt
$ ./shfmt -w -s .
```
2021-03-13 20:10:43 +01:00
Harald Hoyer 9a52c3fdb0 style: shfmt reformat
reproducible with:

```
$ shfmt_version=3.0.1
$ wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O shfmt
$ chmod u+x shfmt
$ ./shfmt -w .
```
2021-03-13 20:10:43 +01:00
Harald Hoyer 3483509ef6 fix: shellcheck for dracut-functions.sh 2021-02-15 11:00:37 +01:00
Zoltán Böszörményi 560f45b15f fix(dracut-functions.sh): check kernel config from $dracutsysrootdir
Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu>
2021-01-21 16:33:18 +00:00
Kairui Song cbafcd0fc7 dracut-init.sh: Add a helper for detect device kernel modules
Use udevadm to detect the required kernel modules to load a given
device. udevadm will follow the device chain, help detect all required
parent device drivers as well.

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-10-30 10:13:37 +01:00
Kairui Song ab17cb8515 dracut-functions.sh: Fix check_block_and_slaves_all
check_block_and_slaves_all $func $dev should return 0, if $func return 0
for any checked device. Currently if any device don't have any sub
device, 1 is returned instead.

So remove the sub device checking statement. Also remove the same
statement in check_block_and_slaves, the "[[ -f $_x/dev ]]" in the for
loop is enought to ensure sub device exists.

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-10-30 10:13:37 +01:00
Kairui Song c050190f86 dracut-functions: add a helper to check if kernel module is available
It's like check_kernel_config, help to check if a kernel module is
enabled (cover built-in or compiled module case).

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-10-21 17:04:00 +02:00
Daniel Molkentin 480aa9695f 95resume: Do not resume on iSCSI, FCoE or NBD
The iSCSI configuration is started after dracut checks for resume,
so we run into a timeout here. Additionally it's questionable if
resume on iSCSI makes sense (or is even supported on the platform).

Same holds true for Network Block Devices and FcOE, cover those as well

References: bsc#999663

Original-patch-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Daniel Molkentin <daniel.molkentin@suse.com>
2020-08-04 10:37:57 +02:00
Martin Wilck ceca74ccc3 dracut-functions: add ip_params_for_remote_addr() helper
This helper function takes a remote IP address, and tries to
determine the dracut command line arguments ip= and ifname= that
will make this remote address reachable during boot.

Functionality was taken from the module-setup.sh scripts of 95iscsi and 95nfs,
cleaned up and fixed some issues in particular with statically configured
networks, where the old code would print the unsupported string
"$ifname:static".
2020-08-04 08:43:32 +02:00
Alexander Tsoy f769154bcc dracut-functions: fix find_binary() to return full path
Fixes: a01204202b (Allow running on a cross-compiled rootfs)
2020-05-29 10:27:59 +02:00
Böszörményi Zoltán a01204202b Allow running on a cross-compiled rootfs
For the shell scripts, new environment variables were introduced.

dracutsysrootdir is the root directory, file existence checks use it.

DRACUT_LDCONFIG can override ldconfig with a different one that works
on the sysroot with foreign binaries.

DRACUT_LDD can override ldd with a different one that works
with foreign binaries.

DRACUT_TESTBIN can override /bin/sh. A cross-compiled sysroot
may use symlinks that are valid only when running on the target
so a real file must be provided that exist in the sysroot.

DRACUT_INSTALL now supports debugging dracut-install in itself
when run by dracut but without debugging the dracut scripts.
E.g. DRACUT_INSTALL="valgrind dracut-install or
DRACUT_INSTALL="dracut-install --debug".

DRACUT_COMPRESS_BZIP2, DRACUT_COMPRESS_LBZIP2, DRACUT_COMPRESS_LZMA,
DRACUT_COMPRESS_XZ, DRACUT_COMPRESS_GZIP, DRACUT_COMPRESS_PIGZ,
DRACUT_COMPRESS_LZOP, DRACUT_COMPRESS_ZSTD, DRACUT_COMPRESS_LZ4,
DRACUT_COMPRESS_CAT: All of the compression utilities may be
overridden, to support the native binaries in non-standard places.

DRACUT_ARCH overrides "uname -m".

SYSTEMD_VERSION overrides "systemd --version".

The dracut-install utility was overhauled to support sysroot via
a new option -r and fixes for clang-analyze. It supports
cross-compiler-ldd from
https://gist.github.com/jerome-pouiller/c403786c1394f53f44a3b61214489e6f

DRACUT_INSTALL_PATH was introduced so dracut-install can work with
a different PATH. In a cross-compiled environment (e.g. Yocto), PATH
points to natively built binaries that are not in the host's /bin,
/usr/bin, etc. dracut-install still needs plain /bin and /usr/bin
that are relative to the cross-compiled sysroot.

The hashmap pool allocate_tile/deallocate_tile code was removed
because clang-analyze showed errors in it. hashmap_copy was removed
because it wasn't used and clang-analyze showed errors in it.

DRACUT_INSTALL_LOG_TARGET and DRACUT_INSTALL_LOG_LEVEL were
introduced so dracut-install can use different settings from
DRACUT_LOG_TARGET and DRACUT_LOG_LEVEL.

Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>
2019-10-25 11:58:58 +02:00
gaoyi da36b76ab0 dracut: check_vol_slaves_all must return 1 when lvm vgs failed
reason:when filter/global_filter is set in lvm.conf, lvm vgs may be
failed

Signed-off-by: gaoyi <ymuemc@163.com>
2019-10-23 14:38:11 +02:00
Daniel Molkentin 224175d8bc dracut-functions.sh: remove declared unused variables 2019-10-22 13:50:36 +02:00
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