Commit Graph

383 Commits (055)

Author SHA1 Message Date
Kairui Song 83c65fd3db 99squash: Check require module earlier, and properly
Let 99squash fail earlier if required modules are not enabled or
missing, using the new added helper.

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-10-21 17:04:00 +02:00
Daniel Molkentin ff2d8bdfb3 dracut.sh: Add --version 2020-08-28 23:28:25 +02:00
Érico Rolim 497916e13b dracut.sh: fix some indentation.
Command level inside conditional and tab/space usage.
2020-08-24 11:29:34 +02:00
Érico Rolim 3b92d8bf84 dracut.sh: fix errors pointed out by shellcheck.
- use [ ] instead of calling test manually, as most of the script is
doing.

- use quotes in hostonly_cmdline blocks, specially when dealing with the
conf files, whose names are set by users/system administrators

- uefi_splash_image was being assigned set to `${dracutsysroot}...`, which
is a variable that doesn't exist.

- we don't want the conditional to run the output of fsfreeze as
commands. Instead, we just need to know if any of the fsfreeze commands
failed.
2020-08-24 10:27:29 +02:00
mwberry fea53784ad UEFI Mode: only write kernel cmdline to UEFI binary
The kernel command line was being written both into
/etc/cmdline.d/01-default.conf and the UEFI executable.
During boot, getcmdline would concatenate these two
resulting in all arguments being duplicated. Some
args, such as ip=, are sensitive to the number of
times they are specified.
2020-08-05 18:30:44 +02:00
Kairui Song 4159819fbb 99squash: simplify the code
The new dracutsysrootdir could be used to replace the shell function
required_in_root, so drop it and also simplify the code.

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-08-04 14:24:53 +02:00
q66 63b05a8e67 dracut.sh: fix ia32 detection for uefi executables 2020-08-03 18:51:49 +02:00
q66 d8d5cb839c dracut.sh: fix early microcode detection logic
This fixes two issues:

1) on non-x86 systems in non-hostonly config this would cause
   an annoying warning on every initramfs generation
2) on non-x86 systems in hostonly config this would result in
   early microcode not getting disabled
2020-07-26 10:25:42 +02:00
Kairui Song 5a4c346933 dracut.sh: FIPS workaround for openssl-libs on Fedora/RHEL
On Fedora/RHEL, libcryto will verify both itself and libssl on start, if
libssl is missing, FIPS self test will fail. However libssl is not a
dependency of libcryto so dracut will not install it, unless some other
binary or library pulls it in. Systemd requires libssl, so in most cases
it just worked, but could fail in some corner cases where systemd is not
used.

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-07-02 17:05:23 +02:00
Kairui Song de3cb0e321 dracut.sh: Move the library workaround after squash
Ensure the workaround is also valid when dracut-squash module is used

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-07-02 17:05:23 +02:00
Harald Hoyer dfe2247a43 dracut.sh: add check for invalid configuration files
Emit a warning about possible misconfigured configuration files, where
the spaces around values are missing for +=""

Better report a possible source of problems. We can fix annoying false
positives later.
2020-03-18 16:34:35 +01:00
Dusty Mabe 97a931c7d9 don't prefer $TMPDIR over --tmpdir
Ability to use `$TMPDIR` was introduced in bc1e69b but
causes the `--tmpdir` option on the command line to be
ignored. Switch to only using `$TMPDIR` if `--tmpdir`
wasn't specified.
2020-03-16 14:45:01 +01:00
Topi Miettinen bc1e69b691 Use TMPDIR if available
Use environment variable TMPDIR (typically /run/user/$UID) as default
temporary directory, if available. This should be more private
location than /var/tmp. Path specified with --tmpdir is takes
precedence over TMPDIR and /var/tmp is still used as last resort if
neither TMPDIR is set nor --tmpdir is used.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2020-03-06 11:40:00 +01:00
Martin Wilck 0386e46277 dracut.sh: don't call fsfreeze on subvol of root file system
dracut.sh already doesn't call fsfreeze if the output file is on
the root file system. For btrfs, however, this is not sufficient.
Because fsfreeze is a superblock operation, and all btrfs subvolumes
share the same superblock, fsfreeze may freeze the entire system
if the subvolume on which the output file is written and / are
subvolumes of the same file system. Avoid this by comparing file
system UUIDs for btrfs.

