diff options
182 files changed, 1358 insertions, 771 deletions
diff --git a/.github/labeler.yml b/.github/labeler.yml index 00142bc..0cea58c 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -418,6 +418,10 @@ fstab-sys: - changed-files: - any-glob-to-any-file: 'modules.d/95fstab-sys/*' +hwdb: + - changed-files: + - any-glob-to-any-file: 'modules.d/95hwdb/*' + iscsi: - changed-files: - any-glob-to-any-file: 'modules.d/95iscsi/*' diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 666f887..7f2853f 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -49,7 +49,7 @@ jobs: - name: Set up env run: echo "repository_owner=${GITHUB_REPOSITORY_OWNER,,}" >>${GITHUB_ENV} - name: Build and Push Container - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: file: test/container/${{ matrix.config.dockerfile }} tags: ghcr.io/${{env.repository_owner}}/${{ matrix.config.tag }}:latest @@ -87,7 +87,7 @@ jobs: - name: Set up env run: echo "repository_owner=${GITHUB_REPOSITORY_OWNER,,}" >>${GITHUB_ENV} - name: Build and Push Container - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: file: test/container/${{ matrix.config.dockerfile }} tags: ghcr.io/${{env.repository_owner}}/${{ matrix.config.tag }}:latest diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 6e323b7..7ccb0aa 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -9,6 +9,7 @@ env: jobs: basic: + # run this test on all containers name: ${{ matrix.test }} on ${{ matrix.container }} runs-on: ubuntu-latest timeout-minutes: 30 @@ -16,6 +17,7 @@ jobs: group: basic-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }} cancel-in-progress: true strategy: + fail-fast: false matrix: container: [ "alpine", @@ -30,7 +32,6 @@ jobs: test: [ "01", ] - fail-fast: false container: image: ghcr.io/dracut-ng/${{ matrix.container }} options: "--privileged -v /dev:/dev" @@ -39,28 +40,42 @@ jobs: uses: actions/checkout@v4 - name: "${{ matrix.container }} TEST-${{ matrix.test }}" run: ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} - network: - name: ${{ matrix.test }} on ${{ matrix.container }} using ${{ matrix.network }} + extended: + name: ${{ matrix.test }} on ${{ matrix.container }} runs-on: ubuntu-latest - timeout-minutes: 45 + timeout-minutes: 30 concurrency: - group: network-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }}-${{ matrix.network }} + group: extended-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }} cancel-in-progress: true strategy: + fail-fast: false matrix: container: [ + "alpine", + "arch", + "debian", "fedora", - ] - network: [ - "network", + "gentoo", + "opensuse", + "ubuntu", + "void", ] test: [ - "20", - "40", - "50", - "60", + "02", + "03", + "04", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "62", + "98", ] - fail-fast: false container: image: ghcr.io/dracut-ng/${{ matrix.container }} options: "--privileged -v /dev:/dev" @@ -68,28 +83,23 @@ jobs: - name: "Checkout Repository" uses: actions/checkout@v4 - name: "${{ matrix.container }} TEST-${{ matrix.test }}" - run: USE_NETWORK=${{ matrix.network }} ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} - network-legacy: - name: ${{ matrix.test }} on ${{ matrix.container }} using ${{ matrix.network }} + run: ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} + dracut-cpio: + name: ${{ matrix.test }} on ${{ matrix.container }} runs-on: ubuntu-latest - timeout-minutes: 45 + timeout-minutes: 30 concurrency: - group: network-legacy-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }}-${{ matrix.network }} + group: dracut-cpio-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }} cancel-in-progress: true strategy: + fail-fast: false matrix: container: [ "opensuse", ] - network: [ - "network-legacy", - ] test: [ - "20", - "30", - "40", + "63", ] - fail-fast: false container: image: ghcr.io/dracut-ng/${{ matrix.container }} options: "--privileged -v /dev:/dev" @@ -97,68 +107,65 @@ jobs: - name: "Checkout Repository" uses: actions/checkout@v4 - name: "${{ matrix.container }} TEST-${{ matrix.test }}" - run: USE_NETWORK=${{ matrix.network }} ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} - systemd-networkd: - name: ${{ matrix.test }} on ${{ matrix.container }} using ${{ matrix.network }} + run: ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} + arm64: + name: ${{ matrix.test }} on ${{ matrix.container }} on arm64 runs-on: ubuntu-latest - timeout-minutes: 45 + timeout-minutes: 30 concurrency: - group: systemd-networkd-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }}-${{ matrix.network }} + group: arm64-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }} cancel-in-progress: true strategy: + fail-fast: false matrix: container: [ - "arch", - ] - network: [ - "systemd-networkd", + "debian", + "fedora", ] test: [ - "35", - "40", + "98", ] - fail-fast: false - container: - image: ghcr.io/dracut-ng/${{ matrix.container }} - options: "--privileged -v /dev:/dev" steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: 'linux/arm64' - name: "Checkout Repository" uses: actions/checkout@v4 - name: "${{ matrix.container }} TEST-${{ matrix.test }}" - run: USE_NETWORK=${{ matrix.network }} ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} - extended: + run: docker run --platform linux/arm64 --privileged -v /dev:/dev -v $PWD:/w ghcr.io/dracut-ng/${{ matrix.container }} /w/tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} + network: + # all nfs based on default networking name: ${{ matrix.test }} on ${{ matrix.container }} runs-on: ubuntu-latest - timeout-minutes: 30 + timeout-minutes: 45 concurrency: - group: extended-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }} + group: network-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }}-${{ matrix.network }} cancel-in-progress: true strategy: + fail-fast: false matrix: container: [ "arch", "debian", "fedora", "gentoo", + "opensuse", "ubuntu", ] test: [ - "02", - "03", - "04", - "10", - "11", - "12", - "13", - "14", - "15", - "16", - "17", - "18", - "62", - "98", + "20", + "50", + "60", ] - fail-fast: false + include: + - network: "" + - # on debian run tests with systemd-networkd + container: "debian" + network: "systemd-networkd" + - # on openSUSE run tests with network-legacy + container: "opensuse" + network: "network-legacy" container: image: ghcr.io/dracut-ng/${{ matrix.container }} options: "--privileged -v /dev:/dev" @@ -166,23 +173,36 @@ jobs: - name: "Checkout Repository" uses: actions/checkout@v4 - name: "${{ matrix.container }} TEST-${{ matrix.test }}" - run: ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} - dracut-cpio: + run: USE_NETWORK=${{ matrix.network }} ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} + network-iscsi: name: ${{ matrix.test }} on ${{ matrix.container }} runs-on: ubuntu-latest - timeout-minutes: 30 + timeout-minutes: 45 concurrency: - group: dracut-cpio-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }} + group: network-iscsi-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }}-${{ matrix.network }} cancel-in-progress: true strategy: + # run tests sequentially + max-parallel: 1 + fail-fast: false matrix: container: [ + "arch", + "debian", + "fedora", + "gentoo", "opensuse", + "ubuntu", ] - test: [ - "63", - ] - fail-fast: false + test: [ "30","35" ] + include: + - network: "" + - # on debian run tests with systemd-networkd + container: "debian" + network: "systemd-networkd" + - # on openSUSE run tests with network-legacy + container: "opensuse" + network: "network-legacy" container: image: ghcr.io/dracut-ng/${{ matrix.container }} options: "--privileged -v /dev:/dev" @@ -190,30 +210,39 @@ jobs: - name: "Checkout Repository" uses: actions/checkout@v4 - name: "${{ matrix.container }} TEST-${{ matrix.test }}" - run: ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} - arm64: - name: ${{ matrix.test }} on ${{ matrix.container }} on arm64 + run: USE_NETWORK=${{ matrix.network }} ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} + network-nbd: + name: ${{ matrix.test }} on ${{ matrix.container }} runs-on: ubuntu-latest - timeout-minutes: 30 + timeout-minutes: 45 concurrency: - group: arm64-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }} + group: network-nbd-${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }}-${{ matrix.network }} cancel-in-progress: true strategy: + # run tests sequentially + max-parallel: 1 + fail-fast: false matrix: container: [ + "arch", "debian", "fedora", + "opensuse", ] - test: [ - "98", - ] - fail-fast: false + test: [ "40" ] + include: + - network: "" + - # on openSUSE run tests with network-legacy + container: "opensuse" + network: "network-legacy" + - # on debian run this test on network-legacy to be able to pass it + container: "debian" + network: "network-legacy" + container: + image: ghcr.io/dracut-ng/${{ matrix.container }} + options: "--privileged -v /dev:/dev" steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: 'linux/arm64' - name: "Checkout Repository" uses: actions/checkout@v4 - name: "${{ matrix.container }} TEST-${{ matrix.test }}" - run: docker run --platform linux/arm64 --privileged -v /dev:/dev -v $PWD:/w ghcr.io/dracut-ng/${{ matrix.container }} /w/tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} + run: USE_NETWORK=${{ matrix.network }} ./tools/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a12126e..4347d69 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: - name: Release if: ${{ env.new_version }} - uses: softprops/action-gh-release@v2.0.5 + uses: softprops/action-gh-release@v2.0.6 with: tag_name: ${{ env.new_version }} name: dracut-${{ env.new_version }} diff --git a/.shellcheckrc b/.shellcheckrc index ce5c883..26c5c47 100644 --- a/.shellcheckrc +++ b/.shellcheckrc @@ -1,11 +1,3 @@ -# SC2039: In POSIX sh, 'local' is undefined. -# https://github.com/koalaman/shellcheck/wiki/SC2039 -disable=SC2039 - -# SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. -# https://github.com/koalaman/shellcheck/wiki/SC2166 -disable=SC2166 - # SC2154: Variable is referenced but not assigned # https://github.com/koalaman/shellcheck/wiki/SC2154 disable=SC2154 @@ -27,8 +19,3 @@ disable=SC3043 # https://github.com/koalaman/shellcheck/wiki/SC3013 # ... but dash supports it disable=SC3013 - -# SC3045: In POSIX sh, read -p is undefined. -# https://github.com/koalaman/shellcheck/wiki/SC3045 -# ... but dash supports it -disable=SC3045 @@ -10,6 +10,7 @@ Kairui Song <kasong@redhat.com> Will Woods <wwoods@redhat.com> Philippe Seewer <philippe.seewer@bfh.ch> Warren Togami <wtogami@redhat.com> +Benjamin Drung <benjamin.drung@canonical.com> Dave Young <dyoung@redhat.com> Martin Wilck <mwilck@suse.de> Jeremy Katz <katzj@redhat.com> @@ -25,26 +26,25 @@ Frederick Grose <fgrose@sugarlabs.org> Alexander Tsoy <alexander@tsoy.me> Beniamino Galvani <bgalvani@redhat.com> наб <nabijaczleweli@nabijaczleweli.xyz> -Benjamin Drung <benjamin.drung@canonical.com> Jonathan Lebon <jonathan@jlebon.com> Steffen Maier <maier@linux.ibm.com> WANG Chao <chaowang@redhat.com> +David Tardon <dtardon@redhat.com> Yu Watanabe <watanabe.yu+github@gmail.com> Andrey Borzenkov <arvidjaar@gmail.com> David Disseldorp <ddiss@suse.de> -David Tardon <dtardon@redhat.com> Frantisek Sumsal <frantisek@sumsal.cz> +Pavel Valena <pvalena@redhat.com> Peter Robinson <pbrobinson@fedoraproject.org> Thomas Blume <thomas.blume@suse.com> +Brian C. Lane <bcl@redhat.com> Hans de Goede <hdegoede@redhat.com> -Pavel Valena <pvalena@redhat.com> Peter Jones <pjones@redhat.com> Andreas Thienemann <andreas@bawue.net> +Andrew Ammerlaan <andrewammerlaan@gentoo.org> Marcos Mello <marcosfrm@gmail.com> Renaud Métrich <rmetrich@redhat.com> Tomasz PaweÅ‚ Gajc <tpgxyz@gmail.com> -Andrew Ammerlaan <andrewammerlaan@gentoo.org> -Brian C. Lane <bcl@redhat.com> Fabian Vogt <fvogt@suse.com> Nicolas Chauvet <kwizart@gmail.com> Zoltán Böszörményi <zboszor@pr.hu> @@ -70,8 +70,10 @@ Ondrej Mosnacek <omosnace@redhat.com> Tao Liu <ltao@redhat.com> Baoquan He <bhe@redhat.com> Brendan Germain <brendan.germain@nasdaqomx.com> +BtbN <timo@rothenpieler.org> Jonas Witschel <diabonas@gmx.de> Leho Kraav <leho@kraav.com> +Lidong Zhong <lidong.zhong@suse.com> Moritz Maxeiner <moritz@ucworks.org> Nathan Rini <nate@ucar.edu> Radek Vykydal <rvykydal@redhat.com> @@ -81,13 +83,13 @@ Adam Williamson <awilliam@redhat.com> Fabian Deutsch <fabiand@fedoraproject.org> Jan Macku <jamacku@redhat.com> Kamil Rytarowski <n54@gmx.com> -Lidong Zhong <lidong.zhong@suse.com> Marc Grimme <grimme@atix.de> NeilBrown <neilb@suse.de> Peter Rajnoha <prajnoha@redhat.com> Thorsten Behrens <tbehrens@suse.com> q66 <daniel@octaforge.org> Chao Wang <chaowang@redhat.com> +Cornelius Hoffmann <coding@hoffmn.de> Frederic Crozat <fcrozat@suse.com> James Lee <jlee@thestaticvoid.com> Jesse Keating <jkeating@redhat.com> @@ -101,6 +103,7 @@ Stefan Reimer <it@startux.de> Takashi Iwai <tiwai@suse.de> Tony Asleson <tasleson@redhat.com> Zoltán Böszörményi <zboszor@gmail.com> +Alper Nebi Yasak <alpernebiyasak@gmail.com> Anton Blanchard <anton@samba.org> Bill Nottingham <notting@redhat.com> Chapman Flack <g2@anastigmatix.net> @@ -145,9 +148,9 @@ Antony Messerli <amesserl@rackspace.com> Benjamin Marzinski <bmarzins@redhat.com> Chao Fan <cfan@redhat.com> Coiby Xu <coxu@redhat.com> -Cornelius Hoffmann <coding@hoffmn.de> Daniel Cordero <dracut@0xdc.io> Daniel Kahn Gillmor <dkg@fifthhorseman.net> +Daniel McIlvaney <damcilva@microsoft.com> Daniel Schaal <farbing@web.de> Daniel Winzen <daniel@danwin1210.de> Denis Silakov <dsilakov@virtuozzo.com> @@ -160,10 +163,12 @@ German Maglione <gmaglione@redhat.com> Guido Trentalancia <guido@trentalancia.net> Hari Bathini <hbathini@linux.ibm.com> Hari Bathini <hbathini@linux.vnet.ibm.com> +Hector Martin <marcan@marcan.st> Ian Dall <ian@beware.dropbear.id.au> Imran Haider <imran1008@gmail.com> James Buren <ryuo@frugalware.org> Joey Boggs <jboggs@redhat.com> +Jose Ignacio Tornos Martinez <jtornosm@redhat.com> José MarÃa Fernández <josemariafg@gmail.com> Julian Wolf <juwolf@suse.com> Kamil SzczÄ™k <kamil@szczek.dev> @@ -232,6 +237,7 @@ Brandon Sloane <btsloane@verizon.net> Brian Harring <ferringb@gmail.com> Bruno E. O. Meneguele <bmeneg@redhat.com> Bryn M. Reeves <bmr@redhat.com> +Cameron Baird <cameronbaird@microsoft.com> Canek Peláez Valdés <caneko@gmail.com> Carlo Caione <carlo@endlessm.com> Chad Dupuis <chad.dupuis@cavium.com> @@ -242,7 +248,6 @@ Cong Wang <amwang@redhat.com> Conrad Hoffmann <ch@bitfehler.net> Daan De Meyer <daan.j.demeyer@gmail.com> Dan Fuhry <dfuhry@datto.com> -Daniel McIlvaney <damcilva@microsoft.com> Daniel P. Berrangé <berrange@redhat.com> Dave Jones <davej@redhat.com> David Cassany <dcassany@suse.com> @@ -277,7 +282,9 @@ Hendrik Brueckner <brueckner@linux.ibm.com> Hermann Gausterer <git-dracut-2012@mrq1.org> Hiroaki Mizuguchi <hiroaki-m@iij.ad.jp> Hongxu Jia <hongxu.jia@windriver.com> +Huaxin Lu <luhuaxin1@huawei.com> Hui Wang <john.wanghui@huawei.com> +Ian Wienand <iwienand@redhat.com> Icenowy Zheng <uwu@icenowy.me> Ignaz Forster <iforster@suse.com> Ihno Krumreich <ihno@suse.com> @@ -309,6 +316,7 @@ Lennart Poettering <lennart@poettering.net> Lennert Buytenhek <buytenh@wantstofly.org> Lev Veyde <lveyde@redhat.com> Lianbo Jiang <lijiang@redhat.com> +Louis Sautier <sautier.louis@gmail.com> Luca BRUNO <luca.bruno@coreos.com> Lucas C. Villa Real <lucasvr@gmail.com> Major Hayden <major@mhtx.net> @@ -337,6 +345,7 @@ Olivier Blin <dev@blino.org> Ondrej Dubaj <odubaj@redhat.com> P J P <ppandit@redhat.com> Paolo Bonzini <pbonzini@redhat.com> +Paul Charlton <techguru@byiq.com> Paul Robins <exp@users.noreply.github.com> Pavel Zhukov <pzhukov@redhat.com> Pawel Wieczorkiewicz <pwieczorkiewicz@suse.de> @@ -369,6 +378,7 @@ Thierry Vignaud <thierry.vignaud@gmail.com> Thilo Bangert <thilo.bangert@gmx.net> Thomas Abraham <tabraham@suse.com> Thomas Haller <thaller@redhat.com> +Timo Rothenpieler <timo@rothenpieler.org> Tobias Geerinckx <tobias.geerinckx@gmail.com> Tobias Klauser <tklauser@distanz.ch> Tom Gundersen <teg@jklm.no> @@ -1,5 +1,171 @@ [Rendered view](https://github.com/dracut-ng/dracut-ng/blob/master/NEWS.md) +dracut-ng-103 +============= + +New dracut modules introduced by this release: + - hwdb: separate out hwdb module + +Notable new features: + - erofs support for dmsquash-live module + - install platform/chrome modules on ARM/RISC-V + - force the inclusion of crypttab entries with x-initrd.attach + - configuration files for common packaging options (50-hostonly.conf.example) + +Commits that resolve notable regressions: + - perf(dracut-install): memoize find_kmod_module_from_sysfs_node + - perf(dracut-install): use driver/module sysfs dirs for module name + - fix(crypt): decryption when rd.luks.name is set + - fix(systemd-pcrphase): make tpm2-tss an optional dependency + +The project builds test containers daily for the following Linux distributions: + - Alpine, Arch, Debian (amd64 and arm64), Fedora (amd64 and arm64), Gentoo, openSUSE, Ubuntu, Void + - These Linux distributions test dracut in various configurations (systemd/OpenRC/runit, glibc/musl, dhclient/NetworkManager/systemd-networkd). + +#### Features + +* add common config for Integrity Measurement ([5d9fe8c5](https://github.com/dracut-ng/dracut-ng/commit/5d9fe8c5020ff7e895ddfc3a88cab98d4e7a67ea)) +* add additional common configs ([69e119da](https://github.com/dracut-ng/dracut-ng/commit/69e119daea14cb25fed2ed8134d628f3b233108d)) +* **crypt:** force the inclusion of crypttab entries with x-initrd.attach ([61ab3386](https://github.com/dracut-ng/dracut-ng/commit/61ab3386e83a9bd219dcaa05c6499fec56d092b8)) +* **debug:** add findmnt to help debugging ([41d61114](https://github.com/dracut-ng/dracut-ng/commit/41d61114e2eaca20824660aafc0ffae56d09d395)) +* **dmdquash-live:** add support for using erofs ([ca5ae5d3](https://github.com/dracut-ng/dracut-ng/commit/ca5ae5d3466eec40d118fc96d450478aa6faebb6)) +* **dracut:** search for zstd compressor first ([9663307c](https://github.com/dracut-ng/dracut-ng/commit/9663307ceb244ae6293e090f418f9888d6dff8bf)) +* **dracut-install:** + * configure if weak dep is still not supported in kmod ([77c3efa6](https://github.com/dracut-ng/dracut-ng/commit/77c3efa67e1ad724a441eb3341b3fc8a3d9684b6)) + * add weak dependencies support ([8517a6be](https://github.com/dracut-ng/dracut-ng/commit/8517a6be5e20f4a6d87e55fce35ee3e29e2a1150)) + * add hashmap_get_exists() ([2b13d74d](https://github.com/dracut-ng/dracut-ng/commit/2b13d74d4429c8c242a610f10b8389c7e46ff835)) +* **hwdb:** separate out hwdb module ([3c5d5e39](https://github.com/dracut-ng/dracut-ng/commit/3c5d5e398e80b51527420bd9112c37536df219a5)) +* **kernel-modules:** install platform/chrome modules on ARM/RISC-V ([e69e4132](https://github.com/dracut-ng/dracut-ng/commit/e69e41326241c8fa538a5c4383c16ddbab296e6f)) +* **lsinitrd.sh:** support configurable initrd filenames ([7c11c8cf](https://github.com/dracut-ng/dracut-ng/commit/7c11c8cfa4d12389705f447efb130a675cf48b53)) +* **multipath:** warn if included with no multipath devices and no user conf ([ae1b1003](https://github.com/dracut-ng/dracut-ng/commit/ae1b1003305f1553c057970d07a917deb255b7ef)) +* **qemu:** include the virtio_crypto kernel module ([0fe20f85](https://github.com/dracut-ng/dracut-ng/commit/0fe20f85d02cd8496d27b85844307afc9523026b)) +* **test:** + * add erofs-utils to the containers ([e11bc8bf](https://github.com/dracut-ng/dracut-ng/commit/e11bc8bfbd86b8eddb1f4c4f75ba35b1c97fffa1)) + * support V=2 without logtee ([3f005c8a](https://github.com/dracut-ng/dracut-ng/commit/3f005c8aa3436d70328a833d551a6e9a175c1332)) + +#### Bug Fixes + +* check for searched initrds to be present ([9c396ce2](https://github.com/dracut-ng/dracut-ng/commit/9c396ce29fc9e2ced6ebddbdf43fb31a672c2c37)) +* rename dracut.conf.d .conf files to conf.example ([ddc9e4e9](https://github.com/dracut-ng/dracut-ng/commit/ddc9e4e922e91e0a2ea5d17035c45d8dab674b6f)) +* disable SC2317 for calls by for_each_host_dev_and_slaves ([23c9d85a](https://github.com/dracut-ng/dracut-ng/commit/23c9d85a1fdcc31d175a27fd2dc3ac2789e528ef)) +* quote single CTTY parameter ([61d93421](https://github.com/dracut-ng/dracut-ng/commit/61d93421aa949c9022efab37aafadb2203aba537)) +* address shellcheck SC2166 ([d3802b10](https://github.com/dracut-ng/dracut-ng/commit/d3802b10b3f9d1f887546ea42b0e014c8ec76d74)) +* move shellcheck SC3045 override to occurrences ([e1728ee9](https://github.com/dracut-ng/dracut-ng/commit/e1728ee9763dc9917de77dcb2d128d6363b3f05f)) +* **01fips:** replace read -d that is not supported by dash ([15b94c44](https://github.com/dracut-ng/dracut-ng/commit/15b94c4403188cafc6f401f1430bd3692bd7cef8)) +* **90kernel-modules:** install blk modules using symbol blk_alloc_disk ([194ef8eb](https://github.com/dracut-ng/dracut-ng/commit/194ef8ebbf113c48b97ada4981bf50e87d6b0204)) +* **Dockerfile-Gentoo:** add requirements for systemd-pcrphase ([f7e19b3a](https://github.com/dracut-ng/dracut-ng/commit/f7e19b3a11a2e03c01984a13df119184a6206997)) +* **TEST-35-ISCSI-MULTI:** increrase storage space ([9f183a98](https://github.com/dracut-ng/dracut-ng/commit/9f183a9815c480b92a05e7c92abef4f6281350fb)) +* **TEST-40-NBD:** + * disable broken tests ([eb32b30b](https://github.com/dracut-ng/dracut-ng/commit/eb32b30b73b6846048d219a7b304bc8e57c53119)) + * return actual test run result from test_run() ([cfe3ce3c](https://github.com/dracut-ng/dracut-ng/commit/cfe3ce3cee04669291e7b412a1f9730a59ad8f66)) + * enable serial console for test runs ([1993786f](https://github.com/dracut-ng/dracut-ng/commit/1993786f8aa183ce44705fce2a748cefdd2ed5c9)) + * don't double-pass test dir to marker check ([5928c938](https://github.com/dracut-ng/dracut-ng/commit/5928c938590c69ef297d2f86dd0eb27080c0e03f)) +* **TEST-NFS:** use --add instead of --modules to create test-makeroot ([0a94eab6](https://github.com/dracut-ng/dracut-ng/commit/0a94eab66d330dd3d01593fd474103e8fb9e4ad7)) +* **convertfs:** + * drop unused find_mount function ([04628fc4](https://github.com/dracut-ng/dracut-ng/commit/04628fc4ae37bb0f32c426e9a3661f9bb2ead1ab)) + * disable SC2317 for EXIT trap function ([6668694d](https://github.com/dracut-ng/dracut-ng/commit/6668694df0895a9aa61f859b8b618a4bb65b3178)) + * quote single CP_HARDLINK variable ([00ba4dae](https://github.com/dracut-ng/dracut-ng/commit/00ba4dae4e392942c9090723133f3acba1731962)) +* **crypt:** decryption when rd.luks.name is set ([015a0fa6](https://github.com/dracut-ng/dracut-ng/commit/015a0fa63367f6e48fd9edd7808305877276ed7f)) +* **dbus:** drop unreachable return statement ([c3764b92](https://github.com/dracut-ng/dracut-ng/commit/c3764b925ae0a9aab2a2db86a77a02e48f6a4d96)) +* **dbus-daemon:** actually enable the dbus service and socket ([71f2ff50](https://github.com/dracut-ng/dracut-ng/commit/71f2ff50f55f24b4435aff6143fc3041db6f3d1d)) +* **dmsquash-live:** + * make sure erofs module is installed ([e52cf3c1](https://github.com/dracut-ng/dracut-ng/commit/e52cf3c128b3b818a5830b6d92e257084d34b3dc)) + * quote variables ([5391fa2e](https://github.com/dracut-ng/dracut-ng/commit/5391fa2e671f3ed78e0346bd1f7de47abcb7fe73)) +* **dmsquash-live-autooverlay:** quote variables ([24ab9e66](https://github.com/dracut-ng/dracut-ng/commit/24ab9e66d0421eb8441b62f5a7dad3b7e3e0324f)) +* **dracut:** + * microcode loading named .initramfs ([cd3f04ab](https://github.com/dracut-ng/dracut-ng/commit/cd3f04ab9d7521f59bbd7fde489584aba5db5384)) + * address shellcheck SC2004 ([79e372de](https://github.com/dracut-ng/dracut-ng/commit/79e372def132818df988f821d3e60dd9137fee01)) + * quote strip_cmd variable ([538689bc](https://github.com/dracut-ng/dracut-ng/commit/538689bc723f096341fbf780fd7b4ec1f023e085)) +* **dracut-catimages.sh:** drop unused dwarning function ([34bf2fe4](https://github.com/dracut-ng/dracut-ng/commit/34bf2fe40308ee67a3d555cc475af230f983e958)) +* **dracut-functions:** avoid awk in get_maj_min() ([ec7efd57](https://github.com/dracut-ng/dracut-ng/commit/ec7efd5701e9a1b24f2e85666d625fb1fe46ce86)) +* **dracut-init:** change lookup order for rules files ([46932e33](https://github.com/dracut-ng/dracut-ng/commit/46932e33536e2223f297dc7369bd14d8b578caa3)) +* **dracut-init.sh:** + * clarify the error message ([f83d8f90](https://github.com/dracut-ng/dracut-ng/commit/f83d8f90a15812ea260032d05885c989665b5933)) + * quote dracutbasedir variable ([5969b230](https://github.com/dracut-ng/dracut-ng/commit/5969b2306d65c231a2a6be89f1ca13862287dac3)) +* **dracut-initramfs-restore.sh:** correct initrd globbing ([cc5e8d6f](https://github.com/dracut-ng/dracut-ng/commit/cc5e8d6f9ff965e91a749a653c7114cb04edb358)) +* **dracut-install:** copy xattr when use clone ioctl ([3e1d0bc1](https://github.com/dracut-ng/dracut-ng/commit/3e1d0bc1df6fcc5649e38d1016f05712f634b2f5)) +* **dracut-lib:** + * quote _ctty variable ([22910365](https://github.com/dracut-ng/dracut-ng/commit/2291036520413379932e41ff22d704cd3397e76f)) + * quote var variable ([7a277629](https://github.com/dracut-ng/dracut-ng/commit/7a277629b5c37ab5bf7a39605e8d1546c0086835)) + * quote _b variable ([e4ec0d33](https://github.com/dracut-ng/dracut-ng/commit/e4ec0d3397d0f10abb69a4c91d1c6b448f986d02)) +* **dracut-logger.sh:** + * disable SC2317 for logger functions ([c77365ce](https://github.com/dracut-ng/dracut-ng/commit/c77365ce2c38cd9d1cd4aab27edd0fab14950ced)) + * quote _dlogfd variable ([89eddc42](https://github.com/dracut-ng/dracut-ng/commit/89eddc420f00f0c1b790b960c1e5abc348b98722)) +* **dracut.sh:** drop unused read_arg function ([a9ea0175](https://github.com/dracut-ng/dracut-ng/commit/a9ea01755edb4a63518234b52c25e240b4c6e1d3)) +* **fips:** remove reference to kernel module zlib in fips module ([22f451d5](https://github.com/dracut-ng/dracut-ng/commit/22f451d57585cb01ee5a84ef73d104110cb7d422)) +* **iscsi:** address shellcheck SC2319 ([54676c83](https://github.com/dracut-ng/dracut-ng/commit/54676c83d1101d709a958d1a87e6d8508b360c3b)) +* **lsinitrd.sh:** disable SC2317 for cat functions ([f62049b2](https://github.com/dracut-ng/dracut-ng/commit/f62049b251d66c0c8f755a0a2e769cfe90b9b901)) +* **lunmask:** quote LUN variable ([d20be112](https://github.com/dracut-ng/dracut-ng/commit/d20be112231d89e220f97bb4adb0b5db572bbc24)) +* **lvmthinpool-monitor:** adress shellcheck SC2319 ([199f4108](https://github.com/dracut-ng/dracut-ng/commit/199f410861d2e2204ec77045fcf37a21fe31bdfe)) +* **man:** clarify semantics for --kernel-cmdline ([aba502f3](https://github.com/dracut-ng/dracut-ng/commit/aba502f324b957bc625462b39748f4aca1650225)) +* **mdraid:** try to assemble the missing raid device ([3fd43858](https://github.com/dracut-ng/dracut-ng/commit/3fd4385873bb82ae9f759ef5af32bf1732d298b4)) +* **multipath:** + * omit module if included with no multipath devices ([377d52cb](https://github.com/dracut-ng/dracut-ng/commit/377d52cb9867dc4074fe78965e1bfcdf80be14a1)) + * omit module if included with no multipath devices ([4957ffa9](https://github.com/dracut-ng/dracut-ng/commit/4957ffa935ea8c393c8fed867f6051da4ca43d58)) +* **net-lib:** require and install only the necessary binaries ([29609268](https://github.com/dracut-ng/dracut-ng/commit/29609268b74472cbf4ac02f83e1edd9609169de2)) +* **network:** deprioritize connman for network selection ([dec4978f](https://github.com/dracut-ng/dracut-ng/commit/dec4978fa06252d69c63a5939adb6d706195fe96)) +* **network-legacy:** quote bridgename variable ([bc166ece](https://github.com/dracut-ng/dracut-ng/commit/bc166ece9924793c53ac43ce7505669d5b84b829)) +* **nfs:** + * support rpcbind user named _rpc ([4a236f01](https://github.com/dracut-ng/dracut-ng/commit/4a236f015905f598e2976ae6f0f460ec9a567f2b)) + * quote rpcpipefspath variable ([58a46715](https://github.com/dracut-ng/dracut-ng/commit/58a46715598185d0fd836847abc2fdd6408a736b)) +* **release:** version lock clog ([58d4d7d6](https://github.com/dracut-ng/dracut-ng/commit/58d4d7d683cfaa1455ed3be8430613e8251cfeab)) +* **rt:** use singular argument for timeout value ([e2e6579a](https://github.com/dracut-ng/dracut-ng/commit/e2e6579afa49b7878bf03327f16b2ddabd139380)) +* **shell-completion:** remove hashbang from bash completions ([c50e742c](https://github.com/dracut-ng/dracut-ng/commit/c50e742c530f114c50ef9a2b63e0cc6d0150838a)) +* **syslog:** quote conf variable ([28e1b17b](https://github.com/dracut-ng/dracut-ng/commit/28e1b17b750ef7d8a269fa50d7ab0e43fd7b3ebd)) +* **systemd:** check for systemd-vconsole-setup.service ([5a3ad259](https://github.com/dracut-ng/dracut-ng/commit/5a3ad259aca1a0ed09dccdb0db5873cd5b94f666)) +* **systemd-hostnamed:** + * also enable socket units ([133978d9](https://github.com/dracut-ng/dracut-ng/commit/133978d96c9dbf02e9bfbf8214111540c6e1d6ab)) + * add missing systemd-hostnamed.socket ([f25bb1e2](https://github.com/dracut-ng/dracut-ng/commit/f25bb1e2b27cb3246e6fc51a33b13775e4f4ffce)) +* **systemd-networkd:** + * remove default network if others were generated ([02a1ea4b](https://github.com/dracut-ng/dracut-ng/commit/02a1ea4b308aeb339dcddf90b489b7de86e12149)) + * add support for proper netroot invocation ([0e1e7871](https://github.com/dracut-ng/dracut-ng/commit/0e1e78711502347412e2c0a0621773f034332499)) + * this module depends on systemd ([1aa2e4ff](https://github.com/dracut-ng/dracut-ng/commit/1aa2e4ffe7e04bb57ca57bc7cd3d38a7d5d3dc33)) +* **systemd-pcrphase:** + * make tpm2-tss an optional dependency ([a2193b71](https://github.com/dracut-ng/dracut-ng/commit/a2193b71f7be75f719eec29faacae36ab25e9147)) + * in hostonly mode do not try to include systemd-pcrphase ([96d153fe](https://github.com/dracut-ng/dracut-ng/commit/96d153fe927987ce31a1f876b7eeea6fe9cee06a)) +* **test:** + * run test 14 with systemd again ([43fa0c4e](https://github.com/dracut-ng/dracut-ng/commit/43fa0c4e36c78566421092c63239985806a6610c)) + * reenable extended tests for Arch ([130f4dfc](https://github.com/dracut-ng/dracut-ng/commit/130f4dfce48b187944be9a0cacca794dd32428ad)) + * tests needs more storage space ([96aa5073](https://github.com/dracut-ng/dracut-ng/commit/96aa5073e38622fa431daec0c7237b71670de703)) + * use --add instead of --modules to create test-makeroot ([51d06540](https://github.com/dracut-ng/dracut-ng/commit/51d06540d19e4702ec61de6d2b5e2e68e8593b01)) + * use `-cpu max` by default ([44f5359f](https://github.com/dracut-ng/dracut-ng/commit/44f5359fe068d4c925777cf5291d8c64894bff4b)) +* **test-root:** quote _terminfodir variable ([db4ea5f3](https://github.com/dracut-ng/dracut-ng/commit/db4ea5f3cf3850432db411fab084fbc831ed043f)) +* **udev-rules:** install all rules even if systemd is not installed ([df8bf213](https://github.com/dracut-ng/dracut-ng/commit/df8bf213566ed1ac886775e2d6cb935119acbf20)) +* **zipl:** + * quote zipl_env variable ([39b1ffa2](https://github.com/dracut-ng/dracut-ng/commit/39b1ffa2ea05cb20371bb9fc3b1bd2d386d419d3)) + * quote ID_FS_TYPE variable ([34da5799](https://github.com/dracut-ng/dracut-ng/commit/34da5799512365513a4060fe41656d125d3db609)) +* **znet:** quote initdir variable ([79dbd435](https://github.com/dracut-ng/dracut-ng/commit/79dbd435bc500000877765e13bea69a83724e8d2)) + +#### Performance + +* **dracut-install:** + * use driver/module sysfs dirs for module name ([d71bec4a](https://github.com/dracut-ng/dracut-ng/commit/d71bec4aa444d92820e428c0629d0e75e268c815)) + * memoize find_kmod_module_from_sysfs_node ([6500e954](https://github.com/dracut-ng/dracut-ng/commit/6500e95494175819b382acbac8eafcdf72fabd6d)) + * preload kmod resources for quicker module lookup ([5a3f3773](https://github.com/dracut-ng/dracut-ng/commit/5a3f377300ee38a573a5a29f534e926106805bb6)) + +#### Contributors + +- Laszlo Gombos <laszlo.gombos@gmail.com> +- Benjamin Drung <benjamin.drung@canonical.com> +- BtbN <timo@rothenpieler.org> +- Antonio Alvarez Feijoo <antonio.feijoo@suse.com> +- Brian C. Lane <bcl@redhat.com> +- Alper Nebi Yasak <alpernebiyasak@gmail.com> +- Cornelius Hoffmann <coding@hoffmn.de> +- Hector Martin <marcan@marcan.st> +- Jose Ignacio Tornos Martinez <jtornosm@redhat.com> +- Andrew Ammerlaan <andrewammerlaan@gentoo.org> +- Cameron Baird <cameronbaird@microsoft.com> +- Daniel McIlvaney <damcilva@microsoft.com> +- David Tardon <dtardon@redhat.com> +- Huaxin Lu <luhuaxin1@huawei.com> +- Ian Wienand <iwienand@redhat.com> +- Lidong Zhong <lidong.zhong@suse.com> +- Louis Sautier <sautier.louis@gmail.com> +- Paul Charlton <techguru@byiq.com> +- Pavel Valena <pvalena@redhat.com> +- Timo Rothenpieler <timo@rothenpieler.org> + dracut-ng-102 ============= @@ -3384,4 +3550,3 @@ dracut-0.3 ========== - first public version - @@ -144,6 +144,27 @@ if test "$enable_dracut_cpio" = "yes"; then fi fi +cat << EOF > weakdep_test.c +#include <stddef.h> +#include <libkmod.h> + +int main(void) { + struct kmod_module *mod = NULL; + struct kmod_list *modweak = NULL; + + return kmod_module_get_weakdeps(mod, &modweak); +} +EOF + +# shellcheck disable=SC2086,SC2046 +${CC} $CFLAGS $LDFLAGS weakdep_test.c $(${PKG_CONFIG} --libs libkmod) > /dev/null 2>&1 +ret=$? +rm -f weakdep_test.c a.out + +if test $ret -eq 0; then + KMOD_CFLAGS_EXTRA+=" -DCONFIG_WEAKDEP" +fi + cat > Makefile.inc.$$ << EOF prefix ?= ${prefix} libdir ?= ${libdir:-${prefix}/lib} @@ -154,7 +175,7 @@ mandir ?= ${mandir:-${prefix}/share/man} enable_documentation ?= ${enable_documentation:-yes} enable_dracut_cpio ?= ${enable_dracut_cpio} bindir ?= ${bindir:-${prefix}/bin} -KMOD_CFLAGS ?= $(${PKG_CONFIG} --cflags " libkmod >= 23 ") +KMOD_CFLAGS ?= $(${PKG_CONFIG} --cflags " libkmod >= 23 ") ${KMOD_CFLAGS_EXTRA} KMOD_LIBS ?= $(${PKG_CONFIG} --libs " libkmod >= 23 ") FTS_LIBS ?= ${FTS_LIBS} EOF diff --git a/docs/BASH.md b/docs/BASH.md index e72a2f6..bed9321 100644 --- a/docs/BASH.md +++ b/docs/BASH.md @@ -210,4 +210,3 @@ func '' # cmd func ``` - diff --git a/docs/README.kernel b/docs/README.kernel index 69751eb..a4fd3c3 100644 --- a/docs/README.kernel +++ b/docs/README.kernel @@ -1,3 +1,2 @@ "dracut --kernel-only" is to build an initrd with only kernel modules and firmware files. "dracut --kernel-only" only executes "installkernel" in the modules subdirectories. - diff --git a/dracut-catimages.sh b/dracut-catimages.sh index b87e000..949e89b 100755 --- a/dracut-catimages.sh +++ b/dracut-catimages.sh @@ -16,10 +16,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -dwarning() { - echo "Warning: $*" >&2 -} - dinfo() { [[ $beverbose ]] && echo "$@" >&2 } diff --git a/dracut-functions.sh b/dracut-functions.sh index f9e5d3b..1f7a905 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -243,7 +243,7 @@ get_maj_min() { local _out if [[ $get_maj_min_cache_file ]]; then - _out="$(grep -m1 -oE "^$1 \S+$" "$get_maj_min_cache_file" | awk '{print $NF}')" + _out="$(grep -m1 -oE "^$1 \S+$" "$get_maj_min_cache_file" | grep -oE "\S+$")" fi if ! [[ "$_out" ]]; then diff --git a/dracut-init.sh b/dracut-init.sh index 863df0c..986da96 100755 --- a/dracut-init.sh +++ b/dracut-init.sh @@ -35,7 +35,7 @@ if ! [[ $dracutbasedir ]]; then dracutbasedir=${BASH_SOURCE[0]%/*} [[ $dracutbasedir == dracut-functions* ]] && dracutbasedir="." [[ $dracutbasedir ]] || dracutbasedir="." - dracutbasedir="$(readlink -f $dracutbasedir)" + dracutbasedir="$(readlink -f "$dracutbasedir")" fi if ! is_func dinfo > /dev/null 2>&1; then @@ -515,7 +515,7 @@ inst_rules() { inst_dir "$_target" for _rule in "$@"; do if [ "${_rule#/}" = "$_rule" ]; then - for r in "$dracutsysrootdir${udevdir}/rules.d" ${hostonly:+"$dracutsysrootdir"/etc/udev/rules.d}; do + for r in ${hostonly:+"$dracutsysrootdir"/etc/udev/rules.d} "$dracutsysrootdir${udevdir}/rules.d"; do [[ -e $r/$_rule ]] || continue _found="$r/$_rule" inst_rule_programs "$_found" @@ -610,7 +610,7 @@ prepare_udev_rules() { printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}" else # shellcheck disable=SC2016 - printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}" + printf '%sIMPORT{program}="/sbin/blkid -o udev -p $devnode"\n' "${line%%IMPORT BLKID}" fi else echo "$line" @@ -709,6 +709,15 @@ inst_libdir_file() { [[ ${#_files[@]} -gt 0 ]] && inst_multiple "${_files[@]}" } +# install sysusers files +inst_sysusers() { + inst_multiple -o "$sysusers/$*" + + if [[ $hostonly ]]; then + inst_multiple -H -o "$sysusersconfdir/$*" + fi +} + # get a command to decompress the given file get_decompress_cmd() { case "$1" in @@ -923,7 +932,7 @@ check_mount() { && force_add_dracutmodules+=" $_moddep " # if a module we depend on fail, fail also if ! check_module "$_moddep"; then - derror "Module '$_mod' depends on '$_moddep', which can't be installed" + derror "Module '$_mod' depends on module '$_moddep', which can't be installed" return 1 fi done @@ -998,7 +1007,7 @@ check_module() { && force_add_dracutmodules+=" $_moddep " # if a module we depend on fail, fail also if ! check_module "$_moddep"; then - derror "Module '$_mod' depends on '$_moddep', which can't be installed" + derror "Module '$_mod' depends on module '$_moddep', which can't be installed" return 1 fi done diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh index cc561b2..7472530 100755 --- a/dracut-initramfs-restore.sh +++ b/dracut-initramfs-restore.sh @@ -17,39 +17,46 @@ KERNEL_VERSION="$(uname -r)" SKIP="$dracutbasedir/skipcpio" [[ -x $SKIP ]] || SKIP="cat" -if [[ -d /efi/Default ]] || [[ -d /boot/Default ]] || [[ -d /boot/efi/Default ]]; then - MACHINE_ID="Default" -elif [[ -s /etc/machine-id ]]; then - read -r MACHINE_ID < /etc/machine-id - [[ $MACHINE_ID == "uninitialized" ]] && MACHINE_ID="Default" -else - MACHINE_ID="Default" -fi +find_initrd_for_kernel_version() { + local kernel_version="$1" + local base_path files initrd machine_id + + if [[ -d /efi/Default ]] || [[ -d /boot/Default ]] || [[ -d /boot/efi/Default ]]; then + machine_id="Default" + elif [[ -s /etc/machine-id ]]; then + read -r machine_id < /etc/machine-id + [[ $machine_id == "uninitialized" ]] && machine_id="Default" + else + machine_id="Default" + fi + + if [ -n "$machine_id" ]; then + for base_path in /efi /boot /boot/efi; do + initrd="${base_path}/${machine_id}/${kernel_version}/initrd" + if [ -f "$initrd" ]; then + echo "$initrd" + return + fi + done + fi + + if [[ -f /lib/modules/${kernel_version}/initrd ]]; then + echo "/lib/modules/${kernel_version}/initrd" + elif [[ -f /boot/initramfs-${kernel_version}.img ]]; then + echo "/boot/initramfs-${kernel_version}.img" + else + files=(/boot/initr*"${kernel_version}"*) + if [ "${#files[@]}" -ge 1 ] && [ -e "${files[0]}" ]; then + echo "${files[0]}" + fi + fi +} mount -o ro /boot &> /dev/null || true -if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \ - && [[ -d /efi/$MACHINE_ID || -L /efi/$MACHINE_ID ]]; then - IMG="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd" -elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \ - && [[ -d /boot/$MACHINE_ID || -L /boot/$MACHINE_ID ]]; then - IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd" -elif [[ -d /boot/efi/loader/entries || -L /boot/efi/loader/entries ]] \ - && [[ -d /boot/efi/$MACHINE_ID || -L /boot/efi/$MACHINE_ID ]]; then - IMG="/boot/efi/$MACHINE_ID/$KERNEL_VERSION/initrd" -elif [[ -f /lib/modules/${KERNEL_VERSION}/initrd ]]; then - IMG="/lib/modules/${KERNEL_VERSION}/initrd" -elif [[ -f /boot/initramfs-${KERNEL_VERSION}.img ]]; then - IMG="/boot/initramfs-${KERNEL_VERSION}.img" -elif mountpoint -q /efi; then - IMG="/efi/$MACHINE_ID/$KERNEL_VERSION/initrd" -elif mountpoint -q /boot/efi; then - IMG="/boot/efi/$MACHINE_ID/$KERNEL_VERSION/initrd" -else - files=("/boot/initr*${KERNEL_VERSION}*") - if [ "${#files[@]}" -ge 1 ] && [ -e "${files[0]}" ]; then - IMG="${files[0]}" - elif [[ -f /boot/initramfs-linux.img ]]; then +IMG=$(find_initrd_for_kernel_version "$KERNEL_VERSION") +if [ -z "$IMG" ]; then + if [[ -f /boot/initramfs-linux.img ]]; then IMG="/boot/initramfs-linux.img" else echo "No initramfs image found to restore!" @@ -83,7 +90,7 @@ if [[ -d squash ]]; then fi if grep -q -w selinux /sys/kernel/security/lsm 2> /dev/null \ - && [ -e /etc/selinux/config -a -x /usr/sbin/setfiles ]; then + && [ -e /etc/selinux/config ] && [ -x /usr/sbin/setfiles ]; then . /etc/selinux/config if [[ $SELINUX != "disabled" && -n $SELINUXTYPE ]]; then /usr/sbin/setfiles -v -r /run/initramfs /etc/selinux/"${SELINUXTYPE}"/contexts/files/file_contexts /run/initramfs > /dev/null diff --git a/dracut-logger.sh b/dracut-logger.sh index 1a57e5e..64eb5f5 100755 --- a/dracut-logger.sh +++ b/dracut-logger.sh @@ -179,33 +179,40 @@ dlog_init() { if ((stdloglvl < 6)) && ((kmsgloglvl < 6)) && ((fileloglvl < 6)) && ((sysloglvl < 6)); then unset dtrace + # shellcheck disable=SC2317 # exposed via API dtrace() { :; } fi if ((stdloglvl < 5)) && ((kmsgloglvl < 5)) && ((fileloglvl < 5)) && ((sysloglvl < 5)); then unset ddebug + # shellcheck disable=SC2317 # exposed via API ddebug() { :; } fi if ((stdloglvl < 4)) && ((kmsgloglvl < 4)) && ((fileloglvl < 4)) && ((sysloglvl < 4)); then unset dinfo + # shellcheck disable=SC2317 # exposed via API dinfo() { :; } fi if ((stdloglvl < 3)) && ((kmsgloglvl < 3)) && ((fileloglvl < 3)) && ((sysloglvl < 3)); then unset dwarn + # shellcheck disable=SC2317 # exposed via API dwarn() { :; } unset dwarning + # shellcheck disable=SC2317 # exposed via API dwarning() { :; } fi if ((stdloglvl < 2)) && ((kmsgloglvl < 2)) && ((fileloglvl < 2)) && ((sysloglvl < 2)); then unset derror + # shellcheck disable=SC2317 # exposed via API derror() { :; } fi if ((stdloglvl < 1)) && ((kmsgloglvl < 1)) && ((fileloglvl < 1)) && ((sysloglvl < 1)); then unset dfatal + # shellcheck disable=SC2317 # exposed via API dfatal() { :; } fi @@ -327,7 +334,7 @@ _do_dlog() { if ((lvl <= sysloglvl)); then if [[ "$_dlogfd" ]]; then - printf -- "<%s>%s\n" "$(($(_dlvl2syslvl "$lvl") & 7))" "$msg" >&$_dlogfd + printf -- "<%s>%s\n" "$(($(_dlvl2syslvl "$lvl") & 7))" "$msg" >&"$_dlogfd" else logger -t "dracut[$$]" -p "$(_lvl2syspri "$lvl")" -- "$msg" fi diff --git a/dracut-version.sh b/dracut-version.sh index b790a80..327ef10 100755 --- a/dracut-version.sh +++ b/dracut-version.sh @@ -1,3 +1,3 @@ #!/bin/sh # shellcheck disable=SC2034 -DRACUT_VERSION=102 +DRACUT_VERSION=103 diff --git a/dracut.conf.d/fips.conf.example b/dracut.conf.d/50-fips.conf.example index ccf56c7..4363869 100644 --- a/dracut.conf.d/fips.conf.example +++ b/dracut.conf.d/50-fips.conf.example @@ -1,3 +1,2 @@ # turn on fips module - add_dracutmodules+=" fips " diff --git a/dracut.conf.d/50-generic.conf.example b/dracut.conf.d/50-generic.conf.example new file mode 100644 index 0000000..27494d6 --- /dev/null +++ b/dracut.conf.d/50-generic.conf.example @@ -0,0 +1,2 @@ +# generic initrd works on other platforms than the one dracut was called +hostonly="no" diff --git a/dracut.conf.d/50-hostonly.conf.example b/dracut.conf.d/50-hostonly.conf.example new file mode 100644 index 0000000..72fc929 --- /dev/null +++ b/dracut.conf.d/50-hostonly.conf.example @@ -0,0 +1,2 @@ +# optimize initrd to be as small as possible for faster boot performance, tailored to the current host +hostonly="yes" diff --git a/dracut.conf.d/50-ima.conf.example b/dracut.conf.d/50-ima.conf.example new file mode 100644 index 0000000..e5478f5 --- /dev/null +++ b/dracut.conf.d/50-ima.conf.example @@ -0,0 +1,2 @@ +# turn on Linux Integrity Measurement Architecture (IMA) modules +add_dracutmodules+=" integrity " diff --git a/dracut.conf.d/50-rescue.conf.example b/dracut.conf.d/50-rescue.conf.example new file mode 100644 index 0000000..6d6a170 --- /dev/null +++ b/dracut.conf.d/50-rescue.conf.example @@ -0,0 +1 @@ +dracut_rescue_image="yes" diff --git a/dracut.conf.d/suse.conf.example b/dracut.conf.d/suse.conf.example index b9b0c37..9cd0c53 100644 --- a/dracut.conf.d/suse.conf.example +++ b/dracut.conf.d/suse.conf.example @@ -11,4 +11,3 @@ compress="zstd -3 -T0 -q" i18n_vars="/etc/sysconfig/language:RC_LANG-LANG,RC_LC_ALL-LC_ALL /etc/sysconfig/console:CONSOLE_UNICODEMAP-FONT_UNIMAP,CONSOLE_FONT-FONT,CONSOLE_SCREENMAP-FONT_MAP /etc/sysconfig/keyboard:KEYTABLE-KEYMAP" omit_drivers+=" i2o_scsi " - diff --git a/dracut.html b/dracut.html index 7bf14aa..b288556 100644 --- a/dracut.html +++ b/dracut.html @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>dracut 102</title><style type="text/css"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>dracut 103</title><style type="text/css"> body, h1, h2, h3, h4, h5, h6, pre, li, div { line-height: 1.29em; @@ -1117,7 +1117,7 @@ table tr.even td { color: #3c6eb4; } -</style><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="book" lang="en"><div class="titlepage"><div><div><h1 class="title"><a id="idm1"></a>dracut 102</h1></div><div><div class="author"><h3 class="author"><span class="firstname">Harald</span> <span class="surname">Hoyer</span></h3><code class="email"><<a class="email" href="mailto:harald@profian.com">harald@profian.com</a>></code></div></div></div><hr /></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="part"><a href="#_introduction">I. Introduction</a></span></dt><dd><dl><dt><span class="chapter"><a href="#_definition">1. Definition</a></span></dt><dt><span class="chapter"><a href="#_rationale">2. Rationale</a></span></dt><dt><span class="chapter"><a href="#_implementation">3. Implementation</a></span></dt><dt><span class="chapter"><a href="#_mount_preparations">4. Mount preparations</a></span></dt><dt><span class="chapter"><a href="#_dracut_on_shutdown">5. Dracut on shutdown</a></span></dt></dl></dd><dt><span class="part"><a href="#_user_manual">II. User Manual</a></span></dt><dd><dl><dt><span class="chapter"><a href="#_dracut_8">6. DRACUT(8)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name">NAME</a></span></dt><dt><span class="section"><a href="#_synopsis">SYNOPSIS</a></span></dt><dt><span class="section"><a href="#_description">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_usage">USAGE</a></span></dt><dd><dl><dt><span class="section"><a href="#_inspecting_the_contents">Inspecting the Contents</a></span></dt><dt><span class="section"><a href="#_adding_dracut_modules">Adding dracut Modules</a></span></dt><dt><span class="section"><a href="#_omitting_dracut_modules">Omitting dracut Modules</a></span></dt><dt><span class="section"><a href="#_adding_kernel_modules">Adding Kernel Modules</a></span></dt><dt><span class="section"><a href="#_boot_parameters">Boot parameters</a></span></dt><dt><span class="section"><a href="#Injecting">Injecting custom Files</a></span></dt><dt><span class="section"><a href="#NetworkBoot">Network Boot</a></span></dt></dl></dd><dt><span class="section"><a href="#_troubleshooting">Troubleshooting</a></span></dt><dd><dl><dt><span class="section"><a href="#identifying-your-problem-area">Identifying your problem area</a></span></dt><dt><span class="section"><a href="#information-to-include-in-your-report">Information to include in your report</a></span></dt><dt><span class="section"><a href="#debugging-dracut">Debugging dracut</a></span></dt></dl></dd><dt><span class="section"><a href="#_options">OPTIONS</a></span></dt><dt><span class="section"><a href="#_environment">ENVIRONMENT</a></span></dt><dt><span class="section"><a href="#_files">FILES</a></span></dt><dd><dl><dt><span class="section"><a href="#_configuration_in_the_initramfs">Configuration in the initramfs</a></span></dt></dl></dd><dt><span class="section"><a href="#_availability">AVAILABILITY</a></span></dt><dt><span class="section"><a href="#_authors">AUTHORS</a></span></dt><dt><span class="section"><a href="#_see_also">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#dracutconf5">7. DRACUT.CONF(5)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_2">NAME</a></span></dt><dt><span class="section"><a href="#_synopsis_2">SYNOPSIS</a></span></dt><dt><span class="section"><a href="#_description_2">Description</a></span></dt><dt><span class="section"><a href="#_files_2">Files</a></span></dt><dt><span class="section"><a href="#_author">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_2">See Also</a></span></dt></dl></dd><dt><span class="chapter"><a href="#dracutcmdline7">8. DRACUT.CMDLINE(7)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_3">NAME</a></span></dt><dt><span class="section"><a href="#_description_3">DESCRIPTION</a></span></dt><dd><dl><dt><span class="section"><a href="#_standard">Standard</a></span></dt><dt><span class="section"><a href="#_iso_scan_filename">iso-scan/filename</a></span></dt><dt><span class="section"><a href="#_misc">Misc</a></span></dt><dt><span class="section"><a href="#dracutkerneldebug">Debug</a></span></dt><dt><span class="section"><a href="#_i18n">I18N</a></span></dt><dt><span class="section"><a href="#_lvm">LVM</a></span></dt><dt><span class="section"><a href="#_crypto_luks">crypto LUKS</a></span></dt><dt><span class="section"><a href="#_crypto_luks_key_on_removable_device_support">crypto LUKS - key on removable device support</a></span></dt><dt><span class="section"><a href="#_md_raid">MD RAID</a></span></dt><dt><span class="section"><a href="#_dm_raid">DM RAID</a></span></dt><dt><span class="section"><a href="#_multipath">MULTIPATH</a></span></dt><dt><span class="section"><a href="#_fips">FIPS</a></span></dt><dt><span class="section"><a href="#_network">Network</a></span></dt><dt><span class="section"><a href="#_nfs">NFS</a></span></dt><dt><span class="section"><a href="#_cifs">CIFS</a></span></dt><dt><span class="section"><a href="#_iscsi">iSCSI</a></span></dt><dt><span class="section"><a href="#_fcoe">FCoE</a></span></dt><dt><span class="section"><a href="#_nvmf">NVMf</a></span></dt><dt><span class="section"><a href="#_nbd">NBD</a></span></dt><dt><span class="section"><a href="#_virtiofs">VIRTIOFS</a></span></dt><dt><span class="section"><a href="#_dasd">DASD</a></span></dt><dt><span class="section"><a href="#_zfcp">ZFCP</a></span></dt><dt><span class="section"><a href="#_znet">ZNET</a></span></dt><dt><span class="section"><a href="#_booting_live_images">Booting live images</a></span></dt><dt><span class="section"><a href="#_zipl">ZIPL</a></span></dt><dt><span class="section"><a href="#_cio_ignore">CIO_IGNORE</a></span></dt><dt><span class="section"><a href="#_plymouth_boot_splash">Plymouth Boot Splash</a></span></dt><dt><span class="section"><a href="#_kernel_keys">Kernel keys</a></span></dt><dt><span class="section"><a href="#_deprecated_renamed_options">Deprecated, renamed Options</a></span></dt><dt><span class="section"><a href="#_configuration_in_the_initramfs_2">Configuration in the Initramfs</a></span></dt></dl></dd><dt><span class="section"><a href="#_author_2">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_3">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#lsinitrd1">9. LSINITRD(1)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_4">NAME</a></span></dt><dt><span class="section"><a href="#_synopsis_3">SYNOPSIS</a></span></dt><dt><span class="section"><a href="#_description_4">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_options_2">OPTIONS</a></span></dt><dt><span class="section"><a href="#_availability_2">AVAILABILITY</a></span></dt><dt><span class="section"><a href="#_authors_2">AUTHORS</a></span></dt><dt><span class="section"><a href="#_see_also_4">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#_developer_manual">10. Developer Manual</a></span></dt><dt><span class="chapter"><a href="#dracutmodules7">11. DRACUT.MODULES(7)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_5">NAME</a></span></dt><dt><span class="section"><a href="#_description_5">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#stages">Boot Process Stages</a></span></dt><dd><dl><dt><span class="section"><a href="#_hook_cmdline">Hook: cmdline</a></span></dt><dt><span class="section"><a href="#_hook_pre_udev">Hook: pre-udev</a></span></dt><dt><span class="section"><a href="#_start_udev">Start Udev</a></span></dt><dt><span class="section"><a href="#_hook_pre_trigger">Hook: pre-trigger</a></span></dt><dt><span class="section"><a href="#_trigger_udev">Trigger Udev</a></span></dt><dt><span class="section"><a href="#_main_loop">Main Loop</a></span></dt><dt><span class="section"><a href="#_hook_pre_mount">Hook: pre-mount</a></span></dt><dt><span class="section"><a href="#_hook_mount">Hook: mount</a></span></dt><dt><span class="section"><a href="#_hook_pre_pivot">Hook: pre-pivot</a></span></dt><dt><span class="section"><a href="#_hook_cleanup">Hook: cleanup</a></span></dt><dt><span class="section"><a href="#_cleanup_and_switch_root">Cleanup and switch_root</a></span></dt></dl></dd><dt><span class="section"><a href="#_network_infrastructure">Network Infrastructure</a></span></dt><dt><span class="section"><a href="#_writing_a_module">Writing a Module</a></span></dt><dd><dl><dt><span class="section"><a href="#_module_setup_sh_check">module-setup.sh: check()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_depends">module-setup.sh: depends()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_cmdline">module-setup.sh: cmdline()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_install">module-setup.sh: install()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_installkernel">module-setup.sh: installkernel()</a></span></dt><dt><span class="section"><a href="#_anchor_id_creation_xreflabel_creation_creation_functions">Creation Functions</a></span></dt><dt><span class="section"><a href="#_initramfs_functions">Initramfs Functions</a></span></dt><dt><span class="section"><a href="#_network_modules">Network Modules</a></span></dt></dl></dd><dt><span class="section"><a href="#_author_3">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_5">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#dracutbootup7">12. DRACUT.BOOTUP(7)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_6">NAME</a></span></dt><dt><span class="section"><a href="#_description_6">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_author_4">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_6">SEE ALSO</a></span></dt></dl></dd><dt><span class="appendix"><a href="#_license">A. License</a></span></dt></dl></dd></dl></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a id="_introduction"></a>Part I. Introduction</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="chapter"><a href="#_definition">1. Definition</a></span></dt><dt><span class="chapter"><a href="#_rationale">2. Rationale</a></span></dt><dt><span class="chapter"><a href="#_implementation">3. Implementation</a></span></dt><dt><span class="chapter"><a href="#_mount_preparations">4. Mount preparations</a></span></dt><dt><span class="chapter"><a href="#_dracut_on_shutdown">5. Dracut on shutdown</a></span></dt></dl></div><p>This section is a modified version of +</style><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="book" lang="en"><div class="titlepage"><div><div><h1 class="title"><a id="idm1"></a>dracut 103</h1></div><div><div class="author"><h3 class="author"><span class="firstname">Harald</span> <span class="surname">Hoyer</span></h3><code class="email"><<a class="email" href="mailto:harald@profian.com">harald@profian.com</a>></code></div></div></div><hr /></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="part"><a href="#_introduction">I. Introduction</a></span></dt><dd><dl><dt><span class="chapter"><a href="#_definition">1. Definition</a></span></dt><dt><span class="chapter"><a href="#_rationale">2. Rationale</a></span></dt><dt><span class="chapter"><a href="#_implementation">3. Implementation</a></span></dt><dt><span class="chapter"><a href="#_mount_preparations">4. Mount preparations</a></span></dt><dt><span class="chapter"><a href="#_dracut_on_shutdown">5. Dracut on shutdown</a></span></dt></dl></dd><dt><span class="part"><a href="#_user_manual">II. User Manual</a></span></dt><dd><dl><dt><span class="chapter"><a href="#_dracut_8">6. DRACUT(8)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name">NAME</a></span></dt><dt><span class="section"><a href="#_synopsis">SYNOPSIS</a></span></dt><dt><span class="section"><a href="#_description">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_usage">USAGE</a></span></dt><dd><dl><dt><span class="section"><a href="#_inspecting_the_contents">Inspecting the Contents</a></span></dt><dt><span class="section"><a href="#_adding_dracut_modules">Adding dracut Modules</a></span></dt><dt><span class="section"><a href="#_omitting_dracut_modules">Omitting dracut Modules</a></span></dt><dt><span class="section"><a href="#_adding_kernel_modules">Adding Kernel Modules</a></span></dt><dt><span class="section"><a href="#_boot_parameters">Boot parameters</a></span></dt><dt><span class="section"><a href="#Injecting">Injecting custom Files</a></span></dt><dt><span class="section"><a href="#NetworkBoot">Network Boot</a></span></dt></dl></dd><dt><span class="section"><a href="#_troubleshooting">Troubleshooting</a></span></dt><dd><dl><dt><span class="section"><a href="#identifying-your-problem-area">Identifying your problem area</a></span></dt><dt><span class="section"><a href="#information-to-include-in-your-report">Information to include in your report</a></span></dt><dt><span class="section"><a href="#debugging-dracut">Debugging dracut</a></span></dt></dl></dd><dt><span class="section"><a href="#_options">OPTIONS</a></span></dt><dt><span class="section"><a href="#_environment">ENVIRONMENT</a></span></dt><dt><span class="section"><a href="#_files">FILES</a></span></dt><dd><dl><dt><span class="section"><a href="#_configuration_in_the_initramfs">Configuration in the initramfs</a></span></dt></dl></dd><dt><span class="section"><a href="#_availability">AVAILABILITY</a></span></dt><dt><span class="section"><a href="#_authors">AUTHORS</a></span></dt><dt><span class="section"><a href="#_see_also">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#dracutconf5">7. DRACUT.CONF(5)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_2">NAME</a></span></dt><dt><span class="section"><a href="#_synopsis_2">SYNOPSIS</a></span></dt><dt><span class="section"><a href="#_description_2">Description</a></span></dt><dt><span class="section"><a href="#_files_2">Files</a></span></dt><dt><span class="section"><a href="#_author">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_2">See Also</a></span></dt></dl></dd><dt><span class="chapter"><a href="#dracutcmdline7">8. DRACUT.CMDLINE(7)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_3">NAME</a></span></dt><dt><span class="section"><a href="#_description_3">DESCRIPTION</a></span></dt><dd><dl><dt><span class="section"><a href="#_standard">Standard</a></span></dt><dt><span class="section"><a href="#_iso_scan_filename">iso-scan/filename</a></span></dt><dt><span class="section"><a href="#_misc">Misc</a></span></dt><dt><span class="section"><a href="#dracutkerneldebug">Debug</a></span></dt><dt><span class="section"><a href="#_i18n">I18N</a></span></dt><dt><span class="section"><a href="#_lvm">LVM</a></span></dt><dt><span class="section"><a href="#_crypto_luks">crypto LUKS</a></span></dt><dt><span class="section"><a href="#_crypto_luks_key_on_removable_device_support">crypto LUKS - key on removable device support</a></span></dt><dt><span class="section"><a href="#_md_raid">MD RAID</a></span></dt><dt><span class="section"><a href="#_dm_raid">DM RAID</a></span></dt><dt><span class="section"><a href="#_multipath">MULTIPATH</a></span></dt><dt><span class="section"><a href="#_fips">FIPS</a></span></dt><dt><span class="section"><a href="#_network">Network</a></span></dt><dt><span class="section"><a href="#_nfs">NFS</a></span></dt><dt><span class="section"><a href="#_cifs">CIFS</a></span></dt><dt><span class="section"><a href="#_iscsi">iSCSI</a></span></dt><dt><span class="section"><a href="#_fcoe">FCoE</a></span></dt><dt><span class="section"><a href="#_nvmf">NVMf</a></span></dt><dt><span class="section"><a href="#_nbd">NBD</a></span></dt><dt><span class="section"><a href="#_virtiofs">VIRTIOFS</a></span></dt><dt><span class="section"><a href="#_dasd">DASD</a></span></dt><dt><span class="section"><a href="#_zfcp">ZFCP</a></span></dt><dt><span class="section"><a href="#_znet">ZNET</a></span></dt><dt><span class="section"><a href="#_booting_live_images">Booting live images</a></span></dt><dt><span class="section"><a href="#_zipl">ZIPL</a></span></dt><dt><span class="section"><a href="#_cio_ignore">CIO_IGNORE</a></span></dt><dt><span class="section"><a href="#_plymouth_boot_splash">Plymouth Boot Splash</a></span></dt><dt><span class="section"><a href="#_kernel_keys">Kernel keys</a></span></dt><dt><span class="section"><a href="#_deprecated_renamed_options">Deprecated, renamed Options</a></span></dt><dt><span class="section"><a href="#_configuration_in_the_initramfs_2">Configuration in the Initramfs</a></span></dt></dl></dd><dt><span class="section"><a href="#_author_2">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_3">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#lsinitrd1">9. LSINITRD(1)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_4">NAME</a></span></dt><dt><span class="section"><a href="#_synopsis_3">SYNOPSIS</a></span></dt><dt><span class="section"><a href="#_description_4">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_options_2">OPTIONS</a></span></dt><dt><span class="section"><a href="#_availability_2">AVAILABILITY</a></span></dt><dt><span class="section"><a href="#_authors_2">AUTHORS</a></span></dt><dt><span class="section"><a href="#_see_also_4">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#_developer_manual">10. Developer Manual</a></span></dt><dt><span class="chapter"><a href="#dracutmodules7">11. DRACUT.MODULES(7)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_5">NAME</a></span></dt><dt><span class="section"><a href="#_description_5">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#stages">Boot Process Stages</a></span></dt><dd><dl><dt><span class="section"><a href="#_hook_cmdline">Hook: cmdline</a></span></dt><dt><span class="section"><a href="#_hook_pre_udev">Hook: pre-udev</a></span></dt><dt><span class="section"><a href="#_start_udev">Start Udev</a></span></dt><dt><span class="section"><a href="#_hook_pre_trigger">Hook: pre-trigger</a></span></dt><dt><span class="section"><a href="#_trigger_udev">Trigger Udev</a></span></dt><dt><span class="section"><a href="#_main_loop">Main Loop</a></span></dt><dt><span class="section"><a href="#_hook_pre_mount">Hook: pre-mount</a></span></dt><dt><span class="section"><a href="#_hook_mount">Hook: mount</a></span></dt><dt><span class="section"><a href="#_hook_pre_pivot">Hook: pre-pivot</a></span></dt><dt><span class="section"><a href="#_hook_cleanup">Hook: cleanup</a></span></dt><dt><span class="section"><a href="#_cleanup_and_switch_root">Cleanup and switch_root</a></span></dt></dl></dd><dt><span class="section"><a href="#_network_infrastructure">Network Infrastructure</a></span></dt><dt><span class="section"><a href="#_writing_a_module">Writing a Module</a></span></dt><dd><dl><dt><span class="section"><a href="#_module_setup_sh_check">module-setup.sh: check()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_depends">module-setup.sh: depends()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_cmdline">module-setup.sh: cmdline()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_install">module-setup.sh: install()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_installkernel">module-setup.sh: installkernel()</a></span></dt><dt><span class="section"><a href="#_anchor_id_creation_xreflabel_creation_creation_functions">Creation Functions</a></span></dt><dt><span class="section"><a href="#_initramfs_functions">Initramfs Functions</a></span></dt><dt><span class="section"><a href="#_network_modules">Network Modules</a></span></dt></dl></dd><dt><span class="section"><a href="#_author_3">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_5">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#dracutbootup7">12. DRACUT.BOOTUP(7)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_6">NAME</a></span></dt><dt><span class="section"><a href="#_description_6">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_author_4">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_6">SEE ALSO</a></span></dt></dl></dd><dt><span class="appendix"><a href="#_license">A. License</a></span></dt></dl></dd></dl></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a id="_introduction"></a>Part I. Introduction</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="chapter"><a href="#_definition">1. Definition</a></span></dt><dt><span class="chapter"><a href="#_rationale">2. Rationale</a></span></dt><dt><span class="chapter"><a href="#_implementation">3. Implementation</a></span></dt><dt><span class="chapter"><a href="#_mount_preparations">4. Mount preparations</a></span></dt><dt><span class="chapter"><a href="#_dracut_on_shutdown">5. Dracut on shutdown</a></span></dt></dl></div><p>This section is a modified version of <a class="ulink" href="http://en.wikipedia.org/wiki/Initrd" target="_top">http://en.wikipedia.org/wiki/Initrd</a> which is licensed under the Creative Commons Attribution/Share-Alike License.</p><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_definition"></a>Chapter 1. Definition</h2></div></div></div><p>An <span class="emphasis"><em>initial ramdisk</em></span> is a temporary file system used in the boot process of the Linux kernel. <span class="emphasis"><em>initrd</em></span> and <span class="emphasis"><em>initramfs</em></span> refer to slightly different schemes for @@ -1208,27 +1208,26 @@ rotated away. Instead, it is simply emptied and the final root file system mounted over the top.</p><p>If the systemd module is used in the initramfs, the ordering of the services started looks like <a class="xref" href="#dracutbootup7" title="Chapter 12. DRACUT.BOOTUP(7)">Chapter 12, <em>DRACUT.BOOTUP(7)</em></a>.</p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_dracut_on_shutdown"></a>Chapter 5. Dracut on shutdown</h2></div></div></div><p>On a systemd driven system, the dracut initramfs is also used for the shutdown procedure.</p><p>The following steps are executed during a shutdown:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> -systemd switches to the shutdown.target +The system starts to shut down </li><li class="listitem"> -systemd starts - $prefix/lib/systemd/system/shutdown.target.wants/dracut-shutdown.service +``$prefix/lib/systemd/system/sysinit.target.wants/dracut-shutdown.service`` + gets its ``ExecStop`` target triggered. </li><li class="listitem"> -dracut-shutdown.service executes /usr/lib/dracut/dracut-initramfs-restore - which unpacks the initramfs to /run/initramfs -</li><li class="listitem"> -systemd finishes shutdown.target +``dracut-shutdown.service`` executes + ``/usr/lib/dracut/dracut-initramfs-restore`` which unpacks the initramfs to + ``/run/initramfs`` </li><li class="listitem"> systemd kills all processes </li><li class="listitem"> systemd tries to unmount everything and mounts the remaining read-only </li><li class="listitem"> -systemd checks, if there is a /run/initramfs/shutdown executable +systemd checks if there is a ``/run/initramfs/shutdown`` executable </li><li class="listitem"> -if yes, it does a pivot_root to /run/initramfs and executes ./shutdown. - The old root is then mounted on /oldroot. - /usr/lib/dracut/modules.d/99shutdown/shutdown.sh is the shutdown executable. +if yes, it does a pivot_root to ``/run/initramfs`` and executes ``./shutdown``. + The old root is then mounted on ``/oldroot``. + ``/usr/lib/dracut/modules.d/99shutdown/shutdown.sh`` is the shutdown executable. </li><li class="listitem"> -shutdown will try to unmount every /oldroot mount and calls the various +shutdown will try to unmount every ``/oldroot`` mount and calls the various shutdown hooks from the dracut modules </li></ul></div><p>This ensures, that all devices are disassembled and unmounted cleanly.</p></div></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a id="_user_manual"></a>Part II. User Manual</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="chapter"><a href="#_dracut_8">6. DRACUT(8)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name">NAME</a></span></dt><dt><span class="section"><a href="#_synopsis">SYNOPSIS</a></span></dt><dt><span class="section"><a href="#_description">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_usage">USAGE</a></span></dt><dd><dl><dt><span class="section"><a href="#_inspecting_the_contents">Inspecting the Contents</a></span></dt><dt><span class="section"><a href="#_adding_dracut_modules">Adding dracut Modules</a></span></dt><dt><span class="section"><a href="#_omitting_dracut_modules">Omitting dracut Modules</a></span></dt><dt><span class="section"><a href="#_adding_kernel_modules">Adding Kernel Modules</a></span></dt><dt><span class="section"><a href="#_boot_parameters">Boot parameters</a></span></dt><dt><span class="section"><a href="#Injecting">Injecting custom Files</a></span></dt><dt><span class="section"><a href="#NetworkBoot">Network Boot</a></span></dt></dl></dd><dt><span class="section"><a href="#_troubleshooting">Troubleshooting</a></span></dt><dd><dl><dt><span class="section"><a href="#identifying-your-problem-area">Identifying your problem area</a></span></dt><dt><span class="section"><a href="#information-to-include-in-your-report">Information to include in your report</a></span></dt><dt><span class="section"><a href="#debugging-dracut">Debugging dracut</a></span></dt></dl></dd><dt><span class="section"><a href="#_options">OPTIONS</a></span></dt><dt><span class="section"><a href="#_environment">ENVIRONMENT</a></span></dt><dt><span class="section"><a href="#_files">FILES</a></span></dt><dd><dl><dt><span class="section"><a href="#_configuration_in_the_initramfs">Configuration in the initramfs</a></span></dt></dl></dd><dt><span class="section"><a href="#_availability">AVAILABILITY</a></span></dt><dt><span class="section"><a href="#_authors">AUTHORS</a></span></dt><dt><span class="section"><a href="#_see_also">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#dracutconf5">7. DRACUT.CONF(5)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_2">NAME</a></span></dt><dt><span class="section"><a href="#_synopsis_2">SYNOPSIS</a></span></dt><dt><span class="section"><a href="#_description_2">Description</a></span></dt><dt><span class="section"><a href="#_files_2">Files</a></span></dt><dt><span class="section"><a href="#_author">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_2">See Also</a></span></dt></dl></dd><dt><span class="chapter"><a href="#dracutcmdline7">8. DRACUT.CMDLINE(7)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_3">NAME</a></span></dt><dt><span class="section"><a href="#_description_3">DESCRIPTION</a></span></dt><dd><dl><dt><span class="section"><a href="#_standard">Standard</a></span></dt><dt><span class="section"><a href="#_iso_scan_filename">iso-scan/filename</a></span></dt><dt><span class="section"><a href="#_misc">Misc</a></span></dt><dt><span class="section"><a href="#dracutkerneldebug">Debug</a></span></dt><dt><span class="section"><a href="#_i18n">I18N</a></span></dt><dt><span class="section"><a href="#_lvm">LVM</a></span></dt><dt><span class="section"><a href="#_crypto_luks">crypto LUKS</a></span></dt><dt><span class="section"><a href="#_crypto_luks_key_on_removable_device_support">crypto LUKS - key on removable device support</a></span></dt><dt><span class="section"><a href="#_md_raid">MD RAID</a></span></dt><dt><span class="section"><a href="#_dm_raid">DM RAID</a></span></dt><dt><span class="section"><a href="#_multipath">MULTIPATH</a></span></dt><dt><span class="section"><a href="#_fips">FIPS</a></span></dt><dt><span class="section"><a href="#_network">Network</a></span></dt><dt><span class="section"><a href="#_nfs">NFS</a></span></dt><dt><span class="section"><a href="#_cifs">CIFS</a></span></dt><dt><span class="section"><a href="#_iscsi">iSCSI</a></span></dt><dt><span class="section"><a href="#_fcoe">FCoE</a></span></dt><dt><span class="section"><a href="#_nvmf">NVMf</a></span></dt><dt><span class="section"><a href="#_nbd">NBD</a></span></dt><dt><span class="section"><a href="#_virtiofs">VIRTIOFS</a></span></dt><dt><span class="section"><a href="#_dasd">DASD</a></span></dt><dt><span class="section"><a href="#_zfcp">ZFCP</a></span></dt><dt><span class="section"><a href="#_znet">ZNET</a></span></dt><dt><span class="section"><a href="#_booting_live_images">Booting live images</a></span></dt><dt><span class="section"><a href="#_zipl">ZIPL</a></span></dt><dt><span class="section"><a href="#_cio_ignore">CIO_IGNORE</a></span></dt><dt><span class="section"><a href="#_plymouth_boot_splash">Plymouth Boot Splash</a></span></dt><dt><span class="section"><a href="#_kernel_keys">Kernel keys</a></span></dt><dt><span class="section"><a href="#_deprecated_renamed_options">Deprecated, renamed Options</a></span></dt><dt><span class="section"><a href="#_configuration_in_the_initramfs_2">Configuration in the Initramfs</a></span></dt></dl></dd><dt><span class="section"><a href="#_author_2">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_3">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#lsinitrd1">9. LSINITRD(1)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_4">NAME</a></span></dt><dt><span class="section"><a href="#_synopsis_3">SYNOPSIS</a></span></dt><dt><span class="section"><a href="#_description_4">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_options_2">OPTIONS</a></span></dt><dt><span class="section"><a href="#_availability_2">AVAILABILITY</a></span></dt><dt><span class="section"><a href="#_authors_2">AUTHORS</a></span></dt><dt><span class="section"><a href="#_see_also_4">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#_developer_manual">10. Developer Manual</a></span></dt><dt><span class="chapter"><a href="#dracutmodules7">11. DRACUT.MODULES(7)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_5">NAME</a></span></dt><dt><span class="section"><a href="#_description_5">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#stages">Boot Process Stages</a></span></dt><dd><dl><dt><span class="section"><a href="#_hook_cmdline">Hook: cmdline</a></span></dt><dt><span class="section"><a href="#_hook_pre_udev">Hook: pre-udev</a></span></dt><dt><span class="section"><a href="#_start_udev">Start Udev</a></span></dt><dt><span class="section"><a href="#_hook_pre_trigger">Hook: pre-trigger</a></span></dt><dt><span class="section"><a href="#_trigger_udev">Trigger Udev</a></span></dt><dt><span class="section"><a href="#_main_loop">Main Loop</a></span></dt><dt><span class="section"><a href="#_hook_pre_mount">Hook: pre-mount</a></span></dt><dt><span class="section"><a href="#_hook_mount">Hook: mount</a></span></dt><dt><span class="section"><a href="#_hook_pre_pivot">Hook: pre-pivot</a></span></dt><dt><span class="section"><a href="#_hook_cleanup">Hook: cleanup</a></span></dt><dt><span class="section"><a href="#_cleanup_and_switch_root">Cleanup and switch_root</a></span></dt></dl></dd><dt><span class="section"><a href="#_network_infrastructure">Network Infrastructure</a></span></dt><dt><span class="section"><a href="#_writing_a_module">Writing a Module</a></span></dt><dd><dl><dt><span class="section"><a href="#_module_setup_sh_check">module-setup.sh: check()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_depends">module-setup.sh: depends()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_cmdline">module-setup.sh: cmdline()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_install">module-setup.sh: install()</a></span></dt><dt><span class="section"><a href="#_module_setup_sh_installkernel">module-setup.sh: installkernel()</a></span></dt><dt><span class="section"><a href="#_anchor_id_creation_xreflabel_creation_creation_functions">Creation Functions</a></span></dt><dt><span class="section"><a href="#_initramfs_functions">Initramfs Functions</a></span></dt><dt><span class="section"><a href="#_network_modules">Network Modules</a></span></dt></dl></dd><dt><span class="section"><a href="#_author_3">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_5">SEE ALSO</a></span></dt></dl></dd><dt><span class="chapter"><a href="#dracutbootup7">12. DRACUT.BOOTUP(7)</a></span></dt><dd><dl><dt><span class="section"><a href="#_name_6">NAME</a></span></dt><dt><span class="section"><a href="#_description_6">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_author_4">AUTHOR</a></span></dt><dt><span class="section"><a href="#_see_also_6">SEE ALSO</a></span></dt></dl></dd><dt><span class="appendix"><a href="#_license">A. License</a></span></dt></dl></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_dracut_8"></a>Chapter 6. DRACUT(8)</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="section"><a href="#_name">NAME</a></span></dt><dt><span class="section"><a href="#_synopsis">SYNOPSIS</a></span></dt><dt><span class="section"><a href="#_description">DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_usage">USAGE</a></span></dt><dd><dl><dt><span class="section"><a href="#_inspecting_the_contents">Inspecting the Contents</a></span></dt><dt><span class="section"><a href="#_adding_dracut_modules">Adding dracut Modules</a></span></dt><dt><span class="section"><a href="#_omitting_dracut_modules">Omitting dracut Modules</a></span></dt><dt><span class="section"><a href="#_adding_kernel_modules">Adding Kernel Modules</a></span></dt><dt><span class="section"><a href="#_boot_parameters">Boot parameters</a></span></dt><dt><span class="section"><a href="#Injecting">Injecting custom Files</a></span></dt><dt><span class="section"><a href="#NetworkBoot">Network Boot</a></span></dt></dl></dd><dt><span class="section"><a href="#_troubleshooting">Troubleshooting</a></span></dt><dd><dl><dt><span class="section"><a href="#identifying-your-problem-area">Identifying your problem area</a></span></dt><dt><span class="section"><a href="#information-to-include-in-your-report">Information to include in your report</a></span></dt><dt><span class="section"><a href="#debugging-dracut">Debugging dracut</a></span></dt></dl></dd><dt><span class="section"><a href="#_options">OPTIONS</a></span></dt><dt><span class="section"><a href="#_environment">ENVIRONMENT</a></span></dt><dt><span class="section"><a href="#_files">FILES</a></span></dt><dd><dl><dt><span class="section"><a href="#_configuration_in_the_initramfs">Configuration in the initramfs</a></span></dt></dl></dd><dt><span class="section"><a href="#_availability">AVAILABILITY</a></span></dt><dt><span class="section"><a href="#_authors">AUTHORS</a></span></dt><dt><span class="section"><a href="#_see_also">SEE ALSO</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_name"></a>NAME</h2></div></div></div><p>dracut - low-level tool for generating an initramfs/initrd image</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_synopsis"></a>SYNOPSIS</h2></div></div></div><p><span class="strong"><strong>dracut</strong></span> [<span class="emphasis"><em>OPTION…</em></span>] [<span class="emphasis"><em><image></em></span> [<span class="emphasis"><em><kernel version></em></span>]]</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_description"></a>DESCRIPTION</h2></div></div></div><p>Create an initramfs <image> for the kernel with the version <kernel version>. If <kernel version> is omitted, then the version of the actual running @@ -1255,9 +1254,8 @@ the --hostonly or -H option. Using this option, the resulting image will contain only those dracut modules, kernel modules and filesystems, which are needed to boot this specific machine. This has the drawback, that you can’t put the disk on another controller or machine, and that you can’t switch to another -root filesystem, without recreating the initramfs image. The usage of the ---hostonly option is only for experts and you will have to keep the broken -pieces. At least keep a copy of a general purpose image (and corresponding +root filesystem, without recreating the initramfs image. +It is recommended to keep a copy of a general purpose image (and corresponding kernel) as a fallback to rescue your system.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_inspecting_the_contents"></a>Inspecting the Contents</h3></div></div></div><p>To see the contents of the image created by dracut, you can use the lsinitrd tool.</p><pre class="screen"># lsinitrd | less</pre><p>To display the contents of a file in the initramfs also use the lsinitrd tool:</p><pre class="screen"># lsinitrd -f /etc/ld.so.conf include ld.so.conf.d/*.conf</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_adding_dracut_modules"></a>Adding dracut Modules</h3></div></div></div><p>Some dracut modules are turned off by default and have to be activated manually. @@ -1564,7 +1562,8 @@ example:</p><pre class="screen"># dracut --filesystems "filesystem1 filesystem2" example:</p><pre class="screen"># dracut --libdirs "dir1 dir2" ...</pre></div></dd><dt><span class="term"> <span class="strong"><strong>--kernel-cmdline <parameters></strong></span> </span></dt><dd> - Specify default kernel command line parameters. + Specify default kernel command line parameters. Despite its name, + this command only sets initrd parameters. </dd><dt><span class="term"> <span class="strong"><strong>--kernel-only</strong></span> </span></dt><dd> @@ -2299,7 +2298,8 @@ provide a valid <span class="emphasis"><em>/etc/fstab</em></span>.</p></div><div </dd><dt><span class="term"> <span class="strong"><strong>kernel_cmdline=</strong></span>"<span class="emphasis"><em>parameters</em></span>" </span></dt><dd> - Specify default kernel command line parameters. + Specify default kernel command line parameters. Despite + its name, this command only sets initrd parameters. </dd><dt><span class="term"> <span class="strong"><strong>kernel_only=</strong></span>"<span class="emphasis"><em>{yes|no}</em></span>" </span></dt><dd> @@ -2843,8 +2843,8 @@ it, e.g. <code class="literal">rd.luks.name=cccc=mykeys</code>, otherwise it get when not needed anymore.</p></div><div class="variablelist"><dl class="variablelist"><dt><span class="term"> <span class="strong"><strong>rd.luks.key.tout=0</strong></span> </span></dt><dd> - specify how many times dracut will try to read the keys specified in in - rd.luk.key. This gives a chance to the removable device containing the key + specify how many times dracut will try to read the keys specified in + rd.luks.key. This gives a chance to the removable device containing the key to initialise. </dd></dl></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_md_raid"></a>MD RAID</h3></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term"> <span class="strong"><strong>rd.md=0</strong></span> @@ -3999,7 +3999,7 @@ arguments and sets up the directory, in which everything is installed. It then executes all check, install, installkernel scripts found in the modules, which are to be processed. After everything is installed, the install directory is archived and compressed to the final initramfs image. All helper functions used -by check, install and installkernel are found in in the file <span class="emphasis"><em>dracut-functions</em></span>. +by check, install and installkernel are found in the file <span class="emphasis"><em>dracut-functions</em></span>. These shell functions are available to all module installer (install, installkernel) scripts, without the need to source <span class="emphasis"><em>dracut-functions</em></span>.</p><p>A module can check the preconditions for install and installkernel with the check script. Also dependencies can be expressed with check. If a module passed @@ -122,7 +122,8 @@ Creates initial ramdisk images for preloading modules --early-microcode Combine early microcode with ramdisk. --no-early-microcode Do not combine early microcode with ramdisk. --kernel-cmdline [PARAMETERS] - Specify default kernel command line parameters. + Specify default kernel command line parameters. Despite + its name, this command only sets initrd parameters. --strip Strip binaries in the initramfs. --aggressive-strip Strip more than just debug symbol and sections, for a smaller initramfs build. The --strip option must @@ -311,24 +312,6 @@ push_host_devs() { done } -# Little helper function for reading args from the commandline. -# it automatically handles -a b and -a=b variants, and returns 1 if -# we need to shift $3. -read_arg() { - # $1 = arg name - # $2 = arg value - # $3 = arg parameter - local rematch='^[^=]*=(.*)$' - if [[ $2 =~ $rematch ]]; then - read -r "$1" <<< "${BASH_REMATCH[1]}" - else - read -r "$1" <<< "$3" - # There is no way to shift our callers args, so - # return 1 to indicate they should do it instead. - return 1 - fi -} - check_conf_file() { if grep -H -e '^[^#]*[+]=\("[^ ]\|.*[^ ]"\)' "$@"; then printf '\ndracut[W]: <key>+=" <values> ": <values> should have surrounding white spaces!\n' >&2 @@ -1378,8 +1361,8 @@ unset omit_drivers_corrected # prepare args for logging for ((i = 0; i < ${#dracut_args[@]}; i++)); do - [[ ${dracut_args[$i]} == *\ * ]] \ - && dracut_args[$i]="\"${dracut_args[$i]}\"" + [[ ${dracut_args[i]} == *\ * ]] \ + && dracut_args[i]="\"${dracut_args[i]}\"" #" keep vim happy done @@ -2042,6 +2025,7 @@ if [[ $kernel_only != yes ]]; then printf "%s\n" "systemdutildir=\"$systemdutildir\"" printf "%s\n" "systemdsystemunitdir=\"$systemdsystemunitdir\"" printf "%s\n" "systemdsystemconfdir=\"$systemdsystemconfdir\"" + printf "%s\n" "systemdnetworkconfdir=\"$systemdnetworkconfdir\"" } > "${initdir}"/etc/conf.d/systemd.conf fi fi @@ -2117,8 +2101,8 @@ if [[ $do_strip == yes ]]; then strip_cmd=$(command -v eu-strip) [ -z "$strip_cmd" ] && strip_cmd="strip" - for p in $strip_cmd xargs find; do - if ! type -P $p > /dev/null; then + for p in "$strip_cmd" xargs find; do + if ! type -P "$p" > /dev/null; then dinfo "Could not find '$p'. Not stripping the initramfs." do_strip=no fi @@ -2157,9 +2141,13 @@ if [[ $early_microcode == yes ]]; then if [[ $hostonly ]]; then _src=$(get_ucode_file) [[ $_src ]] || break - [[ -r $_fwdir/$_fw/$_src ]] || _src="${_src}.early" - [[ -r $_fwdir/$_fw/$_src ]] || _src="${_src}.initramfs" - [[ -r $_fwdir/$_fw/$_src ]] || break + if [[ -r "$_fwdir/$_fw/${_src}.early" ]]; then + _src="${_src}.early" + elif [[ -r "$_fwdir/$_fw/${_src}.initramfs" ]]; then + _src="${_src}.initramfs" + else + [[ -r $_fwdir/$_fw/$_src ]] || break + fi fi for i in $_fwdir/$_fw/$_src; do @@ -2269,14 +2257,14 @@ if [[ $do_strip == yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then dinfo "*** Stripping files ***" find "$initdir" -type f \ -executable -not -path '*/lib/modules/*.ko*' -print0 \ - | xargs -r -0 $strip_cmd "${strip_args[@]}" 2> /dev/null + | xargs -r -0 "$strip_cmd" "${strip_args[@]}" 2> /dev/null # strip kernel modules, but do not touch signed modules find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \ | while read -r -d $'\0' f || [ -n "$f" ]; do SIG=$(tail -c 28 "$f" | tr -d '\000') [[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; } - done | xargs -r -0 $strip_cmd "${strip_args[@]}" + done | xargs -r -0 "$strip_cmd" "${strip_args[@]}" dinfo "*** Stripping files done ***" fi @@ -2382,7 +2370,7 @@ fi if ! [[ $compress ]]; then # check all known compressors, if none specified - for i in $DRACUT_COMPRESS_PIGZ $DRACUT_COMPRESS_GZIP $DRACUT_COMPRESS_LZ4 $DRACUT_COMPRESS_LZOP $DRACUT_COMPRESS_ZSTD $DRACUT_COMPRESS_LZMA $DRACUT_COMPRESS_XZ $DRACUT_COMPRESS_LBZIP2 $DRACUT_COMPRESS_BZIP2 $DRACUT_COMPRESS_CAT; do + for i in $DRACUT_COMPRESS_ZSTD $DRACUT_COMPRESS_PIGZ $DRACUT_COMPRESS_GZIP $DRACUT_COMPRESS_LZ4 $DRACUT_COMPRESS_LZOP $DRACUT_COMPRESS_LZMA $DRACUT_COMPRESS_XZ $DRACUT_COMPRESS_LBZIP2 $DRACUT_COMPRESS_BZIP2 $DRACUT_COMPRESS_CAT; do [[ $i != "$DRACUT_COMPRESS_ZSTD" || $DRACUT_KERNEL_RD_ZSTD ]] || continue command -v "$i" &> /dev/null || continue compress="$i" diff --git a/lsinitrd.sh b/lsinitrd.sh index 1329ab7..b36d0e1 100755 --- a/lsinitrd.sh +++ b/lsinitrd.sh @@ -98,6 +98,43 @@ done [[ $KERNEL_VERSION ]] || KERNEL_VERSION="$(uname -r)" +find_initrd_for_kernel_version() { + local kernel_version="$1" + local base_path files initrd machine_id + + if [[ -d /efi/Default ]] || [[ -d /boot/Default ]] || [[ -d /boot/efi/Default ]]; then + machine_id="Default" + elif [[ -s /etc/machine-id ]]; then + read -r machine_id < /etc/machine-id + [[ $machine_id == "uninitialized" ]] && machine_id="Default" + else + machine_id="Default" + fi + + if [ -n "$machine_id" ]; then + for base_path in /efi /boot /boot/efi; do + initrd="${base_path}/${machine_id}/${kernel_version}/initrd" + if [ -f "$initrd" ]; then + echo "$initrd" + return + fi + done + fi + + if [[ -f /lib/modules/${kernel_version}/initrd ]]; then + echo "/lib/modules/${kernel_version}/initrd" + elif [[ -f /lib/modules/${kernel_version}/initramfs.img ]]; then + echo "/lib/modules/${kernel_version}/initramfs.img" + elif [[ -f /boot/initramfs-${kernel_version}.img ]]; then + echo "/boot/initramfs-${kernel_version}.img" + else + files=(/boot/initr*"${kernel_version}"*) + if [ "${#files[@]}" -ge 1 ] && [ -e "${files[0]}" ]; then + echo "${files[0]}" + fi + fi +} + if [[ $1 ]]; then image="$1" if ! [[ -f $image ]]; then @@ -109,42 +146,7 @@ if [[ $1 ]]; then exit 1 fi else - if [[ -d /efi/Default ]] || [[ -d /boot/Default ]] || [[ -d /boot/efi/Default ]]; then - MACHINE_ID="Default" - elif [[ -s /etc/machine-id ]]; then - read -r MACHINE_ID < /etc/machine-id - [[ $MACHINE_ID == "uninitialized" ]] && MACHINE_ID="Default" - else - MACHINE_ID="Default" - fi - - if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \ - && [[ $MACHINE_ID ]] \ - && [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]]; then - image="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd" - elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \ - && [[ $MACHINE_ID ]] \ - && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]]; then - image="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd" - elif [[ -d /boot/efi/loader/entries || -L /boot/efi/loader/entries ]] \ - && [[ $MACHINE_ID ]] \ - && [[ -d /boot/efi/${MACHINE_ID} || -L /boot/efi/${MACHINE_ID} ]]; then - image="/boot/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd" - elif [[ -f /lib/modules/${KERNEL_VERSION}/initrd ]]; then - image="/lib/modules/${KERNEL_VERSION}/initrd" - elif [[ -f /lib/modules/${KERNEL_VERSION}/initramfs.img ]]; then - image="/lib/modules/${KERNEL_VERSION}/initramfs.img" - elif [[ -f /boot/initramfs-${KERNEL_VERSION}.img ]]; then - image="/boot/initramfs-${KERNEL_VERSION}.img" - elif [[ $MACHINE_ID ]] \ - && mountpoint -q /efi; then - image="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd" - elif [[ $MACHINE_ID ]] \ - && mountpoint -q /boot/efi; then - image="/boot/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd" - else - image="" - fi + image=$(find_initrd_for_kernel_version "$KERNEL_VERSION") fi shift @@ -398,6 +400,7 @@ type "${CAT%% *}" > /dev/null 2>&1 || { exit 1 } +# shellcheck disable=SC2317 # assigned to CAT and $CAT called later skipcpio() { $SKIP "$@" | $ORIG_CAT } @@ -410,6 +413,7 @@ fi if ((${#filenames[@]} > 1)); then TMPFILE="$TMPDIR/initrd.cpio" $CAT "$image" 2> /dev/null > "$TMPFILE" + # shellcheck disable=SC2317 # assigned to CAT and $CAT called later pre_decompress() { cat "$TMPFILE" } diff --git a/man/dracut-catimages.8.asc b/man/dracut-catimages.8.asc index 8ddc365..f3c74a9 100644 --- a/man/dracut-catimages.8.asc +++ b/man/dracut-catimages.8.asc @@ -56,4 +56,3 @@ link:$$https://github.com/dracut-ng/dracut-ng$$[https://github.com/dracut-ng/dra SEE ALSO -------- *dracut*(8) - diff --git a/man/dracut.8.asc b/man/dracut.8.asc index 25f601b..77a4a8a 100644 --- a/man/dracut.8.asc +++ b/man/dracut.8.asc @@ -211,7 +211,8 @@ example: =============================== **--kernel-cmdline <parameters>**:: - Specify default kernel command line parameters. + Specify default kernel command line parameters. Despite its name, + this command only sets initrd parameters. **--kernel-only**:: Only install kernel drivers and firmware files. diff --git a/man/dracut.asc b/man/dracut.asc index c806ab2..8caf8d5 100644 --- a/man/dracut.asc +++ b/man/dracut.asc @@ -130,19 +130,19 @@ procedure. The following steps are executed during a shutdown: -* systemd switches to the shutdown.target -* systemd starts - $prefix/lib/systemd/system/shutdown.target.wants/dracut-shutdown.service -* dracut-shutdown.service executes /usr/lib/dracut/dracut-initramfs-restore - which unpacks the initramfs to /run/initramfs -* systemd finishes shutdown.target +* The system starts to shut down +* ``$prefix/lib/systemd/system/sysinit.target.wants/dracut-shutdown.service`` + gets its ``ExecStop`` target triggered. +* ``dracut-shutdown.service`` executes + ``/usr/lib/dracut/dracut-initramfs-restore`` which unpacks the initramfs to + ``/run/initramfs`` * systemd kills all processes * systemd tries to unmount everything and mounts the remaining read-only -* systemd checks, if there is a /run/initramfs/shutdown executable -* if yes, it does a pivot_root to /run/initramfs and executes ./shutdown. - The old root is then mounted on /oldroot. - /usr/lib/dracut/modules.d/99shutdown/shutdown.sh is the shutdown executable. -* shutdown will try to unmount every /oldroot mount and calls the various +* systemd checks if there is a ``/run/initramfs/shutdown`` executable +* if yes, it does a pivot_root to ``/run/initramfs`` and executes ``./shutdown``. + The old root is then mounted on ``/oldroot``. + ``/usr/lib/dracut/modules.d/99shutdown/shutdown.sh`` is the shutdown executable. +* shutdown will try to unmount every ``/oldroot`` mount and calls the various shutdown hooks from the dracut modules This ensures, that all devices are disassembled and unmounted cleanly. @@ -179,4 +179,3 @@ This work is licensed under the Creative Commons Attribution/Share-Alike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. - diff --git a/man/dracut.cmdline.7.asc b/man/dracut.cmdline.7.asc index 7c0051e..1f4973e 100644 --- a/man/dracut.cmdline.7.asc +++ b/man/dracut.cmdline.7.asc @@ -452,8 +452,8 @@ when not needed anymore. =============================== **rd.luks.key.tout=0**:: - specify how many times dracut will try to read the keys specified in in - rd.luk.key. This gives a chance to the removable device containing the key + specify how many times dracut will try to read the keys specified in + rd.luks.key. This gives a chance to the removable device containing the key to initialise. MD RAID diff --git a/man/dracut.conf.5.asc b/man/dracut.conf.5.asc index dd42891..5ca07a0 100644 --- a/man/dracut.conf.5.asc +++ b/man/dracut.conf.5.asc @@ -184,7 +184,8 @@ provide a valid _/etc/fstab_. Mount _/_ and _/usr_ read-only by default (default=no). *kernel_cmdline=*"__parameters__":: - Specify default kernel command line parameters. + Specify default kernel command line parameters. Despite + its name, this command only sets initrd parameters. *kernel_only=*"__{yes|no}__":: Only install kernel drivers and firmware files (default=no). @@ -344,4 +345,3 @@ Harald Hoyer See Also -------- *dracut*(8) *dracut.cmdline*(7) - diff --git a/man/dracut.modules.7.asc b/man/dracut.modules.7.asc index 0f33bd7..c2fcf51 100644 --- a/man/dracut.modules.7.asc +++ b/man/dracut.modules.7.asc @@ -25,7 +25,7 @@ arguments and sets up the directory, in which everything is installed. It then executes all check, install, installkernel scripts found in the modules, which are to be processed. After everything is installed, the install directory is archived and compressed to the final initramfs image. All helper functions used -by check, install and installkernel are found in in the file _dracut-functions_. +by check, install and installkernel are found in the file _dracut-functions_. These shell functions are available to all module installer (install, installkernel) scripts, without the need to source _dracut-functions_. diff --git a/man/dracut.usage.asc b/man/dracut.usage.asc index 3b652d3..ba9c2da 100644 --- a/man/dracut.usage.asc +++ b/man/dracut.usage.asc @@ -38,9 +38,8 @@ the --hostonly or -H option. Using this option, the resulting image will contain only those dracut modules, kernel modules and filesystems, which are needed to boot this specific machine. This has the drawback, that you can't put the disk on another controller or machine, and that you can't switch to another -root filesystem, without recreating the initramfs image. The usage of the ---hostonly option is only for experts and you will have to keep the broken -pieces. At least keep a copy of a general purpose image (and corresponding +root filesystem, without recreating the initramfs image. +It is recommended to keep a copy of a general purpose image (and corresponding kernel) as a fallback to rescue your system. === Inspecting the Contents @@ -517,4 +516,3 @@ To do this from an already booted system: This will give you a dracut shell after the system pivot'ed back in the initramfs. - diff --git a/modules.d/00systemd/module-setup.sh b/modules.d/00systemd/module-setup.sh index d173c99..ce7bb52 100755 --- a/modules.d/00systemd/module-setup.sh +++ b/modules.d/00systemd/module-setup.sh @@ -158,7 +158,9 @@ EOF emergency.target \ rescue.target; do [[ -f "$systemdsystemunitdir"/$i ]] || continue - $SYSTEMCTL -q --root "$initdir" add-wants "$i" systemd-vconsole-setup.service + if [ -e "$systemdsystemunitdir"/systemd-vconsole-setup.service ]; then + $SYSTEMCTL -q --root "$initdir" add-wants "$i" systemd-vconsole-setup.service + fi done mkdir -p "$initdir/etc/systemd" diff --git a/modules.d/00warpclock/module-setup.sh b/modules.d/00warpclock/module-setup.sh index 44aa177..dd093f3 100755 --- a/modules.d/00warpclock/module-setup.sh +++ b/modules.d/00warpclock/module-setup.sh @@ -7,7 +7,7 @@ check() { # hwclock does not exist on S390(x), bail out silently then local _arch=${DRACUT_ARCH:-$(uname -m)} - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] && return 1 + [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] && return 1 # If the binary(s) requirements are not fulfilled the module can't be installed. require_binaries hwclock || return 1 diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh index c81c2a6..2c7b2e3 100755 --- a/modules.d/01fips/fips.sh +++ b/modules.d/01fips/fips.sh @@ -94,16 +94,14 @@ fips_load_crypto() { local _module local _found - read -d '' -r FIPSMODULES < /etc/fipsmodules - fips_info "Loading and integrity checking all crypto modules" - for _module in $FIPSMODULES; do + while read -r _module; do if [ "$_module" != "tcrypt" ]; then if ! nonfatal_modprobe "${_module}" 2> /tmp/fips.modprobe_err; then # check if kernel provides generic algo _found=0 while read -r _k _ _v || [ -n "$_k" ]; do - [ "$_k" != "name" -a "$_k" != "driver" ] && continue + [ "$_k" != "name" ] && [ "$_k" != "driver" ] && continue [ "$_v" != "$_module" ] && continue _found=1 break @@ -111,7 +109,7 @@ fips_load_crypto() { [ "$_found" = "0" ] && cat /tmp/fips.modprobe_err >&2 && return 1 fi fi - done + done < /etc/fipsmodules if [ -f /etc/fips.conf ]; then mkdir -p /run/modprobe.d cp /etc/fips.conf /run/modprobe.d/fips.conf diff --git a/modules.d/01fips/module-setup.sh b/modules.d/01fips/module-setup.sh index 83fcd56..1e0c9d0 100755 --- a/modules.d/01fips/module-setup.sh +++ b/modules.d/01fips/module-setup.sh @@ -30,7 +30,7 @@ installkernel() { _fipsmodules+="ecb cbc ctr xts gcm ccm authenc hmac cmac ofb cts " # Compression algs: - _fipsmodules+="deflate lzo zlib " + _fipsmodules+="deflate lzo " # PRNG algs: _fipsmodules+="ansi_cprng " diff --git a/modules.d/01systemd-coredump/module-setup.sh b/modules.d/01systemd-coredump/module-setup.sh index 47666b6..0c5cbcf 100755 --- a/modules.d/01systemd-coredump/module-setup.sh +++ b/modules.d/01systemd-coredump/module-setup.sh @@ -30,6 +30,8 @@ depends() { install() { inst_dir /var/lib/systemd/coredump + inst_sysusers systemd-coredump.conf + inst_multiple -o \ "$sysctld"/50-coredump.conf \ "$systemdutildir"/coredump.conf \ @@ -37,7 +39,6 @@ install() { "$systemdsystemunitdir"/systemd-coredump.socket \ "$systemdsystemunitdir"/systemd-coredump@.service \ "$systemdsystemunitdir"/sockets.target.wants/systemd-coredump.socket \ - "$sysusers"/systemd-coredump.conf \ coredumpctl # Install library file(s) @@ -56,7 +57,6 @@ install() { "$systemdsystemconfdir/systemd-coredump.socket.d/*.conf" \ "$systemdsystemconfdir"/systemd-coredump@.service \ "$systemdsystemconfdir/systemd-coredump@.service.d/*.conf" \ - "$systemdsystemconfdir"/sockets.target.wants/systemd-coredump.socket \ - "$sysusersconfdir"/systemd-coredump.conf + "$systemdsystemconfdir"/sockets.target.wants/systemd-coredump.socket fi } diff --git a/modules.d/01systemd-hostnamed/module-setup.sh b/modules.d/01systemd-hostnamed/module-setup.sh index 2a1fa02..d589061 100755 --- a/modules.d/01systemd-hostnamed/module-setup.sh +++ b/modules.d/01systemd-hostnamed/module-setup.sh @@ -39,6 +39,9 @@ install() { "$systemdutildir"/systemd-hostnamed \ "$systemdsystemunitdir"/systemd-hostnamed.service \ "$systemdsystemunitdir/systemd-hostnamed.service.d/*.conf" \ + "$systemdsystemunitdir"/systemd-hostnamed.socket \ + "$systemdsystemunitdir/systemd-hostnamed.socket.d/*.conf" \ + "$systemdsystemunitdir"/sockets.target.wants/systemd-hostnamed.socket \ "$systemdsystemunitdir"/dbus-org.freedesktop.hostname1.service \ hostnamectl @@ -47,6 +50,9 @@ install() { inst_multiple -H -o \ /etc/hostname \ "$systemdsystemconfdir"/systemd-hostnamed.service \ - "$systemdsystemconfdir/systemd-hostnamed.service.d/*.conf" + "$systemdsystemconfdir/systemd-hostnamed.service.d/*.conf" \ + "$systemdsystemconfdir"/systemd-hostnamed.socket \ + "$systemdsystemconfdir"/sockets.target.wants/systemd-hostnamed.socket \ + "$systemdsystemconfdir/systemd-hostnamed.socket.d/*.conf" fi } diff --git a/modules.d/01systemd-journald/module-setup.sh b/modules.d/01systemd-journald/module-setup.sh index e0944d2..77d6a2e 100755 --- a/modules.d/01systemd-journald/module-setup.sh +++ b/modules.d/01systemd-journald/module-setup.sh @@ -31,6 +31,8 @@ install() { inst_simple "$moddir/initrd.conf" "$systemdutildir/journald.conf.d/initrd.conf" + inst_sysusers systemd-journal.conf + inst_multiple -o \ "$systemdutildir"/journald.conf \ "$systemdutildir/journald.conf.d/*.conf" \ @@ -47,7 +49,6 @@ install() { "$systemdsystemunitdir"/sockets.target.wants/systemd-journald-dev-log.socket \ "$systemdsystemunitdir"/sockets.target.wants/systemd-journald.socket \ "$systemdsystemunitdir"/sysinit.target.wants/systemd-journald.service \ - "$sysusers"/systemd-journal.conf \ journalctl # Install library file(s) @@ -66,8 +67,7 @@ install() { "$systemdsystemconfdir"/systemd-journald.service \ "$systemdsystemconfdir/systemd-journald.service.d/*.conf" \ "$systemdsystemconfdir"/systemd-journal-catalog-update.service \ - "$systemdsystemconfdir/systemd-journal-catalog-update.service.d/*.conf" \ - "$sysusersconfdir"/systemd-journal.conf + "$systemdsystemconfdir/systemd-journal-catalog-update.service.d/*.conf" fi } diff --git a/modules.d/01systemd-networkd/99-default.network b/modules.d/01systemd-networkd/99-default.network new file mode 100644 index 0000000..d4fe15c --- /dev/null +++ b/modules.d/01systemd-networkd/99-default.network @@ -0,0 +1,13 @@ +[Match] +Kind=!* +Type=!loopback + +[Network] +DHCP=yes + +[DHCPv4] +ClientIdentifier=mac +RequestOptions=17 + +[DHCPv6] +RequestOptions=59 60 diff --git a/modules.d/01systemd-networkd/99-wait-online-dracut.conf b/modules.d/01systemd-networkd/99-wait-online-dracut.conf new file mode 100644 index 0000000..da90596 --- /dev/null +++ b/modules.d/01systemd-networkd/99-wait-online-dracut.conf @@ -0,0 +1,9 @@ +[Unit] +Before=dracut-initqueue.service +ConditionPathExists=/run/networkd/initrd/neednet + +[Service] +TimeoutStartSec=120 + +[Install] +WantedBy=initrd.target diff --git a/modules.d/01systemd-networkd/module-setup.sh b/modules.d/01systemd-networkd/module-setup.sh index 3658882..007590b 100755 --- a/modules.d/01systemd-networkd/module-setup.sh +++ b/modules.d/01systemd-networkd/module-setup.sh @@ -22,7 +22,7 @@ check() { depends() { # This module has external dependency on other module(s). - echo kernel-network-modules systemd-sysusers + echo kernel-network-modules systemd-sysusers systemd # Return 0 to include the dependent module(s) in the initramfs. return 0 @@ -31,6 +31,8 @@ depends() { # Install the required file(s) and directories for the module in the initramfs. install() { + inst_sysusers systemd-network.conf + inst_multiple -o \ "$tmpfilesdir"/systemd-network.conf \ "$dbussystem"/org.freedesktop.network1.conf \ @@ -55,8 +57,16 @@ install() { "$systemdsystemunitdir"/systemd-networkd-wait-online.service \ "$systemdsystemunitdir"/systemd-networkd-wait-online@.service \ "$systemdsystemunitdir"/systemd-network-generator.service \ - "$sysusers"/systemd-network.conf \ - ip + ip sed grep + + inst_simple "$moddir"/99-wait-online-dracut.conf \ + "$systemdsystemunitdir"/systemd-networkd-wait-online.service.d/99-dracut.conf + + inst_simple "$moddir"/99-default.network \ + "$systemdnetworkconfdir"/99-dracut-default.network + + inst_hook cmdline 99 "$moddir"/networkd-config.sh + inst_hook initqueue/settled 99 "$moddir"/networkd-run.sh # Enable systemd type units for i in \ @@ -82,7 +92,6 @@ install() { "$systemdsystemconfdir"/systemd-networkd-wait-online.service \ "$systemdsystemconfdir/systemd-networkd-wait-online.service.d/*.conf" \ "$systemdsystemconfdir"/systemd-networkd-wait-online@.service \ - "$systemdsystemconfdir/systemd-networkd-wait-online@.service.d/*.conf" \ - "$sysusersconfdir"/systemd-network.conf + "$systemdsystemconfdir/systemd-networkd-wait-online@.service.d/*.conf" fi } diff --git a/modules.d/01systemd-networkd/networkd-config.sh b/modules.d/01systemd-networkd/networkd-config.sh new file mode 100755 index 0000000..eb450c6 --- /dev/null +++ b/modules.d/01systemd-networkd/networkd-config.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +type getcmdline > /dev/null 2>&1 || . /lib/dracut-lib.sh + +# Just in case we're running before it +systemctl start systemd-network-generator.service + +# Customizations for systemd-network-generator generated networks. +# We need to request certain DHCP options, and there is no way to +# tell the generator to add those. +for f in /run/systemd/network/*.network; do + [ -f "$f" ] || continue + + { + echo "[DHCPv4]" + echo "ClientIdentifier=mac" + echo "RequestOptions=17" + echo "[DHCPv6]" + echo "RequestOptions=59 60" + } >> "$f" + + # Remove the default network if at least one was generated + rm -f "$systemdnetworkconfdir"/99-dracut-default.network +done + +# Just in case networkd was already running +systemctl try-reload-or-restart systemd-networkd.service + +if [ -n "$netroot" ] || [ -e /tmp/net.ifaces ]; then + echo rd.neednet >> /etc/cmdline.d/networkd.conf +fi + +if getargbool 0 rd.neednet; then + mkdir -p /run/networkd/initrd + : > /run/networkd/initrd/neednet +fi diff --git a/modules.d/01systemd-networkd/networkd-run.sh b/modules.d/01systemd-networkd/networkd-run.sh new file mode 100755 index 0000000..5445b46 --- /dev/null +++ b/modules.d/01systemd-networkd/networkd-run.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +type source_hook > /dev/null 2>&1 || . /lib/dracut-lib.sh + +for ifpath in /sys/class/net/*; do + ifname="$(basename "$ifpath")" + + # shellcheck disable=SC2015 + [ "$ifname" != "lo" ] && [ -e "$ifpath" ] && [ ! -e /tmp/networkd."$ifname".done ] || continue + + if /usr/lib/systemd/systemd-networkd-wait-online --timeout=0.000001 --interface="$ifname" 2> /dev/null; then + leases_file="/run/systemd/netif/leases/$(cat "$ifpath"/ifindex)" + dhcpopts_file="/tmp/dhclient.${ifname}.dhcpopts" + if [ -r "$leases_file" ]; then + grep -E "^(NEXT_SERVER|ROOT_PATH)=" "$leases_file" \ + | sed -e "s/NEXT_SERVER=/new_next_server='/" \ + -e "s/ROOT_PATH=/new_root_path='/" \ + -e "s/$/'/" > "$dhcpopts_file" || true + fi + + source_hook initqueue/online "$ifname" + /sbin/netroot "$ifname" + + : > /tmp/networkd."$ifname".done + fi +done diff --git a/modules.d/01systemd-pcrphase/module-setup.sh b/modules.d/01systemd-pcrphase/module-setup.sh index eb85207..3016d7e 100755 --- a/modules.d/01systemd-pcrphase/module-setup.sh +++ b/modules.d/01systemd-pcrphase/module-setup.sh @@ -4,7 +4,6 @@ # Prerequisite check(s) for module. check() { - # If the binary(s) requirements are not fulfilled the module can't be installed. # systemd-255 renamed the binary, check for old and new location. if ! require_binaries "$systemdutildir"/systemd-pcrphase \ @@ -12,23 +11,34 @@ check() { return 1 fi - return 0 + if [[ $hostonly ]]; then + return 255 + fi + return 0 } # Module dependency requirements. depends() { - # This module has external dependency on other module(s). - echo systemd tpm2-tss + + local deps + deps="systemd" + + # optional dependencies + module="tpm2-tss" + module_check $module > /dev/null 2>&1 + if [[ $? == 255 ]]; then + deps+=" $module" + fi + echo "$deps" + # Return 0 to include the dependent module(s) in the initramfs. return 0 - } # Install the required file(s) and directories for the module in the initramfs. install() { - inst_multiple -o \ "$systemdutildir"/systemd-pcrphase \ "$systemdutildir"/systemd-pcrextend \ @@ -43,5 +53,4 @@ install() { "$systemdsystemconfdir/systemd-pcrphase-initrd.service.d/*.conf" \ "$systemdsystemconfdir"/initrd.target.wants/systemd-pcrphase-initrd.service fi - } diff --git a/modules.d/01systemd-resolved/module-setup.sh b/modules.d/01systemd-resolved/module-setup.sh index 0c2e8c2..b354bc6 100755 --- a/modules.d/01systemd-resolved/module-setup.sh +++ b/modules.d/01systemd-resolved/module-setup.sh @@ -31,6 +31,8 @@ install() { inst_simple "$moddir/resolved-tmpfile-dracut.conf" "$tmpfilesdir/resolved-tmpfile-dracut.conf" + inst_sysusers systemd-resolve.conf + inst_multiple -o \ "$dbussystem"/org.freedesktop.resolve1.conf \ "$dbussystemservices"/org.freedesktop.resolve1.service \ @@ -40,7 +42,6 @@ install() { "$systemdutildir"/systemd-resolved \ "$systemdsystemunitdir"/systemd-resolved.service \ "$systemdsystemunitdir/systemd-resolved.service.d/*.conf" \ - "$sysusers"/systemd-resolve.conf \ resolvectl # Enable systemd type unit(s) @@ -52,7 +53,6 @@ install() { "$systemdutilconfdir"/resolved.conf \ "$systemdutilconfdir/resolved.conf.d/*.conf" \ "$systemdsystemconfdir"/systemd-resolved.service \ - "$systemdsystemconfdir/systemd-resolved.service.d/*.conf" \ - "$sysusersconfdir"/systemd-resolve.conf + "$systemdsystemconfdir/systemd-resolved.service.d/*.conf" fi } diff --git a/modules.d/01systemd-sysusers/module-setup.sh b/modules.d/01systemd-sysusers/module-setup.sh index 4ec48dc..351f45c 100755 --- a/modules.d/01systemd-sysusers/module-setup.sh +++ b/modules.d/01systemd-sysusers/module-setup.sh @@ -26,9 +26,10 @@ install() { inst_simple "$moddir/sysusers-dracut.conf" "$systemdsystemunitdir/systemd-sysusers.service.d/sysusers-dracut.conf" + inst_sysusers basic.conf + inst_sysusers systemd.conf + inst_multiple -o \ - "$sysusers"/basic.conf \ - "$sysusers"/systemd.conf \ "$systemdsystemunitdir"/systemd-sysusers.service \ "$systemdsystemunitdir"/sysinit.target.wants/systemd-sysusers.service \ systemd-sysusers @@ -36,8 +37,6 @@ install() { # Install the hosts local user configurations if enabled. if [[ $hostonly ]]; then inst_multiple -H -o \ - "$sysusersconfdir"/basic.conf \ - "$sysusersconfdir"/systemd.conf \ "$systemdsystemconfdir"/systemd-sysusers.service \ "$systemdsystemconfdir/systemd-sysusers.service.d/*.conf" fi diff --git a/modules.d/01systemd-timesyncd/module-setup.sh b/modules.d/01systemd-timesyncd/module-setup.sh index a2c6754..0c065af 100755 --- a/modules.d/01systemd-timesyncd/module-setup.sh +++ b/modules.d/01systemd-timesyncd/module-setup.sh @@ -32,6 +32,8 @@ install() { # Enable this if networkd ( not the module ) is disabled at build time and you want to use timesyncd # inst_simple "$moddir/timesyncd-tmpfile-dracut.conf" "$tmpfilesdir/timesyncd-tmpfile-dracut.conf" + inst_sysusers systemd-timesync.conf + inst_multiple -o \ "$dbussystem"/org.freedesktop.timesync1.conf \ "$dbussystemservices"/org.freedesktop.timesync1.service \ @@ -42,8 +44,7 @@ install() { "$systemdsystemunitdir"/systemd-timesyncd.service \ "$systemdsystemunitdir/systemd-timesyncd.service.d/*.conf" \ "$systemdsystemunitdir"/systemd-time-wait-sync.service \ - "$systemdsystemunitdir/systemd-time-wait-sync.service.d/*.conf" \ - "$sysusers"/systemd-timesync.conf + "$systemdsystemunitdir/systemd-time-wait-sync.service.d/*.conf" # Enable systemd type unit(s) for i in \ @@ -61,7 +62,6 @@ install() { "$systemdsystemconfdir"/systemd-timesyncd.service \ "$systemdsystemconfdir/systemd-timesyncd.service.d/*.conf" \ "$systemdsystemconfdir"/systemd-time-wait-sync.service \ - "$systemdsystemconfdir/systemd-time-wait-sync.service.d/*.conf" \ - "$sysusersconfdir"/systemd-timesync.conf + "$systemdsystemconfdir/systemd-time-wait-sync.service.d/*.conf" fi } diff --git a/modules.d/01systemd-udevd/module-setup.sh b/modules.d/01systemd-udevd/module-setup.sh index 168167f..8d4a8b9 100755 --- a/modules.d/01systemd-udevd/module-setup.sh +++ b/modules.d/01systemd-udevd/module-setup.sh @@ -30,31 +30,6 @@ depends() { install() { inst_multiple -o \ - /etc/udev/udev.hwdb \ - "$udevdir"/hwdb.bin \ - "$udevdir"/dmi_memory_id \ - "$udevdir"/fido_id \ - "$udevdir"/mtd_probe \ - "$udevdir"/mtp-probe \ - "$udevdir"/v4l_id \ - "$udevrulesdir"/60-autosuspend.rules \ - "$udevrulesdir"/60-drm.rules \ - "$udevrulesdir"/60-evdev.rules \ - "$udevrulesdir"/60-fido-id.rules \ - "$udevrulesdir"/60-input-id.rules \ - "$udevrulesdir"/60-persistent-alsa.rules \ - "$udevrulesdir"/60-persistent-input.rules \ - "$udevrulesdir"/60-persistent-storage-tape.rules \ - "$udevrulesdir"/60-persistent-v4l.rules \ - "$udevrulesdir"/60-sensor.rules \ - "$udevrulesdir"/60-serial.rules \ - "$udevrulesdir"/70-joystick.rules \ - "$udevrulesdir"/70-memory.rules \ - "$udevrulesdir"/70-mouse.rules \ - "$udevrulesdir"/70-touchpad.rules \ - "$udevrulesdir"/75-probe_mtd.rules \ - "$udevrulesdir"/78-sound-card.rules \ - "$udevrulesdir"/81-net-dhcp.rules \ "$udevrulesdir"/99-systemd.rules \ "$systemdutildir"/systemd-udevd \ "$systemdsystemunitdir"/systemd-udevd.service \ @@ -73,9 +48,6 @@ install() { # Install the hosts local user configurations if enabled. if [[ $hostonly ]]; then inst_multiple -H -o \ - "$udevconfdir"/hwdb.bin \ - "$udevrulesconfdir/*.rules" \ - "$systemdutilconfdir"/hwdb/hwdb.bin \ "$systemdsystemconfdir"/systemd-udevd.service \ "$systemdsystemconfdir/systemd-udevd.service.d/*.conf" \ "$systemdsystemconfdir"/systemd-udev-trigger.service \ @@ -90,6 +62,11 @@ install() { "$systemdsystemconfdir"/sockets.target.wants/systemd-udevd-kernel.socket \ "$systemdsystemconfdir"/sysinit.target.wants/systemd-udevd.service \ "$systemdsystemconfdir"/sysinit.target.wants/systemd-udev-trigger.service + + if dracut_module_included "hwdb"; then + inst_multiple -H -o \ + "$systemdutilconfdir"/hwdb/hwdb.bin + fi fi # Install required libraries. diff --git a/modules.d/02caps/caps.sh b/modules.d/02caps/caps.sh index 6c28299..d0997a1 100755 --- a/modules.d/02caps/caps.sh +++ b/modules.d/02caps/caps.sh @@ -12,12 +12,12 @@ if [ "$capsmode" = "1" ]; then info "Loading CAPS_MODULES $CAPS_MODULES" for i in $CAPS_MODULES; do modprobe "$i" 2>&1 > /dev/null | vinfo; done - if [ "$CAPS_MODULES_DISABLED" = "1" -a -e /proc/sys/kernel/modules_disabled ]; then + if [ "$CAPS_MODULES_DISABLED" = "1" ] && [ -e /proc/sys/kernel/modules_disabled ]; then info "Disabling module loading." echo "$CAPS_MODULES_DISABLED" > /proc/sys/kernel/modules_disabled fi - if [ "$CAPS_KEXEC_DISABLED" = "1" -a -e /proc/sys/kernel/kexec_disabled ]; then + if [ "$CAPS_KEXEC_DISABLED" = "1" ] && [ -e /proc/sys/kernel/kexec_disabled ]; then info "Disabling kexec." echo "$CAPS_KEXEC_DISABLED" > /proc/sys/kernel/kexec_disabled fi diff --git a/modules.d/06dbus-broker/module-setup.sh b/modules.d/06dbus-broker/module-setup.sh index a38fce8..2128c28 100755 --- a/modules.d/06dbus-broker/module-setup.sh +++ b/modules.d/06dbus-broker/module-setup.sh @@ -41,13 +41,14 @@ install() { inst_dir "$dbussystemconfdir" inst_dir "$dbussystemservicesconfdir" + inst_sysusers dbus.conf + inst_multiple -o \ "$dbus"/session.conf \ "$dbus"/system.conf \ "$dbussystem"/org.freedesktop.systemd1.conf \ "$dbusservicesconfdir"/org.freedesktop.systemd1.service \ "$dbussystemservices"/org.freedesktop.systemd1.service \ - "$sysusers"/dbus.conf \ "$systemdcatalog"/dbus-broker.catalog \ "$systemdcatalog"/dbus-broker-launch.catalog \ "$systemdsystemunitdir"/dbus-broker.service \ @@ -75,7 +76,6 @@ install() { inst_multiple -H -o \ "$dbusconfdir"/session.conf \ "$dbusconfdir"/system.conf \ - "$sysusersconfdir"/dbus.conf \ "$systemdsystemconfdir"/dbus.socket \ "$systemdsystemconfdir"/dbus.socket.d/*.conf \ "$systemdsystemconfdir"/dbus-broker.service \ diff --git a/modules.d/06dbus-daemon/module-setup.sh b/modules.d/06dbus-daemon/module-setup.sh index 8345585..e5ad43c 100755 --- a/modules.d/06dbus-daemon/module-setup.sh +++ b/modules.d/06dbus-daemon/module-setup.sh @@ -53,6 +53,8 @@ install() { "$systemdsystemunitdir"/dbus.service \ "$systemdsystemunitdir"/dbus.socket \ "$systemdsystemunitdir"/dbus.target.wants \ + "$systemdsystemunitdir"/multi-user.target.wants/dbus.service \ + "$systemdsystemunitdir"/sockets.target.wants/dbus.socket \ busctl dbus-send dbus-daemon # Adjusting dependencies for initramfs in the dbus service unit. diff --git a/modules.d/09dbus/module-setup.sh b/modules.d/09dbus/module-setup.sh index 679483d..c59995a 100755 --- a/modules.d/09dbus/module-setup.sh +++ b/modules.d/09dbus/module-setup.sh @@ -22,10 +22,7 @@ depends() { if check_module "dbus-broker"; then echo "dbus-broker" return 0 - else - echo "dbus-daemon" - return 0 fi - - return 1 + echo "dbus-daemon" + return 0 } diff --git a/modules.d/30convertfs/convertfs.sh b/modules.d/30convertfs/convertfs.sh index 58fa56d..1052e5c 100755 --- a/modules.d/30convertfs/convertfs.sh +++ b/modules.d/30convertfs/convertfs.sh @@ -21,13 +21,13 @@ while [[ $ROOT != "${ROOT%/}" ]]; do ROOT=${ROOT%/} done -if [ ! -L "$ROOT"/var/run -a -e "$ROOT"/var/run ]; then +if [ ! -L "$ROOT"/var/run ] && [ -e "$ROOT"/var/run ]; then echo "Converting /var/run to symlink" mv -f "$ROOT"/var/run "$ROOT"/var/run.runmove~ ln -sfn ../run "$ROOT"/var/run fi -if [ ! -L "$ROOT"/var/lock -a -e "$ROOT"/var/lock ]; then +if [ ! -L "$ROOT"/var/lock ] && [ -e "$ROOT"/var/lock ]; then echo "Converting /var/lock to symlink" mv -f "$ROOT"/var/lock "$ROOT"/var/lock.lockmove~ ln -sfn ../run/lock "$ROOT"/var/lock @@ -72,16 +72,8 @@ if [[ ! -e $testfile ]]; then fi rm -f -- "$testfile" -find_mount() { - local dev wanted_dev - wanted_dev="$(readlink -e -q "$1")" - while read -r dev _ || [ -n "$dev" ]; do - [ "$dev" = "$wanted_dev" ] && echo "$dev" && return 0 - done < /proc/mounts - return 1 -} - # clean up after ourselves no matter how we die. +# shellcheck disable=SC2317 # called via EXIT trap cleanup() { echo "Something failed. Move back to the original state" for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64" \ @@ -114,7 +106,7 @@ for dir in bin sbin lib lib64; do echo "Merge the copy with \`$ROOT/$dir'." [[ -d "$ROOT/usr/${dir}.usrmove-new" ]] \ || mkdir -p "$ROOT/usr/${dir}.usrmove-new" - cp -axT $CP_HARDLINK --backup --suffix=.usrmove~ "$ROOT/$dir" "$ROOT/usr/${dir}.usrmove-new" + cp -axT ${CP_HARDLINK:+"$CP_HARDLINK"} --backup --suffix=.usrmove~ "$ROOT/$dir" "$ROOT/usr/${dir}.usrmove-new" echo "Clean up duplicates in \`$ROOT/usr/$dir'." # delete all symlinks that have been backed up find "$ROOT/usr/${dir}.usrmove-new" -type l -name '*.usrmove~' -delete || : diff --git a/modules.d/35network-legacy/dhclient-script.sh b/modules.d/35network-legacy/dhclient-script.sh index b3e5e75..6cbc9c2 100755 --- a/modules.d/35network-legacy/dhclient-script.sh +++ b/modules.d/35network-legacy/dhclient-script.sh @@ -114,7 +114,7 @@ parse_option_121() { shift # Is the destination a multicast group? - if [ "$1" -ge 224 -a "$1" -lt 240 ]; then + if [ "$1" -ge 224 ] && [ "$1" -lt 240 ]; then multicast=1 else multicast=0 @@ -153,7 +153,7 @@ parse_option_121() { # Multicast routing on Linux # - If you set a next-hop address for a multicast group, this breaks with Cisco switches # - If you simply leave it link-local and attach it to an interface, it works fine. - if [ $multicast -eq 1 -o "$gateway" = "0.0.0.0" ]; then + if [ $multicast -eq 1 ] || [ "$gateway" = "0.0.0.0" ]; then temp_result="$destination dev $interface" else temp_result="$destination via $gateway dev $interface" diff --git a/modules.d/35network-legacy/ifup.sh b/modules.d/35network-legacy/ifup.sh index 3b54b6c..9827e2e 100755 --- a/modules.d/35network-legacy/ifup.sh +++ b/modules.d/35network-legacy/ifup.sh @@ -301,7 +301,7 @@ if [ -z "$NO_BOND_MASTER" ]; then key=${arg%%=*} value=${arg##*=} # %{value:0:1} is replaced with non-bash specific construct - if [ "${key}" = "arp_ip_target" -a "${#value}" != "0" -a "+${value%%+*}" != "+" ]; then + if [ "${key}" = "arp_ip_target" ] && [ "${#value}" != "0" ] && [ "+${value%%+*}" != "+" ]; then OLDIFS=$IFS IFS=',' for arp_ip in $value; do @@ -421,7 +421,7 @@ fi # disable manual ifup while netroot is set for simplifying our logic # in netroot case we prefer netroot to bringup $netif automatically -[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2" +[ -n "$2" ] && [ "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2" if [ -n "$manualup" ]; then : > "/tmp/net.$netif.manualup" @@ -536,12 +536,12 @@ if [ -z "$NO_AUTO_DHCP" ] && [ ! -e "/tmp/net.${netif}.up" ]; then # No ip lines, no bootdev -> default to dhcp ip=$(getarg ip) - if getargs 'ip=dhcp6' > /dev/null || [ -z "$ip" -a "$netroot" = "dhcp6" ]; then + if getargs 'ip=dhcp6' > /dev/null || [ -z "$ip" ] && [ "$netroot" = "dhcp6" ]; then load_ipv6 do_dhcp -6 ret=$? fi - if getargs 'ip=dhcp' > /dev/null || [ -z "$ip" -a "$netroot" != "dhcp6" ]; then + if getargs 'ip=dhcp' > /dev/null || [ -z "$ip" ] && [ "$netroot" != "dhcp6" ]; then do_dhcp -4 ret=$? fi diff --git a/modules.d/35network-legacy/module-setup.sh b/modules.d/35network-legacy/module-setup.sh index 42257eb..00e1f36 100755 --- a/modules.d/35network-legacy/module-setup.sh +++ b/modules.d/35network-legacy/module-setup.sh @@ -71,7 +71,7 @@ install() { ( # shellcheck disable=SC1090 . "$i" - if ! [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ] \ + if ! [ "${ONBOOT}" = "no" ] || [ "${ONBOOT}" = "NO" ] \ && [ -n "${TEAM_MASTER}${TEAM_CONFIG}${TEAM_PORT_CONFIG}" ]; then if [ -n "$TEAM_CONFIG" ] && [ -n "$DEVICE" ]; then mkdir -p "$initdir"/etc/teamd diff --git a/modules.d/35network-legacy/parse-bridge.sh b/modules.d/35network-legacy/parse-bridge.sh index caea1da..d331f9d 100755 --- a/modules.d/35network-legacy/parse-bridge.sh +++ b/modules.d/35network-legacy/parse-bridge.sh @@ -45,5 +45,5 @@ for bridge in $(getargs bridge=); do { echo "bridgename=$bridgename" echo "bridgeslaves=\"$bridgeslaves\"" - } > /tmp/bridge.${bridgename}.info + } > "/tmp/bridge.${bridgename}.info" done diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh index 970c252..a72ca54 100755 --- a/modules.d/40network/module-setup.sh +++ b/modules.d/40network/module-setup.sh @@ -17,12 +17,12 @@ depends() { done if [ -z "$network_handler" ]; then - if check_module "connman"; then - network_handler="connman" - elif check_module "network-manager"; then + if check_module "network-manager"; then network_handler="network-manager" elif check_module "systemd-networkd"; then network_handler="systemd-networkd" + elif check_module "connman"; then + network_handler="connman" else network_handler="network-legacy" fi diff --git a/modules.d/45net-lib/ifname-genrules.sh b/modules.d/45net-lib/ifname-genrules.sh index b9b95c4..34b7a2e 100755 --- a/modules.d/45net-lib/ifname-genrules.sh +++ b/modules.d/45net-lib/ifname-genrules.sh @@ -17,7 +17,7 @@ command -v parse_ifname_opts > /dev/null || . /lib/net-lib.sh if [ -f /tmp/ifname-"$ifname_if" ]; then read -r oldmac < /tmp/ifname-"$ifname_if" fi - if [ -n "$oldif" -a -n "$oldmac" -a "$oldif" = "$ifname_if" -a "$oldmac" = "$ifname_mac" ]; then + if [ -n "$oldif" ] && [ -n "$oldmac" ] && [ "$oldif" = "$ifname_if" ] && [ "$oldmac" = "$ifname_mac" ]; then # skip same ifname= declaration continue fi diff --git a/modules.d/45net-lib/module-setup.sh b/modules.d/45net-lib/module-setup.sh index 8053aa6..ed5e5ed 100755 --- a/modules.d/45net-lib/module-setup.sh +++ b/modules.d/45net-lib/module-setup.sh @@ -1,6 +1,7 @@ #!/bin/bash check() { + require_binaries ip awk grep || return 1 return 255 } @@ -14,7 +15,7 @@ install() { inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh" inst_hook pre-udev 50 "$moddir/ifname-genrules.sh" inst_hook cmdline 91 "$moddir/dhcp-root.sh" - inst_multiple ip sed awk grep pgrep tr + inst_multiple ip awk grep inst_multiple -o arping arping2 dracut_need_initqueue } diff --git a/modules.d/45net-lib/net-lib.sh b/modules.d/45net-lib/net-lib.sh index 9d88e0d..dc6be88 100755 --- a/modules.d/45net-lib/net-lib.sh +++ b/modules.d/45net-lib/net-lib.sh @@ -319,7 +319,7 @@ ibft_to_cmdline() { gw="[${gw}]" fi fi - if [ -n "$ip" ] && [ -n "$mask" -o -n "$prefix" ]; then + if [ -n "$ip" ] && [ -n "$mask" ] || [ -n "$prefix" ]; then echo "ip=$ip::$gw:$mask:$hostname:$dev:none${dns1:+:$dns1}${dns2:+:$dns2}" else warn "${iface} does not contain a valid iBFT configuration" @@ -517,7 +517,7 @@ ip_to_var() { return 0 fi - if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" -o "$2" = "either6" ]; then + if [ "$2" = "dhcp" ] || [ "$2" = "on" ] || [ "$2" = "any" ] || [ "$2" = "dhcp6" ] || [ "$2" = "auto6" ] || [ "$2" = "either6" ]; then # format: ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]] [ -n "$1" ] && dev="$1" [ -n "$2" ] && autoconf="$2" @@ -546,16 +546,16 @@ ip_to_var() { ;; [0-9]*) mtu="$8" - if [ -n "${9}" -a -z "${10}" ]; then + if [ -n "${9}" ] && [ -z "${10}" ]; then macaddr="${9}" - elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then + elif [ -n "${9}" ] && [ -n "${10}" ] && [ -n "${11}" ] && [ -n "${12}" ] && [ -n "${13}" ] && [ -n "${14}" ]; then macaddr="${9}:${10}:${11}:${12}:${13}:${14}" fi ;; *) - if [ -n "${9}" -a -z "${10}" ]; then + if [ -n "${9}" ] && [ -z "${10}" ]; then macaddr="${9}" - elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then + elif [ -n "${9}" ] && [ -n "${10}" ] && [ -n "${11}" ] && [ -n "${12}" ] && [ -n "${13}" ] && [ -n "${14}" ]; then macaddr="${9}:${10}:${11}:${12}:${13}:${14}" fi ;; diff --git a/modules.d/50plymouth/plymouth-pretrigger.sh b/modules.d/50plymouth/plymouth-pretrigger.sh index 3d11999..a04c791 100755 --- a/modules.d/50plymouth/plymouth-pretrigger.sh +++ b/modules.d/50plymouth/plymouth-pretrigger.sh @@ -18,10 +18,10 @@ if type plymouthd > /dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then mkdir -m 0755 /run/plymouth read -r consoledev rest < /sys/class/tty/console/active consoledev=${consoledev:-tty0} - [ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" + [ -x /lib/udev/console_init ] && [ -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" plymouthd --attach-to-session --pid-file /run/plymouth/pid plymouth --show-splash 2>&1 | vinfo # reset tty after plymouth messed with it - [ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" + [ -x /lib/udev/console_init ] && [ -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" fi fi diff --git a/modules.d/80cms/cmssetup.sh b/modules.d/80cms/cmssetup.sh index 5e5b926..8050f2b 100755 --- a/modules.d/80cms/cmssetup.sh +++ b/modules.d/80cms/cmssetup.sh @@ -158,7 +158,7 @@ processcmsfile() { [[ $CMSCONFFILE ]] || CMSCONFFILE=$(getarg "CMSCONFFILE=") # Parse configuration -if [ -n "$CMSDASD" -a -n "$CMSCONFFILE" ]; then +if [ -n "$CMSDASD" ] && [ -n "$CMSCONFFILE" ]; then if readcmsfile "$CMSDASD" "$CMSCONFFILE"; then ln -s /run/initramfs/"$CMSCONFFILE" /tmp/"$CMSCONFFILE" ln -s /run/initramfs/"$CMSCONFFILE" /tmp/cms.conf diff --git a/modules.d/80cms/module-setup.sh b/modules.d/80cms/module-setup.sh index 5b33cd1..920f0a0 100755 --- a/modules.d/80cms/module-setup.sh +++ b/modules.d/80cms/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut check() { arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1 require_binaries chzdev lszdev || return 1 return 255 } @@ -11,7 +11,7 @@ check() { # called by dracut depends() { arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1 echo znet bash return 0 } diff --git a/modules.d/80lvmthinpool-monitor/start-thinpool-monitor.sh b/modules.d/80lvmthinpool-monitor/start-thinpool-monitor.sh index 10f4a4b..4a7ccd0 100755 --- a/modules.d/80lvmthinpool-monitor/start-thinpool-monitor.sh +++ b/modules.d/80lvmthinpool-monitor/start-thinpool-monitor.sh @@ -9,7 +9,7 @@ is_lvm2_thinp_device() { _lvm2_thin_device=$(lvm lvs -S 'lv_layout=sparse && lv_layout=thin' \ --nosuffix --noheadings -o vg_name,lv_name "$_device_path" 2> /dev/null) - [ -n "$_lvm2_thin_device" ] && return $? + [ -n "$_lvm2_thin_device" ] } for LV in $LVS; do diff --git a/modules.d/80test-root/module-setup.sh b/modules.d/80test-root/module-setup.sh index 64d618f..c39111c 100755 --- a/modules.d/80test-root/module-setup.sh +++ b/modules.d/80test-root/module-setup.sh @@ -22,9 +22,9 @@ install() { inst_multiple mkdir ln dd stty mount poweroff umount setsid sync for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do - [ -f ${_terminfodir}/l/linux ] && break + [ -f "${_terminfodir}/l/linux" ] && break done - inst_multiple -o ${_terminfodir}/l/linux + inst_multiple -o "${_terminfodir}/l/linux" inst_binary "${dracutbasedir}/dracut-util" "/usr/bin/dracut-util" ln -s dracut-util "${initdir}/usr/bin/dracut-getarg" diff --git a/modules.d/80test-root/test-init.sh b/modules.d/80test-root/test-init.sh index bd6e485..49116fa 100755 --- a/modules.d/80test-root/test-init.sh +++ b/modules.d/80test-root/test-init.sh @@ -18,9 +18,9 @@ grep -q '^tmpfs /run tmpfs' /proc/self/mounts \ exec > /dev/console 2>&1 -if [ -s /failed ]; then +if [ -s /run/failed ]; then echo "**************************FAILED**************************" - cat /failed + cat /run/failed echo "**************************FAILED**************************" else echo "dracut-root-block-success" | dd oflag=direct,dsync status=none of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker @@ -29,8 +29,6 @@ fi export TERM=linux export PS1='initramfs-test:\w\$ ' -[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab -[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab stty sane echo "made it to the rootfs!" @@ -38,12 +36,10 @@ echo "made it to the rootfs!" if getargbool 0 rd.shell; then strstr "$(setsid --help)" "control" && CTTY="-c" - # shellcheck disable=SC2086 - setsid $CTTY sh -i + setsid ${CTTY:+"${CTTY}"} sh -i fi echo "Powering down." -mount -n -o remount,ro / if [ -d /run/initramfs/etc ]; then echo " rd.debug=0 " >> /run/initramfs/etc/cmdline fi diff --git a/modules.d/81cio_ignore/module-setup.sh b/modules.d/81cio_ignore/module-setup.sh index a54fcb9..6c618fb 100755 --- a/modules.d/81cio_ignore/module-setup.sh +++ b/modules.d/81cio_ignore/module-setup.sh @@ -6,7 +6,7 @@ check() { # do not add this module by default local arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1 return 0 } @@ -15,7 +15,7 @@ cmdline() { if [ -e /boot/zipl/active_devices.txt ]; then while read -r dev _; do - [ "$dev" = "#" -o "$dev" = "" ] && continue + [ "$dev" = "#" ] || [ "$dev" = "" ] && continue if [ -z "$cio_accept" ]; then cio_accept="$dev" else diff --git a/modules.d/90crypt/crypt-lib.sh b/modules.d/90crypt/crypt-lib.sh index f3ba20d..7669828 100755 --- a/modules.d/90crypt/crypt-lib.sh +++ b/modules.d/90crypt/crypt-lib.sh @@ -148,7 +148,7 @@ test_dev() { local mount_point mount_point=$(mkuniqdir /mnt testdev) - [ -n "$dev" -a -n "$*" ] || return 1 + [ -n "$dev" ] && [ -n "$*" ] || return 1 [ -d "$mount_point" ] || die 'Mount point does not exist!' if mount -r "$dev" "$mount_point" > /dev/null 2>&1; then @@ -175,7 +175,7 @@ test_dev() { # match_dev UUID=123 /dev/dm-1 # Returns true if /dev/dm-1 UUID starts with "123". match_dev() { - [ -z "$1" -o "$1" = '*' ] && return 0 + [ -z "$1" ] || [ "$1" = '*' ] && return 0 local devlist local dev @@ -206,7 +206,7 @@ getkey() { local key_dev local key_path - [ -z "$keys_file" -o -z "$for_dev" ] && die 'getkey: wrong usage!' + [ -z "$keys_file" ] || [ -z "$for_dev" ] && die 'getkey: wrong usage!' [ -f "$keys_file" ] || return 1 while IFS=: read -r luks_dev key_dev key_path _ || [ -n "$luks_dev" ]; do diff --git a/modules.d/90crypt/cryptroot-ask.sh b/modules.d/90crypt/cryptroot-ask.sh index b1f8df8..901c9a3 100755 --- a/modules.d/90crypt/cryptroot-ask.sh +++ b/modules.d/90crypt/cryptroot-ask.sh @@ -30,7 +30,7 @@ numtries=${4:-10} if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -d -n rd_NO_CRYPTTAB; then while read -r name dev luksfile luksoptions || [ -n "$name" ]; do # ignore blank lines and comments - if [ -z "$name" -o "${name#\#}" != "$name" ]; then + if [ -z "$name" ] || [ "${name#\#}" != "$name" ]; then continue fi @@ -137,7 +137,7 @@ unset allowdiscards # fallback to passphrase ask_passphrase=1 -if [ -n "$luksfile" -a "$luksfile" != "none" -a -e "$luksfile" ]; then +if [ -n "$luksfile" ] && [ "$luksfile" != "none" ] && [ -e "$luksfile" ]; then # shellcheck disable=SC2086 if readkey "$luksfile" / "$device" \ | cryptsetup -d - $cryptsetupopts luksOpen "$device" "$luksname"; then @@ -176,7 +176,7 @@ fi if [ $ask_passphrase -ne 0 ]; then luks_open="$(command -v cryptsetup) $cryptsetupopts luksOpen" - _timeout=$(getargs "rd.luks.timeout") + _timeout=$(getarg "rd.luks.timeout") _timeout=${_timeout:-0} ask_for_password --ply-tries 5 \ --ply-cmd "$luks_open -T1 $device $luksname" \ @@ -187,7 +187,7 @@ if [ $ask_passphrase -ne 0 ]; then unset _timeout fi -if [ "$is_keysource" -ne 0 -a "${luksname##luks-}" != "$luksname" ]; then +if [ "$is_keysource" -ne 0 ] && [ "${luksname##luks-}" != "$luksname" ]; then luks_close="$(command -v cryptsetup) close" { printf -- '[ -e /dev/mapper/%s ] && ' "$luksname" diff --git a/modules.d/90crypt/module-setup.sh b/modules.d/90crypt/module-setup.sh index 8d24825..cc74077 100755 --- a/modules.d/90crypt/module-setup.sh +++ b/modules.d/90crypt/module-setup.sh @@ -118,7 +118,7 @@ install() { forceentry="" while [ $# -gt 0 ]; do case $1 in - force) + force | x-initrd.attach) forceentry="yes" break ;; diff --git a/modules.d/90crypt/parse-crypt.sh b/modules.d/90crypt/parse-crypt.sh index 39fc6d2..9567a4a 100755 --- a/modules.d/90crypt/parse-crypt.sh +++ b/modules.d/90crypt/parse-crypt.sh @@ -174,7 +174,7 @@ else } >> "$hookdir/emergency/90-crypt.sh" fi done - elif getargbool 1 rd.auto; then + elif getargbool 1 rd.auto && [ -z "$(getargs rd.luks.name)" ]; then if [ -z "$DRACUT_SYSTEMD" ]; then { printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' "$(command -v initqueue)" diff --git a/modules.d/90crypt/probe-keydev.sh b/modules.d/90crypt/probe-keydev.sh index e5a3f36..bb86b8f 100755 --- a/modules.d/90crypt/probe-keydev.sh +++ b/modules.d/90crypt/probe-keydev.sh @@ -6,7 +6,7 @@ real_keydev="$1" keypath="$2" luksdev="$3" -[ -z "$real_keydev" -o -z "$keypath" ] && die 'probe-keydev: wrong usage!' +[ -z "$real_keydev" ] || [ -z "$keypath" ] && die 'probe-keydev: wrong usage!' [ -z "$luksdev" ] && luksdev='*' info "Probing $real_keydev for $keypath..." diff --git a/modules.d/90dmraid/dmraid.sh b/modules.d/90dmraid/dmraid.sh index b517320..c12d92e 100755 --- a/modules.d/90dmraid/dmraid.sh +++ b/modules.d/90dmraid/dmraid.sh @@ -15,7 +15,7 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then info "Scanning for dmraid devices $DM_RAIDS" SETS=$(dmraid -c -s) - if [ "$SETS" = "no raid disks" -o "$SETS" = "no raid sets" ]; then + if [ "$SETS" = "no raid disks" ] || [ "$SETS" = "no raid sets" ]; then return fi diff --git a/modules.d/90dmsquash-live-autooverlay/create-overlay.sh b/modules.d/90dmsquash-live-autooverlay/create-overlay.sh index 10e8ea5..05a8c35 100755 --- a/modules.d/90dmsquash-live-autooverlay/create-overlay.sh +++ b/modules.d/90dmsquash-live-autooverlay/create-overlay.sh @@ -14,14 +14,12 @@ gatherData() { info "Skipping overlay creation: kernel command line parameter 'rd.live.overlay' is not set" exit 0 fi - # shellcheck disable=SC2086 - if ! str_starts ${overlay} LABEL=; then + if ! str_starts "${overlay}" LABEL=; then die "Overlay creation failed: the partition must be set by LABEL in the 'rd.live.overlay' kernel parameter" fi overlayLabel=${overlay#LABEL=} - # shellcheck disable=SC2086 - if [ -b /dev/disk/by-label/${overlayLabel} ]; then + if [ -b "/dev/disk/by-label/${overlayLabel}" ]; then info "Skipping overlay creation: overlay already exists" exit 0 fi @@ -41,32 +39,24 @@ gatherData() { # The kernel command line's 'root=' parameter was parsed into the $root variable by the dmsquash-live module. # $root contains the path to a symlink within /dev/disk/by-label, which points to a partition. # This script needs that partition's parent block device. - # shellcheck disable=SC2046 - # shellcheck disable=SC2086 - rootDeviceAbsolutePath=$(readlink -f ${rootDevice}) - rootDeviceSysfsPath=/sys/class/block/${rootDeviceAbsolutePath##*/} + rootDeviceAbsolutePath=$(readlink -f "${rootDevice}") + rootDeviceSysfsPath="/sys/class/block/${rootDeviceAbsolutePath##*/}" if [ -f "${rootDeviceSysfsPath}/partition" ]; then - # shellcheck disable=SC2086 - read -r partition < ${rootDeviceSysfsPath}/partition + read -r partition < "${rootDeviceSysfsPath}/partition" else partition=0 fi - # shellcheck disable=SC2086 - read -r readonly < ${rootDeviceSysfsPath}/ro - # shellcheck disable=SC2086 + read -r readonly < "${rootDeviceSysfsPath}/ro" if [ "$partition" != "1" ] || [ "$readonly" != "0" ]; then info "Skipping overlay creation: unpartitioned or read-only media detected" exit 0 fi - # shellcheck disable=SC2046 - # shellcheck disable=SC2086 - fullDriveSysfsPath=$(readlink -f ${rootDeviceSysfsPath}/..) - blockDevice=/dev/${fullDriveSysfsPath##*/} + fullDriveSysfsPath=$(readlink -f "${rootDeviceSysfsPath}/..") + blockDevice="/dev/${fullDriveSysfsPath##*/}" currentPartitionCount=$(grep --count -E "${blockDevice#/dev/}[0-9]+" /proc/partitions) - # shellcheck disable=SC2086 - freeSpaceStart=$(parted --script ${blockDevice} unit % print free \ - | awk -v x=${currentPartitionCount} '$1 == x {getline; print $1}') + freeSpaceStart=$(parted --script "${blockDevice}" unit % print free \ + | awk -v "x=${currentPartitionCount}" '$1 == x {getline; print $1}') if [ -z "$freeSpaceStart" ]; then info "Skipping overlay creation: there is no free space after the last partition" exit 0 @@ -87,22 +77,18 @@ gatherData() { } createPartition() { - # shellcheck disable=SC2086 - parted --script --align optimal ${blockDevice} mkpart primary ${partitionStart}% 100% + parted --script --align optimal "${blockDevice}" mkpart primary ${partitionStart}% 100% } createFilesystem() { - # shellcheck disable=SC2086 - mkfs.${filesystem} -L ${overlayLabel} ${overlayPartition} + "mkfs.${filesystem}" -L "${overlayLabel}" "${overlayPartition}" baseDir=/run/initramfs/create-overlayfs mkdir -p ${baseDir} - # shellcheck disable=SC2086 - mount -t ${filesystem} ${overlayPartition} ${baseDir} + mount -t "${filesystem}" "${overlayPartition}" ${baseDir} - mkdir -p ${baseDir}/${live_dir}/ovlwork - # shellcheck disable=SC2086 - mkdir ${baseDir}/${live_dir}/overlay-${label}-${uuid} + mkdir -p "${baseDir}/${live_dir}/ovlwork" + mkdir "${baseDir}/${live_dir}/overlay-${label}-${uuid}" umount ${baseDir} rm -r ${baseDir} diff --git a/modules.d/90dmsquash-live/apply-live-updates.sh b/modules.d/90dmsquash-live/apply-live-updates.sh index a5a5a39..be3b2c2 100755 --- a/modules.d/90dmsquash-live/apply-live-updates.sh +++ b/modules.d/90dmsquash-live/apply-live-updates.sh @@ -1,6 +1,6 @@ #!/bin/sh -if [ -h /dev/root ] && [ -d /run/initramfs/live/updates -o -d /updates ]; then +if [ -h /dev/root ] && [ -d /run/initramfs/live/updates ] || [ -d /updates ]; then info "Applying updates to live image..." mount -o bind /run "$NEWROOT"/run # avoid overwriting symlinks (e.g. /lib -> /usr/lib) with directories @@ -16,7 +16,7 @@ if [ -h /dev/root ] && [ -d /run/initramfs/live/updates -o -d /updates ]; then fi # release resources on iso-scan boots with rd.live.ram if [ -d /run/initramfs/isoscan ] \ - && [ -f /run/initramfs/squashed.img -o -f /run/initramfs/rootfs.img ]; then + && [ -f /run/initramfs/squashed.img ] || [ -f /run/initramfs/rootfs.img ]; then umount --detach-loop /run/initramfs/live umount /run/initramfs/isoscan fi diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh index 4518852..e4a3f00 100755 --- a/modules.d/90dmsquash-live/dmsquash-live-root.sh +++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh @@ -67,7 +67,7 @@ if [ ! -f "$livedev" ]; then check_dev=$(get_check_dev "$livedev") # CD/DVD media check [ -b "$check_dev" ] && fs=$(det_fs "$check_dev") - if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then + if [ "$fs" = "iso9660" ] || [ "$fs" = "udf" ]; then check="yes" fi getarg rd.live.check -d check || check="" @@ -97,7 +97,6 @@ det_img_fs() { blkid -s TYPE -u noraid -o value "$1" } -load_fstype squashfs CMDLINE=$(getcmdline) for arg in $CMDLINE; do case $arg in @@ -112,14 +111,15 @@ if [ -f "$livedev" ]; then # check filesystem type and handle accordingly fstype=$(det_img_fs "$livedev") case $fstype in - squashfs) SQUASHED=$livedev ;; - auto) die "cannot mount live image (unknown filesystem type)" ;; + squashfs | erofs) SQUASHED=$livedev ;; + auto) die "cannot mount live image (unknown filesystem type $fstype)" ;; *) FSIMG=$livedev ;; esac load_fstype "$fstype" else livedev_fstype=$(det_fs "$livedev") - if [ "$livedev_fstype" = "squashfs" ]; then + load_fstype "$livedev_fstype" + if [ "$livedev_fstype" = "squashfs" ] || [ "$livedev_fstype" = "erofs" ]; then # no mount needed - we've already got the LiveOS image in $livedev SQUASHED=$livedev elif [ "$livedev_fstype" != "ntfs" ]; then @@ -148,7 +148,7 @@ do_live_overlay() { pathspec=${overlay##*:} fi - if [ -z "$pathspec" -o "$pathspec" = "auto" ]; then + if [ -z "$pathspec" ] || [ "$pathspec" = "auto" ]; then pathspec="/${live_dir}/overlay-$l-$u" elif ! str_starts "$pathspec" "/"; then pathspec=/"${pathspec}" @@ -156,7 +156,7 @@ do_live_overlay() { devspec=${overlay%%:*} # need to know where to look for the overlay - if [ -z "$setup" -a -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then + if [ -z "$setup" ] && [ -n "$devspec" ] && [ -n "$pathspec" ] && [ -n "$overlay" ]; then mkdir -m 0755 -p /run/initramfs/overlayfs if ismounted "$devspec"; then devmnt=$(findmnt -e -v -n -o 'TARGET' --source "$devspec") @@ -166,8 +166,8 @@ do_live_overlay() { else mount -n -t auto "$devspec" /run/initramfs/overlayfs || : fi - if [ -f /run/initramfs/overlayfs$pathspec -a -w /run/initramfs/overlayfs$pathspec ]; then - OVERLAY_LOOPDEV=$(losetup -f --show ${readonly_overlay:+-r} /run/initramfs/overlayfs$pathspec) + if [ -f "/run/initramfs/overlayfs$pathspec" ] && [ -w "/run/initramfs/overlayfs$pathspec" ]; then + OVERLAY_LOOPDEV=$(losetup -f --show ${readonly_overlay:+-r} "/run/initramfs/overlayfs$pathspec") over=$OVERLAY_LOOPDEV umount -l /run/initramfs/overlayfs || : oltype=$(det_img_fs "$OVERLAY_LOOPDEV") @@ -194,10 +194,10 @@ do_live_overlay() { setup="yes" fi fi - elif [ -d /run/initramfs/overlayfs$pathspec ] \ - && [ -d /run/initramfs/overlayfs$pathspec/../ovlwork ]; then - ln -s /run/initramfs/overlayfs$pathspec /run/overlayfs${readonly_overlay:+-r} - ln -s /run/initramfs/overlayfs$pathspec/../ovlwork /run/ovlwork${readonly_overlay:+-r} + elif [ -d "/run/initramfs/overlayfs$pathspec" ] \ + && [ -d "/run/initramfs/overlayfs$pathspec/../ovlwork" ]; then + ln -s "/run/initramfs/overlayfs$pathspec" /run/overlayfs${readonly_overlay:+-r} + ln -s "/run/initramfs/overlayfs$pathspec/../ovlwork" /run/ovlwork${readonly_overlay:+-r} if [ -z "$overlayfs" ] && [ -n "$DRACUT_SYSTEMD" ]; then reloadsysrootmountunit=":>/xor_overlayfs;" fi @@ -218,10 +218,10 @@ do_live_overlay() { fi fi - if [ -z "$setup" -o -n "$readonly_overlay" ]; then + if [ -z "$setup" ] || [ -n "$readonly_overlay" ]; then if [ -n "$setup" ]; then warn "Using temporary overlay." - elif [ -n "$devspec" -a -n "$pathspec" ]; then + elif [ -n "$devspec" ] && [ -n "$pathspec" ]; then [ -z "$m" ] \ && m=' Unable to find a persistent overlay; using a temporary one.' m="$m"' @@ -265,7 +265,7 @@ do_live_overlay() { fi else dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((overlay_size * 1024)) 2> /dev/null - if [ -n "$setup" -a -n "$readonly_overlay" ]; then + if [ -n "$setup" ] && [ -n "$readonly_overlay" ]; then RO_OVERLAY_LOOPDEV=$(losetup -f --show /overlay) over=$RO_OVERLAY_LOOPDEV else @@ -319,24 +319,24 @@ do_live_overlay() { # end do_live_overlay() # we might have an embedded fs image on squashfs (compressed live) -if [ -e /run/initramfs/live/${live_dir}/${squash_image} ]; then +if [ -e "/run/initramfs/live/${live_dir}/${squash_image}" ]; then SQUASHED="/run/initramfs/live/${live_dir}/${squash_image}" fi if [ -e "$SQUASHED" ]; then if [ -n "$live_ram" ]; then - imgsize=$(($(stat -c %s -- $SQUASHED) / (1024 * 1024))) + imgsize=$(($(stat -c %s -- "$SQUASHED") / (1024 * 1024))) check_live_ram $imgsize echo 'Copying live image to RAM...' > /dev/kmsg echo ' (this may take a minute)' > /dev/kmsg - dd if=$SQUASHED of=/run/initramfs/squashed.img bs=512 2> /dev/null + dd "if=$SQUASHED" of=/run/initramfs/squashed.img bs=512 2> /dev/null echo 'Done copying live image to RAM.' > /dev/kmsg SQUASHED="/run/initramfs/squashed.img" fi SQUASHED_LOOPDEV=$(losetup -f) - losetup -r "$SQUASHED_LOOPDEV" $SQUASHED + losetup -r "$SQUASHED_LOOPDEV" "$SQUASHED" mkdir -m 0755 -p /run/initramfs/squashfs - mount -n -t squashfs -o ro "$SQUASHED_LOOPDEV" /run/initramfs/squashfs + mount -n -o ro "$SQUASHED_LOOPDEV" /run/initramfs/squashfs if [ -d /run/initramfs/squashfs/LiveOS ]; then if [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then @@ -356,15 +356,15 @@ if [ -e "$SQUASHED" ]; then fi else # we might have an embedded fs image to use as rootfs (uncompressed live) - if [ -e /run/initramfs/live/${live_dir}/rootfs.img ]; then + if [ -e "/run/initramfs/live/${live_dir}/rootfs.img" ]; then FSIMG="/run/initramfs/live/${live_dir}/rootfs.img" - elif [ -e /run/initramfs/live/${live_dir}/ext3fs.img ]; then + elif [ -e "/run/initramfs/live/${live_dir}/ext3fs.img" ]; then FSIMG="/run/initramfs/live/${live_dir}/ext3fs.img" fi if [ -n "$live_ram" ]; then echo 'Copying live image to RAM...' > /dev/kmsg echo ' (this may take a minute or so)' > /dev/kmsg - dd if=$FSIMG of=/run/initramfs/rootfs.img bs=512 2> /dev/null + dd "if=$FSIMG" of=/run/initramfs/rootfs.img bs=512 2> /dev/null echo 'Done copying live image to RAM.' > /dev/kmsg FSIMG='/run/initramfs/rootfs.img' fi @@ -376,17 +376,17 @@ if [ -n "$FSIMG" ]; then echo "Unpacking live filesystem (may take some time)" > /dev/kmsg mkdir -m 0755 -p /run/initramfs/fsimg/ if [ -n "$SQUASHED" ]; then - cp -v $FSIMG /run/initramfs/fsimg/rootfs.img + cp -v "$FSIMG" /run/initramfs/fsimg/rootfs.img else - unpack_archive $FSIMG /run/initramfs/fsimg/ + unpack_archive "$FSIMG" /run/initramfs/fsimg/ fi FSIMG=/run/initramfs/fsimg/rootfs.img fi # For writable DM images... readonly_base=1 - if [ -z "$SQUASHED" -a -n "$live_ram" -a -z "$overlayfs" ] \ + if [ -z "$SQUASHED" ] && [ -n "$live_ram" ] && [ -z "$overlayfs" ] \ || [ -n "$writable_fsimg" ] \ - || [ "$overlay" = none -o "$overlay" = None -o "$overlay" = NONE ]; then + || [ "$overlay" = none ] || [ "$overlay" = None ] || [ "$overlay" = NONE ]; then if [ -z "$readonly_overlay" ]; then unset readonly_base setup=rw @@ -397,7 +397,7 @@ if [ -n "$FSIMG" ]; then if [ "$FSIMG" = "$SQUASHED" ]; then BASE_LOOPDEV=$SQUASHED_LOOPDEV else - BASE_LOOPDEV=$(losetup -f --show ${readonly_base:+-r} $FSIMG) + BASE_LOOPDEV=$(losetup -f --show ${readonly_base:+-r} "$FSIMG") sz=$(blockdev --getsz "$BASE_LOOPDEV") fi if [ "$setup" = rw ]; then @@ -422,7 +422,7 @@ fi if [ -n "$overlayfs" ]; then if [ -n "$FSIMG" ]; then mkdir -m 0755 -p /run/rootfsbase - mount -r $FSIMG /run/rootfsbase + mount -r "$FSIMG" /run/rootfsbase else ln -sf /run/initramfs/live /run/rootfsbase fi diff --git a/modules.d/90dmsquash-live/module-setup.sh b/modules.d/90dmsquash-live/module-setup.sh index b905e3d..99d2114 100755 --- a/modules.d/90dmsquash-live/module-setup.sh +++ b/modules.d/90dmsquash-live/module-setup.sh @@ -17,7 +17,7 @@ depends() { # called by dracut installkernel() { - instmods squashfs loop iso9660 + instmods squashfs loop iso9660 erofs } # called by dracut diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh index ec60f39..f159f0b 100755 --- a/modules.d/90kernel-modules/module-setup.sh +++ b/modules.d/90kernel-modules/module-setup.sh @@ -2,9 +2,10 @@ # called by dracut installkernel() { - local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host|scsi_add_host_with_dma|blk_mq_alloc_disk|blk_mq_alloc_request|blk_mq_destroy_queue|blk_cleanup_disk' + local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host|scsi_add_host_with_dma|blk_alloc_disk|blk_mq_alloc_disk|blk_mq_alloc_request|blk_mq_destroy_queue|blk_cleanup_disk' local -A _hostonly_drvs + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves record_block_dev_drv() { for _mod in $(get_dev_module /dev/block/"$1"); do @@ -80,6 +81,7 @@ installkernel() { "=drivers/mmc/host" \ "=drivers/nvmem" \ "=drivers/phy" \ + "=drivers/platform/chrome" \ "=drivers/power" \ "=drivers/regulator" \ "=drivers/reset" \ diff --git a/modules.d/90livenet/livenetroot.sh b/modules.d/90livenet/livenetroot.sh index 34f91ff..eccaaed 100755 --- a/modules.d/90livenet/livenetroot.sh +++ b/modules.d/90livenet/livenetroot.sh @@ -47,7 +47,7 @@ while [ "$i" -le "$RETRIES" ]; do imgfile= fi - if [ -n "$imgfile" -a -s "$imgfile" ]; then + if [ -n "$imgfile" ] && [ -s "$imgfile" ]; then break else if [ $i -ge "$RETRIES" ]; then diff --git a/modules.d/90mdraid/59-persistent-storage-md.rules b/modules.d/90mdraid/59-persistent-storage-md.rules index 0d745cc..9e29135 100644 --- a/modules.d/90mdraid/59-persistent-storage-md.rules +++ b/modules.d/90mdraid/59-persistent-storage-md.rules @@ -16,7 +16,7 @@ ATTR{md/array_state}=="|clear|inactive", GOTO="md_end" LABEL="md_ignore_state" -IMPORT{program}="/sbin/mdadm --detail --export $tempnode" +IMPORT{program}="/sbin/mdadm --detail --export $devnode" IMPORT{builtin}="blkid" OPTIONS+="link_priority=100" OPTIONS+="watch" diff --git a/modules.d/90mdraid/mdraid_start.sh b/modules.d/90mdraid/mdraid_start.sh index d8c5de2..2645f1c 100755 --- a/modules.d/90mdraid/mdraid_start.sh +++ b/modules.d/90mdraid/mdraid_start.sh @@ -32,11 +32,14 @@ _md_force_run() { local _md local _UUID local _MD_UUID + local _LEFT_UUID + local _uuid _MD_UUID=$(getargs rd.md.uuid -d rd_MD_UUID=) [ -n "$_MD_UUID" ] || getargbool 0 rd.auto || return if [ -n "$_MD_UUID" ]; then + _LEFT_UUID=$(str_replace "$_MD_UUID" "-" ":") _MD_UUID=$(str_replace "$_MD_UUID" "-" "") _MD_UUID=$(str_replace "$_MD_UUID" ":" "") @@ -51,6 +54,9 @@ _md_force_run() { ) [ -z "$_UUID" ] && continue + # remove the UUID already assembled from the list + _LEFT_UUID=$(str_replace "$_LEFT_UUID" "$_UUID" "") + _UUID=$(str_replace "$_UUID" ":" "") # check if we should handle this device @@ -65,6 +71,14 @@ _md_force_run() { _md_start "${_md}" done fi + + # try to assemble all the left md devices that should be assembled + # probably failed because of timing issue in the first beginning + if [ -n "$_LEFT_UUID" ]; then + for _uuid in ${_LEFT_UUID}; do + mdadm --assemble --scan --uuid="$_uuid" + done + fi } _md_force_run diff --git a/modules.d/90mdraid/parse-md.sh b/modules.d/90mdraid/parse-md.sh index 4d3a6b2..adc8aa6 100755 --- a/modules.d/90mdraid/parse-md.sh +++ b/modules.d/90mdraid/parse-md.sh @@ -21,7 +21,7 @@ else printf 'ENV{ID_FS_UUID}=="%s", GOTO="md_uuid_ok"\n' "$(expr substr "$uuid" 1 8)-$(expr substr "$uuid" 9 4)-$(expr substr "$uuid" 13 4)-$(expr substr "$uuid" 17 4)-$(expr substr "$uuid" 21 12)" done # shellcheck disable=SC2016 - printf 'IMPORT{program}="/sbin/mdadm --examine --export $tempnode"\n' + printf 'IMPORT{program}="/sbin/mdadm --examine --export $devnode"\n' for uuid in $MD_UUID; do printf 'ENV{MD_UUID}=="%s", GOTO="md_uuid_ok"\n' "$(expr substr "$uuid" 1 8):$(expr substr "$uuid" 9 8):$(expr substr "$uuid" 17 8):$(expr substr "$uuid" 25 8)" done diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh index 782a880..0a1fd55 100755 --- a/modules.d/90multipath/module-setup.sh +++ b/modules.d/90multipath/module-setup.sh @@ -21,14 +21,23 @@ majmin_to_mpath_dev() { # called by dracut check() { - [[ $hostonly ]] || [[ $mount_needs ]] && { - for_each_host_dev_and_slaves is_mpath || return 255 - } + local _any_mpath_dev # if there's no multipath binary, no go. require_binaries multipath || return 1 require_binaries kpartx || return 1 + for_each_host_dev_and_slaves is_mpath + _any_mpath_dev=$? + + [[ $hostonly ]] || [[ $mount_needs ]] && { + [[ $_any_mpath_dev == 0 ]] || return 255 + } + + if [[ $_any_mpath_dev != 0 ]] && [[ ! -f /etc/multipath.conf ]]; then + return 255 + fi + return 0 } @@ -53,7 +62,7 @@ installkernel() { local _arch=${DRACUT_ARCH:-$(uname -m)} local _funcs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target' - if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then + if [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ]; then _s390drivers="=drivers/s390/scsi" fi @@ -69,6 +78,7 @@ install() { local -A _allow local config_dir + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves add_hostonly_mpath_conf() { if is_mpath "$1"; then local _dev diff --git a/modules.d/90qemu/module-setup.sh b/modules.d/90qemu/module-setup.sh index d11f377..9e8c3a5 100755 --- a/modules.d/90qemu/module-setup.sh +++ b/modules.d/90qemu/module-setup.sh @@ -15,7 +15,7 @@ installkernel() { # qemu specific modules hostonly='' instmods \ ata_piix ata_generic pata_acpi cdrom sr_mod ahci \ - virtio_blk virtio virtio_ring virtio_pci \ + virtio_blk virtio virtio_crypto virtio_ring virtio_pci \ virtio_scsi virtio_console virtio_rng virtio_mem \ spapr-vscsi \ qemu_fw_cfg \ diff --git a/modules.d/91tpm2-tss/module-setup.sh b/modules.d/91tpm2-tss/module-setup.sh index 4106e3e..4441f55 100755 --- a/modules.d/91tpm2-tss/module-setup.sh +++ b/modules.d/91tpm2-tss/module-setup.sh @@ -30,9 +30,9 @@ installkernel() { # Install the required file(s) and directories for the module in the initramfs. install() { + inst_sysusers tpm2-tss.conf inst_multiple -o \ - "$sysusers"/tpm2-tss.conf \ "$tmpfilesdir"/tpm2-tss-fapi.conf \ "$udevrulesdir"/60-tpm-udev.rules \ "$systemdutildir"/system-generators/systemd-tpm2-generator \ diff --git a/modules.d/91zipl/install_zipl_cmdline.sh b/modules.d/91zipl/install_zipl_cmdline.sh index 9332d31..3a51332 100755 --- a/modules.d/91zipl/install_zipl_cmdline.sh +++ b/modules.d/91zipl/install_zipl_cmdline.sh @@ -23,7 +23,7 @@ fi if [ -f ${MNT}/active_devices.txt ]; then while read -r dev _ || [[ $dev ]]; do - [ "$dev" = "#" -o "$dev" = "" ] && continue + [ "$dev" = "#" ] || [ "$dev" = "" ] && continue cio_ignore -r "$dev" done < ${MNT}/active_devices.txt fi diff --git a/modules.d/91zipl/module-setup.sh b/modules.d/91zipl/module-setup.sh index cb21454..16e5c96 100755 --- a/modules.d/91zipl/module-setup.sh +++ b/modules.d/91zipl/module-setup.sh @@ -12,7 +12,7 @@ get_boot_zipl_dev() { check() { local _arch=${DRACUT_ARCH:-$(uname -m)} # Only for systems on s390 using indirect booting via userland grub - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 + [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1 # /boot/zipl contains a first stage kernel used to launch grub in initrd [ -d /boot/zipl ] || return 1 return 0 @@ -36,7 +36,7 @@ installkernel() { ID_FS_TYPE=ext4 ;; esac - instmods ${ID_FS_TYPE} + instmods "${ID_FS_TYPE}" fi fi } diff --git a/modules.d/91zipl/parse-zipl.sh b/modules.d/91zipl/parse-zipl.sh index d95a1dd..dc0a291 100755 --- a/modules.d/91zipl/parse-zipl.sh +++ b/modules.d/91zipl/parse-zipl.sh @@ -42,7 +42,7 @@ if [ -n "$zipl_arg" ]; then if [ "$zipl_env" ]; then { printf 'ACTION=="add|change", SUBSYSTEM=="block", %s=="%s", ENV{SYSTEMD_READY}!="0", RUN+="/sbin/initqueue --settled --onetime --unique --name install_zipl_cmdline /sbin/install_zipl_cmdline.sh %s"\n' \ - ${zipl_env} "${zipl_val}" "${zipl_arg}" + "${zipl_env}" "${zipl_val}" "${zipl_arg}" echo "[ -f /tmp/install.zipl.cmdline-done ]" > "$hookdir"/initqueue/finished/wait-zipl-conf.sh } >> /etc/udev/rules.d/99zipl-conf.rules cat /etc/udev/rules.d/99zipl-conf.rules diff --git a/modules.d/95cifs/cifs-lib.sh b/modules.d/95cifs/cifs-lib.sh index b996b41..9564534 100755 --- a/modules.d/95cifs/cifs-lib.sh +++ b/modules.d/95cifs/cifs-lib.sh @@ -30,7 +30,7 @@ cifs_to_var() { # shellcheck disable=SC2034 server=${server%/*} - if [ ! "$cifsuser" -o ! "$cifspass" ]; then + if [ ! "$cifsuser" ] || [ ! "$cifspass" ]; then die "For CIFS support you need to specify a cifsuser and cifspass either in the cifsuser and cifspass commandline parameters or in the root= CIFS URL." fi # shellcheck disable=SC2034 diff --git a/modules.d/95dasd/module-setup.sh b/modules.d/95dasd/module-setup.sh index 825f95d..c89d09e 100755 --- a/modules.d/95dasd/module-setup.sh +++ b/modules.d/95dasd/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut check() { local _arch=${DRACUT_ARCH:-$(uname -m)} - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 + [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1 require_binaries dasdconf.sh || return 1 return 0 } diff --git a/modules.d/95dasd_mod/module-setup.sh b/modules.d/95dasd_mod/module-setup.sh index 155eaac..8770683 100755 --- a/modules.d/95dasd_mod/module-setup.sh +++ b/modules.d/95dasd_mod/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut check() { local _arch=${DRACUT_ARCH:-$(uname -m)} - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 + [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1 return 0 } diff --git a/modules.d/95debug/module-setup.sh b/modules.d/95debug/module-setup.sh index 3124f1a..b21148a 100755 --- a/modules.d/95debug/module-setup.sh +++ b/modules.d/95debug/module-setup.sh @@ -13,10 +13,44 @@ depends() { # called by dracut install() { - inst_multiple -o ls ps grep more cat rm strace free showmount df du lsblk \ - ping netstat rpcinfo vi scp ping6 ssh find chroot \ - tcpdump cp dd less hostname mkdir systemd-analyze \ - fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.f2fs fsck.vfat e2fsck + inst_multiple -o \ + cat \ + chroot \ + cp \ + dd \ + df \ + du \ + e2fsck \ + findmnt \ + find \ + free \ + fsck \ + fsck.ext2 \ + fsck.ext3 \ + fsck.ext4 \ + fsck.ext4dev \ + fsck.f2fs \ + fsck.vfat \ + grep \ + hostname \ + less \ + ls \ + lsblk \ + mkdir \ + more \ + netstat \ + ping \ + ping6 \ + ps \ + rm \ + rpcinfo \ + scp \ + showmount \ + ssh \ + strace \ + systemd-analyze \ + tcpdump \ + vi grep '^tcpdump:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd" } diff --git a/modules.d/95fcoe-uefi/module-setup.sh b/modules.d/95fcoe-uefi/module-setup.sh index 9dc1e73..24acf99 100755 --- a/modules.d/95fcoe-uefi/module-setup.sh +++ b/modules.d/95fcoe-uefi/module-setup.sh @@ -2,6 +2,7 @@ # called by dracut check() { + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves is_fcoe() { block_is_fcoe "$1" || return 1 } diff --git a/modules.d/95fcoe/fcoe-edd.sh b/modules.d/95fcoe/fcoe-edd.sh index 17f8a7c..ece31ba 100755 --- a/modules.d/95fcoe/fcoe-edd.sh +++ b/modules.d/95fcoe/fcoe-edd.sh @@ -34,7 +34,7 @@ for disk in /sys/firmware/edd/int13_*; do fi for nic in "${disk}"/pci_dev/net/*; do [ -d "$nic" ] || continue - if [ -n "${dev_port}" -a -e "${nic}/dev_port" ]; then + if [ -n "${dev_port}" ] && [ -e "${nic}/dev_port" ]; then if [ "$(cat "${nic}"/dev_port)" -ne "${dev_port}" ]; then continue fi diff --git a/modules.d/95fcoe/fcoe-up.sh b/modules.d/95fcoe/fcoe-up.sh index 0828f03..3c6654c 100755 --- a/modules.d/95fcoe/fcoe-up.sh +++ b/modules.d/95fcoe/fcoe-up.sh @@ -11,7 +11,7 @@ type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh type ip_to_var > /dev/null 2>&1 || . /lib/net-lib.sh # Huh? Missing arguments ?? -[ -z "$1" -o -z "$2" ] && exit 1 +[ -z "$1" ] || [ -z "$2" ] && exit 1 netif=$1 dcb=$2 diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh index 3de85c2..ecebbda 100755 --- a/modules.d/95fcoe/module-setup.sh +++ b/modules.d/95fcoe/module-setup.sh @@ -2,6 +2,7 @@ # called by dracut check() { + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves is_fcoe() { block_is_fcoe "$1" || return 1 } diff --git a/modules.d/95fcoe/parse-fcoe.sh b/modules.d/95fcoe/parse-fcoe.sh index a6f284b..dc4ca32 100755 --- a/modules.d/95fcoe/parse-fcoe.sh +++ b/modules.d/95fcoe/parse-fcoe.sh @@ -72,7 +72,7 @@ parse_fcoe_opts() { ;; esac - if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ]; then + if [ "$fcoe_dcb" != "nodcb" ] && [ "$fcoe_dcb" != "dcb" ]; then warn "Invalid FCoE DCB option: $fcoe_dcb" fi @@ -81,7 +81,7 @@ parse_fcoe_opts() { return 0 fi - if [ -z "$fcoe_interface" -a -z "$fcoe_mac" ]; then + if [ -z "$fcoe_interface" ] && [ -z "$fcoe_mac" ]; then warn "fcoe: Neither interface nor MAC specified for fcoe=$fcoe" return 1 fi diff --git a/modules.d/95hwdb/module-setup.sh b/modules.d/95hwdb/module-setup.sh new file mode 100644 index 0000000..19112be --- /dev/null +++ b/modules.d/95hwdb/module-setup.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# This file is part of dracut. +# SPDX-License-Identifier: GPL-2.0-or-later + +# called by dracut +install() { + inst_multiple -o \ + /etc/udev/udev.hwdb \ + "${udevdir}"/hwdb.bin + + # Install the hosts local user configurations if enabled. + if [[ $hostonly ]]; then + inst_multiple -H -o \ + "$udevconfdir"/hwdb.bin + fi +} diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh index b6af7f4..5c65357 100755 --- a/modules.d/95iscsi/iscsiroot.sh +++ b/modules.d/95iscsi/iscsiroot.sh @@ -229,7 +229,7 @@ handle_netroot() { echo "$target" done }) - [ -z "$targets" ] && warn "Target discovery to $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} failed with status $?" && return 1 + [ -z "$targets" ] && warn "Target discovery to $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} failed" && return 1 found= for target in $targets; do diff --git a/modules.d/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh index 5eaab4e..d3307b9 100755 --- a/modules.d/95iscsi/module-setup.sh +++ b/modules.d/95iscsi/module-setup.sh @@ -109,11 +109,11 @@ install_iscsiroot() { [ -z "$iscsi_address" ] && return ip_params_for_remote_addr "$iscsi_address" - if [ -n "$iscsi_address" -a -n "$iscsi_targetname" ]; then - if [ -n "$iscsi_port" -a "$iscsi_port" -eq 3260 ]; then + if [ -n "$iscsi_address" ] && [ -n "$iscsi_targetname" ]; then + if [ -n "$iscsi_port" ] && [ "$iscsi_port" -eq 3260 ]; then iscsi_port= fi - if [ -n "$iscsi_lun" -a "$iscsi_lun" -eq 0 ]; then + if [ -n "$iscsi_lun" ] && [ "$iscsi_lun" -eq 0 ]; then iscsi_lun= fi # In IPv6 case rd.iscsi.initatior= must pass address in [] brackets @@ -134,6 +134,7 @@ install_iscsiroot() { install_softiscsi() { [ -d /sys/firmware/ibft ] && return 0 + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves is_softiscsi() { local _dev=$1 local iscsi_dev @@ -163,7 +164,7 @@ installkernel() { instmods bnx2i qla4xxx cxgb3i cxgb4i be2iscsi qedi hostonly="" instmods iscsi_tcp iscsi_ibft crc32c iscsi_boot_sysfs 8021q - if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then + if [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ]; then _s390drivers="=drivers/s390/scsi" fi diff --git a/modules.d/95lunmask/fc_transport_scan_lun.sh b/modules.d/95lunmask/fc_transport_scan_lun.sh index d14d2ca..57b530a 100755 --- a/modules.d/95lunmask/fc_transport_scan_lun.sh +++ b/modules.d/95lunmask/fc_transport_scan_lun.sh @@ -23,4 +23,4 @@ if [ -f /sys"$DEVPATH"/scsi_target_id ]; then read -r TARGET < /sys"$DEVPATH"/scsi_target_id fi [ -z "$TARGET" ] && exit 1 -echo "$CHANNEL" "$TARGET" $LUN > /sys/class/scsi_host/host"$HOST"/scan +echo "$CHANNEL $TARGET $LUN" > /sys/class/scsi_host/host"$HOST"/scan diff --git a/modules.d/95lunmask/module-setup.sh b/modules.d/95lunmask/module-setup.sh index cf6e3d7..f78cb26 100755 --- a/modules.d/95lunmask/module-setup.sh +++ b/modules.d/95lunmask/module-setup.sh @@ -4,6 +4,7 @@ # called by dracut cmdline() { + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves get_lunmask() { local _dev=$1 local _devpath _sdev _lun _rport _end_device _classdev _wwpn _sas_address diff --git a/modules.d/95lunmask/sas_transport_scan_lun.sh b/modules.d/95lunmask/sas_transport_scan_lun.sh index 1d1fc47..2f1cd42 100755 --- a/modules.d/95lunmask/sas_transport_scan_lun.sh +++ b/modules.d/95lunmask/sas_transport_scan_lun.sh @@ -23,4 +23,4 @@ if [ -f /sys"$DEVPATH"/scsi_target_id ]; then read -r TARGET < /sys"$DEVPATH"/scsi_target_id fi [ -z "$TARGET" ] && exit 1 -echo 0 "$TARGET" $LUN > /sys/class/scsi_host/host"$HOST"/scan +echo "0 $TARGET $LUN" > /sys/class/scsi_host/host"$HOST"/scan diff --git a/modules.d/95nbd/nbdroot.sh b/modules.d/95nbd/nbdroot.sh index b1a8030..35e24fa 100755 --- a/modules.d/95nbd/nbdroot.sh +++ b/modules.d/95nbd/nbdroot.sh @@ -60,7 +60,7 @@ while [ -n "$nbdopts" ]; do if [ -z "$f" ]; then break fi - if [ -z "${f%bs=*}" -o -z "${f%timeout=*}" ]; then + if [ -z "${f%bs=*}" ] || [ -z "${f%timeout=*}" ]; then preopts="$preopts $f" continue fi @@ -75,7 +75,7 @@ while [ -n "$nbdflags" ]; do if [ -z "$f" ]; then break fi - if [ "$f" = "ro" -o "$f" = "rw" ]; then + if [ "$f" = "ro" ] || [ "$f" = "rw" ]; then nbdrw=$f continue fi @@ -96,7 +96,7 @@ done # If we didn't get a root= on the command line, then we need to # add the udev rules for mounting the nbd0 device -if [ "$root" = "block:/dev/root" -o "$root" = "dhcp" ]; then +if [ "$root" = "block:/dev/root" ] || [ "$root" = "dhcp" ]; then printf 'KERNEL=="nbd0", ENV{DEVTYPE}!="partition", ENV{ID_FS_TYPE}=="?*", SYMLINK+="root"\n' > /etc/udev/rules.d/99-nbd-root.rules udevadm control --reload wait_for_dev -n /dev/root diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh index abe1ee5..5cc4289 100755 --- a/modules.d/95nfs/module-setup.sh +++ b/modules.d/95nfs/module-setup.sh @@ -125,7 +125,7 @@ install() { # Rather than copy the passwd file in, just set a user for rpcbind # We'll save the state and restart the daemon from the root anyway - grep -E '^nfsnobody:|^rpc:|^rpcuser:' "$dracutsysrootdir"/etc/passwd >> "$initdir/etc/passwd" + grep -E '^(nfsnobody|_rpc|rpc|rpcuser):' "$dracutsysrootdir"/etc/passwd >> "$initdir/etc/passwd" grep -E '^nogroup:|^rpc:|^nobody:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group" dracut_need_initqueue diff --git a/modules.d/95nfs/nfs-lib.sh b/modules.d/95nfs/nfs-lib.sh index 7896da9..52fa97b 100755 --- a/modules.d/95nfs/nfs-lib.sh +++ b/modules.d/95nfs/nfs-lib.sh @@ -155,3 +155,16 @@ mount_nfs() { fi mount -t "$nfs" -o"$options" "$server:$path" "$mntdir" } + +get_rpc_user() { + while read -r line; do + user="${line%%:*}" + case $user in + _rpc | rpc | rpcuser | nfsnobody) + echo "$user" + return + ;; + esac + done < /etc/passwd + echo "root" +} diff --git a/modules.d/95nfs/nfs-start-rpc.sh b/modules.d/95nfs/nfs-start-rpc.sh index 52f6a4d..641a58d 100755 --- a/modules.d/95nfs/nfs-start-rpc.sh +++ b/modules.d/95nfs/nfs-start-rpc.sh @@ -8,8 +8,9 @@ if load_fstype sunrpc rpc_pipefs; then # FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why? command -v portmap > /dev/null && [ -z "$(pidof portmap)" ] && portmap if command -v rpcbind > /dev/null && [ -z "$(pidof rpcbind)" ]; then + . /lib/nfs-lib.sh mkdir -p /run/rpcbind - chown rpc:rpc /run/rpcbind + chown "$(get_rpc_user):root" /run/rpcbind rpcbind fi diff --git a/modules.d/95nfs/nfsroot-cleanup.sh b/modules.d/95nfs/nfsroot-cleanup.sh index d99519b..3b164de 100755 --- a/modules.d/95nfs/nfsroot-cleanup.sh +++ b/modules.d/95nfs/nfsroot-cleanup.sh @@ -16,12 +16,12 @@ pid=$(pidof rpcbind) if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then # try to create the destination directory - [ -d "$NEWROOT"/$rpcpipefspath ] \ - || mkdir -m 0755 -p "$NEWROOT"/$rpcpipefspath 2> /dev/null + [ -d "$NEWROOT/$rpcpipefspath" ] \ + || mkdir -m 0755 -p "$NEWROOT/$rpcpipefspath" 2> /dev/null - if [ -d "$NEWROOT"/$rpcpipefspath ]; then + if [ -d "$NEWROOT/$rpcpipefspath" ]; then # mount --move does not seem to work??? - mount --bind /var/lib/nfs/rpc_pipefs "$NEWROOT"/$rpcpipefspath + mount --bind /var/lib/nfs/rpc_pipefs "$NEWROOT/$rpcpipefspath" umount /var/lib/nfs/rpc_pipefs 2> /dev/null else umount /var/lib/nfs/rpc_pipefs 2> /dev/null diff --git a/modules.d/95nfs/parse-nfsroot.sh b/modules.d/95nfs/parse-nfsroot.sh index a07c5f4..00497c2 100755 --- a/modules.d/95nfs/parse-nfsroot.sh +++ b/modules.d/95nfs/parse-nfsroot.sh @@ -126,5 +126,5 @@ echo '[ -e $NEWROOT/proc ]' > "$hookdir"/initqueue/finished/nfsroot.sh # rpc user needs to be able to write to this directory to save the warmstart # file mkdir -p /var/lib/rpcbind -chown rpc:rpc /var/lib/rpcbind +chown "$(get_rpc_user):root" /var/lib/rpcbind chmod 770 /var/lib/rpcbind diff --git a/modules.d/95nvmf/module-setup.sh b/modules.d/95nvmf/module-setup.sh index 6a1e3f5..c2cf0fb 100755 --- a/modules.d/95nvmf/module-setup.sh +++ b/modules.d/95nvmf/module-setup.sh @@ -4,6 +4,7 @@ check() { require_binaries nvme jq || return 1 + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves is_nvmf() { local _dev=$1 local trtype @@ -68,6 +69,7 @@ cmdline() { local _hostnqn local _hostid + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves gen_nvmf_cmdline() { local _dev=$1 local trtype diff --git a/modules.d/95resume/parse-resume.sh b/modules.d/95resume/parse-resume.sh index 75a905d..b5c60a6 100755 --- a/modules.d/95resume/parse-resume.sh +++ b/modules.d/95resume/parse-resume.sh @@ -72,7 +72,7 @@ if ! getarg noresume; then if [ -x /usr/sbin/resume ]; then printf -- '%s' 'SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_FS_TYPE}=="suspend|swsuspend|swsupend",' # shellcheck disable=SC2016 - printf -- ' RUN+="/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s $tempnode"\n' "$a_splash" + printf -- ' RUN+="/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s $devnode"\n' "$a_splash" fi printf -- '%s' 'SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_FS_TYPE}=="suspend|swsuspend|swsupend",' printf -- '%s\n' ' RUN+="/sbin/initqueue --finished --unique --name 00resume echo %M:%m > /sys/power/resume"' diff --git a/modules.d/95resume/resume.sh b/modules.d/95resume/resume.sh index c808880..a39b064 100755 --- a/modules.d/95resume/resume.sh +++ b/modules.d/95resume/resume.sh @@ -2,7 +2,7 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin -[ -s /.resume -a -b "$resume" ] && { +[ -s /.resume ] && [ -b "$resume" ] && { # First try user level resume; it offers splash etc case "$splash" in quiet) diff --git a/modules.d/95rootfs-block/module-setup.sh b/modules.d/95rootfs-block/module-setup.sh index 396fb11..943db48 100755 --- a/modules.d/95rootfs-block/module-setup.sh +++ b/modules.d/95rootfs-block/module-setup.sh @@ -40,7 +40,7 @@ cmdline_rootfs() { return fi - if [ -n "$_block" -a -b "$_dev" ]; then + if [ -n "$_block" ] && [ -b "$_dev" ]; then printf " root=%s" "$(shorten_persistent_dev "$(get_persistent_dev "$_dev")")" fi _fstype="$(find_mp_fstype /)" diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh index 973069b..5bb6f0f 100755 --- a/modules.d/95rootfs-block/mount-root.sh +++ b/modules.d/95rootfs-block/mount-root.sh @@ -98,7 +98,7 @@ mount_root() { # printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab if ! getargbool 0 ro && fsck_able "$rootfs" \ - && [ "$rootfsck" != "0" -a -z "$fastboot" ] \ + && [ "$rootfsck" != "0" ] && [ -z "$fastboot" ] \ && ! strstr "${rflags}" _netdev \ && ! getargbool 0 rd.skipfsck; then umount "$NEWROOT" @@ -121,6 +121,6 @@ mount_root() { fi } -if [ -n "$root" -a -z "${root%%block:*}" ]; then +if [ -n "$root" ] && [ -z "${root%%block:*}" ]; then mount_root fi diff --git a/modules.d/95udev-rules/module-setup.sh b/modules.d/95udev-rules/module-setup.sh index e5b7f97..d82ed5e 100755 --- a/modules.d/95udev-rules/module-setup.sh +++ b/modules.d/95udev-rules/module-setup.sh @@ -29,16 +29,36 @@ install() { 55-scsi-sg3_id.rules \ 58-scsi-sg3_symlink.rules \ 59-scsi-sg3_utils.rules \ + 60-autosuspend.rules \ 60-block.rules \ 60-cdrom_id.rules \ + 60-drm.rules \ + 60-evdev.rules \ + 60-fido-id.rules \ + 60-input-id.rules \ + 60-persistent-alsa.rules \ + 60-persistent-input.rules \ + 60-persistent-storage-tape.rules \ 60-persistent-storage.rules \ + 60-persistent-v4l.rules \ + 60-sensor.rules \ + 60-serial.rules \ 64-btrfs.rules \ + 70-joystick.rules \ + 70-memory.rules \ + 70-mouse.rules \ + 70-touchpad.rules \ 70-uaccess.rules \ 71-seat.rules \ 73-seat-late.rules \ 75-net-description.rules \ - 80-drivers.rules 95-udev-late.rules \ - 80-net-name-slot.rules 80-net-setup-link.rules \ + 75-probe_mtd.rules \ + 78-sound-card.rules \ + 80-drivers.rules \ + 80-net-name-slot.rules \ + 80-net-setup-link.rules \ + 81-net-dhcp.rules \ + 95-udev-late.rules \ "$moddir/59-persistent-storage.rules" \ "$moddir/61-persistent-storage.rules" @@ -61,12 +81,17 @@ install() { "${udevdir}"/ata_id \ "${udevdir}"/cdrom_id \ "${udevdir}"/create_floppy_devices \ + "${udevdir}"/dmi_memory_id \ + "${udevdir}"/fido_id \ "${udevdir}"/fw_unit_symlinks.sh \ "${udevdir}"/hid2hci \ - "${udevdir}"/path_id \ "${udevdir}"/input_id \ + "${udevdir}"/mtd_probe \ + "${udevdir}"/mtp-probe \ + "${udevdir}"/path_id \ "${udevdir}"/scsi_id \ - "${udevdir}"/usb_id + "${udevdir}"/usb_id \ + "${udevdir}"/v4l_id inst_libdir_file "libnss_files*" @@ -74,6 +99,7 @@ install() { if [[ $hostonly ]]; then inst_dir /etc/udev inst_multiple -H -o \ - /etc/udev/udev.conf + /etc/udev/udev.conf \ + "$udevrulesconfdir/*.rules" fi } diff --git a/modules.d/95virtfs/mount-virtfs.sh b/modules.d/95virtfs/mount-virtfs.sh index e52c752..417ace7 100755 --- a/modules.d/95virtfs/mount-virtfs.sh +++ b/modules.d/95virtfs/mount-virtfs.sh @@ -68,7 +68,7 @@ mount_root() { [ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2> /dev/null } -if [ -n "$root" -a -z "${root%%virtfs:*}" ]; then +if [ -n "$root" ] && [ -z "${root%%virtfs:*}" ]; then mount_root fi : diff --git a/modules.d/95virtiofs/mount-virtiofs.sh b/modules.d/95virtiofs/mount-virtiofs.sh index 3d73884..3f499cd 100755 --- a/modules.d/95virtiofs/mount-virtiofs.sh +++ b/modules.d/95virtiofs/mount-virtiofs.sh @@ -2,7 +2,7 @@ type ismounted > /dev/null 2>&1 || . /lib/dracut-lib.sh -if [ "${fstype}" = "virtiofs" -o "${root%%:*}" = "virtiofs" ]; then +if [ "${fstype}" = "virtiofs" ] || [ "${root%%:*}" = "virtiofs" ]; then if ! load_fstype virtiofs; then die "virtiofs is required but not available." fi diff --git a/modules.d/95virtiofs/parse-virtiofs.sh b/modules.d/95virtiofs/parse-virtiofs.sh index 760e413..192a950 100755 --- a/modules.d/95virtiofs/parse-virtiofs.sh +++ b/modules.d/95virtiofs/parse-virtiofs.sh @@ -3,7 +3,7 @@ # rootfstype=virtiofs root=<tag> # root=virtiofs:<tag> -if [ "${fstype}" = "virtiofs" -o "${root%%:*}" = "virtiofs" ]; then +if [ "${fstype}" = "virtiofs" ] || [ "${root%%:*}" = "virtiofs" ]; then # shellcheck disable=SC2034 rootok=1 fi diff --git a/modules.d/95zfcp/module-setup.sh b/modules.d/95zfcp/module-setup.sh index b547f9b..09a6420 100755 --- a/modules.d/95zfcp/module-setup.sh +++ b/modules.d/95zfcp/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut check() { arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1 require_binaries zfcp_cio_free sed || return 1 diff --git a/modules.d/95znet/module-setup.sh b/modules.d/95znet/module-setup.sh index 95164bb..3b5ed60 100755 --- a/modules.d/95znet/module-setup.sh +++ b/modules.d/95znet/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut check() { arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1 require_binaries grep sed seq readlink chzdev || return 1 @@ -45,14 +45,12 @@ install() { # shellcheck disable=SC2155 local _nullglob=$(shopt -p nullglob) shopt -u nullglob - # shellcheck disable=SC2086 readarray -t _array < <( - ls -1 $initdir/etc/udev/rules.d/41-*.rules 2> /dev/null + ls -1 "$initdir"/etc/udev/rules.d/41-*.rules 2> /dev/null ) [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}" - # shellcheck disable=SC2086 readarray -t _array < <( - ls -1 $initdir/etc/modprobe.d/s390x-*.conf 2> /dev/null + ls -1 "$initdir"/etc/modprobe.d/s390x-*.conf 2> /dev/null ) [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}" $_nullglob diff --git a/modules.d/98dracut-systemd/dracut-cmdline-ask.sh b/modules.d/98dracut-systemd/dracut-cmdline-ask.sh index 13c4f20..895cd90 100755 --- a/modules.d/98dracut-systemd/dracut-cmdline-ask.sh +++ b/modules.d/98dracut-systemd/dracut-cmdline-ask.sh @@ -14,6 +14,8 @@ echo echo echo echo "Enter additional kernel command line parameter (end with ctrl-d or .)" +# In POSIX sh, read -p is undefined, but dash supports it +# shellcheck disable=SC3045 while read -r -p "> " ${BASH:+-e} line || [ -n "$line" ]; do [ "$line" = "." ] && break [ -n "$line" ] && printf -- "%s\n" "$line" >> /etc/cmdline.d/99-cmdline-ask.conf diff --git a/modules.d/98dracut-systemd/dracut-shutdown.service.8.asc b/modules.d/98dracut-systemd/dracut-shutdown.service.8.asc index 21ec88c..1e9f88c 100644 --- a/modules.d/98dracut-systemd/dracut-shutdown.service.8.asc +++ b/modules.d/98dracut-systemd/dracut-shutdown.service.8.asc @@ -20,15 +20,20 @@ can be safely unmounted. The following steps are executed during a shutdown: -* systemd switches to the shutdown.target -* systemd starts /lib/systemd/system/shutdown.target.wants/dracut-shutdown.service -* dracut-shutdown.service executes /usr/lib/dracut/dracut-initramfs-restore which unpacks the initramfs to /run/initramfs -* systemd finishes shutdown.target +* The system starts to shut down +* ``$prefix/lib/systemd/system/sysinit.target.wants/dracut-shutdown.service`` + gets its ``ExecStop`` target triggered. +* ``dracut-shutdown.service`` executes + ``/usr/lib/dracut/dracut-initramfs-restore`` which unpacks the initramfs to + ``/run/initramfs`` * systemd kills all processes * systemd tries to unmount everything and mounts the remaining read-only -* systemd checks, if there is a /run/initramfs/shutdown executable -* if yes, it does a pivot_root to /run/initramfs and executes ./shutdown. The old root is then mounted on /oldroot. /usr/lib/dracut/modules.d/99shutdown/shutdown.sh is the shutdown executable. -* shutdown will try to umount every /oldroot mount and calls the various shutdown hooks from the dracut modules +* systemd checks if there is a ``/run/initramfs/shutdown`` executable +* if yes, it does a pivot_root to ``/run/initramfs`` and executes ``./shutdown``. + The old root is then mounted on ``/oldroot``. + ``/usr/lib/dracut/modules.d/99shutdown/shutdown.sh`` is the shutdown executable. +* shutdown will try to unmount every ``/oldroot`` mount and calls the various + shutdown hooks from the dracut modules This ensures, that all devices are disassembled and unmounted cleanly. diff --git a/modules.d/98selinux/selinux-loadpolicy.sh b/modules.d/98selinux/selinux-loadpolicy.sh index 0235b8e..4e00859 100755 --- a/modules.d/98selinux/selinux-loadpolicy.sh +++ b/modules.d/98selinux/selinux-loadpolicy.sh @@ -18,7 +18,7 @@ rd_load_policy() { fi # Attempt to load SELinux Policy - if [ -x "$NEWROOT/usr/sbin/load_policy" -o -x "$NEWROOT/sbin/load_policy" ]; then + if [ -x "$NEWROOT/usr/sbin/load_policy" ] || [ -x "$NEWROOT/sbin/load_policy" ]; then local ret=0 local out info "Loading SELinux policy" @@ -41,7 +41,7 @@ rd_load_policy() { return 0 fi - if [ $ret -eq 0 -o $ret -eq 2 ]; then + if [ $ret -eq 0 ] || [ $ret -eq 2 ]; then # If machine requires a relabel, force to permissive mode [ -e "$NEWROOT"/.autorelabel ] && LANG=C /usr/sbin/setenforce 0 mount --rbind /dev "$NEWROOT/dev" @@ -51,14 +51,14 @@ rd_load_policy() { fi warn "Initial SELinux policy load failed." - if [ $ret -eq 3 -o $permissive -eq 0 ]; then + if [ $ret -eq 3 ] || [ $permissive -eq 0 ]; then warn "Machine in enforcing mode." warn "Not continuing" emergency_shell -n selinux exit 1 fi return 0 - elif [ $permissive -eq 0 -a "$SELINUX" != "disabled" ]; then + elif [ $permissive -eq 0 ] && [ "$SELINUX" != "disabled" ]; then warn "Machine in enforcing mode and cannot execute load_policy." warn "To disable selinux, add selinux=0 to the kernel command line." warn "Not continuing" diff --git a/modules.d/98syslog/rsyslogd-start.sh b/modules.d/98syslog/rsyslogd-start.sh index d404e51..19a7229 100755 --- a/modules.d/98syslog/rsyslogd-start.sh +++ b/modules.d/98syslog/rsyslogd-start.sh @@ -41,7 +41,7 @@ rsyslog_config() { if [ "$type" = "rsyslogd" ]; then template=/etc/templates/rsyslog.conf if [ -n "$server" ]; then - rsyslog_config "$server" "$template" "$filters" > $conf + rsyslog_config "$server" "$template" "$filters" > "$conf" rsyslogd -c3 fi fi diff --git a/modules.d/99base/dracut-dev-lib.sh b/modules.d/99base/dracut-dev-lib.sh index 5779508..6a443a6 100755 --- a/modules.d/99base/dracut-dev-lib.sh +++ b/modules.d/99base/dracut-dev-lib.sh @@ -30,7 +30,7 @@ dev_unit_name() { return $? fi - if [ "$dev" = "/" -o -z "$dev" ]; then + if [ "$dev" = "/" ] || [ -z "$dev" ]; then printf -- "-" return 0 fi diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index e83ee94..cbef2db 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -37,7 +37,7 @@ strstr() { # matches; as it would match anything, it's not an interesting case. strglob() { # shellcheck disable=SC2295 - [ -n "$1" -a -z "${1##$2}" ] + [ -n "$1" ] && [ -z "${1##$2}" ] } # returns OK if $1 contains (anywhere) a match of glob pattern $2 @@ -45,7 +45,7 @@ strglob() { # matches; as it would match anything, it's not an interesting case. strglobin() { # shellcheck disable=SC2295 - [ -n "$1" -a -z "${1##*$2*}" ] + [ -n "$1" ] && [ -z "${1##*$2*}" ] } # returns OK if $1 contains literal string $2 at the beginning, and isn't empty @@ -266,7 +266,7 @@ getargnum() { _b=$(getarg "$1") || _b=${_b:-"$_default"} if [ -n "$_b" ]; then isdigit "$_b" && _b=$((_b)) \ - && [ $_b -ge "$_min" ] && [ $_b -le "$_max" ] && echo $_b && return + && [ "$_b" -ge "$_min" ] && [ "$_b" -le "$_max" ] && echo "$_b" && return fi echo "$_default" } @@ -354,14 +354,14 @@ splitsep() { shift 2 local tmp - while [ -n "$str" -a "$#" -gt 1 ]; do + while [ -n "$str" ] && [ "$#" -gt 1 ]; do tmp="${str%%"$sep"*}" eval "$1='${tmp}'" str="${str#"$tmp"}" str="${str#"$sep"}" shift done - [ -n "$str" -a -n "$1" ] && eval "$1='$str'" + [ -n "$str" ] && [ -n "$1" ] && eval "$1='$str'" debug_on return 0 } @@ -937,15 +937,15 @@ _emergency_shell() { _ctty="$(RD_DEBUG='' getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}" if [ -z "$_ctty" ]; then _ctty=console - while [ -f /sys/class/tty/$_ctty/active ]; do - read -r _ctty < /sys/class/tty/$_ctty/active + while [ -f "/sys/class/tty/$_ctty/active" ]; do + read -r _ctty < "/sys/class/tty/$_ctty/active" _ctty=${_ctty##* } # last one in the list done _ctty=/dev/$_ctty fi [ -c "$_ctty" ] || _ctty=/dev/tty1 case "$(/usr/bin/setsid --help 2>&1)" in *--ctty*) CTTY="--ctty" ;; esac - setsid $CTTY /bin/sh -i -l 0<> $_ctty 1<> $_ctty 2<> $_ctty + setsid ${CTTY:+"${CTTY}"} /bin/sh -i -l 0<> "$_ctty" 1<> "$_ctty" 2<> "$_ctty" fi } @@ -1002,8 +1002,8 @@ export_n() { local var local val for var in "$@"; do - eval val=\$$var - unset $var + eval "val=\$$var" + unset "$var" [ -n "$val" ] && eval "$var=\"$val\"" done } diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh index 727f279..2a095a6 100755 --- a/modules.d/99base/init.sh +++ b/modules.d/99base/init.sh @@ -109,6 +109,8 @@ source_conf /etc/conf.d if getarg "rd.cmdline=ask"; then echo "Enter additional kernel command line parameter (end with ctrl-d or .)" + # In POSIX sh, read -p is undefined, but dash supports it + # shellcheck disable=SC3045 while read -r -p "> " ${BASH:+-e} line || [ -n "$line" ]; do [ "$line" = "." ] && break echo "$line" >> /etc/cmdline.d/99-cmdline-ask.conf diff --git a/shell-completion/bash/dracut b/shell-completion/bash/dracut index e8a8691..d54fe5f 100644 --- a/shell-completion/bash/dracut +++ b/shell-completion/bash/dracut @@ -1,4 +1,5 @@ -#!/bin/bash +# bash completion for dracut +# shellcheck shell=bash # Copyright 2013 Red Hat, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify diff --git a/shell-completion/bash/lsinitrd b/shell-completion/bash/lsinitrd index da7e7ad..be48f38 100644 --- a/shell-completion/bash/lsinitrd +++ b/shell-completion/bash/lsinitrd @@ -1,4 +1,5 @@ -#!/bin/bash +# bash completion for lsinitrd +# shellcheck shell=bash # Copyright 2013 Red Hat, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c index 0c34363..ccb3200 100644 --- a/src/install/dracut-install.c +++ b/src/install/dracut-install.c @@ -42,6 +42,7 @@ #include <fts.h> #include <regex.h> #include <sys/utsname.h> +#include <sys/xattr.h> #include "log.h" #include "hashmap.h" @@ -84,6 +85,7 @@ static Hashmap *items_failed = NULL; static Hashmap *modules_loaded = NULL; static Hashmap *modules_suppliers = NULL; static Hashmap *processed_suppliers = NULL; +static Hashmap *modalias_to_kmod = NULL; static regex_t mod_filter_path; static regex_t mod_filter_nopath; static regex_t mod_filter_symbol; @@ -291,6 +293,56 @@ static inline int clone_file(int dest_fd, int src_fd) return ioctl(dest_fd, BTRFS_IOC_CLONE, src_fd); } +static int copy_xattr(int dest_fd, int src_fd) +{ + int ret = 0; + ssize_t name_len = 0, value_len = 0; + char *name_buf = NULL, *name = NULL, *value = NULL, *value_save = NULL; + + name_len = flistxattr(src_fd, NULL, 0); + if (name_len < 0) + return -1; + + name_buf = calloc(1, name_len + 1); + if (name_buf == NULL) + return -1; + + name_len = flistxattr(src_fd, name_buf, name_len); + if (name_len < 0) + goto out; + + for (name = name_buf; name != name_buf + name_len; name = strchr(name, '\0') + 1) { + value_len = fgetxattr(src_fd, name, NULL, 0); + if (value_len < 0) { + ret = -1; + continue; + } + + value_save = value; + value = realloc(value, value_len); + if (value == NULL) { + value = value_save; + ret = -1; + goto out; + } + + value_len = fgetxattr(src_fd, name, value, value_len); + if (value_len < 0) { + ret = -1; + continue; + } + + value_len = fsetxattr(dest_fd, name, value, value_len, 0); + if (value_len < 0) + ret = -1; + } + +out: + free(name_buf); + free(value); + return ret; +} + static bool use_clone = true; static int cp(const char *src, const char *dst) @@ -332,6 +384,11 @@ static int cp(const char *src, const char *dst) log_info("Failed to chown %s: %m", dst); } + if (geteuid() == 0 && no_xattr == false) { + if (copy_xattr(dest_desc, source_desc) != 0) + log_error("Failed to copy xattr %s: %m", dst); + } + tv[0].tv_sec = sb.st_atime; tv[0].tv_usec = 0; tv[1].tv_sec = sb.st_mtime; @@ -1507,8 +1564,26 @@ static bool check_module_path(const char *path) return true; } -static int find_kmod_module_from_sysfs_node(struct kmod_ctx *ctx, const char *sysfs_node, int sysfs_node_len, - struct kmod_list **modules) +static int find_kmod_module_from_sysfs_driver(struct kmod_ctx *ctx, const char *sysfs_node, int sysfs_node_len, + struct kmod_module **module) +{ + char mod_path[PATH_MAX], mod_realpath[PATH_MAX]; + const char *mod_name; + if (snprintf(mod_path, sizeof(mod_path), "%.*s/driver/module", + sysfs_node_len, sysfs_node) >= sizeof(mod_path)) + return -1; + + if (realpath(mod_path, mod_realpath) == NULL) + return -1; + + if ((mod_name = basename(mod_realpath)) == NULL) + return -1; + + return kmod_module_new_from_name(ctx, mod_name, module); +} + +static int find_kmod_module_from_sysfs_modalias(struct kmod_ctx *ctx, const char *sysfs_node, int sysfs_node_len, + struct kmod_list **modules) { char modalias_path[PATH_MAX]; if (snprintf(modalias_path, sizeof(modalias_path), "%.*s/modalias", sysfs_node_len, @@ -1523,15 +1598,35 @@ static int find_kmod_module_from_sysfs_node(struct kmod_ctx *ctx, const char *sy ssize_t len = read(modalias_file, alias, sizeof(alias)); alias[len - 1] = '\0'; - return kmod_module_new_from_lookup(ctx, alias, modules); + void *list; + + if (hashmap_get_exists(modalias_to_kmod, alias, &list) == 1) { + *modules = list; + return 0; + } + + int ret = kmod_module_new_from_lookup(ctx, alias, modules); + if (!ret) { + hashmap_put(modalias_to_kmod, strdup(alias), *modules); + } + + return ret; } static int find_modules_from_sysfs_node(struct kmod_ctx *ctx, const char *sysfs_node, Hashmap *modules) { - _cleanup_kmod_module_unref_list_ struct kmod_list *list = NULL; + _cleanup_kmod_module_unref_ struct kmod_module *drv = NULL; + struct kmod_list *list = NULL; struct kmod_list *l = NULL; - if (find_kmod_module_from_sysfs_node(ctx, sysfs_node, strlen(sysfs_node), &list) >= 0) { + if (find_kmod_module_from_sysfs_driver(ctx, sysfs_node, strlen(sysfs_node), &drv) >= 0) { + char *module = strdup(kmod_module_get_name(drv)); + if (hashmap_put(modules, module, module) < 0) + free(module); + return 0; + } + + if (find_kmod_module_from_sysfs_modalias(ctx, sysfs_node, strlen(sysfs_node), &list) >= 0) { kmod_list_foreach(l, list) { struct kmod_module *mod = kmod_module_get_module(l); char *module = strdup(kmod_module_get_name(mod)); @@ -1585,10 +1680,25 @@ static void find_suppliers(struct kmod_ctx *ctx) for (FTSENT *ftsent = fts_read(fts); ftsent != NULL; ftsent = fts_read(fts)) { if (strcmp(ftsent->fts_name, "modalias") == 0) { - _cleanup_kmod_module_unref_list_ struct kmod_list *list = NULL; + _cleanup_kmod_module_unref_ struct kmod_module *drv = NULL; + struct kmod_list *list = NULL; struct kmod_list *l; - if (find_kmod_module_from_sysfs_node(ctx, ftsent->fts_parent->fts_path, ftsent->fts_parent->fts_pathlen, &list) < 0) + if (find_kmod_module_from_sysfs_driver(ctx, ftsent->fts_parent->fts_path, ftsent->fts_parent->fts_pathlen, &drv) >= 0) { + const char *name = kmod_module_get_name(drv); + Hashmap *suppliers = hashmap_get(modules_suppliers, name); + if (suppliers == NULL) { + suppliers = hashmap_new(string_hash_func, string_compare_func); + hashmap_put(modules_suppliers, strdup(name), suppliers); + } + + find_suppliers_for_sys_node(ctx, suppliers, ftsent->fts_parent->fts_path, ftsent->fts_parent->fts_pathlen); + + /* Skip modalias check */ + continue; + } + + if (find_kmod_module_from_sysfs_modalias(ctx, ftsent->fts_parent->fts_path, ftsent->fts_parent->fts_pathlen, &list) < 0) continue; kmod_list_foreach(l, list) { @@ -1639,6 +1749,9 @@ static int install_dependent_module(struct kmod_ctx *ctx, struct kmod_module *mo _cleanup_kmod_module_unref_list_ struct kmod_list *modlist = NULL; _cleanup_kmod_module_unref_list_ struct kmod_list *modpre = NULL; _cleanup_kmod_module_unref_list_ struct kmod_list *modpost = NULL; +#ifdef CONFIG_WEAKDEP + _cleanup_kmod_module_unref_list_ struct kmod_list *modweak = NULL; +#endif log_debug("dracut_install '%s' '%s' OK", path, &path[kerneldirlen]); install_firmware(mod); modlist = kmod_module_get_dependencies(mod); @@ -1652,6 +1765,13 @@ static int install_dependent_module(struct kmod_ctx *ctx, struct kmod_module *mo *err = *err ? : r; } } +#ifdef CONFIG_WEAKDEP + if (*err == 0) { + *err = kmod_module_get_weakdeps(mod, &modweak); + if (*err == 0) + *err = install_dependent_modules(ctx, modweak, NULL); + } +#endif } else { log_error("dracut_install '%s' '%s' ERROR", path, &path[kerneldirlen]); } @@ -1710,6 +1830,9 @@ static int install_module(struct kmod_ctx *ctx, struct kmod_module *mod) _cleanup_kmod_module_unref_list_ struct kmod_list *modlist = NULL; _cleanup_kmod_module_unref_list_ struct kmod_list *modpre = NULL; _cleanup_kmod_module_unref_list_ struct kmod_list *modpost = NULL; +#ifdef CONFIG_WEAKDEP + _cleanup_kmod_module_unref_list_ struct kmod_list *modweak = NULL; +#endif const char *path = NULL; const char *name = NULL; @@ -1767,6 +1890,13 @@ static int install_module(struct kmod_ctx *ctx, struct kmod_module *mod) ret = ret ? : r; } } +#ifdef CONFIG_WEAKDEP + if (ret == 0) { + ret = kmod_module_get_weakdeps(mod, &modweak); + if (ret == 0) + ret = install_dependent_modules(ctx, modweak, NULL); + } +#endif return ret; } @@ -1868,6 +1998,7 @@ static int install_modules(int argc, char **argv) int modinst = 0; ctx = kmod_new(kerneldir, NULL); + kmod_load_resources(ctx); abskpath = kmod_get_dirname(ctx); p = strstr(abskpath, "/lib/modules/"); @@ -2196,6 +2327,7 @@ int main(int argc, char **argv) items = hashmap_new(string_hash_func, string_compare_func); items_failed = hashmap_new(string_hash_func, string_compare_func); processed_suppliers = hashmap_new(string_hash_func, string_compare_func); + modalias_to_kmod = hashmap_new(string_hash_func, string_compare_func); if (!items || !items_failed || !processed_suppliers || !modules_loaded) { log_error("Out of memory"); @@ -2269,11 +2401,17 @@ finish2: while ((i = hashmap_steal_first(processed_suppliers))) item_free(i); + /* + * Note: modalias_to_kmod's values are freed implicitly by the kmod context destruction + * in kmod_unref(). + */ + hashmap_free(items); hashmap_free(items_failed); hashmap_free(modules_loaded); hashmap_free(modules_suppliers); hashmap_free(processed_suppliers); + hashmap_free(modalias_to_kmod); if (arg_mod_filter_path) regfree(&mod_filter_path); diff --git a/src/install/hashmap.c b/src/install/hashmap.c index ff0f681..e6f8c79 100644 --- a/src/install/hashmap.c +++ b/src/install/hashmap.c @@ -273,20 +273,32 @@ int hashmap_replace(Hashmap *h, const void *key, void *value) return hashmap_put(h, key, value); } -void *hashmap_get(Hashmap *h, const void *key) +int hashmap_get_exists(Hashmap *h, const void *key, void **value) { unsigned int hash; struct hashmap_entry *e; + *value = NULL; + if (!h) - return NULL; + return 0; hash = h->hash_func(key) % NBUCKETS; if (!(e = hash_scan(h, hash, key))) - return NULL; + return 0; - return e->value; + *value = e->value; + return 1; +} + +void *hashmap_get(Hashmap *h, const void *key) +{ + void *ret; + + hashmap_get_exists(h, key, &ret); + + return ret; } void *hashmap_remove(Hashmap *h, const void *key) diff --git a/src/install/hashmap.h b/src/install/hashmap.h index 2537c49..77dbd54 100644 --- a/src/install/hashmap.h +++ b/src/install/hashmap.h @@ -51,6 +51,7 @@ int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t int hashmap_put(Hashmap *h, const void *key, void *value); int hashmap_replace(Hashmap *h, const void *key, void *value); void *hashmap_get(Hashmap *h, const void *key); +int hashmap_get_exists(Hashmap *h, const void *key, void **value); void *hashmap_remove(Hashmap *h, const void *key); void *hashmap_remove_value(Hashmap *h, const void *key, void *value); int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value); diff --git a/test/Makefile b/test/Makefile index 518e7d6..c19f0c2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -19,4 +19,3 @@ clean: done all: - diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh index 252c3f9..78fa730 100755 --- a/test/TEST-01-BASIC/test.sh +++ b/test/TEST-01-BASIC/test.sh @@ -14,7 +14,7 @@ test_run() { test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append 'rw "root=LABEL= rdinit=/bin/sh" rd.retry=3' \ + -append "$TEST_KERNEL_CMDLINE rw \"root=LABEL= rdinit=/bin/sh\" rd.retry=3" \ -initrd "$TESTDIR"/initramfs.testing || return 1 test_marker_check || return 1 @@ -32,7 +32,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot" \ + -a "test-makeroot" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 rm -rf -- "$TESTDIR"/overlay @@ -45,7 +45,7 @@ test_setup() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 rm -- "$TESTDIR"/marker.img diff --git a/test/TEST-02-SYSTEMD/test.sh b/test/TEST-02-SYSTEMD/test.sh index 4d48fd2..0a7d05a 100755 --- a/test/TEST-02-SYSTEMD/test.sh +++ b/test/TEST-02-SYSTEMD/test.sh @@ -17,7 +17,7 @@ test_run() { test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=LABEL=dracut rw systemd.log_target=console rd.retry=3 init=/sbin/init" \ + -append "$TEST_KERNEL_CMDLINE root=LABEL=dracut rw systemd.log_target=console rd.retry=3 init=/sbin/init" \ -initrd "$TESTDIR"/initramfs.testing || return 1 test_marker_check || return 1 @@ -35,7 +35,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot" \ + -a "test-makeroot" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ --nomdadmconf \ --no-hostonly-cmdline -N \ @@ -50,7 +50,7 @@ test_setup() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 rm -- "$TESTDIR"/marker.img diff --git a/test/TEST-03-USR-MOUNT/test.sh b/test/TEST-03-USR-MOUNT/test.sh index c64a582..22e9d4d 100755 --- a/test/TEST-03-USR-MOUNT/test.sh +++ b/test/TEST-03-USR-MOUNT/test.sh @@ -22,7 +22,7 @@ client_run() { test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=LABEL=dracut $client_opts rd.retry=3" \ + -append "$TEST_KERNEL_CMDLINE root=LABEL=dracut $client_opts rd.retry=3" \ -initrd "$TESTDIR"/initramfs.testing || return 1 if ! test_marker_check; then @@ -51,7 +51,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot" \ + -a "test-makeroot" \ -I "mkfs.btrfs" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 @@ -67,7 +67,7 @@ test_setup() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=btrfs quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 if ! test_marker_check dracut-root-block-created; then diff --git a/test/TEST-04-FULL-SYSTEMD/create-root.sh b/test/TEST-04-FULL-SYSTEMD/create-root.sh index 734f377..0436c18 100755 --- a/test/TEST-04-FULL-SYSTEMD/create-root.sh +++ b/test/TEST-04-FULL-SYSTEMD/create-root.sh @@ -13,21 +13,37 @@ set -e udevadm settle modprobe btrfs || : mkfs.btrfs -q -L dracut /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root +printf test > keyfile +cryptsetup -q luksFormat /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_crypt /keyfile +cryptsetup luksOpen /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_crypt dracut_crypt_test < /keyfile +mkfs.btrfs -q -L dracut_crypt /dev/mapper/dracut_crypt_test mkfs.btrfs -q -L dracutusr /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_usr btrfs device scan /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root +btrfs device scan /dev/mapper/dracut_crypt_test btrfs device scan /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_usr -mkdir -p /root +mkdir -p /root /root_crypt mount -t btrfs /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root /root +mount -t btrfs /dev/mapper/dracut_crypt_test /root_crypt [ -d /root/usr ] || mkdir -p /root/usr +[ -d /root-crypt/usr ] || mkdir -p /root_crypt/usr mount -t btrfs /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_usr /root/usr btrfs subvolume create /root/usr/usr umount /root/usr mount -t btrfs -o subvol=usr /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_usr /root/usr +mount --bind /root/usr /root_crypt/usr cp -a -t /root /source/* -mkdir -p /root/run +cp -a -t /root_crypt /source/* +mkdir -p /root/run /root_crypt/run btrfs filesystem sync /root/usr btrfs filesystem sync /root -umount /root/usr -umount /root -echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker status=none +btrfs filesystem sync /root_crypt/usr +btrfs filesystem sync /root_crypt +umount /root/usr /root_crypt/usr +umount /root /root_crypt +cryptsetup luksClose /dev/mapper/dracut_crypt_test +eval "$(udevadm info --query=property --name=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_crypt | while read -r line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo "$line"; done)" +{ + echo "dracut-root-block-created" + echo "ID_FS_UUID=$ID_FS_UUID" +} | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker status=none poweroff -f diff --git a/test/TEST-04-FULL-SYSTEMD/fstab b/test/TEST-04-FULL-SYSTEMD/fstab deleted file mode 100644 index 114f945..0000000 --- a/test/TEST-04-FULL-SYSTEMD/fstab +++ /dev/null @@ -1,2 +0,0 @@ -/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root / btrfs defaults 0 0 -/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_usr /usr btrfs subvol=usr,ro 0 0 diff --git a/test/TEST-04-FULL-SYSTEMD/test-init.sh b/test/TEST-04-FULL-SYSTEMD/test-init.sh index eeec8a2..c60c0ff 100755 --- a/test/TEST-04-FULL-SYSTEMD/test-init.sh +++ b/test/TEST-04-FULL-SYSTEMD/test-init.sh @@ -5,7 +5,7 @@ export PATH=/usr/sbin:/usr/bin:/sbin:/bin command -v plymouth > /dev/null 2>&1 && plymouth --quit exec > /dev/console 2>&1 -systemctl --failed --no-legend --no-pager > /failed +systemctl --failed --no-legend --no-pager > /run/failed ismounted() { findmnt "$1" > /dev/null 2>&1 @@ -14,7 +14,7 @@ ismounted() { if ! ismounted /usr; then echo "**************************FAILED**************************" echo "/usr not mounted!!" - cat /proc/mounts >> /failed + cat /proc/mounts >> /run/failed echo "**************************FAILED**************************" fi diff --git a/test/TEST-04-FULL-SYSTEMD/test.sh b/test/TEST-04-FULL-SYSTEMD/test.sh index afd7645..c9a0826 100755 --- a/test/TEST-04-FULL-SYSTEMD/test.sh +++ b/test/TEST-04-FULL-SYSTEMD/test.sh @@ -10,7 +10,6 @@ test_check() { # Uncomment this to debug failures #DEBUGFAIL="rd.shell rd.break" #DEBUGOUT="quiet systemd.log_level=debug systemd.log_target=console loglevel=77 rd.info rd.debug" -DEBUGOUT="loglevel=0 " client_run() { local test_name="$1" shift @@ -22,12 +21,13 @@ client_run() { declare -i disk_index=0 qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker qemu_add_drive disk_index disk_args "$TESTDIR"/root.btrfs root + qemu_add_drive disk_index disk_args "$TESTDIR"/root_crypt.btrfs root_crypt qemu_add_drive disk_index disk_args "$TESTDIR"/usr.btrfs usr test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "systemd.unit=testsuite.target systemd.mask=systemd-firstboot rd.multipath=0 root=LABEL=dracut $client_opts rd.retry=3 $DEBUGOUT" \ + -append "$TEST_KERNEL_CMDLINE systemd.unit=testsuite.target systemd.mask=systemd-firstboot systemd.mask=systemd-vconsole-setup root=LABEL=dracut mount.usr=LABEL=dracutusr mount.usrfstype=btrfs mount.usrflags=subvol=usr,ro $client_opts rd.retry=3 $DEBUGOUT" \ -initrd "$TESTDIR"/initramfs.testing || return 1 if ! test_marker_check; then @@ -35,13 +35,23 @@ client_run() { return 1 fi echo "CLIENT TEST END: $test_name [OK]" - } test_run() { client_run "no option specified" || return 1 client_run "readonly root" "ro" || return 1 client_run "writeable root" "rw" || return 1 + + # volatile mode + client_run "volatile=overlayfs root" "systemd.volatile=overlayfs" || return 1 + client_run "volatile=state root" "systemd.volatile=state" || return 1 + + # shellcheck source=$TESTDIR/luks.uuid + . "$TESTDIR"/luks.uuid + + # luks + client_run "encrypted root with rd.luks.uuid" "root=LABEL=dracut_crypt rd.luks.uuid=$ID_FS_UUID rd.luks.key=/etc/key" || return 1 + client_run "encrypted root with rd.luks.name" "root=/dev/mapper/crypt rd.luks.name=$ID_FS_UUID=crypt rd.luks.key=/etc/key" || return 1 return 0 } @@ -55,8 +65,6 @@ test_setup() { -m "test-root systemd-ldconfig" \ -i "${PKGLIBDIR}/modules.d/80test-root/test-init.sh" "/sbin/test-init.sh" \ -i ./test-init.sh /sbin/test-init \ - -I "findmnt" \ - -i ./fstab /etc/fstab \ -f "$TESTDIR"/initramfs.root "$KVERSION" || return 1 mkdir -p "$TESTDIR"/overlay/source && cp -a "$TESTDIR"/dracut.*/initramfs/* "$TESTDIR"/overlay/source && rm -rf "$TESTDIR"/dracut.* && export initdir=$TESTDIR/overlay/source @@ -117,8 +125,8 @@ EOF # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot bash btrfs" \ - -I "mkfs.btrfs" \ + -a "test-makeroot btrfs" \ + -I "mkfs.btrfs cryptsetup" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 rm -rf -- "$TESTDIR"/overlay/* @@ -129,26 +137,22 @@ EOF declare -i disk_index=0 qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker 1 qemu_add_drive disk_index disk_args "$TESTDIR"/root.btrfs root 160 + qemu_add_drive disk_index disk_args "$TESTDIR"/root_crypt.btrfs root_crypt 160 qemu_add_drive disk_index disk_args "$TESTDIR"/usr.btrfs usr 160 # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 + test_marker_check dracut-root-block-created || return 1 - if ! test_marker_check dracut-root-block-created; then - echo "Could not create root filesystem" - return 1 - fi - - [ -e /etc/machine-id ] && EXTRA_MACHINE="/etc/machine-id" - [ -e /etc/machine-info ] && EXTRA_MACHINE+=" /etc/machine-info" + grep -F -a -m 1 ID_FS_UUID "$TESTDIR"/marker.img > "$TESTDIR"/luks.uuid + echo -n test > /tmp/key test_dracut \ - -a "systemd i18n qemu" \ - -d "btrfs" \ - ${EXTRA_MACHINE:+-I "$EXTRA_MACHINE"} \ + -m "btrfs dracut-systemd i18n systemd-ac-power systemd-coredump systemd-creds systemd-cryptsetup systemd-integritysetup systemd-ldconfig systemd-pcrphase systemd-pstore systemd-repart systemd-sysext systemd-veritysetup" \ + -i "/tmp/key" "/etc/key" \ "$TESTDIR"/initramfs.testing rm -rf -- "$TESTDIR"/overlay diff --git a/test/TEST-10-RAID/test.sh b/test/TEST-10-RAID/test.sh index 0a2d094..17d2c68 100755 --- a/test/TEST-10-RAID/test.sh +++ b/test/TEST-10-RAID/test.sh @@ -16,7 +16,7 @@ test_run() { test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rd.auto rw" \ + -append "$TEST_KERNEL_CMDLINE root=/dev/dracut/root rd.auto rw" \ -initrd "$TESTDIR"/initramfs.testing || return 1 test_marker_check || return 1 @@ -33,8 +33,8 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot bash crypt lvm mdraid kernel-modules" \ - -I "grep" \ + -a "test-makeroot bash crypt lvm mdraid kernel-modules" \ + -I "grep cryptsetup" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 rm -rf -- "$TESTDIR"/overlay @@ -43,13 +43,13 @@ test_setup() { declare -a disk_args=() declare -i disk_index=0 qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker 1 - qemu_add_drive disk_index disk_args "$TESTDIR"/raid-1.img raid1 40 - qemu_add_drive disk_index disk_args "$TESTDIR"/raid-2.img raid2 40 - qemu_add_drive disk_index disk_args "$TESTDIR"/raid-3.img raid3 40 + qemu_add_drive disk_index disk_args "$TESTDIR"/raid-1.img raid1 80 + qemu_add_drive disk_index disk_args "$TESTDIR"/raid-2.img raid2 80 + qemu_add_drive disk_index disk_args "$TESTDIR"/raid-3.img raid3 80 "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/cannotreach rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/cannotreach rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 eval "$(grep -F -a -m 1 ID_FS_UUID "$TESTDIR"/marker.img)" diff --git a/test/TEST-11-LVM/test.sh b/test/TEST-11-LVM/test.sh index fb76ab9..dcbf96b 100755 --- a/test/TEST-11-LVM/test.sh +++ b/test/TEST-11-LVM/test.sh @@ -17,7 +17,7 @@ test_run() { test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rd.auto=1 rd.retry=3" \ + -append "$TEST_KERNEL_CMDLINE root=/dev/dracut/root rw rd.auto=1 rd.retry=3" \ -initrd "$TESTDIR"/initramfs.testing || return 1 test_marker_check || return 1 @@ -35,7 +35,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot bash lvm mdraid kernel-modules" \ + -a "test-makeroot bash lvm mdraid kernel-modules" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 rm -rf -- "$TESTDIR"/overlay @@ -51,7 +51,7 @@ test_setup() { "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 diff --git a/test/TEST-12-RAID-DEG/test.sh b/test/TEST-12-RAID-DEG/test.sh index 5c1b94e..be6cb73 100755 --- a/test/TEST-12-RAID-DEG/test.sh +++ b/test/TEST-12-RAID-DEG/test.sh @@ -21,7 +21,7 @@ client_run() { test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "$* systemd.log_target=kmsg root=LABEL=root rw log_buf_len=2M" \ + -append "$TEST_KERNEL_CMDLINE $* systemd.log_target=kmsg root=LABEL=root rw log_buf_len=2M systemd.mask=systemd-vconsole-setup" \ -initrd "$TESTDIR"/initramfs.testing if ! test_marker_check; then @@ -55,7 +55,7 @@ test_run() { } test_setup() { - "$basedir"/dracut.sh -N -l --keep --tmpdir "$TESTDIR" \ + "$DRACUT" -N -l --keep --tmpdir "$TESTDIR" \ -m "test-root" \ -f "$TESTDIR"/initramfs.root "$KVERSION" || return 1 mkdir -p "$TESTDIR"/overlay/source && mv "$TESTDIR"/dracut.*/initramfs/* "$TESTDIR"/overlay/source && rm -rf "$TESTDIR"/dracut.* @@ -65,8 +65,8 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot bash crypt lvm mdraid kernel-modules" \ - -I "grep" \ + -a "test-makeroot bash crypt lvm mdraid kernel-modules" \ + -I "grep cryptsetup" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 rm -rf -- "$TESTDIR"/overlay @@ -75,13 +75,13 @@ test_setup() { declare -a disk_args=() declare -i disk_index=0 qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker 1 - qemu_add_drive disk_index disk_args "$TESTDIR"/raid-1.img raid1 40 - qemu_add_drive disk_index disk_args "$TESTDIR"/raid-2.img raid2 40 - qemu_add_drive disk_index disk_args "$TESTDIR"/raid-3.img raid3 40 + qemu_add_drive disk_index disk_args "$TESTDIR"/raid-1.img raid1 80 + qemu_add_drive disk_index disk_args "$TESTDIR"/raid-2.img raid2 80 + qemu_add_drive disk_index disk_args "$TESTDIR"/raid-3.img raid3 80 "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 @@ -97,7 +97,8 @@ test_setup() { chmod 0600 /tmp/key test_dracut \ - -m "crypt lvm mdraid" \ + -a "crypt lvm mdraid" \ + -o "systemd" \ -i "./cryptroot-ask.sh" "/sbin/cryptroot-ask" \ -i "/tmp/mdadm.conf" "/etc/mdadm.conf" \ -i "/tmp/crypttab" "/etc/crypttab" \ diff --git a/test/TEST-13-ENC-RAID-LVM/test.sh b/test/TEST-13-ENC-RAID-LVM/test.sh index 5129bcc..b3e5291 100755 --- a/test/TEST-13-ENC-RAID-LVM/test.sh +++ b/test/TEST-13-ENC-RAID-LVM/test.sh @@ -22,7 +22,7 @@ test_run() { test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rd.auto rd.retry=20 rootwait $LUKSARGS" \ + -append "$TEST_KERNEL_CMDLINE root=/dev/dracut/root ro rd.auto rd.retry=20 rootwait $LUKSARGS" \ -initrd "$TESTDIR"/initramfs.testing test_marker_check || return 1 echo "CLIENT TEST END: [OK]" @@ -32,7 +32,7 @@ test_run() { echo "CLIENT TEST START: Any LUKS" "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rd.auto rd.retry=20" \ + -append "$TEST_KERNEL_CMDLINE root=/dev/dracut/root rw rd.auto rd.retry=20" \ -initrd "$TESTDIR"/initramfs.testing test_marker_check || return 1 echo "CLIENT TEST END: [OK]" @@ -42,7 +42,7 @@ test_run() { echo "CLIENT TEST START: Wrong LUKS UUID" "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rd.auto rd.luks.uuid=failme" \ + -append "$TEST_KERNEL_CMDLINE root=/dev/dracut/root rw rd.auto rd.luks.uuid=failme" \ -initrd "$TESTDIR"/initramfs.testing test_marker_check && return 1 echo "CLIENT TEST END: [OK]" @@ -63,8 +63,8 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot bash crypt lvm mdraid kernel-modules" \ - -I "grep" \ + -a "test-makeroot bash crypt lvm mdraid kernel-modules" \ + -I "grep cryptsetup" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 rm -rf -- "$TESTDIR"/overlay @@ -79,7 +79,7 @@ test_setup() { "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 cryptoUUIDS=$(grep -F --binary-files=text -m 3 ID_FS_UUID "$TESTDIR"/marker.img) diff --git a/test/TEST-14-IMSM/test.sh b/test/TEST-14-IMSM/test.sh index fc3e429..3d43154 100755 --- a/test/TEST-14-IMSM/test.sh +++ b/test/TEST-14-IMSM/test.sh @@ -18,7 +18,7 @@ client_run() { test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "$* root=LABEL=root rw rd.retry=5" \ + -append "$TEST_KERNEL_CMDLINE $* root=LABEL=root rw rd.retry=5" \ -initrd "$TESTDIR"/initramfs.testing || return 1 if ! test_marker_check; then @@ -60,7 +60,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot bash lvm mdraid dmraid kernel-modules" \ + -a "test-makeroot bash lvm mdraid dmraid kernel-modules" \ -d "piix ide-gd_mod ata_piix ext4 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \ -I "grep sfdisk realpath" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ @@ -77,7 +77,7 @@ test_setup() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 eval "$(grep -F --binary-files=text -m 1 MD_UUID "$TESTDIR"/marker.img)" diff --git a/test/TEST-15-BTRFSRAID/test.sh b/test/TEST-15-BTRFSRAID/test.sh index 2745950..2d8c9d9 100755 --- a/test/TEST-15-BTRFSRAID/test.sh +++ b/test/TEST-15-BTRFSRAID/test.sh @@ -16,7 +16,7 @@ test_run() { test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=LABEL=root rw rd.retry=3" \ + -append "$TEST_KERNEL_CMDLINE root=LABEL=root rw rd.retry=3" \ -initrd "$TESTDIR"/initramfs.testing test_marker_check || return 1 } @@ -38,7 +38,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot bash btrfs rootfs-block kernel-modules" \ + -a "test-makeroot bash btrfs rootfs-block kernel-modules" \ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \ -I "mkfs.btrfs" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ @@ -58,7 +58,7 @@ test_setup() { "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 diff --git a/test/TEST-16-DMSQUASH/create-root.sh b/test/TEST-16-DMSQUASH/create-root.sh index b424a1a..042d974 100755 --- a/test/TEST-16-DMSQUASH/create-root.sh +++ b/test/TEST-16-DMSQUASH/create-root.sh @@ -27,6 +27,18 @@ cp -a -t /root /source/* echo "Creating squashfs" mksquashfs /source /root/testdir/rootfs.img -quiet +# Write the erofs compressed filesystem to the partition +if [ -e "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_erofs" ]; then + sfdisk /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_erofs << EOF +2048,161792 +EOF + + udevadm settle + + echo "Creating erofs" + mkfs.erofs /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_erofs-part1 /source +fi + # Copy rootfs.img to the NTFS drive if exists if [ -e "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_ntfs" ]; then mkfs.ntfs -q -F -L dracut_ntfs /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_ntfs diff --git a/test/TEST-16-DMSQUASH/test.sh b/test/TEST-16-DMSQUASH/test.sh index 6087ccd..4245c20 100755 --- a/test/TEST-16-DMSQUASH/test.sh +++ b/test/TEST-16-DMSQUASH/test.sh @@ -12,6 +12,11 @@ test_run() { qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker qemu_add_drive disk_index disk_args "$TESTDIR"/root.img root + # erofs drive + if modprobe erofs &> /dev/null && command -v mkfs.erofs &> /dev/null; then + qemu_add_drive disk_index disk_args "$TESTDIR"/root_erofs.img root_erofs + fi + # NTFS drive if modprobe --dry-run ntfs3 &> /dev/null && command -v mkfs.ntfs &> /dev/null; then qemu_add_drive disk_index disk_args "$TESTDIR"/root_ntfs.img root_ntfs @@ -21,16 +26,28 @@ test_run() { "$testdir"/run-qemu \ "${disk_args[@]}" \ -boot order=d \ - -append "rd.live.overlay.overlayfs=1 root=live:/dev/disk/by-label/dracut" \ + -append "$TEST_KERNEL_CMDLINE rd.live.overlay.overlayfs=1 root=live:/dev/disk/by-label/dracut" \ -initrd "$TESTDIR"/initramfs.testing test_marker_check || return 1 + # Run the erofs test only if mkfs.ntfs is available + if modprobe erofs &> /dev/null && command -v mkfs.erofs &> /dev/null; then + test_marker_reset + "$testdir"/run-qemu \ + "${disk_args[@]}" \ + -boot order=d \ + -append "$TEST_KERNEL_CMDLINE rd.live.overlay.overlayfs=1 root=live:/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_erofs-part1" \ + -initrd "$TESTDIR"/initramfs.testing + + test_marker_check || return 1 + fi + test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ -boot order=d \ - -append "rd.live.image rd.live.overlay.overlayfs=1 root=LABEL=dracut" \ + -append "$TEST_KERNEL_CMDLINE rd.live.image rd.live.overlay.overlayfs=1 root=LABEL=dracut" \ -initrd "$TESTDIR"/initramfs.testing test_marker_check || return 1 @@ -39,7 +56,7 @@ test_run() { "$testdir"/run-qemu \ "${disk_args[@]}" \ -boot order=d \ - -append "rd.live.image rd.live.overlay.overlayfs=1 rd.live.dir=testdir root=LABEL=dracut" \ + -append "$TEST_KERNEL_CMDLINE rd.live.image rd.live.overlay.overlayfs=1 rd.live.dir=testdir root=LABEL=dracut" \ -initrd "$TESTDIR"/initramfs.testing test_marker_check || return 1 @@ -50,7 +67,7 @@ test_run() { "$testdir"/run-qemu \ "${disk_args[@]}" \ -boot order=d \ - -append "rd.live.image rd.live.overlay.overlayfs=1 rd.live.dir=testdir root=LABEL=dracut_ntfs quiet rd.info rd.shell=0" \ + -append "$TEST_KERNEL_CMDLINE rd.live.image rd.live.overlay.overlayfs=1 rd.live.dir=testdir root=LABEL=dracut_ntfs" \ -initrd "$TESTDIR"/initramfs.testing test_marker_check || return 1 @@ -63,7 +80,7 @@ test_run() { "$testdir"/run-qemu \ "${disk_args[@]}" \ -boot order=d \ - -append "init=/sbin/init-persist rd.live.image rd.live.overlay.overlayfs=1 rd.live.overlay=LABEL=persist rd.live.dir=testdir root=LABEL=dracut console=ttyS0,115200n81 quiet selinux=0 rd.info rd.shell=0 panic=1 oops=panic softlockup_panic=1 $DEBUGFAIL" \ + -append "init=/sbin/init-persist rd.live.image rd.live.overlay.overlayfs=1 rd.live.overlay=LABEL=persist rd.live.dir=testdir root=LABEL=dracut console=ttyS0,115200n81 quiet rd.info rd.shell=0 panic=1 oops=panic softlockup_panic=1 $DEBUGFAIL" \ -initrd "$TESTDIR"/initramfs.testing-autooverlay rootPartitions=$(sfdisk -d "$TESTDIR"/root.img | grep -c 'root\.img[0-9]') @@ -92,8 +109,8 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - --modules "test-makeroot" \ - --install "sfdisk mkfs.ntfs mksquashfs" \ + --add "test-makeroot" \ + --install "sfdisk mkfs.ntfs mksquashfs mkfs.erofs" \ --drivers "ntfs3" \ --include ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ --force "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 @@ -105,6 +122,11 @@ test_setup() { qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker 1 qemu_add_drive disk_index disk_args "$TESTDIR"/root.img root 160 + # erofs drive + if modprobe erofs &> /dev/null && command -v mkfs.erofs &> /dev/null; then + qemu_add_drive disk_index disk_args "$TESTDIR"/root_erofs.img root_erofs 160 + fi + # NTFS drive if modprobe --dry-run ntfs3 &> /dev/null && command -v mkfs.ntfs &> /dev/null; then dd if=/dev/zero of="$TESTDIR"/root_ntfs.img bs=1MiB count=160 @@ -114,7 +136,7 @@ test_setup() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 if ! test_marker_check dracut-root-block-created; then @@ -128,14 +150,16 @@ SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="ntfs", ENV{ID_FS_TYPE}="ntfs3" EOF test_dracut \ - --modules "dash dmsquash-live qemu" \ + --add "dash dmsquash-live qemu" \ + --omit "systemd" \ --drivers "ntfs3" \ --install "mkfs.ext4" \ --include /tmp/ntfs3.rules /lib/udev/rules.d/ntfs3.rules \ "$TESTDIR"/initramfs.testing test_dracut \ - --modules "dmsquash-live-autooverlay qemu" \ + --add "dmsquash-live-autooverlay qemu" \ + --omit "systemd" \ --install "mkfs.ext4" \ "$TESTDIR"/initramfs.testing-autooverlay diff --git a/test/TEST-17-LVM-THIN/test.sh b/test/TEST-17-LVM-THIN/test.sh index 9326433..0cc9c1f 100755 --- a/test/TEST-17-LVM-THIN/test.sh +++ b/test/TEST-17-LVM-THIN/test.sh @@ -16,7 +16,7 @@ test_run() { test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rd.auto=1 rd.driver.pre=dm_thin_pool rd.retry=3" \ + -append "$TEST_KERNEL_CMDLINE root=/dev/dracut/root rw rd.auto=1 rd.driver.pre=dm_thin_pool rd.retry=3" \ -initrd "$TESTDIR"/initramfs.testing || return 1 test_marker_check || return 1 } @@ -35,7 +35,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot bash lvm mdraid kernel-modules" \ + -a "test-makeroot bash lvm mdraid kernel-modules" \ -I "grep" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 @@ -52,7 +52,7 @@ test_setup() { "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 diff --git a/test/TEST-18-UEFI/test.sh b/test/TEST-18-UEFI/test.sh index 769a0e3..7e75590 100755 --- a/test/TEST-18-UEFI/test.sh +++ b/test/TEST-18-UEFI/test.sh @@ -44,7 +44,7 @@ test_setup() { mkdir -p "$TESTDIR"/ESP/EFI/BOOT test_dracut \ - --modules 'rootfs-block' \ + --add 'rootfs-block' \ --kernel-cmdline 'root=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root ro rd.skipfsck rootfstype=squashfs' \ --drivers 'squashfs' \ --uefi \ @@ -52,7 +52,7 @@ test_setup() { test_dracut \ --hostonly \ - --modules 'rootfs-block' \ + --add 'rootfs-block' \ --kernel-cmdline 'root=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root ro rd.skipfsck rootfstype=squashfs' \ --drivers 'squashfs' \ --uefi \ diff --git a/test/TEST-20-NFS/client-init.sh b/test/TEST-20-NFS/client-init.sh index 04fb6a7..f50d0e2 100755 --- a/test/TEST-20-NFS/client-init.sh +++ b/test/TEST-20-NFS/client-init.sh @@ -13,13 +13,13 @@ stty sane if getargbool 0 rd.shell; then [ -c /dev/watchdog ] && printf 'V' > /dev/watchdog strstr "$(setsid --help)" "control" && CTTY="-c" - setsid $CTTY sh -i + setsid ${CTTY:+"${CTTY}"} sh -i fi echo "made it to the rootfs! Powering down." while read -r dev _ fstype opts rest || [ -n "$dev" ]; do - [ "$fstype" != "nfs" -a "$fstype" != "nfs4" ] && continue + [ "$fstype" != "nfs" ] && [ "$fstype" != "nfs4" ] && continue echo "nfs-OK $dev $fstype $opts" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker status=none break done < /proc/mounts @@ -31,7 +31,7 @@ if grep -qF 'rd.live.overlay' /proc/cmdline; then fi fi -if [ "$fstype" = "nfs" -o "$fstype" = "nfs4" ]; then +if [ "$fstype" = "nfs" ] || [ "$fstype" = "nfs4" ]; then serverip=${dev%:*} path=${dev#*:} diff --git a/test/TEST-20-NFS/hosts b/test/TEST-20-NFS/hosts deleted file mode 100644 index 36be908..0000000 --- a/test/TEST-20-NFS/hosts +++ /dev/null @@ -1,5 +0,0 @@ -127.0.0.1 localhost -192.168.50.1 server -192.168.50.2 server-ip -192.168.50.3 server-proto-ip -192.168.50.101 workstation2 diff --git a/test/TEST-20-NFS/test.sh b/test/TEST-20-NFS/test.sh index 1be5a73..efbfcf3 100755 --- a/test/TEST-20-NFS/test.sh +++ b/test/TEST-20-NFS/test.sh @@ -25,7 +25,7 @@ run_server() { -net socket,listen=127.0.0.1:12320 \ -net nic,macaddr=52:54:00:12:34:56,model=e1000 \ -serial "${SERIAL:-"file:$TESTDIR/server.log"}" \ - -append "panic=1 oops=panic softlockup_panic=1 root=LABEL=dracut rootfstype=ext4 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \ + -append "panic=1 oops=panic softlockup_panic=1 root=LABEL=dracut rootfstype=ext4 rw console=ttyS0,115200n81 $SERVER_DEBUG" \ -initrd "$TESTDIR"/initramfs.server \ -pidfile "$TESTDIR"/server.pid -daemonize || return 1 chmod 644 "$TESTDIR"/server.pid || return 1 @@ -66,7 +66,7 @@ client_test() { "${disk_args[@]}" \ -net nic,macaddr="$mac",model=e1000 \ -net socket,connect=127.0.0.1:12320 \ - -append "$cmdline ro" \ + -append "$TEST_KERNEL_CMDLINE $cmdline ro" \ -initrd "$TESTDIR"/initramfs.testing # shellcheck disable=SC2181 @@ -267,7 +267,6 @@ test_setup() { instmods nfsd sunrpc ipv6 lockd af_packet inst ./server-init.sh /sbin/init inst_simple /etc/os-release - inst ./hosts /etc/hosts inst ./exports /etc/exports inst ./dhcpd.conf /etc/dhcpd.conf inst_multiple -o {,/usr}/etc/nsswitch.conf {,/usr}/etc/rpc \ @@ -366,7 +365,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -l -i "$TESTDIR"/server/overlay / \ - -m "bash rootfs-block kernel-modules qemu" \ + -a "bash rootfs-block kernel-modules qemu" \ -d "piix ide-gd_mod ata_piix ext4 sd_mod" \ --nomdadmconf \ --no-hostonly-cmdline -N \ @@ -382,7 +381,7 @@ test_setup() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 @@ -416,7 +415,7 @@ test_setup() { ) # Make server's dracut image "$DRACUT" -l -i "$TESTDIR"/overlay / \ - -m "bash rootfs-block debug kernel-modules watchdog qemu network-legacy" \ + -a "bash rootfs-block debug kernel-modules watchdog qemu ${USE_NETWORK}" \ -d "af_packet piix ide-gd_mod ata_piix ext4 sd_mod e1000 i6300esb" \ --no-hostonly-cmdline -N \ -f "$TESTDIR"/initramfs.server "$KVERSION" || return 1 diff --git a/test/TEST-30-ISCSI/client-init.sh b/test/TEST-30-ISCSI/client-init.sh index d7f1370..ab70d17 100755 --- a/test/TEST-30-ISCSI/client-init.sh +++ b/test/TEST-30-ISCSI/client-init.sh @@ -17,7 +17,7 @@ done < /proc/mounts if getargbool 0 rd.shell; then strstr "$(setsid --help)" "control" && CTTY="-c" - setsid $CTTY sh -i + setsid ${CTTY:+"${CTTY}"} sh -i fi sync diff --git a/test/TEST-30-ISCSI/hosts b/test/TEST-30-ISCSI/hosts deleted file mode 100644 index f8c18b6..0000000 --- a/test/TEST-30-ISCSI/hosts +++ /dev/null @@ -1,8 +0,0 @@ -127.0.0.1 localhost -192.168.50.1 server -192.168.50.2 server-ip -192.168.50.3 server-proto-ip -192.168.50.100 workstation1 -192.168.50.101 workstation2 -192.168.50.102 workstation3 -192.168.50.103 workstation4 diff --git a/test/TEST-30-ISCSI/test.sh b/test/TEST-30-ISCSI/test.sh index f4bf33e..ca56a9d 100755 --- a/test/TEST-30-ISCSI/test.sh +++ b/test/TEST-30-ISCSI/test.sh @@ -24,7 +24,7 @@ run_server() { -net nic,macaddr=52:54:00:12:34:56,model=e1000 \ -net nic,macaddr=52:54:00:12:34:57,model=e1000 \ -net socket,listen=127.0.0.1:12330 \ - -append "panic=1 oops=panic softlockup_panic=1 quiet root=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_serverroot rootfstype=ext4 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \ + -append "panic=1 oops=panic softlockup_panic=1 quiet root=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_serverroot rootfstype=ext4 rw console=ttyS0,115200n81 $SERVER_DEBUG" \ -initrd "$TESTDIR"/initramfs.server \ -pidfile "$TESTDIR"/server.pid -daemonize || return 1 chmod 644 "$TESTDIR"/server.pid || return 1 @@ -62,7 +62,7 @@ run_client() { -net nic,macaddr=52:54:00:12:34:01,model=e1000 \ -net socket,connect=127.0.0.1:12330 \ -acpitable file=ibft.table \ - -append "$*" \ + -append "$TEST_KERNEL_CMDLINE $*" \ -initrd "$TESTDIR"/initramfs.testing # shellcheck disable=SC2181 @@ -149,7 +149,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot crypt lvm mdraid" \ + -a "test-makeroot crypt lvm mdraid" \ -I "setsid blockdev" \ -i ./create-client-root.sh /lib/dracut/hooks/initqueue/01-create-client-root.sh \ --no-hostonly-cmdline -N \ @@ -166,20 +166,19 @@ test_setup() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 rm -- "$TESTDIR"/marker.img # Create what will eventually be the server root filesystem onto an overlay "$DRACUT" -N -l --keep --tmpdir "$TESTDIR" \ - -m "test-root network-legacy" \ + -m "test-root ${USE_NETWORK}" \ -d "iscsi_tcp crc32c ipv6" \ -i "${PKGLIBDIR}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh" \ -i "${PKGLIBDIR}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh" \ -I "modprobe chmod ip tcpdump setsid pidof tgtd tgtadm /etc/passwd" \ --install-optional "/etc/netconfig dhcpd /etc/group /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/services /usr/etc/nsswitch.conf /usr/etc/rpc /usr/etc/protocols /usr/etc/services" \ - -i "./hosts" "/etc/hosts" \ -i "./dhcpd.conf" "/etc/dhcpd.conf" \ -f "$TESTDIR"/initramfs.root "$KVERSION" || return 1 mkdir -p "$TESTDIR"/overlay/source && mv "$TESTDIR"/dracut.*/initramfs/* "$TESTDIR"/overlay/source && rm -rf "$TESTDIR"/dracut.* @@ -192,7 +191,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot" \ + -a "test-makeroot" \ -i ./create-server-root.sh /lib/dracut/hooks/initqueue/01-create-server-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 rm -rf -- "$TESTDIR"/overlay @@ -206,14 +205,14 @@ test_setup() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 rm -- "$TESTDIR"/marker.img # Make server's dracut image "$DRACUT" -l \ - -a "dash rootfs-block test kernel-modules network-legacy" \ + -a "dash rootfs-block test kernel-modules ${USE_NETWORK}" \ -d "piix ide-gd_mod ata_piix ext4 sd_mod e1000 drbg virtio_pci virtio_scsi" \ -i "./server.link" "/etc/systemd/network/01-server.link" \ -i ./wait-if-server.sh /lib/dracut/hooks/pre-mount/99-wait-if-server.sh \ diff --git a/test/TEST-35-ISCSI-MULTI/client-init.sh b/test/TEST-35-ISCSI-MULTI/client-init.sh index d7f1370..ab70d17 100755 --- a/test/TEST-35-ISCSI-MULTI/client-init.sh +++ b/test/TEST-35-ISCSI-MULTI/client-init.sh @@ -17,7 +17,7 @@ done < /proc/mounts if getargbool 0 rd.shell; then strstr "$(setsid --help)" "control" && CTTY="-c" - setsid $CTTY sh -i + setsid ${CTTY:+"${CTTY}"} sh -i fi sync diff --git a/test/TEST-35-ISCSI-MULTI/hosts b/test/TEST-35-ISCSI-MULTI/hosts deleted file mode 100644 index f8c18b6..0000000 --- a/test/TEST-35-ISCSI-MULTI/hosts +++ /dev/null @@ -1,8 +0,0 @@ -127.0.0.1 localhost -192.168.50.1 server -192.168.50.2 server-ip -192.168.50.3 server-proto-ip -192.168.50.100 workstation1 -192.168.50.101 workstation2 -192.168.50.102 workstation3 -192.168.50.103 workstation4 diff --git a/test/TEST-35-ISCSI-MULTI/test.sh b/test/TEST-35-ISCSI-MULTI/test.sh index f807798..20fc7b0 100755 --- a/test/TEST-35-ISCSI-MULTI/test.sh +++ b/test/TEST-35-ISCSI-MULTI/test.sh @@ -24,7 +24,7 @@ run_server() { -net nic,macaddr=52:54:00:12:34:56,model=e1000 \ -net nic,macaddr=52:54:00:12:34:57,model=e1000 \ -net socket,listen=127.0.0.1:12331 \ - -append "panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot root=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_serverroot rootfstype=ext4 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \ + -append "panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot root=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_serverroot rootfstype=ext4 rw console=ttyS0,115200n81 $SERVER_DEBUG" \ -initrd "$TESTDIR"/initramfs.server \ -pidfile "$TESTDIR"/server.pid -daemonize || return 1 chmod 644 "$TESTDIR"/server.pid || return 1 @@ -60,7 +60,7 @@ run_client() { -net nic,macaddr=52:54:00:12:34:00,model=e1000 \ -net nic,macaddr=52:54:00:12:34:01,model=e1000 \ -net socket,connect=127.0.0.1:12331 \ - -append "rw rd.auto rd.retry=50 $*" \ + -append "$TEST_KERNEL_CMDLINE rw rd.auto rd.retry=50 $*" \ -initrd "$TESTDIR"/initramfs.testing if ! test_marker_check iscsi-OK; then echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" @@ -163,7 +163,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot crypt lvm mdraid" \ + -a "test-makeroot crypt lvm mdraid" \ -I "setsid blockdev" \ -i ./create-client-root.sh /lib/dracut/hooks/initqueue/01-create-client-root.sh \ --no-hostonly-cmdline -N \ @@ -173,28 +173,27 @@ test_setup() { declare -a disk_args=() declare -i disk_index=0 qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker 1 - qemu_add_drive disk_index disk_args "$TESTDIR"/singleroot.img singleroot 400 - qemu_add_drive disk_index disk_args "$TESTDIR"/raid0-1.img raid0-1 200 - qemu_add_drive disk_index disk_args "$TESTDIR"/raid0-2.img raid0-2 200 + qemu_add_drive disk_index disk_args "$TESTDIR"/singleroot.img singleroot 800 + qemu_add_drive disk_index disk_args "$TESTDIR"/raid0-1.img raid0-1 400 + qemu_add_drive disk_index disk_args "$TESTDIR"/raid0-2.img raid0-2 400 # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 rm -- "$TESTDIR"/marker.img rm -rf -- "$TESTDIR"/overlay "$DRACUT" -N -l --keep --tmpdir "$TESTDIR" \ - -m "test-root network-legacy iscsi" \ + -m "test-root ${USE_NETWORK} iscsi" \ -d "iscsi_tcp crc32c ipv6 af_packet" \ -I "ip grep sleep setsid chmod modprobe pidof tgtd tgtadm" \ -i "${basedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh" \ -i "${basedir}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh" \ --install-optional "/etc/netconfig dhcpd /etc/group /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/services /usr/etc/nsswitch.conf /usr/etc/rpc /usr/etc/protocols /usr/etc/services" \ -i /tmp/config /etc/nbd-server/config \ - -i "./hosts" "/etc/hosts" \ -i "./dhcpd.conf" "/etc/dhcpd.conf" \ -f "$TESTDIR"/initramfs.root "$KVERSION" || return 1 mkdir -p "$TESTDIR"/overlay/source && mv "$TESTDIR"/dracut.*/initramfs/* "$TESTDIR"/overlay/source && rm -rf "$TESTDIR"/dracut.* @@ -207,7 +206,7 @@ test_setup() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot" \ + -a "test-makeroot" \ -i ./create-server-root.sh /lib/dracut/hooks/initqueue/01-create-server-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 rm -rf -- "$TESTDIR"/overlay @@ -215,12 +214,12 @@ test_setup() { declare -a disk_args=() declare -i disk_index=0 qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker 1 - qemu_add_drive disk_index disk_args "$TESTDIR"/server.img root 120 + qemu_add_drive disk_index disk_args "$TESTDIR"/server.img root 240 # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 rm -- "$TESTDIR"/marker.img @@ -233,7 +232,7 @@ test_setup() { # Make server's dracut image "$DRACUT" -l -i "$TESTDIR"/overlay / \ - -a "test dash rootfs-block debug kernel-modules network-legacy" \ + -a "test dash rootfs-block debug kernel-modules ${USE_NETWORK}" \ -d "af_packet piix ide-gd_mod ata_piix ext4 sd_mod e1000 drbg" \ -i "./server.link" "/etc/systemd/network/01-server.link" \ -i "./wait-if-server.sh" "/lib/dracut/hooks/pre-mount/99-wait-if-server.sh" \ diff --git a/test/TEST-40-NBD/client-init.sh b/test/TEST-40-NBD/client-init.sh index 9de7436..b8637f0 100755 --- a/test/TEST-40-NBD/client-init.sh +++ b/test/TEST-40-NBD/client-init.sh @@ -20,7 +20,7 @@ echo "made it to the rootfs! Powering down." if getargbool 0 rd.shell; then strstr "$(setsid --help)" "control" && CTTY="-c" - setsid $CTTY sh -i + setsid ${CTTY:+"${CTTY}"} sh -i fi mount -n -o remount,ro / diff --git a/test/TEST-40-NBD/hosts b/test/TEST-40-NBD/hosts deleted file mode 100644 index f8c18b6..0000000 --- a/test/TEST-40-NBD/hosts +++ /dev/null @@ -1,8 +0,0 @@ -127.0.0.1 localhost -192.168.50.1 server -192.168.50.2 server-ip -192.168.50.3 server-proto-ip -192.168.50.100 workstation1 -192.168.50.101 workstation2 -192.168.50.102 workstation3 -192.168.50.103 workstation4 diff --git a/test/TEST-40-NBD/test.sh b/test/TEST-40-NBD/test.sh index e935f53..a8efabe 100755 --- a/test/TEST-40-NBD/test.sh +++ b/test/TEST-40-NBD/test.sh @@ -37,7 +37,7 @@ run_server() { -serial "${SERIAL:-"file:$TESTDIR/server.log"}" \ -net nic,macaddr=52:54:00:12:34:56,model=e1000 \ -net socket,listen=127.0.0.1:12340 \ - -append "panic=1 oops=panic softlockup_panic=1 rd.luks=0 systemd.crash_reboot quiet root=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_serverroot rootfstype=ext4 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \ + -append "panic=1 oops=panic softlockup_panic=1 rd.luks=0 systemd.crash_reboot quiet root=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_serverroot rootfstype=ext4 rw console=ttyS0,115200n81 $SERVER_DEBUG" \ -initrd "$TESTDIR"/initramfs.server \ -pidfile "$TESTDIR"/server.pid -daemonize || return 1 chmod 644 "$TESTDIR"/server.pid || return 1 @@ -80,11 +80,11 @@ client_test() { "${disk_args[@]}" \ -net nic,macaddr="$mac",model=e1000 \ -net socket,connect=127.0.0.1:12340 \ - -append "$cmdline rd.auto ro" \ + -append "$cmdline rd.auto ro console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.testing # shellcheck disable=SC2181 - if [[ $? -ne 0 ]] || ! test_marker_check nbd-OK "$TESTDIR"/marker.img; then + if [[ $? -ne 0 ]] || ! test_marker_check nbd-OK; then echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" return 1 fi @@ -120,7 +120,9 @@ test_run() { return 1 fi client_run + local res="$?" kill_server + return "$res" } client_run() { @@ -145,23 +147,22 @@ client_run() { client_test "NBD root=/dev/root netroot=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \ "root=/dev/root netroot=dhcp ip=dhcp rd.luks=0" || return 1 - client_test "NBD root=/dev/root netroot=dhcp DHCP root-path nbd:srv:port:fstype" \ - 52:54:00:12:34:02 "root=/dev/root netroot=dhcp ip=dhcp rd.luks=0" ext2 || return 1 + # BROKEN + #client_test "NBD root=/dev/root netroot=dhcp DHCP root-path nbd:srv:port:fstype" \ + # 52:54:00:12:34:02 "root=/dev/root netroot=dhcp ip=dhcp rd.luks=0" ext2 || return 1 client_test "NBD root=/dev/root netroot=dhcp DHCP root-path nbd:srv:port::fsopts" \ 52:54:00:12:34:03 "root=/dev/root netroot=dhcp ip=dhcp rd.luks=0" ext4 errors=panic || return 1 - client_test "NBD root=/dev/root netroot=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \ - 52:54:00:12:34:04 "root=/dev/root netroot=dhcp ip=dhcp rd.luks=0" ext2 errors=panic || return 1 + # BROKEN + #client_test "NBD root=/dev/root netroot=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \ + # 52:54:00:12:34:04 "root=/dev/root netroot=dhcp ip=dhcp rd.luks=0" ext2 errors=panic || return 1 # netroot handling client_test "NBD netroot=nbd:IP:port" 52:54:00:12:34:00 \ "root=LABEL=dracut netroot=nbd:192.168.50.1:raw ip=dhcp rd.luks=0" || return 1 - client_test "NBD root=/dev/root netroot=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \ - 52:54:00:12:34:04 "root=/dev/root netroot=dhcp ip=dhcp rd.luks=0" ext2 errors=panic || return 1 - # Encrypted root handling via LVM/LUKS over NBD # shellcheck source=$TESTDIR/luks.uuid @@ -203,7 +204,8 @@ make_encrypted_root() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot crypt lvm mdraid" \ + -a "test-makeroot crypt lvm mdraid" \ + -I "cryptsetup" \ -i ./create-encrypted-root.sh /lib/dracut/hooks/initqueue/01-create-encrypted-root.sh \ --no-hostonly-cmdline -N \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 @@ -217,7 +219,7 @@ make_encrypted_root() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 grep -F -a -m 1 ID_FS_UUID "$TESTDIR"/marker.img > "$TESTDIR"/luks.uuid @@ -240,7 +242,7 @@ make_client_root() { # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot" \ + -a "test-makeroot" \ -i ./create-client-root.sh /lib/dracut/hooks/initqueue/01-create-client-root.sh \ --nomdadmconf \ --no-hostonly-cmdline -N \ @@ -254,7 +256,7 @@ make_client_root() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 rm -fr "$TESTDIR"/overlay @@ -276,14 +278,12 @@ bs = 4096 EOF "$DRACUT" -l --keep --tmpdir "$TESTDIR" \ - -m "test-root network-legacy" \ - -d "nfsd sunrpc ipv6 lockd af_packet 8021q ipvlan macvlan" \ + -a "test-root ${USE_NETWORK}" \ -I "ip grep sleep nbd-server chmod modprobe vi pidof" \ -i "${basedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh" \ -i "${basedir}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh" \ --install-optional "/etc/netconfig dhcpd /etc/group /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/services /usr/etc/nsswitch.conf /usr/etc/rpc /usr/etc/protocols /usr/etc/services" \ -i /tmp/config /etc/nbd-server/config \ - -i "./hosts" "/etc/hosts" \ -i "./dhcpd.conf" "/etc/dhcpd.conf" \ --no-hostonly --no-hostonly-cmdline --nohardlink \ -f "$TESTDIR"/initramfs.root "$KVERSION" || return 1 @@ -297,7 +297,7 @@ EOF # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -m "test-makeroot" \ + -a "test-makeroot ${USE_NETWORK}" \ -i ./create-server-root.sh /lib/dracut/hooks/initqueue/01-create-server-root.sh \ --nomdadmconf \ --no-hostonly-cmdline -N \ @@ -306,12 +306,12 @@ EOF declare -a disk_args=() declare -i disk_index=0 qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker 1 - qemu_add_drive disk_index disk_args "$TESTDIR"/server.img root 240 + qemu_add_drive disk_index disk_args "$TESTDIR"/server.img root 480 # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 rm -fr "$TESTDIR"/overlay @@ -340,7 +340,7 @@ test_setup() { "$TESTDIR"/initramfs.testing "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ - -a "test rootfs-block debug kernel-modules network-legacy" \ + -a "test rootfs-block debug kernel-modules ${USE_NETWORK}" \ -d "af_packet piix ide-gd_mod ata_piix ext4 sd_mod e1000 drbg" \ -i "./server.link" "/etc/systemd/network/01-server.link" \ -i "./wait-if-server.sh" "/lib/dracut/hooks/pre-mount/99-wait-if-server.sh" \ diff --git a/test/TEST-50-MULTINIC/client-init.sh b/test/TEST-50-MULTINIC/client-init.sh index 8495913..09db5b3 100755 --- a/test/TEST-50-MULTINIC/client-init.sh +++ b/test/TEST-50-MULTINIC/client-init.sh @@ -23,7 +23,7 @@ for i in /sys/class/net/*; do done for i in /run/initramfs/net.*.did-setup; do - # booting with network-legacy module + # booting with network module [ -f "$i" ] || continue strglobin "$i" ":*:*:*:*:" && continue i=${i%.did-setup} diff --git a/test/TEST-50-MULTINIC/hosts b/test/TEST-50-MULTINIC/hosts deleted file mode 100644 index d02a4e9..0000000 --- a/test/TEST-50-MULTINIC/hosts +++ /dev/null @@ -1,5 +0,0 @@ -127.0.0.1 localhost -192.168.50.1 server -192.168.50.100 client-if1 -192.168.50.101 client-if2 -192.168.50.102 client-if3 diff --git a/test/TEST-50-MULTINIC/test.sh b/test/TEST-50-MULTINIC/test.sh index e2aa5a3..71a6271 100755 --- a/test/TEST-50-MULTINIC/test.sh +++ b/test/TEST-50-MULTINIC/test.sh @@ -26,7 +26,7 @@ run_server() { -net socket,listen=127.0.0.1:12350 \ -net nic,macaddr=52:54:01:12:34:56,model=e1000 \ -serial "${SERIAL:-"file:$TESTDIR/server.log"}" \ - -append "panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot root=LABEL=dracut rootfstype=ext4 rw console=ttyS0,115200n81 selinux=0" \ + -append "panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot root=LABEL=dracut rootfstype=ext4 rw console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.server \ -pidfile "$TESTDIR"/server.pid -daemonize || return 1 @@ -76,7 +76,7 @@ client_test() { -netdev hubport,id=n2,hubid=2 \ -device e1000,netdev=n1,mac=52:54:00:12:34:98 \ -device e1000,netdev=n2,mac=52:54:00:12:34:99 \ - -append "$cmdline rd.retry=5 ro init=/sbin/init systemd.log_target=console" \ + -append "$TEST_KERNEL_CMDLINE $cmdline rd.retry=5 ro init=/sbin/init systemd.log_target=console" \ -initrd "$TESTDIR"/initramfs.testing || return 1 { @@ -208,7 +208,6 @@ test_setup() { instmods nfsd sunrpc ipv6 lockd af_packet inst ./server-init.sh /sbin/init inst_simple /etc/os-release - inst ./hosts /etc/hosts inst ./exports /etc/exports inst ./dhcpd.conf /etc/dhcpd.conf inst_multiple -o {,/usr}/etc/nsswitch.conf {,/usr}/etc/rpc \ @@ -319,7 +318,7 @@ test_setup() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 @@ -355,7 +354,7 @@ test_setup() { ) # Make server's dracut image "$DRACUT" -l -i "$TESTDIR"/overlay / \ - -m "bash rootfs-block debug kernel-modules watchdog qemu network-legacy" \ + -m "bash rootfs-block debug kernel-modules watchdog qemu ${USE_NETWORK}" \ -d "af_packet piix ide-gd_mod ata_piix ext4 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb" \ --no-hostonly-cmdline -N \ -f "$TESTDIR"/initramfs.server "$KVERSION" || return 1 diff --git a/test/TEST-60-BONDBRIDGEVLAN/hosts b/test/TEST-60-BONDBRIDGEVLAN/hosts deleted file mode 100644 index d02a4e9..0000000 --- a/test/TEST-60-BONDBRIDGEVLAN/hosts +++ /dev/null @@ -1,5 +0,0 @@ -127.0.0.1 localhost -192.168.50.1 server -192.168.50.100 client-if1 -192.168.50.101 client-if2 -192.168.50.102 client-if3 diff --git a/test/TEST-60-BONDBRIDGEVLAN/test.sh b/test/TEST-60-BONDBRIDGEVLAN/test.sh index be4cb6d..2ac6d63 100755 --- a/test/TEST-60-BONDBRIDGEVLAN/test.sh +++ b/test/TEST-60-BONDBRIDGEVLAN/test.sh @@ -49,7 +49,7 @@ run_server() { -device virtio-net-pci,netdev=n3,mac=52:54:01:12:34:59 \ -hda "$TESTDIR"/server.ext4 \ -serial "${SERIAL:-"file:$TESTDIR/server.log"}" \ - -append "panic=1 oops=panic softlockup_panic=1 root=LABEL=dracut rootfstype=ext4 rw console=ttyS0,115200n81 selinux=0" \ + -append "panic=1 oops=panic softlockup_panic=1 root=LABEL=dracut rootfstype=ext4 rw console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.server \ -pidfile "$TESTDIR"/server.pid -daemonize || return 1 chmod 644 -- "$TESTDIR"/server.pid || return 1 @@ -92,6 +92,7 @@ client_test() { -netdev hubport,id=n5,hubid=1 -device virtio-net-pci,mac=52:54:00:12:34:05,netdev=n5 \ -hda "$TESTDIR"/client.img \ -append " + $TEST_KERNEL_CMDLINE ifname=net1:52:54:00:12:34:01 ifname=net2:52:54:00:12:34:02 ifname=net3:52:54:00:12:34:03 @@ -246,7 +247,6 @@ test_setup() { instmods nfsd sunrpc ipv6 lockd af_packet 8021q bonding inst_simple /etc/os-release inst ./server-init.sh /sbin/init - inst ./hosts /etc/hosts inst ./exports /etc/exports inst ./dhcpd.conf /etc/dhcpd.conf inst_multiple -o {,/usr}/etc/nsswitch.conf {,/usr}/etc/rpc {,/usr}/etc/protocols @@ -348,7 +348,7 @@ test_setup() { # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 rm -- "$TESTDIR"/marker.img diff --git a/test/TEST-98-GETARG/test.sh b/test/TEST-98-GETARG/test.sh index 8f628a2..e7337d9 100755 --- a/test/TEST-98-GETARG/test.sh +++ b/test/TEST-98-GETARG/test.sh @@ -91,14 +91,17 @@ test_run() { . dracut-dev-lib.sh . dracut-lib.sh + # shellcheck disable=SC2317 # overwrites debug_off from dracut-lib.sh debug_off() { : } + # shellcheck disable=SC2317 # overwrites debug_on from dracut-lib.sh debug_on() { : } + # shellcheck disable=SC2317 # called later by getarg in dracut-lib.sh getcmdline() { echo "rdbreak=cmdline rd.lvm rd.auto=0 rd.auto rd.retry=10" } @@ -108,6 +111,7 @@ test_run() { getargbool 1 rd.lvm -d -n rd_NO_LVM || ret=$((ret + 1)) getargbool 0 rd.auto || ret=$((ret + 1)) + # shellcheck disable=SC2317 # called later by getarg in dracut-lib.sh getcmdline() { echo "rd.break=cmdlined rd.lvm=0 rd.auto rd.auto=1 rd.auto=0" } @@ -115,6 +119,7 @@ test_run() { getargbool 1 rd.lvm -d -n rd_NO_LVM && ret=$((ret + 1)) getargbool 0 rd.auto && ret=$((ret + 1)) + # shellcheck disable=SC2317 # called later by getarg in dracut-lib.sh getcmdline() { echo "ip=a ip=b ip=dhcp6" } @@ -126,6 +131,7 @@ test_run() { [[ ${args[$i]} == "${RESULT[$i]}" ]] || ret=$((ret + 1)) done + # shellcheck disable=SC2317 # called later by getarg in dracut-lib.sh getcmdline() { echo "bridge bridge=val" } @@ -136,6 +142,7 @@ test_run() { [[ ${args[$i]} == "${RESULT[$i]}" ]] || ret=$((ret + 1)) done + # shellcheck disable=SC2317 # called later by getarg in dracut-lib.sh getcmdline() { echo "rd.break rd.md.uuid=bf96e457:230c9ad4:1f3e59d6:745cf942 rd.md.uuid=bf96e457:230c9ad4:1f3e59d6:745cf943 rd.shell" } diff --git a/test/container/Dockerfile-Arch b/test/container/Dockerfile-Arch index 2af810a..cc2cb3f 100644 --- a/test/container/Dockerfile-Arch +++ b/test/container/Dockerfile-Arch @@ -16,6 +16,7 @@ RUN pacman --noconfirm -Syu \ dhcp \ dmraid \ elfutils \ + erofs-utils \ f2fs-tools \ git \ glibc \ diff --git a/test/container/Dockerfile-Debian b/test/container/Dockerfile-Debian index 7e7e6d4..37a83a5 100644 --- a/test/container/Dockerfile-Debian +++ b/test/container/Dockerfile-Debian @@ -21,6 +21,7 @@ RUN apt-get update -y -qq && apt-get upgrade -y -qq && apt-get install -y -qq -- docbook \ docbook-xml \ docbook-xsl \ + erofs-utils \ fdisk \ g++ \ gawk \ @@ -57,6 +58,7 @@ RUN apt-get update -y -qq && apt-get upgrade -y -qq && apt-get install -y -qq -- squashfs-tools \ strace \ systemd-boot-efi \ + systemd-coredump \ tcpdump \ tgt \ thin-provisioning-tools \ diff --git a/test/container/Dockerfile-Fedora-latest b/test/container/Dockerfile-Fedora-latest index 106af17..70ea199 100644 --- a/test/container/Dockerfile-Fedora-latest +++ b/test/container/Dockerfile-Fedora-latest @@ -19,6 +19,7 @@ RUN dnf -y install --setopt=install_weak_deps=False \ dhcp-server \ dmraid \ e2fsprogs \ + erofs-utils \ f2fs-tools \ fcoe-utils \ fuse3 \ diff --git a/test/container/Dockerfile-Gentoo b/test/container/Dockerfile-Gentoo index 7b4eb2a..a832752 100644 --- a/test/container/Dockerfile-Gentoo +++ b/test/container/Dockerfile-Gentoo @@ -9,7 +9,7 @@ RUN echo "EMERGE_DEFAULT_OPTS=\"-j$(nproc) -l$(nproc)\"" >> /etc/portage/make.co RUN echo "FEATURES=\"getbinpkg binpkg-ignore-signature parallel-fetch parallel-install pkgdir-index-trusted\"" >> /etc/portage/make.conf # systemd-boot, no need to install intramfs with kernel -RUN echo "USE=\"boot kernel-install -initramfs\"" >> /etc/portage/make.conf +RUN echo "USE=\"boot kernel-install pkcs7 pkcs11 tpm -initramfs\"" >> /etc/portage/make.conf # Use debian's installkernel RUN echo 'sys-kernel/installkernel -systemd' >> /etc/portage/package.use/kernel diff --git a/test/container/Dockerfile-OpenSuse-latest b/test/container/Dockerfile-OpenSuse-latest index a5fb7de..3ea5b10 100644 --- a/test/container/Dockerfile-OpenSuse-latest +++ b/test/container/Dockerfile-OpenSuse-latest @@ -14,8 +14,10 @@ RUN dnf -y install --setopt=install_weak_deps=False \ dhcp-server \ dmraid \ e2fsprogs \ + erofs-utils \ gcc \ git \ + hmaccalc \ iproute \ iputils \ iscsiuio \ diff --git a/test/container/Dockerfile-Ubuntu b/test/container/Dockerfile-Ubuntu index ef15a67..6a0f928 100644 --- a/test/container/Dockerfile-Ubuntu +++ b/test/container/Dockerfile-Ubuntu @@ -20,6 +20,7 @@ RUN apt-get update -y -qq && apt-get upgrade -y -qq && \ docbook \ docbook-xml \ docbook-xsl \ + erofs-utils \ fdisk \ g++ \ gawk \ @@ -56,6 +57,7 @@ RUN apt-get update -y -qq && apt-get upgrade -y -qq && \ squashfs-tools \ strace \ systemd-boot-efi \ + systemd-coredump \ systemd-ukify \ tcpdump \ tgt \ diff --git a/test/container/Dockerfile-Void b/test/container/Dockerfile-Void index 99044c3..9f75547 100644 --- a/test/container/Dockerfile-Void +++ b/test/container/Dockerfile-Void @@ -23,6 +23,7 @@ RUN xbps-install -Syu xbps && xbps-install -yu \ e2fsprogs \ edk2-ovmf \ elfutils \ + erofs-utils \ eudev \ f2fs-tools \ git \ diff --git a/test/container/Dockerfile-alpine b/test/container/Dockerfile-alpine index 4f28c95..c2db721 100644 --- a/test/container/Dockerfile-alpine +++ b/test/container/Dockerfile-alpine @@ -19,6 +19,7 @@ RUN apk add --no-cache \ dmraid \ dosfstools \ e2fsprogs \ + erofs-utils \ eudev \ findmnt \ gawk \ diff --git a/test/run-qemu b/test/run-qemu index 149a407..5c9ee5d 100755 --- a/test/run-qemu +++ b/test/run-qemu @@ -4,13 +4,6 @@ export PATH=/usr/sbin:/usr/bin:/sbin:/bin ARCH="${ARCH-$(uname -m)}" - -case "$ARCH" in - amd64 | i?86 | x86_64) - QEMU_CPU="IvyBridge-v2" - ;; -esac - QEMU_CPU="${QEMU_CPU:-max}" [[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS=(-cpu "$QEMU_CPU") @@ -43,12 +36,17 @@ case "$ARCH" in esac # Provide rng device sourcing the hosts /dev/urandom and other standard parameters -ARGS+=(-smp 2 -m 1024 -nodefaults -vga none -display none -no-reboot -device i6300esb -watchdog-action poweroff -device virtio-rng-pci) +ARGS+=(-smp 2 -m 2048 -nodefaults -vga none -display none -no-reboot -watchdog-action poweroff -device virtio-rng-pci) if ! [[ $* == *-daemonize* ]] && ! [[ $* == *-daemonize* ]]; then ARGS+=(-serial stdio) fi +# virtual hardware watchdog not available on s390x +if [[ $ARCH != "s390x" ]]; then + ARGS+=(-device i6300esb) +fi + KVERSION=${KVERSION-$(uname -r)} VMLINUZ="/lib/modules/${KVERSION}/vmlinuz" diff --git a/test/test-functions b/test/test-functions index b664fb0..2b32821 100644 --- a/test/test-functions +++ b/test/test-functions @@ -12,13 +12,18 @@ export TESTDIR KVERSION=${KVERSION-$(uname -r)} -[ -z "$USE_NETWORK" ] && USE_NETWORK="network-legacy" +[ -z "$USE_NETWORK" ] && USE_NETWORK="network" if [[ -z $basedir ]]; then basedir="$(realpath ../..)"; fi DRACUT=${DRACUT-${basedir}/dracut.sh} PKGLIBDIR=${PKGLIBDIR-$basedir} +TEST_KERNEL_CMDLINE+=" panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot console=ttyS0,115200n81 $DEBUGFAIL " +if [[ $V != "1" && $V != "2" ]]; then + TEST_KERNEL_CMDLINE+="quiet " +fi + test_dracut() { TEST_DRACUT_ARGS+=" --local --no-hostonly --no-hostonly-cmdline --no-early-microcode --add test --force --kver $KVERSION" @@ -31,7 +36,7 @@ test_dracut() { IFS=' ' read -a TEST_DRACUT_ARGS_ARRAY <<< "$TEST_DRACUT_ARGS" "$DRACUT" \ - --kernel-cmdline "panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot quiet rd.retry=10 rd.info rd.shell=0 selinux=0 console=ttyS0,115200n81 $DEBUGFAIL" \ + --kernel-cmdline "rd.retry=10 rd.info rd.shell=0" \ "${TEST_DRACUT_ARGS_ARRAY[@]}" \ "$@" || return 1 } @@ -143,20 +148,11 @@ while (($# > 0)); do else echo -e "TEST: $TEST_DESCRIPTION " "$COLOR_SUCCESS" "[STARTED]" "$COLOR_NORMAL" fi - if [[ $V == "1" ]]; then - set -o pipefail - ( - test_setup && test_run - ret=$? - test_cleanup - if ((ret != 0)) && [[ -f "$TESTDIR"/server.log ]]; then - mv "$TESTDIR"/server.log ./server${TEST_RUN_ID:+-$TEST_RUN_ID}.log - fi - rm -fr -- "$TESTDIR" - rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID} - exit $ret - ) < /dev/null 2>&1 | tee "test${TEST_RUN_ID:+-$TEST_RUN_ID}.log" - elif [[ $V == "2" ]]; then + if [[ $V == "1" || $V == "2" ]]; then + tee_command="tee" + if [[ $V == "2" && -x "$basedir/logtee" ]]; then + tee_command="$basedir/logtee" + fi set -o pipefail ( test_setup && test_run @@ -168,7 +164,7 @@ while (($# > 0)); do rm -fr -- "$TESTDIR" rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID} exit $ret - ) < /dev/null 2>&1 | "$basedir/logtee" "test${TEST_RUN_ID:+-$TEST_RUN_ID}.log" + ) < /dev/null 2>&1 | "$tee_command" "test${TEST_RUN_ID:+-$TEST_RUN_ID}.log" else ( test_setup && test_run diff --git a/tools/profile.py b/tools/profile.py index 7f98a13..51af349 100644 --- a/tools/profile.py +++ b/tools/profile.py @@ -56,4 +56,3 @@ if __name__ == '__main__': sorted_x = sorted(e.iteritems(), key=operator.itemgetter(1), reverse=True) for x in sorted_x: print x[0], x[1] - diff --git a/tools/test-github.sh b/tools/test-github.sh index 4a8d318..b512c54 100755 --- a/tools/test-github.sh +++ b/tools/test-github.sh @@ -30,7 +30,6 @@ else cd /lib/modules ls -1 | tail -1 )" \ - DRACUT_NO_XATTR=1 \ TEST_RUN_ID="$RUN_ID" \ ${TESTS:+TESTS="$TESTS"} \ -k V=1 \ |