Commit Graph

57 Commits (d1a36d3d80b0ed71ee814659e18a020c53cee05e)

Author SHA1 Message Date
Harald Hoyer 7b8c78ff43 fix(multipath): revise multipathd-stop
A shellcheck regression quoted `HARD` in
```shell
    kill "$HARD" "$pid" > /dev/null 2>&1
```

which would error on an empty "HARD".

Instead of fixing this, use `pkill` instead and also add it to the
non-optional list of binaries to install, which was revised also.

Fixes: https://github.com/dracutdevs/dracut/issues/1275
2021-03-31 11:30:10 +02:00
Harald Hoyer 85378f44af fix(multipath): shellcheck regression
`$_allow` should not have been quoted, because it can be multiple options.

Instead of unquoting it, convert it to an associative array with easy
deduplication and prefix every device with the `--allow` option.

Fixes: https://github.com/dracutdevs/dracut/issues/1274
2021-03-31 11:29:31 +02:00
Harald Hoyer 80f5e83ed5 fix(multipath): shellcheck for modules.d/90multipath 2021-03-29 10:52:28 +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
Zoltán Böszörményi 18d36fabf5 feat(dracut.sh): allow overriding the systemctl command for sysroot
Allow overriding the systemctl command for sysroot with $SYSTEMCTL
Modified every modules' module-setup.sh to use the envvar instead
of the hardcoded command name.

Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu>
2021-02-09 07:09:28 +00:00
David Tardon 0f89c0dff6 90multipath: install kpartx's 11-dm-parts.rules
This makes /dev/disk/by-uuid links point to the right device.
2020-11-14 15:15:13 +01:00
Ben Howard b8a92b7156 multipath: add automatic configuration for multipath
Add support for 'rd.multipath=default' for using the default
configuration on boot. The intended purpose for this is to help support
ostree-based image boots from multipathed devices (such as Fedora and
Red Hat CoreOS).
2020-04-03 23:48:32 +02:00
Jan Macku 70b19acf94 Replace ln with systemctl 2020-01-14 09:29:51 +01:00
Doan Tran Cong Danh cf31ed2ae6 multipath: require kpartx binary
multipath requires kpartx to activate device mapper.
But kpartx is only a recommend dependency.

Check for kpartx's existent first.

Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
2019-11-10 01:47:30 +01: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
Kairui Song 35e86ac117 Merge 90-multipath-hostonly and 90-multipath
This commit basically reverts 5ce7cc73

90-multipath-hostonly module was added in 5ce7cc73, because if hostonly
mode is enabled, multipath module will always hardcode wwids which
causes problems when the initramfs is cloned to another system with same
hardware.

Now with tri-state hostonly mode, the two modules could be merged and only
hardcode wwids when "strict" hostonly mode is enabled.
2018-07-05 13:17:19 +02:00
Hannes Reinecke d842d5cf9e 90multipath: load dm_multipath module during startup
As the 'multipath' program will be triggered directly from
udev events it will be called before the multipath service
unit has started up. Which means we cannot rely on the
service unit to load the module for us, but we rather
have to do it early before udev is started.

References: bsc#986734

Signed-off-by: Hannes Reinecke <hare@suse.com>
2018-01-16 16:30:53 +01:00
Hannes Reinecke 239e8ba2ac 90multipath: add shutdown script
As the device-mapper module is removing all device-mapper tables
during shutdown we need to make sure to disable queuing on the
multipath devices; otherwise there might still be I/O pending
and the removal will fail.

References: bsc#994860

Signed-off-by: Hannes Reinecke <hare@suse.com>
2017-12-15 20:42:15 +01:00
Fabian Vogt ee6b44342b Fix warning about multipath if not needed
Although no device uses multipath, the module checks
for presence of the multipath binary first, printing a
warning if not present. This patch fixes the wrong ordering.
2017-11-30 16:51:15 +01:00
Daniel Molkentin d000b9a2c7 95multipath: Pickup files in /etc/multipath/conf.d
Reference: boo#1048551
2017-08-30 09:05:19 +02:00
Harald Hoyer 5ce7cc7337 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
2017-07-10 13:28:40 +02:00
Harald Hoyer 3f60444ec1 removed obsolete kernel module functions and host_modules variable
module_is_host_only()
find_kernel_modules_by_path()
find_kernel_modules()
2016-04-15 16:48:13 +02:00
Harald Hoyer 8d9ab2755d Fix regressions with dracut-install with kernel modules
Make sure, the same modules are installed as before.
2016-04-13 11:47:20 +02:00
Harald Hoyer 794b2d2c75 Use dracut-install to install kernel modules
dracut-install can now install kernel modules and their corresponding
firmware files.
2016-04-11 16:32:10 +02:00
Pekka Wallendahl 28058a2e37 multipath: fix majmin_to_mpath_dev()
* Multipath device names only start with the mpath-prefix if the option
  use_userfriendly_names is set true in /etc/multipath.conf and if user
  has not set any aliases in the said file. Thus the for-loop should go
  through all files in /dev/mapper/, not just ones starting with 'mpath'