Fixes: de576db3c2 ("call fsfreeze(8) on /boot to flush initramfs data & metadata to media")
2020-03-06 11:37:16 +01:00
Daniel Molkentin 5b1d8bcc58
Merge branch 'master' into regenerate_all 2020-03-03 19:25:16 +01:00
Topi Miettinen ecbdff68af Don't resolve libraries lazily if tmpdir is mounted with 'noexec'
If the temporary directory for images is mounted with 'noexec', dracut
would construct unbootable images because most dynamic libraries
aren't installed. Avoid this by not resolving library dependencies
lazily if the temporary directory is mounted with 'noexec'.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2020-03-02 09:56:26 +01:00
Donovan Tremura 4237aeb040 Support the EFI Stub loader's splash image feature.
Checks if `uefi_splash_image` exists in `dracutsysroot` if not unset
`uefi_splash_image`. Alternate Value parameter expansion adds section-vma
for splash image to EFI stub loader when the path to image is valid and
not an empty file.

I did not test on other distributions, but on Arch Linux the `systemd`
package includes a splash image at the path
`/usr/share/systemd/bootctl/splash-arch.bmp`. Perhaps, if this is a
common practice, a default image could be gathered from that directory.

It is required that the image be in bitmap (`.bmp`) format according to
`splash.c`.

The code for `stub.c` and `splash.c` can be found at:
https://github.com/systemd/systemd/blob/master/src/boot/efi/stub.c
https://github.com/systemd/systemd/blob/master/src/boot/efi/splash.c
2020-02-20 11:03:30 +01:00
Renaud Métrich cdc9cd0e41 dracut.sh: added help for --regenerate-all 2020-02-13 11:37:13 +01:00
Daniel Cordero f668e7174e dracut.sh: check kmoddir is properly formed
Due to the way dracut-install handles modules from custom kmoddirs, add
a test that ensures the kmoddir argument seems sane.

In addition to erroring out, provide some guidance on how to proceed, as
well as a method of skipping the test via environment variable.
2020-01-27 09:02:46 +01:00
Jonas Witschel d613d88dd2 ucode: use microcode found in packed cpio images
Some distributions (Arch, Gentoo) ship prepacked microcode images. These
are cpio images that follow the structure specified in the Linux kernel
documentation (x86/microcode.rst, "Early load microcode"), the same
structure dracut uses for its early microcode images.

In case of Arch Linux, the microcode for Intel CPUs is currently only
available in this packed form, /usr/lib/firmware/intel-ucode does not
exist. This commit adds a way to make use of these images on such
systems by unpacking them to the early cpio directory. (Note that the
packed image cannot be used directly since dracut might need to add ACPI
tables to the early initramfs.)

This approach has the drawback that it is not possible to control the
selection of CPUs to be included in the microcode file in host-only
mode, so we only try it as a last ressort if no unpacked microcode could
be found in fw_dir.

The list of possible file names for the packed microcode image is taken
from GRUB (cf. GRUB_EARLY_INITRD_LINUX_STOCK), but can be adapted by
setting "early_microcode_image_name" (and "early_microcode_image_dir")
in a dracut configuration file.
2020-01-24 09:06:32 +01:00
Böszörményi Zoltán 0595a79b19 Fix version reported by dracut --help
Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>
2019-10-25 11:58:58 +02:00
Böszörményi Zoltán 9d88e89350 Set systemdutildir correctly
Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>
2019-10-25 11:58:58 +02:00
Böszörményi Zoltán b552d364a3 Handle -r / --sysroot option in dracut.sh
It was documented but not implemented.

Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>
2019-10-25 11:58:58 +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
Kairui Song 89bc1aa324 Fine tune mksquashfs options for squash module
Drop some unneeded metadata in the squash image, and print the error
message if something went wrong.

