Commit Graph

385 Commits (c7fbc0c8901917baf0d1f0822568e65c6ec00d18)

Author SHA1 Message Date
Kairui Song c7fbc0c890 fix(dracut.sh): handle symlinks appropriately while using '-i' option
[[ -d $symlink ]] will return true if the symlink points to a directory.
So the symlink will not be copied, instead a directory is created with
the symlink name and the content is copied.

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-06-29 09:53:19 +02:00
Hari Bathini f1138012c9 fix(dracut.sh): handle '-i' option to include files beginning with '.'
While including a directory using '--include' option, the file and
subdirectory names that begin with '.' are not included. Also, dracut
throws a warning message when a subdirectory is empty or only has
files or subdirectories that begin with '.'.

For example, while trying to include /tmpdata directory with the
below tree:

  # tree -a /tmpdata
  /tmpdata
  ├── .anothertestdir
  ├── testdir
  │   └── .testsubdir
  └── .testfile

dracut throws the below warning message:

  # dracut --include /tmpdata /root
  cp: cannot stat '/tmpdata/testdir/*': No such file or directory
  #

and this is how the included /tmpdata directory tree looks:

  # tree -a root
  root
  └── testdir

No file or directory beginning with '.' is included & also, copying
/tmpdata/testdir reported "No such file or directory" warning. Using
'.' instead of '*' in the below command will fix the warning whether
the directory being copied is empty or only has files or directories
that begin with dot:

  $DRACUT_CP -t "$object_destdir" "$dracutsysrootdir$objectname"/*

Also, enable 'dotglob' temporarily to include files and directories
beginning with a `.' in the results of pathname expansion of source
directory being included.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
2021-06-29 09:53:19 +02:00
Harald Hoyer 0a6007bf4f fix(dracut): pipe hardlink output to `dinfo`
Otherwise the output is cluttered with:
```
Mode:           real
Files:          1364
Linked:         5 files
Compared:       0 xattrs
Compared:       384 files
Saved:          12.84 KiB
Duration:       0.052674 seconds
```
2021-05-21 14:16:43 +02:00
Harald Hoyer 7275c6f6a0 feat(dracut.sh): detect running in a container
Don't try to `mknod` by setting DRACUT_NO_MKNOD.
Don't try to `cp` extended attributrs by setting DRACUT_NO_XATTR.
2021-05-17 16:23:00 +02:00
Harald Hoyer de0c0872fc fix(dracut): prevent symbolic links containing `//`
Results in `usr/lib64 -> ..//usr/lib` for Arch Linux otherwise.
2021-05-14 08:35:30 +02:00
Jóhann B. Guðmundsson 5c94cf41e8 fix: deprecate gummiboot
Gummiboot was merged into systemd and official became systemd-boot in 2015 ( 6 years ago )
and no longer was being maintained as Gummiboot from that point.

It's safe to say distribution should have migrated to sd-boot by now so let's deprecate
it.
2021-05-11 17:13:09 +02:00
Jóhann B. Guðmundsson 8849dd8d1a fix: add a missing tmpfilesconfdir global variable
Adding a missing tmpfilesconfdir global variable
2021-05-06 15:49:18 +02:00
Renaud Métrich c3bb9d18dc fix(dracut-functions): implement a cache for get_maj_min
On systems with a large number of devices, usually multipath devices,
dracut can spend a lot of time stat'ing the devices to collect the
major/minor numbers, leading to huge slowness rebuilding the initramfs
when stat'ing devices is slow (seen with oracleasm file systems in
particular).
This commit implements a basic cache stored in a file under
DRACUT_TMPDIR storing the major:minor corresponding to the specified
device.

Reproducer: create N loopback devices used as a LVM extension to volume
group hosting the root file system

  # LVMVG="rhel"
  # NDEVICES=200
  # mkdir devices; for i in $(seq 1 $NDEVICES); do
    truncate -s 10m devices/$i; losetup loop$i devices/$i
  done
  # vgextend $LVMVG $(/bin/ls -1 /dev/loop[0-9]*)

With standard code (tested with RHEL8.3 dracut):

  # dracut -f --debug /tmp/initramfs.img $(uname -r) >/tmp/debug 2>&1
  # grep -c "stat -L -c" /tmp/debug
  2440

With this code:

  # dracut -f --debug /tmp/initramfs.img $(uname -r) >/tmp/debug_optim 2>&1
  # grep -c "stat -L -c" /tmp/debug_optim
  205

Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
2021-05-06 09:14:10 +02:00
Harald Hoyer 909961d048 fix: shellcheck 0.7.2
github action `luizm/action-sh-checker@v0.2.2` uses `shellcheck-0.7.2`,
which detects more non-posix shell code and complains accordingly.
2021-05-05 14:55:30 +02:00
Mikhail Novosyolov ce9af251af feat: support ZSTD-compressed kernel modules
Modern Linux kernels support zstd-compressed modules, which was added
by commit 73f3d1b48f50 ("lib: Add zstd modules").

Commit c3d7ef377eb ("kbuild: add support for zstd compressed modules")
added support of compressing modules with zstd to kernel Makefiles.

libkmod >= 28 built with libzstd is also required.
2021-05-04 15:55:19 +00:00
Harald Hoyer 373eadaa9c style: make indent and let shfmt fail again
The bump of removed the `-d` option for `shfmt`. Readd it until upstream
is fixed.

See also:
https://github.com/luizm/action-sh-checker/issues/44
2021-05-04 15:39:55 +02:00
Harald Hoyer 50a01dd4b2 fix: install all depmod relevant configuration files
This is important for running `depmod` in the initrd.
2021-05-04 13:15:49 +02:00
Jóhann B. Guðmundsson f35d479d2b fix(dracut): adding missing globalvars for udev
Adding missing global variables for udev
udevconfdir --> /etc/udev
udevrulesdir --> /usr/lib/udev/rules.d
udevrulesconfdir --> /etc/udev/rules.d
2021-04-29 14:39:51 +02:00
Kairui Song 3fdc734a5c fix: search for btrfs devices from actual mount poiont
Currently when dracut search for btrfs device used for initramfs, it
assumes the mount points passed in with "--mount" are all mounted with
given mount path. If user want the device to be mounted to a different
location in initramfs, this will not be true.

eg. with "--mount '/dev/mapper/vol /sysroot btrfs rw,relatime,subvolid=256,subvol=/root'"
and having '/dev/mapper/vol' currently mounted on '/', will raise an
error:
    ERROR: cannot access '/sysroot': No such file or directory

So search for actual mount point of given device.

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-04-26 13:41:15 +02:00
Jóhann B. Guðmundsson ec4539c606 fix(dracut.sh): add global vars for modules-load
Adding modulesload modulesloadconfdir global variables
2021-04-20 16:10:12 +02:00
Jóhann B. Guðmundsson 3ca9aa1d7b fix(dracut): sysctl global variables 2021-04-20 10:52:45 +02:00
Jóhann B. Guðmundsson 96c313333d fix(dracut.sh): omission is an addition to other omissions in conf files
When omitting a module from the command line via -o or --omit
it's expected that it behaves in the same manner as adding a module from the
command line as in it does not overwrite existing omissions of other modules in
configuration file(s).
2021-04-12 09:18:25 +02:00
Harald Hoyer 43df4ee274 feat(mkinitrd): remove mkinitrd
It was not working anyway, so nobody used it for years.
If it is not used, just remove it.
mkinitrd-suse.sh will be maintained by SUSE as it is SUSE specific
anyway.
2021-03-30 12:38:11 +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 560402c3dc style: shfmt pre correction 2021-03-13 20:10:43 +01:00
Kairui Song 7c0bc0b2fd perf: disable initrd compression when squash module is enabled
With squash module, the initramfs is double compressed, which slow down
the build progress and doesn't shrink the size much.
2021-03-09 13:40:35 +00:00
Kairui Song 5d05ffbd87 feat: squash module follow --compress option
Try to make mksquashfs follow --compress option if squash module is
included, if not specified or invalid, fall back to use mksquashfs's
default compressor.
2021-03-09 13:40:35 +00:00
Kairui Song a9345f6800 refactor: delay compressor detection
No function change, decide which compressor to use right before
compressing the initramfs.

This may delay the print of this message:
"dracut: no compression tool available. Initramfs image is going to be big."
but should be OK, this message is not an error.
2021-03-09 13:40:35 +00:00
Kairui Song 8f7c332e48 refactor(squash): structure in a cleaner way
Simplify the squash mount layout. Instead of overlay on each top
directory (/etc, /usr), just mount and switch_root into the squash
image, with a overlay on top of it.

Also install the binaries and setup scripts separately, so the squash
setup code and the squash image content is independent of each other,
all squash setup script and binaries can be deleted safely upon
switch_root.

With this change, previous squash clean up service and other tricky
implementations are all gone.

This commit depends on systemd commits from:
https://github.com/systemd/systemd/pull/18124

Previouly systemd doesn't recognize non-ramfs initramfs, now this is
doable with SYSTEMD_IN_INITRD=lenient

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-03-09 13:40:35 +00:00
Kairui Song 8c8aecdc63 fix(squash): post install should be the last step before stripping
Ensure dracut squash module doesn't effect other steps, and stripping
can cover the new binaries installed by it.
2021-03-09 13:40:35 +00:00
Kairui Song 95ea16aa60 refactor(squash): move the post install scripts into the module-setup.sh
No function change, just move the post install code to 99squash to clean
up dracut.sh.
2021-03-09 13:40:35 +00:00
Jóhann B. Guðmundsson 9cf7b1c529 fix: always use mkdir -p
Ensuring that directory creations dont trigger error if directory
previously existed as well as create parent directories if needed.
2021-03-03 13:06:02 +01:00
Renaud Métrich d8e47e201a fix(dracut.sh): harden dracut against GZIP environment variable
When a GZIP environment variable is set, this leads to various breakage:

In case 'pigz' is installed and GZIP is defined as a path, e.g.
/usr/local/bin/gzip, then dracut will fail with the following message:

   "
   pigz: abort: cannot provide files in GZIP environment variable
   "

In case 'pigz' isn't installed and regular 'gzip' is used and GZIP is
defined as a path, e.g. /usr/local/bin/gzip, then the path will be
zipped and dracut will fail for no obvious reason.  Trying again, dracut
will then fail with following message:

   "
   gzip: /usr/local/bin/gzip.gz already exists;	not overwritten
   "

In any case, GZIP environment should be unset to avoid breakage or
unwanted behaviour. This variable is anyway obsolescent, from gzip(1)
manpage.

Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
2021-03-02 11:05:52 +01:00
Harald Hoyer c8ebb80590 fix(dracut.sh): remove unneeded variables
There is no `fstab_lines_l` variable used before.

The `--include` option was turned into `++include` and therefore the
switch option is not reachable anymore.
2021-02-23 16:03:44 +01:00
Sergei Iudin d87ae13721 fix(dracut.sh): unfreeze /boot on exit
If SIGWHATEVER will be processed after fsfreeze -f, but before fsfreeze
-u we will end up with /boot/ never unfrozen, let's try to minimize risk of this.
2021-02-23 09:25:08 +01:00
Harald Hoyer 41cfdfc4d3 fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 510a22116b fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 2c10b29999 fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 7b59d15d96 fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer dd8ff5311f fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 6dc1cd052b fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 7310a8484e fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 1ebf454884 fix: correct the squash quirk
Previously with `no_kernel` the `for` loop errored on the modules
wildcard. By checking, if the file exists, this is mitigated.

"mv" asked interactively, if aliased in the user session, so a "--force"
was added.
2021-02-10 14:14:39 +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
Zoltán Böszörményi bbe1434fca fix(dracut.sh): don't override path with foreign sysroot
Don't override PATH with foreign sysroot and
trim the sysroot prefix from NPATH elements.

Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu>
2021-02-09 07:09:28 +00:00
Alexander Tsoy 6eff0ebcf8 fix: move ldconfig after library workaround
Commit de3cb0e321 moved libpthread workaround after the code that runs
ldconfig. As a result, if installed in a non-default path, libgcc_s.so.1
could not be found by dynamic linker.
2021-02-08 22:44:32 +01:00
Matthew Thode 8a2edb1e4d fix: do not set cmdline for uefi images unless asked
The kernel does not allow the cmdline to be overridden if one is defined
in the uefi image.  This means that bootloaders like systemd-boot or
grub cannot manage boot options (editing at boot for debug being a use
case).  This patchset allows for no cmdline to be set (instead of force
setting one if none is provided).

Fixes: https://github.com/dracutdevs/dracut/issues/1012
Signed-off-by: Matthew Thode <mthode@mthode.org>
2021-02-08 10:37:22 +01:00
Jóhann B. Guðmundsson 939b7e11d5 feat(systemd-coredump): introducing systemd-coredump module
This pull request introduces systemd-coredump as a seperated
module and adds the systemdutilconfdir global variable.
2021-02-02 18:01:06 +00:00
Jóhann B. Guðmundsson a47c3f50b6 feat: add addional global variables 2021-01-20 12:40:04 +00:00
Jóhann B. Guðmundsson db36338053 feat: add addional global variables 2021-01-20 12:40:04 +00:00
Jóhann B. Guðmundsson 1acf52b60e feat: add addional global variables 2021-01-18 14:45:18 +00:00
Vladius25 f3cbff1113 feat(cli): add --no-uefi option
To be able to turn off UEFI mode, when it's enabled in config.
2021-01-18 08:30:00 +00:00
Daniel Molkentin 3a12309c0d Revert "Add --uefi-output for custom output filename"
This reverts commit f8f3b0f358.
2020-12-02 00:25:20 +01:00