* Bash is perfectly capable to extend `/dev/mapper/*` notation without a
  need to pass it to an external ls

* Changed the function to use a local variable $_dev instead of the
  global $dev, which seemed to be the original intention as the local
  _dev was defined but not used
2016-01-18 20:28:22 +02:00
Harald Hoyer 848edf22f0 multipath: install all multipath path selector kernel modules
By default, dracut only builds in dm-service-time into the initramfs as
that is the default multipath.conf path selector. If the user changes
the path selector to "round robin" on the fly and runs dracut, multipath
does not find any paths on boot and the user will be dropped into a
shell.

Apparently, in RHEL7 dracut defaults to "hostonly" mode, i.e. modules
not currently in use at the time dracut runs do not get built into
initramfs. This is definitely one case where this doesn't work. A change
to reconfigure multipath probably should not render the system
unbootable.

https://bugzilla.redhat.com/show_bug.cgi?id=1195392
(cherry picked from commit f11d7a81e2)
2015-11-11 15:46:39 +01:00
Dave Young 77403e0032 90multipath: add hostonly multipath.conf in case hostonly mode
For large machine, suppose there's a lot of multipath devices, multipath layer
will use a lot of memory. For kdump kernel memory is very limited thus it causes
oom. To avoid oom, we only add necessary multipath devices in kdump kernel
multipath.conf.

This is done by use mpathconf --allow, a new option which is like whitelist.

Signed-off-by: Dave Young <dyoung@redhat.com>
2015-07-06 10:06:04 +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
Hannes Reinecke 8f4ee8c71b 90multipath: install correct multipath rules
The multipath and kpartx rules have different numbers in SUSE.

The 11-dm-mpath.rules file had been missing, causing
blacklisting to not work properly.

References: bnc#873151, bnc#872662, bnc#883149

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2014-12-16 13:29:35 +01:00
Hannes Reinecke 78a78e4239 90multipath: install dracut-specific service file
The multipathd package might install a service and a socket
file. Using the original service file from the installed
system without the socket file triggers a bug in systemd,
causing systemd to crash.

As we don't actually need to socket file in the initrd we
should be installing our own service file which does not
reference the socket file at all.

References: bnc#871610

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2014-11-25 13:21:03 +01:00
Hannes Reinecke 856f8265aa 90multipath: Load device_handler modules early during boot
The device handler modules need to be loaded early during boot
to avoid I/O errors being printed to the system log.

References: bnc#871617

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2014-11-25 13:21:03 +01:00
Hannes Reinecke cf864c1b80 90multipath: Install libgcc_s library
multipathd is using pthreads, which require libgcc_s for
pthread_cancel to work. Without it multipathd might crash
with SIGABRT.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2014-11-25 13:21:02 +01:00
Harald Hoyer 967cc19ab1 remove all vim and emacs code format comments 2014-08-29 13:38:47 +02:00
Harald Hoyer 30e6e809ed Factor out all the "type -V" commands
Add new functions require_binaries() and require_any_binary() to be used
in the check() section of module-setup.sh.

These functions print a warning line telling the user, which binary is
missing for the specific dracut module.