Signed-off-by: Kairui Song <kasong@redhat.com>
2019-10-25 11:52:05 +02:00
Daniel Molkentin feebf17187 ucode: properly include early only ucode
Intel has notified us that some microcode updates are not safe
to be applied during runtime. To accomodate for that, microcode
files shipped by SUSE and openSUSE have an '.early' postfix such
that triggering

/sys/devices/system/cpu/microcode/reload

from a booted system cannot pick up the ucode by accident, while
still allowing the code to be picked up during initrd time.

This change is needed to make this scheme work also in a hostonly
situation.

Currently, this affects only 06-4f-01, which is now 06-4f-01.early.

If a distro does not change the filename, the behavior does not
change.

Reference: osc#1098915
2019-10-25 11:39:16 +02:00
Kairui Song a69e6c4eae Only generate hostonly-kernel-modules list in strict mode
Fixes #617.
2019-10-23 14:33:36 +02:00
Jonas Witschel 0a01086456 dracut.sh: suppress "ignored null byte in input" warning
Since Bash 4.4, command substitutions containing null bytes produce a
warning of the form

/usr/sbin/dracut: line 1958: warning: command substitution: ignored null byte in input

Remove the trailing null byte from the UEFI kernel command line file
before printing it to suppress this warning.
2019-09-03 11:28:56 +00:00
Renaud Métrich 7a3d661971 Print an error if included item ('-i' option) doesn't exist or is neither a directory nor a regular file
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
2019-08-29 13:46:34 +00:00
Kairui Song 6a74c03b4a dracut.sh: Adjust squash and strip order
Previously with squash module, some binaries will be reinstalled, but
stripping happens before that so new installed binaries is not stripped.
So adjust the squash and strip order, ensure new installed binaries are
stripped just the same way with the old binaries.

Also split squash into two stage to make the split easier, move the
squash temp dir into initdir so stripping will cover that too,
and print more usefule message.

Signed-off-by: Kairui Song <kasong@redhat.com>
2019-08-09 13:11:47 +02:00
Jonas Witschel 12f023ab03 Replace $(arch) by $(uname -m) 2019-07-19 16:25:03 +02:00
Дамјан Георгиевски c8b35bf96a move setting the "systemdutildir" variable before it's used
on line 1086 it's used to check for the uefi_stub:
"${systemdutildir}/boot/efi/linux${EFI_MACHINE_TYPE_NAME}.efi.stub"

so it needs to be defined before that
2019-07-19 16:23:57 +02:00
Jonas Witschel 305c6f91bb dracut.sh: fix EFI directory if ESP is mounted to /efi
The EFI executables produced by dracut --uefi must be placed in the
subdirectory /EFI/Linux of the EFI system partition (ESP) according to
the Boot Loader Specification, see
https://systemd.io/BOOT_LOADER_SPECIFICATION#logic

This is done correctly for the mount points /boot and /boot/efi, but for
the mount point /efi, the files are placed in /efi/Linux instead of the
correct /efi/EFI/Linux. This commit fixes the directory so that the EFI
executables are picked up correctly by conforming boot loaders.

Apart from complying to the specification, the change is also in line
with the commit message of 5c57209ba5
("dracut.sh: add default path for --uefi") which introduced this feature
as well as the documentation in dracut.8.asc.
2019-07-19 16:23:24 +02:00
Max Resch 5a962b5939 add support for creating secureboot signed UEFI images 2019-07-19 16:09:41 +02:00
Harald Hoyer 86f4dd0273
Merge branch 'optimization' of https://github.com/ryncsn/dracut into ryncsn-optimization 2019-07-19 15:48:22 +02:00
Kairui Song 19e5758590 squash: also squash systemctl if switch-root is not needed
systemctl need to be accessible on switch-root, but we unmount the
squash image on switch-root, so it will fail. systemctl depends on a lot
of libraries, squash them can save more RAM. So allow modules
(eg. kdump) to tell dracut that switch-root will be intercepted,
then we don't need to take care of that.

Signed-off-by: Kairui Song <kasong@redhat.com>
2019-07-19 15:38:54 +02:00
Kairui Song f6bbd024d9 squash: fix and simplify required_in_root
If required target is a symbol link, create the link then following the
link. If it's a directory, create new directory, else just move it.

Signed-off-by: Kairui Song <kasong@redhat.com>
2019-07-19 15:38:54 +02:00
Kairui Song ab703f44b4 squash: squash systemd binary and udevadm
systemd binary and udevadm are not needed to be outside the squash
image. Some binaries are kept outside because they are required before
mounting the image, or after umounting the image (when switching root),
or they may block umounting the image. But we are using lazy umounting,
so actually nothing will block the umount.

Keep more binaries outside the squash image won't hurt but cost extra
memories, the idea of squash image is to save memory usage.

So, there is no reason to keep udevadm outside, that should be a debug
left over. For systemd binary, it's running when switch root happens,
But we have lazy umounted the image and overlay, once systemd process
exec the new systemd in new root, everything will be cleared by kernel.

Also tidy up the comment make it less confussing.

Signed-off-by: Kairui Song <kasong@redhat.com>
2019-07-19 15:38:54 +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
Hongxu Jia dddcb80945 dracut.sh: Fix udevdir detection
In commit [9d1b81c dracut.sh: improve udevdir and systemdutildir
fallback logic] , it checked a common binary `collect' to location
udevdir.

But upstream systemd drop binary `collect' since systemd v240
[a168792c2d]