This unifies the way of checking for binaries and makes the life of an
initramfs creator easier, if he wants to find out why a specific dracut
module is not included in the initramfs.
2014-02-06 16:45:20 +01:00
Harald Hoyer 8bcfd683bd */module-setup.sh: add comments for dracut called functions 2013-10-08 10:37:56 +02:00
Harald Hoyer e84d115b93 multipath: need_shutdown if multipath devices exist
https://bugzilla.redhat.com/show_bug.cgi?id=994913
2013-08-09 10:44:34 +02:00
Harald Hoyer af11946054 dracut-functions.sh: inst_multiple == dracut_install 2013-08-07 10:33:15 +02:00
Harald Hoyer 1b0a362d83 multipath: install native systemd service 2013-03-25 07:58:45 +01:00
dyoung@redhat.com 83e0dc7a3d Add for_each_host_dev_and_slaves for device only checking
For lvm, multipath, iscsi modules they do not care about the filesystem,
Also there could be devcie in host_devs but it does not get formated.

For these kind of modules, use for_each_host_dev_and_slaves will be better than use
for_each_host_dev_fs, here add a new function to iterate the host_devs and
their slave devices.

In original for_each_host_dev_fs, it will call check_block_and_slaves which
will return once helper function return 0, but this is not enough for kdump
iscsi setup. For kdump iscsi case, it need setup each slave devices so that
the iscsi target can be properly setuped in initramfs.

Thus, this patch also add new functions check_block_and_slaves_all and
for_each_host_dev_and_slaves_all.

Signed-off-by: Dave Young <dyoung@redhat.com>
Tested-by: WANG Chao <chaowang@redhat.com>
2012-08-23 10:15:09 +02:00
Harald Hoyer 24a38bc1cb fixed install locations for udev rules and change to IMPORT{builtin} 2012-07-27 11:55:31 +02:00
Harald Hoyer 15976a0670 multipath/module-setup.sh: add dm dependency 2012-07-26 12:55:53 +02:00
Amadeusz Żołnowski 15f0b1f624 90multipath: added kpartx.rules; multipath.rules - different prefix 2012-07-26 11:40:37 +02:00
Chao Wang 63c65b984a 90multipath: check() - Regexp fix to match multipath partition.
A multipath partition's uuid will be presented like:
 # cat /sys/dev/block/$_dev/dm/uuid
 part1-mpath-360060e801047103004f2c4b300000008

So in this case, change the match regexp from '^mpath-' to 'mpath-'.

Signed-off-by: Chao Wang <chaowang@redhat.com>
2012-07-26 08:35:02 +02:00
Harald Hoyer 8a240aca9e require kpartx and partx for some modules 2012-07-25 13:00:08 +02:00
Harald Hoyer 53fe81e752 modules.d/*/module-setup.sh: combine and specify type for installs
To speedup image creation, combine dracut_install calls and specify the exact type.
E.g. inst_script instead of the generic inst.
2012-06-29 12:41:27 +02:00
Harald Hoyer 4d0f1d7b28 modules.d/*/module-setup.sh: no more sourcing of dracutfunctions 2012-06-29 12:41:26 +02:00
Harald Hoyer 2d2c8c2078 multipath/module-setup.sh:installkernel() fix return code 2012-06-29 12:41:26 +02:00
Harald Hoyer 361306c131 check for arch before installing drivers/s390 2012-06-21 01:11:43 +02:00
Harald Hoyer 9073ff54c1 fix return value of some installkernel() functions 2012-06-01 17:09:51 +02:00
Harald Hoyer 5dc1be1df8 multipath/module-setup.sh: fix host-only/mount checks 2012-04-25 15:58:40 +02:00
Harald Hoyer eef7649e71 merge "cleanup" and "pre-pivot-cleanup" hooks 2012-04-23 11:32:45 +02:00
Dave Young 1bd76bf981 move cleanup scripts to pre-pivot-cleanup hook
below cleanup scripts is moved:
40network: kill-dhclient.sh
90crypt: crypt-cleanup.sh
90multipath: multipathd-stop.sh
95iscsi: cleanup-iscsi.sh
95nfs: nfsroot-cleanup.sh

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-04-19 11:59:45 +02:00
Jon Ander Hernandez c9143a63fe Debian multiarch support
Another solution could be searching in directories found at
/etc/ld.so.conf.d/*.conf or adding a new parameter. Here is a patch
which adds a new --libdirs parameter, and also a new inst_libdir_file
function which will try to expand metacharacters on each lib
directory:

    inst_libdir_file "libdevmapper-event-lvm*.so"
2012-04-16 14:46:53 +02:00
Harald Hoyer c416b1de5a fix kernel modules search for s390
find_kernel_modules_by_path only takes one parameter

fixes c254ac796f
and 4fcd5409e0
2012-01-26 17:30:06 +01:00