So check binary `ata_id' to instead.

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2019-07-19 11:01:32 +02:00
Kairui Song 5916d31b24 dracut: let module handling function accept optional path option
Let the caller pass in the module path instead of try to find the module
path everytime. This helps optimize the overall runtime.

Test results (3 rounds) on Fedora 30 in KVM VM with 8 CPUs, 2G memory, HDD:

    $ time ./dracut.sh --local --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode 'strict' -o 'plymouth dash resume ifcfg' --mount '/dev/mapper/fedora-root /sysroot xfs defaults' --no-hostonly-default-device -f initramfs.img
    Before the commit:
    real    0m11.782s  |  real    0m11.505s  |  real    0m11.958s
    user    0m9.169s   |  user    0m9.218s   |  user    0m9.327s
    sys     0m10.839s  |  sys     0m10.829s  |  sys     0m10.925s

    After this commit:
    real    0m9.866s  |  real    0m9.580s  |  real    0m9.638s
    user    0m9.048s  |  user    0m9.142s  |  user    0m9.120s
    sys     0m7.411s  |  sys     0m7.775s  |  sys     0m7.745s

Test result of building a ordinary image:

    $ time ./dracut.sh --local --quiet -f initramfs.img
    Before the commit:
    real    0m34.697s  |  real    0m34.371s  |  real    0m35.122s
    user    0m27.608s  |  user    0m27.524s  |  user    0m27.705s
    sys     0m22.341s  |  sys     0m22.032s  |  sys     0m22.246s

    After the commit:
    real    0m31.914s  |  real    0m31.006  |  real    0m31.289ss
    user    0m27.315s  |  user    0m27.324  |  user    0m27.290ss
    sys     0m19.051s  |  sys     0m18.916  |  sys     0m19.022ss

This will have an ~2s speed up.

Signed-off-by: Kairui Song <kasong@redhat.com>
2019-02-22 15:51:40 +08:00
Attila Bruncsak 7e944c77c0 the strip command should avoid changing the file modification time 2018-12-20 17:06:26 +01:00
Kairui Song a60af53413 squash: unsquash the root image instead of mounting it on shutdown
When building squash image, squash module forgot to install the new
shutdown.sh, and the shutdown hooks are always skipped on ordinary
shutdown if squash module is enabled.

The new shutdown.sh will remount the squash image and then everything
will just work, but currently re-mounting the squash image on shutdown
may have selinux problem and make the system hang, and there is no
easy way to fix it.

So skip fixing the shutdown.sh not being install problem, instead
just drop the new shutdown.sh, and unsquash the image on ordinary
shutdown, which is safer and should always work.

Signed-off-by: Kairui Song <kasong@redhat.com>
2018-11-12 09:04:14 +01:00
Pedro Monreal f18d069d46 Fixed some SUSE specific typos and outputs 2018-11-08 14:43:08 +01:00
Pedro Monreal db4d6bb42c Added space in Resolving executable dependencies done as in the rest of the messages 2018-10-09 13:41:55 +02:00
Kairui Song 095e1f37c4 Add support for building a squashed initramfs
With all files stored in ramfs, and most of them are not compressed,
the initramfs will take up a lot of memory. Besides, if the file number
is large, each file will waste some memory due to page fragmetation.
This is due to ramfs' design, at least one page will be allocated for
one file however small the file is. On machine with large page size,
this will become worse and waste too many memory.

One approach to reducing the memory usage is to reduce the number of
files that got directly loaded into the root ramfs, and compress files
by put most files will into a read-only squash image and keep a minimum
set of executable and libraries outside as the loader for the squash
image. After the squash image is mounted, the real 'init' will be
executed and then everything behaves as usual.

This patch will introduce a '99squash' module which will never be
included by default. User can force add it, and if it is included,
dracut will perform some extra steps before creating the final image:

For now, "/etc" and "/usr" will be moved into the squashfs image.
"/init" will be renamed to "/init.stock" and replaced by "/init.squash".
Files and folders need to be accessible before mounting the image will
be still avaliable at their original place. And due to squashfs is
readonly, an overlayfs layer will be created on top of squashfs mount
point, as many dracut module require readwrite access to "/etc" and
"/usr", "init.squash" will ultimately call "/init.stock".

An extra systemd service will be installed. This service will umount all
squashfs related mount points right before switch-root to release
resources properly. This service will not actually do anything if
switch-root is not used.

This is very helpful when mem resource is very limited, like Kdump.
According to my tests, this squash module can help save about 35MB of
memory with 64K page size, or about 15MB with 4K page size on an
ordinary kdump capture routine. This module could also help reduce
memory usage for normal boot up process.

Won't change any behavior if squash module is not enabled.

Signed-off-by: Kairui Song <kasong@redhat.com>
2018-09-21 10:32:04 +02:00
Harald Hoyer 3111988680 dracut.sh: remove bogus dir removal for --rebuild 2018-08-16 09:19: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
Mike Gilbert 9d1b81c0d1 dracut.sh: improve udevdir and systemdutildir fallback logic
Check for a common binary in systemdutildir. This resolves an issue on
split-usr systems, where it is common to have both /lib/systemd[/system]
and /usr/lib/systemd[/user] present.

Check for systemd-udevd specifically, since some distros (Gentoo) allow
udev to be installed without the rest of the systemd stack.

Similar logic is applied to udevdir simply for consistency.
2018-07-05 13:57:43 +02:00
Kairui Song a695250ec7 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>
2018-07-05 09:14:02 +02:00
Daniel Molkentin d00cfc2a7b Remove obsolete prelinking functionality 2018-06-14 12:58:59 +02:00
Renaud Métrich c1c78f8a91 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>
2018-06-08 10:48:45 +02:00
Harald Hoyer f6e777ec4b cleanup empty ldconfig_paths directories
https://bugzilla.redhat.com/show_bug.cgi?id=1324746
2018-05-22 09:51:12 +02:00
Harald Hoyer bfa4e45fa7 s/find_btrfs_devs/btrfs_devs 2018-05-07 10:26:45 +02:00
Colin Walters 740e41b843 Suppress sync/fsfreeze if not running on a live system
It's possible for e.g. `kernel` to be installed as an RPM BuildRequires or equivalent,
and there's no reason to sync, and *definitely* no reason to fsfreeze.

Another case where this happens is rpm-ostree, which performs its own sync/fsfreeze
globally.  See e.g. 8642ef5ab3
2018-05-02 17:44:45 +02:00
Thomas Backlund b25ef46f93 Enable 'early_microcode' by default
We initially enabled it for Haswell TSX bug (mga#16657)

Now there is also Meltdown and Spectre security issues,
and more microcode issues will most likely show up...

So the sane default for 'early_microcode' to have it enabled,
as theese changes must be done early in boot process to take
effect as intended.

Update documentation accordingly.

Reference: https://bugs.mageia.org/show_bug.cgi?id=16657

Signed-off-by: Thomas Backlund <tmb@mageia.org>
Signed-off-by: Neal Gompa <ngompa13@gmail.com>
2018-01-18 05:30:28 -05:00
Harald Hoyer 8e7d0856d0
Merge pull request #351 from danimo/91zipl
Add 91zipl, which adds support for indirect booting on s390.
2018-01-12 09:34:08 +01:00
Thomas Renninger 33260dac6e Add /boot/zipl to host devs if it is a mount point
bnc#892187

Signed-off-by: Thomas Renninger <trenn@suse.de>
2018-01-11 11:40:06 +01:00
Yu Watanabe 7bc681fd88 dracut.sh: do not invoke fsfreeze on EFI System Partition
When the system boots with EFI, then initrd image is stored
on EFI System Partition. Thus dracut always warn about the
failure to invoke fsfreeze on the partition.
This prevents to run fsfreeze on ESP and suppress the warning.
2018-01-11 13:55:14 +09:00
Harald Hoyer 577f109243
Merge pull request #339 from danimo/fix_include_parsing
Fix parsing of "-i" and "--include"
2018-01-08 13:31:55 +01:00
Fabian Vogt dcacd2b072 Fix parsing of "-i" and "--include"
- dracut replaced every instance of "-i" in the cmdline,
  even if it was part of a kernel image name, e.g. "vmlinuz-i"
- Fixes boo#908452

Signed-off-by: Fabian Vogt <fvogt@suse.com>

Adjusted to not support "dracut -ifoo bar", as this breaks expected
upstream behavior.
2018-01-08 10:43:46 +01:00
Harald Hoyer 29a9e92999
Merge pull request #331 from fcami/master-fsfreeze
call fsfreeze(8) on /boot to flush initramfs data & metadata to media
2017-12-19 15:35:18 +01:00
François Cami de576db3c2 call fsfreeze(8) on /boot to flush initramfs data & metadata to media 2017-12-19 14:47:11 +01:00
Fabian Vogt d53bb5c017 Fix possible hang in dracut
- Caused by add_drivers+=" " in dracut.conf (bsc#923116)

Signed-off-by: Fabian Vogt <fvogt@suse.com>
2017-12-19 00:04:35 +01:00
Harald Hoyer ed9281d6d1 dracut.sh: after doing the lazy resolve always install dependencies
Exit the lazy resolving mode after doing the lazy resolve, because there
won't be any lazy resolving anymore after this step.

Fixes https://github.com/dracutdevs/dracut/issues/152
Obsoletes https://github.com/dracutdevs/dracut/pull/225
2017-10-26 09:31:27 +02:00
Harald Hoyer faabcb2360 dracut.sh: quote sync file argument 2017-10-11 15:28:20 +02:00
Harald Hoyer 791d801689 dracut.sh: if /boot/vmlinuz-$version exists use /boot/ as output dir
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1475565
2017-10-10 10:30:44 +02:00
tpgxyz 7dbadcc749 add support for Zstandard 2017-09-05 01:23:38 +02:00
Ziyue Yang bd93e9287d dracut.sh: disable lsinitrd logging when quiet
Currently in Fedora/RedHat dracut installs its fedora.conf.example
as the default config file, in which sysloglvl is set 5. This leads
to maxloglvl=5 in dracut calls, making unnecessary lsinitrd calls
during initramfs builds by kdump.

This patch disables lsinitrd logging when --quiet option is given,
which is controlled by maxloglvl only before. This will speed up
dracut image building as the following if --quiet is used in kdump:

1) Before this patch
$ kdumpctl stop; touch /etc/kdump.conf; time kdumpctl start
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change(s) in the following file(s):
  /etc/kdump.conf
Rebuilding /boot/initramfs-4.13.0-0.rc1.git4.1.fc27.x86_64kdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
real    0m26.824s
user    0m9.958s
sys     0m15.106s

2) After this patch
$ kdumpctl stop; touch /etc/kdump.conf; time kdumpctl start
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change(s) in the following file(s):
  /etc/kdump.conf
Rebuilding /boot/initramfs-4.13.0-0.rc1.git4.1.fc27.x86_64kdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
real    0m20.420s
user    0m8.385s
sys     0m10.468s

Signed-off-by: Ziyue Yang <ziyang@redhat.com>
2017-08-23 11:23:34 +08:00
Xunlei Pang 5634a31156 rootfs-block/module-setup.sh: check root_devs in cmdline_rootfs()
In case of "--no-hostonly-default-device", we do not need
the root device, thus add this check.

Also fixed the stale "root_dev" export.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
2017-08-18 14:44:19 +08:00
Xunlei Pang 37f2fe55d1 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>
2017-08-18 09:58:08 +08:00
Ankit Kumar e316ae0e43 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>
2017-08-09 12:04:16 +02:00
Harald Hoyer ae989390a1 dracut.sh: --nofscks does not take parameters
fixes: https://github.com/dracutdevs/dracut/issues/264
2017-08-07 11:39:45 +02:00
Daniel Molkentin 76dd870bfd Do generate error when hostonly_cmdline is set to "no"
Reference: bsc#1048748
2017-07-17 17:01:07 +02:00
Harald Hoyer 106255afd4 bail out if module directory does not exist
this basically reverts commit 05214a0bed

if people want to build the initramfs without kernel modules,
then --no-kernel should be specified
2017-06-29 17:09:50 +02:00
Harald Hoyer 940169e8d8 check for CONFIG_ACPI_TABLE_UPGRADE
additionally as for CONFIG_ACPI_INITRD_TABLE_OVERRIDE
config parameter got renamed
2017-06-27 12:29:07 +02:00
Daniel Molkentin 8b6d136e62 Make binutils optional when elfutils are available
This is intended for minimum host OSes where 36 MB used by binutils
are deemed too expensive. We only need "strip", which exists as eu-strip
in elfutils, which in turn is < 1 MB in size.

Note that the tests (TEST-04-FULL-SYSTEMD/test.sh) still depend on
strip from binutils. It could use sstrip in the future.
2017-04-10 11:28:04 +02:00
Harald Hoyer f0bfada399 dracut.sh: strip NUL bytes in stream before push in string
seems like bash-4.4 does not like NUL bytes in variables
2017-03-30 12:52:11 +02:00
Harald Hoyer 53475faa81 Correct path for UEFI stub
respect any $prefix given to the systemd installation

https://github.com/dracutdevs/dracut/pull/196
2017-03-20 11:43:04 +01:00
Harald Hoyer 647b521fc7 dracut: check for EUID instead of UID 2017-01-18 11:04:36 +01:00
Harald Hoyer 83a6d6f928 dracut.sh: add /dev/random and /dev/urandom to static device nodes
otherwise libgcrypt might complain

https://bugzilla.redhat.com/show_bug.cgi?id=1401444
2017-01-18 10:37:10 +01:00
Harald Hoyer 8a32bf6107 dracut: unset LC_* after setting LANG and LC_ALL
otherwise bash/glibc might complain verbosely about not finding locales
2017-01-18 10:35:41 +01:00
Harald Hoyer 7e51a94f5b Do not "cp" the selinux context
replace "cp -a" with $DRACUT_CP, so in case the selinux policy disallows
root to set the selinux context in /var/tmp, dracut does not fail.
2017-01-16 14:27:39 +01:00
Harald Hoyer 5c57209ba5 dracut.sh: add default path for --uefi
The default output filename for --uefi is
<EFI>/EFI/Linux/linux-$kernel$-<MACHINE_ID>-<BUILD_ID>.efi.
<EFI> might be /efi, /boot or /boot/efi depending on where the ESP partition
is mounted. The <BUILD_ID> is taken from BUILD_ID in /usr/lib/os-release or
if it exists /etc/os-release and is left out, if BUILD_ID is non-existant or
empty.

Also a new option --no-machineid was added, which affects the default output
filename of --uefi and will discard the <MACHINE_ID> part.
2017-01-16 14:27:39 +01:00
Harald Hoyer 39c725dc4e Merge pull request #157 from ddiss/fix_relative_tmpdir
dracut.sh: support --tmpdir as a relative path
2017-01-09 10:42:40 +01:00
Andreas Stieger 0db98910a1 dracut.sh: create the initramfs non-world readable also if early cpio is used
Fixes: 5f2c30d9bc
Previously fixed CVE-2012-4453: e1b48995c2

Signed-off-by: Andreas Stieger <astieger@suse.com>
2016-11-07 10:41:38 +01:00
David Disseldorp bafc82e732 dracut.sh: support --tmpdir as a relative path
Dracut changes working directory before attempting to output files under
$DRACUT_TMPDIR , resulting in an IO failure if $DRACUT_TMPDIR is a path
relative to the working directory when dracut was started.

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

Signed-off-by: David Disseldorp <ddiss@suse.de>
2016-10-10 16:27:47 +02:00
Harald Hoyer f367b73852 dracut.sh: document --hostonly-i18n and --no-hostonly-i18n
show description in --help

https://bugzilla.redhat.com/show_bug.cgi?id=1266448
(cherry picked from commit 91896ab68e)
2016-08-19 15:49:33 +02:00
Harald Hoyer 3889234f71 dracut.sh: make tmp dirs after the trap function is installed
otherwise a good timed ctrl-c will leave the tmp dir around
2016-06-29 17:32:31 +02:00
Colin Guthrie 55b99a0e4c dracut.sh: fix $tmpfilesdir fallback when systemd-devel is not installed.
Bug introduced in 3a04bddeed in Dec 2014.
2016-06-07 10:48:49 +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 0297fdcb3e Merge pull request #123 from dracut-mailing-devs/40374262.eB5p3XdtTH@linux-lm3i.site
Correctly handle module aliases
2016-04-15 12:05:44 +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
Harald Hoyer f7f5b82b43 dracut.sh: call dracut-install with "-f" in FIPS mode
in fips mode, dracut-install was called with "-H" instead of "-f" in
FIPS mode

missed conversion of commit 26cd262a6a
2016-04-11 11:57:30 +02:00
Fabian Vogt 43819af68c Correctly handle module aliases
Handle module aliases correctly to not generate unbootable
initrds with different kernel versions when modules were renamed
or replaced.

Signed-off-by: Fabian Vogt <fvogt@suse.com>
2016-01-21 18:02:40 +01:00
Harald Hoyer b019952f6d dracut.sh: fail hard, if we find modules and modules.dep is missing
If modules are present in /lib/modules/<kernelversion> and modules.dep
is empty, depmod was not run most likely.
2016-01-13 09:32:24 +01:00
Harald Hoyer 60928f36b6 dracut.sh: restorecon final image file
Instead of "mv" use "cp --reflink=auto" and restorecon the final image
2016-01-08 11:37:25 +01:00
Harald Hoyer 62c00a8896 dracut.sh: only create one TMPDIR
use DRACUT_TMPDIR subdirs for everything
2015-11-25 14:21:33 +01:00
Harald Hoyer c44d2252bb dracut.sh: for microcode generation, skip gpg files
skip all ".asc" files for the AMD microcode generation
2015-11-18 10:58:54 +01:00
Harald Hoyer 27d7936f0e dracut.sh: save systemdutildir env
even, if no systemd is used, we need that variable for systemd-udevd
2015-11-17 09:45:29 +01:00