From a5b13d97877667e19481529b7c4f0f3e52dd0579 Mon Sep 17 00:00:00 2001 From: Packit Date: Aug 19 2020 14:22:48 +0000 Subject: dracut-049 base --- diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..b38d4d6 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,7 @@ +;;; Directory Local Variables +;;; For more information see (info "(emacs) Directory Variables") + +((sh-mode + (indent-tabs-mode) + (sh-basic-offset . 4))) + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e35f43e --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +/Makefile.inc +/dracut.8 +/dracut-catimages.8 +/dracut.conf.5 +/dracut.conf.d/*.conf +/dracut-gencmdline.8 +/dracut.html +/dracut.kernel.7 +/dracut.pc +/dracut-install +/modules.d/99base/switch_root +/test/*/test.log +test*.img +/.buildpath +/.project +/dracut-version.sh +/install/dracut-install +/*.rpm +/*.[0-9] +/modules.d/98dracut-systemd/*.service.8 +/*.sign +*.o +skipcpio/skipcpio diff --git a/.kateconfig b/.kateconfig new file mode 100644 index 0000000..86b4ce5 --- /dev/null +++ b/.kateconfig @@ -0,0 +1 @@ +kate: space-indent on; tab-width 4; indent-width 4; replace-tabs on; eol unix; diff --git a/.kateproject b/.kateproject new file mode 100644 index 0000000..0a0d5da --- /dev/null +++ b/.kateproject @@ -0,0 +1,9 @@ +{ + "name": "Dracut" + , "files": [ { "git": 1 } ] + , "build": { + "directory": "./" + , "build": "make -j $(getconf _NPROCESSORS_ONLN) all" + , "clean": "make clean" + } +} diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000..a58430e --- /dev/null +++ b/.mailmap @@ -0,0 +1,33 @@ +Philippe Seewer +Seewer Philippe +Philippe Seewer +Victor Lowther +Harald Hoyer +Harald Hoyer +Harald Hoyer +Mike Snitzer +Amerigo Wang +Andrey Borzenkov +Dan Horák +John Reiser +Luca Berra +Dave Young +Dave Young +Frederick Grose +Frederic Crozat +Shawn W Dunn +Kyle McMartin +Angelo "pallotron" Failla +Yu Watanabe +Martin Wilck +Thomas Renninger +Andrey Borzenkov +Cristian Rodríguez +Daniel Drake +Fabian Vogt +Hannes Reinecke +Julian Wolf +Lidong Zhong +Nikoli +Peter Robinson +Xunlei Pang diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f913db5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,47 @@ +language: generic +sudo: required +services: +- docker +env: + matrix: + - IMAGE=latest + - IMAGE=latest TESTS=01 + - IMAGE=latest TESTS=12 + - IMAGE=latest TESTS=20 + - IMAGE=latest TESTS=50 + - IMAGE=latest TESTS=30 + - IMAGE=latest TESTS=31 + - IMAGE=latest TESTS=70 + - IMAGE=latest TESTS=99 + - IMAGE=latest TESTS=02 + - IMAGE=latest TESTS=03 + - IMAGE=latest TESTS=04 + - IMAGE=latest TESTS=10 + - IMAGE=latest TESTS=11 + - IMAGE=latest TESTS=13 + - IMAGE=latest TESTS=14 + - IMAGE=latest TESTS=15 + - IMAGE=latest TESTS=17 + +before_script: + - docker pull fedora:$IMAGE + - | + sudo modprobe kvm-intel nested=1 || : + sudo modprobe kvm-amd nested=1 || : + dmesg | tail || : + - git pull --depth=100 + - | + git describe --abbrev=0 --tags || : + git describe --tags || : + +script: +- docker run --privileged -it -v $(pwd)/:/dracut fedora:$IMAGE /dracut/fedora-test.sh $IMAGE-$$ "$TESTS" + +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/effa917ca3e0ed5fd00e + on_success: change # options: [always|never|change] default: always + on_failure: always # options: [always|never|change] default: always + on_start: never # options: [always|never|change] default: always + diff --git a/50-dracut.install b/50-dracut.install new file mode 100755 index 0000000..64e3549 --- /dev/null +++ b/50-dracut.install @@ -0,0 +1,60 @@ +#!/bin/bash + +COMMAND="$1" +KERNEL_VERSION="$2" +BOOT_DIR_ABS="$3" +KERNEL_IMAGE="$4" + +# If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory. +# So, let's skip to create initrd. +if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then + exit 0 +fi + +if [[ -d "$BOOT_DIR_ABS" ]]; then + INITRD="initrd" +else + BOOT_DIR_ABS="/boot" + INITRD="initramfs-${KERNEL_VERSION}.img" +fi + +ret=0 +case "$COMMAND" in + add) + INITRD_IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/initrd + if [[ -f ${INITRD_IMAGE_PREGENERATED} ]]; then + # we found an initrd at the same place as the kernel + # use this and don't generate a new one + cp --reflink=auto "$INITRD_IMAGE_PREGENERATED" "$BOOT_DIR_ABS/$INITRD" \ + && chown root:root "$BOOT_DIR_ABS/$INITRD" \ + && chmod 0600 "$BOOT_DIR_ABS/$INITRD" \ + && exit 0 + fi + + if [[ -f /etc/kernel/cmdline ]]; then + read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline + elif [[ -f /usr/lib/kernel/cmdline ]]; then + read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline + fi + + if ! [[ ${BOOT_OPTIONS[*]} ]]; then + read -r -d '' -a BOOT_OPTIONS < /proc/cmdline + fi + + unset noimageifnotneeded + + for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do + if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then + noimageifnotneeded="yes" + break + fi + done + dracut ${noimageifnotneeded:+--noimageifnotneeded} "$BOOT_DIR_ABS/$INITRD" "$KERNEL_VERSION" + ret=$? + ;; + remove) + rm -f -- "$BOOT_DIR_ABS/$INITRD" + ret=$? + ;; +esac +exit $ret diff --git a/51-dracut-rescue-postinst.sh b/51-dracut-rescue-postinst.sh new file mode 100755 index 0000000..67f5b71 --- /dev/null +++ b/51-dracut-rescue-postinst.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +export LANG=C + +KERNEL_VERSION="$1" +KERNEL_IMAGE="$2" + +[[ -f /etc/os-release ]] && . /etc/os-release + +if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then + systemd-machine-id-setup +fi + +[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id + +[[ $MACHINE_ID ]] || exit 1 +[[ -f $KERNEL_IMAGE ]] || exit 1 + +INITRDFILE="/boot/initramfs-0-rescue-${MACHINE_ID}.img" +NEW_KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-0-rescue-${MACHINE_ID}" + +[[ -f $INITRDFILE ]] && [[ -f $NEW_KERNEL_IMAGE ]] && exit 0 + +dropindirs_sort() +{ + suffix=$1; shift + args=("$@") + files=$( + while (( $# > 0 )); do + for i in ${1}/*${suffix}; do + [[ -f $i ]] && echo ${i##*/} + done + shift + done | sort -Vu + ) + + for f in $files; do + for d in "${args[@]}"; do + if [[ -f "$d/$f" ]]; then + echo "$d/$f" + continue 2 + fi + done + done +} + +# source our config dir +for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do + [[ -e $f ]] && . "$f" +done + +[[ $dracut_rescue_image != "yes" ]] && exit 0 + +if [[ ! -f $INITRDFILE ]]; then + dracut --no-hostonly -a "rescue" "$INITRDFILE" "$KERNEL_VERSION" + ((ret+=$?)) +fi + +if [[ ! -f $NEW_KERNEL_IMAGE ]]; then + cp --reflink=auto "$KERNEL_IMAGE" "$NEW_KERNEL_IMAGE" + ((ret+=$?)) +fi + +new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$NEW_KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$NAME $VERSION_ID Rescue $MACHINE_ID" + +((ret+=$?)) + +exit $ret diff --git a/51-dracut-rescue.install b/51-dracut-rescue.install new file mode 100755 index 0000000..6ddafdb --- /dev/null +++ b/51-dracut-rescue.install @@ -0,0 +1,131 @@ +#!/bin/bash + +export LANG=C + +COMMAND="$1" +KERNEL_VERSION="$2" +BOOT_DIR_ABS="${3%/*}/0-rescue" +KERNEL_IMAGE="$4" + + +dropindirs_sort() +{ + suffix=$1; shift + args=("$@") + files=$( + while (( $# > 0 )); do + for i in ${1}/*${suffix}; do + [[ -f $i ]] && echo ${i##*/} + done + shift + done | sort -Vu + ) + + for f in $files; do + for d in "${args[@]}"; do + if [[ -f "$d/$f" ]]; then + echo "$d/$f" + continue 2 + fi + done + done +} + +[[ -f /etc/os-release ]] && . /etc/os-release + +if [[ ${KERNEL_INSTALL_MACHINE_ID+x} ]]; then + MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID +elif [[ -f /etc/machine-id ]] ; then + read MACHINE_ID < /etc/machine-id +fi + +if ! [[ $MACHINE_ID ]]; then + exit 0 +fi + +if [[ -f /etc/kernel/cmdline ]]; then + read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline +elif [[ -f /usr/lib/kernel/cmdline ]]; then + read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline +fi + +if ! [[ "${BOOT_OPTIONS[@]}" ]]; then + read -r -d '' -a line < /proc/cmdline + for i in "${line[@]}"; do + [[ "${i#initrd=*}" != "$i" ]] && continue + BOOT_OPTIONS+=("$i") + done +fi + +if ! [[ ${BOOT_OPTIONS[*]} ]]; then + echo "Could not determine the kernel command line parameters." >&2 + echo "Please specify the kernel command line in /etc/kernel/cmdline!" >&2 + exit 1 +fi + +if [[ -d "${BOOT_DIR_ABS%/*}" ]]; then + BOOT_DIR="/${MACHINE_ID}/0-rescue" + BOOT_ROOT=${BOOT_DIR_ABS%$BOOT_DIR} + LOADER_ENTRY="$BOOT_ROOT/loader/entries/${MACHINE_ID}-0-rescue.conf" + KERNEL="linux" + INITRD="initrd" +else + BLS_DIR="/boot/loader/entries" + BOOT_DIR_ABS="/boot" + LOADER_ENTRY="$BLS_DIR/${MACHINE_ID}-0-rescue.conf" + KERNEL="vmlinuz-0-rescue-${MACHINE_ID}" + INITRD="initramfs-0-rescue-${MACHINE_ID}.img" +fi + +ret=0 + +case "$COMMAND" in + add) + [[ -f "$LOADER_ENTRY" ]] && [[ -f "$BOOT_DIR_ABS/$KERNEL" ]] \ + && [[ -f "$BOOT_DIR_ABS/$INITRD" ]] && exit 0 + + # source our config dir + for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do + [[ -e $f ]] && . "$f" + done + + [[ $dracut_rescue_image != "yes" ]] && exit 0 + + [[ -d "$BOOT_DIR_ABS" ]] || mkdir -p "$BOOT_DIR_ABS" + + if ! cp --reflink=auto "$KERNEL_IMAGE" "$BOOT_DIR_ABS/$KERNEL"; then + echo "Can't copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/$KERNEL'!" >&2 + fi + + if [[ ! -f "$BOOT_DIR_ABS/$INITRD" ]]; then + dracut --no-hostonly -a "rescue" "$BOOT_DIR_ABS/$INITRD" "$KERNEL_VERSION" + ((ret+=$?)) + fi + + if [[ "${BOOT_DIR_ABS}" != "/boot" ]]; then + { + echo "title $PRETTY_NAME - Rescue Image" + echo "version $KERNEL_VERSION" + echo "machine-id $MACHINE_ID" + echo "options ${BOOT_OPTIONS[@]} rd.auto=1" + echo "linux $BOOT_DIR/linux" + echo "initrd $BOOT_DIR/initrd" + } > $LOADER_ENTRY + else + cp -aT "${KERNEL_IMAGE%/*}/bls.conf" $LOADER_ENTRY + sed -i 's/'$KERNEL_VERSION'/0-rescue-'${MACHINE_ID}'/' $LOADER_ENTRY + fi + + ((ret+=$?)) + ;; + + remove) + exit 0 + ;; + + *) + usage + ret=1;; +esac + +exit $ret diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..c3f5351 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,228 @@ +Harald Hoyer +Victor Lowther +Amadeusz Żołnowski +Hannes Reinecke +Will Woods +Philippe Seewer +Warren Togami +Dave Young +Jeremy Katz +David Dillow +Michal Soltys +Colin Guthrie +Daniel Molkentin +Amerigo Wang +Thomas Renninger +Lukas Nykryn +Alexander Tsoy +Frederick Grose +WANG Chao +Yu Watanabe +Andrey Borzenkov +Hans de Goede +Peter Jones +Andreas Thienemann +Peter Robinson +Fabian Vogt +Kairui Song +John Reiser +Luca Berra +Xunlei Pang +Daniel Drake +Lubomir Rintel +Angelo "pallotron" Failla +Brian C. Lane +Ville Skyttä +Cristian Rodríguez +Dan Horák +Baoquan He +Brendan Germain +Colin Walters +Leho Kraav +Moritz Maxeiner +Nicolas Chauvet +Ondrej Mosnacek +Fabian Deutsch +Javier Martinez Canillas +Kamil Rytarowski +Lidong Zhong +Marc Grimme +NeilBrown +Peter Rajnoha +Radek Vykydal +Thorsten Behrens +Chao Wang +Frederic Crozat +James Lee +Jesse Keating +Martin Wilck +Mike Gilbert +Milan Broz +Mimi Zohar +Roberto Sassu +Stefan Reimer +Adam Williamson +Anton Blanchard +Bill Nottingham +Chapman Flack +Chris Leech +David Cantrell +Dennis Gilmore +Jan Synacek +Jon Ander Hernandez +Juan RP +Lance Albertson +Marcos Mello +Marian Ganisin +Matthias Gerstner +Michael Ploujnikov +Pratyush Anand +Silvio Fricke +Steven Brudenell +Stig Telfer +Thomas Backlund +Vasiliy Tolstov +Wim Muskee +tpgxyz +Alan Jenkins +Alan Pevec +Alex Harpin +Ankit Kumar +Antony Messerli +Chao Fan +Daniel Kahn Gillmor +Daniel Schaal +Denis Silakov +Dimitri John Ledkov +Erwan Velu +Evgeny Vereshchagin +Guido Trentalancia +Hari Bathini +Ian Dall +Imran Haider +James Buren +Joey Boggs +Julian Wolf +Koen Kooi +Konrad Rzeszutek Wilk +Kyle McMartin +Lukas Wunner +Mike Snitzer +Minfei Huang +Nikoli +Pingfan Liu +Przemysław Rudy +Robert LeBlanc +Robert Scheck +Stefan Berger +Thomas Lange +Till Maas +Tony Asleson +Vivek Goyal +Vladislav Bogdanov +Zbigniew Jędrzejewski-Szmek +Alexander Kurtz +Alexander Todorov +Andreas Stieger +Andy Lutomirski +Anssi Hannula +Artem Savkov +B. Wilson +Brandon Philips +Bryn M. Reeves +Canek Peláez Valdés +Carlo Caione +Chad Dupuis +Christian Heinz +Cong Wang +Dan Fuhry +Dave Jones +David Disseldorp +David Michael +Dennis Schridde +Derek Higgins +Duane Griffin +Elan Ruusamäe +Enno Boland +Eugene Syromiatnikov +Florian Albrechtskirchinger +Florian Gamböck +François Cami +Gerd von Egidy +Glen Gray +HATAYAMA Daisuke +Hendrik Brueckner +Hermann Gausterer +Hiroaki Mizuguchi +Hui Wang +Ignaz Forster +James Laska +Jan Stodola +Jason Dana +Jeremy Linton +Jiri Pirko +Joe Lawrence +Johannes Thumshirn +Jonas Jonsson +Kevin Yung +Lars R. Damerow +Lennert Buytenhek +Major Hayden +Marc-Antoine Perennou +Marian Csontos +Mark Fasheh +Marko Myllynen +Matt +Matt Smith +Matthew Thode +Mei Liu +Michael Chapman +Michael McCracken +Michal Koutný +Michal Schmidt +Michal Sekletar +Mike Gorse +Moritz 'Morty' Strübe +Munehiro Matsuda +Nicolas Porcel +Olivier Blin +P J P +Paolo Bonzini +Pavel Zhukov +Pawel Wieczorkiewicz +Pekka Wallendahl +Prarit Bhargava +Praveen_Paladugu@Dell.com +Pádraig Brady +Quentin Armitage +Renaud Métrich +Robert Buchholz +Ruben Kerkhof +Rusty Bird +Sergey Fionov +Shawn W Dunn +Srinivasa T N +Stijn Hoop +Sullivan (CTR), Austin +Thilo Bangert +Thomas Blume +Tobias Geerinckx +Tobias Klauser +Tom Gundersen +Tomasz Paweł Gajc +Tomasz Torcz +Tong Li +Vadim Kuznetsov +Vaughan Cao +Vratislav Podzimek +Yanko Kaneti +Zhiguo Deng +Ziyue Yang +honza801 +jloeser +johannes +jonathan-teh <30538043+jonathan-teh@users.noreply.github.com> +maximilian attems +privb0x23 +tpg +xtraeme diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/HACKING b/HACKING new file mode 100644 index 0000000..3c3a52d --- /dev/null +++ b/HACKING @@ -0,0 +1,23 @@ +Right now, most of the testing is done using a qemu/kvm guest and +generating the initramfs on another box but the support is all present +to build for the "running" machine. For the former, you can boot the guest +using qemu's -kernel and -initrd options. + +dracut exists and will build an image. It is command-line equivalent +to most mkinitrd implementations and should be pretty straight-forward +to use. + +To use, just run dracut with an output file name and, optionally, a +kernel version (it defaults to using the current). The appropriate +modules will be copied over and things should be good to go. If you'd +like to customize the list of modules copied in, edit /etc/dracut.conf +and set + dracutmodules="foo bar baz" + +Note that dracut calls functional components in modules.d "modules" +while kernel modules are called "drivers". + +Requirements: +* udev +* nfs module: nfs daemon and rpc helper +* iscsi: iscsi diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8062343 --- /dev/null +++ b/Makefile @@ -0,0 +1,270 @@ +-include dracut-version.sh + +VERSION ?= $(shell [ -d .git ] && git describe --abbrev=0 --tags --always 2>/dev/null || echo $(DRACUT_VERSION)) +GITVERSION ?= $(shell [ -d .git ] && { v=$$(git describe --tags --always 2>/dev/null); [ -n "$$v" ] && [ $${v\#*-} != $$v ] && echo -$${v\#*-}; } ) + +-include Makefile.inc + +prefix ?= /usr +libdir ?= ${prefix}/lib +datadir ?= ${prefix}/share +pkglibdir ?= ${libdir}/dracut +sysconfdir ?= ${prefix}/etc +bindir ?= ${prefix}/bin +mandir ?= ${prefix}/share/man +CFLAGS ?= -O2 -g -Wall +CFLAGS += -std=gnu99 -D_FILE_OFFSET_BITS=64 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 $(KMOD_CFLAGS) +bashcompletiondir ?= ${datadir}/bash-completion/completions +pkgconfigdatadir ?= $(datadir)/pkgconfig + +man1pages = lsinitrd.1 + +man5pages = dracut.conf.5 + +man7pages = dracut.cmdline.7 \ + dracut.bootup.7 \ + dracut.modules.7 + +man8pages = dracut.8 \ + dracut-catimages.8 \ + mkinitrd.8 \ + mkinitrd-suse.8 \ + modules.d/98dracut-systemd/dracut-cmdline.service.8 \ + modules.d/98dracut-systemd/dracut-initqueue.service.8 \ + modules.d/98dracut-systemd/dracut-mount.service.8 \ + modules.d/98dracut-systemd/dracut-shutdown.service.8 \ + modules.d/98dracut-systemd/dracut-pre-mount.service.8 \ + modules.d/98dracut-systemd/dracut-pre-pivot.service.8 \ + modules.d/98dracut-systemd/dracut-pre-trigger.service.8 \ + modules.d/98dracut-systemd/dracut-pre-udev.service.8 + +manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages) + +.PHONY: install clean archive rpm testimage test all check AUTHORS doc dracut-version.sh + +all: dracut-version.sh dracut.pc dracut-install skipcpio/skipcpio + +DRACUT_INSTALL_OBJECTS = \ + install/dracut-install.o \ + install/hashmap.o\ + install/log.o \ + install/strv.o \ + install/util.o + +# deps generated with gcc -MM +install/dracut-install.o: install/dracut-install.c install/log.h install/macro.h \ + install/hashmap.h install/util.h +install/hashmap.o: install/hashmap.c install/util.h install/macro.h install/log.h \ + install/hashmap.h +install/log.o: install/log.c install/log.h install/macro.h install/util.h +install/util.o: install/util.c install/util.h install/macro.h install/log.h +install/strv.o: install/strv.c install/strv.h install/util.h install/macro.h install/log.h + +install/dracut-install: $(DRACUT_INSTALL_OBJECTS) + $(CC) $(LDFLAGS) -o $@ $(DRACUT_INSTALL_OBJECTS) $(LDLIBS) $(KMOD_LIBS) + +logtee: logtee.c + $(CC) $(LDFLAGS) -o $@ $< + +dracut-install: install/dracut-install + ln -fs $< $@ + +SKIPCPIO_OBJECTS= \ + skipcpio/skipcpio.o + +skipcpio/skipcpio.o: skipcpio/skipcpio.c +skipcpio/skipcpio: skipcpio/skipcpio.o + +indent: + indent -i8 -nut -br -linux -l120 install/dracut-install.c + indent -i8 -nut -br -linux -l120 skipcpio/skipcpio.c + +doc: $(manpages) dracut.html + +ifneq ($(enable_documentation),no) +all: doc +endif + +%: %.xml + @rm -f -- "$@" + xsltproc -o "$@" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $< + +%.xml: %.asc + @rm -f -- "$@" + asciidoc -d manpage -b docbook -o "$@" $< + +dracut.8: dracut.usage.asc dracut.8.asc + +dracut.html: dracut.asc $(manpages) dracut.css dracut.usage.asc + @rm -f -- dracut.xml + asciidoc -a numbered -d book -b docbook -o dracut.xml dracut.asc + @rm -f -- dracut.html + xsltproc -o dracut.html --xinclude -nonet \ + --stringparam custom.css.source dracut.css \ + --stringparam generate.css.header 1 \ + http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml + @rm -f -- dracut.xml + +dracut.pc: Makefile.inc Makefile + @echo "Name: dracut" > dracut.pc + @echo "Description: dracut" >> dracut.pc + @echo "Version: $(VERSION)$(GITVERSION)" >> dracut.pc + @echo "dracutdir=$(pkglibdir)" >> dracut.pc + @echo "dracutmodulesdir=$(pkglibdir)/modules.d" >> dracut.pc + @echo "dracutconfdir=$(pkglibdir)/dracut.conf.d" >> dracut.pc + +install: all + mkdir -p $(DESTDIR)$(pkglibdir) + mkdir -p $(DESTDIR)$(bindir) + mkdir -p $(DESTDIR)$(sysconfdir) + mkdir -p $(DESTDIR)$(pkglibdir)/modules.d + mkdir -p $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7 $(DESTDIR)$(mandir)/man8 + install -m 0755 dracut.sh $(DESTDIR)$(bindir)/dracut + install -m 0755 dracut-catimages.sh $(DESTDIR)$(bindir)/dracut-catimages + install -m 0755 mkinitrd-dracut.sh $(DESTDIR)$(bindir)/mkinitrd + install -m 0755 lsinitrd.sh $(DESTDIR)$(bindir)/lsinitrd + install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf + mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d + mkdir -p $(DESTDIR)$(pkglibdir)/dracut.conf.d + install -m 0755 dracut-init.sh $(DESTDIR)$(pkglibdir)/dracut-init.sh + install -m 0755 dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions.sh + install -m 0755 dracut-version.sh $(DESTDIR)$(pkglibdir)/dracut-version.sh + ln -fs dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions + install -m 0755 dracut-logger.sh $(DESTDIR)$(pkglibdir)/dracut-logger.sh + install -m 0755 dracut-initramfs-restore.sh $(DESTDIR)$(pkglibdir)/dracut-initramfs-restore + cp -arx modules.d $(DESTDIR)$(pkglibdir) +ifneq ($(enable_documentation),no) + for i in $(man1pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man1/$${i##*/}; done + for i in $(man5pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man5/$${i##*/}; done + for i in $(man7pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man7/$${i##*/}; done + for i in $(man8pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man8/$${i##*/}; done + ln -fs dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7 +endif + if [ -n "$(systemdsystemunitdir)" ]; then \ + mkdir -p $(DESTDIR)$(systemdsystemunitdir); \ + ln -srf $(DESTDIR)$(pkglibdir)/modules.d/98dracut-systemd/dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir)/dracut-shutdown.service; \ + mkdir -p $(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants; \ + ln -s ../dracut-shutdown.service \ + $(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants/dracut-shutdown.service; \ + mkdir -p $(DESTDIR)$(systemdsystemunitdir)/initrd.target.wants; \ + for i in \ + dracut-cmdline.service \ + dracut-initqueue.service \ + dracut-mount.service \ + dracut-pre-mount.service \ + dracut-pre-pivot.service \ + dracut-pre-trigger.service \ + dracut-pre-udev.service \ + ; do \ + ln -srf $(DESTDIR)$(pkglibdir)/modules.d/98dracut-systemd/$$i $(DESTDIR)$(systemdsystemunitdir); \ + ln -s ../$$i \ + $(DESTDIR)$(systemdsystemunitdir)/initrd.target.wants/$$i; \ + done \ + fi + if [ -f install/dracut-install ]; then \ + install -m 0755 install/dracut-install $(DESTDIR)$(pkglibdir)/dracut-install; \ + fi + if [ -f skipcpio/skipcpio ]; then \ + install -m 0755 skipcpio/skipcpio $(DESTDIR)$(pkglibdir)/skipcpio; \ + fi + mkdir -p $(DESTDIR)${prefix}/lib/kernel/install.d + install -m 0755 50-dracut.install $(DESTDIR)${prefix}/lib/kernel/install.d/50-dracut.install + install -m 0755 51-dracut-rescue.install $(DESTDIR)${prefix}/lib/kernel/install.d/51-dracut-rescue.install + mkdir -p $(DESTDIR)${bashcompletiondir} + install -m 0644 dracut-bash-completion.sh $(DESTDIR)${bashcompletiondir}/dracut + install -m 0644 lsinitrd-bash-completion.sh $(DESTDIR)${bashcompletiondir}/lsinitrd + mkdir -p $(DESTDIR)${pkgconfigdatadir} + install -m 0644 dracut.pc $(DESTDIR)${pkgconfigdatadir}/dracut.pc + +dracut-version.sh: + @rm -f dracut-version.sh + @echo "DRACUT_VERSION=$(VERSION)$(GITVERSION)" > dracut-version.sh + +clean: + $(RM) *~ + $(RM) */*~ + $(RM) */*/*~ + $(RM) $(manpages:%=%.xml) dracut.xml + $(RM) test-*.img + $(RM) dracut-*.rpm dracut-*.tar.bz2 dracut-*.tar.xz + $(RM) dracut-version.sh + $(RM) dracut-install install/dracut-install $(DRACUT_INSTALL_OBJECTS) + $(RM) skipcpio/skipcpio $(SKIPCPIO_OBJECTS) + $(RM) $(manpages) dracut.html + $(MAKE) -C test clean + +dist: dracut-$(VERSION).tar.xz + +dracut-$(VERSION).tar.xz: doc syncheck + @echo "DRACUT_VERSION=$(VERSION)" > dracut-version.sh + git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ > dracut-$(VERSION).tar + mkdir -p dracut-$(VERSION) + for i in $(manpages) dracut.html dracut-version.sh; do [ "$${i%/*}" != "$$i" ] && mkdir -p "dracut-$(VERSION)/$${i%/*}"; cp "$$i" "dracut-$(VERSION)/$$i"; done + tar --owner=root --group=root -rf dracut-$(VERSION).tar $$(find dracut-$(VERSION) -type f) + rm -fr -- dracut-$(VERSION).tar.xz dracut-$(VERSION) + xz -9 dracut-$(VERSION).tar + rm -f -- dracut-$(VERSION).tar + +rpm: dracut-$(VERSION).tar.xz syncheck + rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \ + cp dracut-$(VERSION).tar.xz "$$rpmbuild"; \ + LC_MESSAGES=C $$src/git2spec.pl $(VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \ + (cd "$$rpmbuild"; \ + wget https://www.gnu.org/licenses/lgpl-2.1.txt; \ + rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \ + --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \ + --define "_rpmdir $$PWD" -ba dracut.spec; ) && \ + ( mv "$$rpmbuild"/{,$$(arch)/}*.rpm $(DESTDIR).; rm -fr -- "$$rpmbuild"; ls $(DESTDIR)*.rpm ) + +syncheck: + @ret=0;for i in dracut-initramfs-restore.sh modules.d/*/*.sh; do \ + [ "$${i##*/}" = "module-setup.sh" ] && continue; \ + read line < "$$i"; [ "$${line#*bash*}" != "$$line" ] && continue; \ + [ $$V ] && echo "posix syntax check: $$i"; bash --posix -n "$$i" ; ret=$$(($$ret+$$?)); \ + [ $$V ] && echo "checking for [[: $$i"; if grep -Fq '[[ ' "$$i" ; then ret=$$(($$ret+1)); echo "$$i contains [["; fi; \ + [ $$V ] && echo "checking for echo -n: $$i"; if grep -Fq 'echo -n ' "$$i" ; then ret=$$(($$ret+1)); echo "$$i contains echo -n"; fi \ + done;exit $$ret + @ret=0;for i in *.sh mkinitrd-dracut.sh modules.d/*/*.sh \ + modules.d/*/module-setup.sh; do \ + [ $$V ] && echo "bash syntax check: $$i"; bash -n "$$i" ; ret=$$(($$ret+$$?)); \ + done;exit $$ret + +check: all syncheck rpm + @[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; } + @$(MAKE) -C test check + +testimage: all + ./dracut.sh -N -l -a debug -f test-$(shell uname -r).img $(shell uname -r) + @echo wrote test-$(shell uname -r).img + +debugtestimage: all + ./dracut.sh --debug -l -a debug -f test-$(shell uname -r).img $(shell uname -r) + @echo wrote test-$(shell uname -r).img + +testimages: all + ./dracut.sh -l -a debug --kernel-only -f test-kernel-$(shell uname -r).img $(shell uname -r) + @echo wrote test-$(shell uname -r).img + ./dracut.sh -l -a debug --no-kernel -f test-dracut.img $(shell uname -r) + @echo wrote test-dracut.img + +debughostimage: all + ./dracut.sh --debug -H -l -f test-$(shell uname -r).img $(shell uname -r) + @echo wrote test-$(shell uname -r).img + +hostimage: all + ./dracut.sh -H -l -f test-$(shell uname -r).img $(shell uname -r) + @echo wrote test-$(shell uname -r).img + +efi: all + ./dracut.sh --uefi -H -l -f linux-$(shell uname -r).efi $(shell uname -r) + @echo wrote linux-$(shell uname -r).efi + +AUTHORS: + git shortlog --numbered --summary -e |while read a rest || [ -n "$$rest" ]; do echo $$rest;done > AUTHORS + +dracut.html.sign: dracut-$(VERSION).tar.xz dracut.html + gpg-sign-all dracut-$(VERSION).tar.xz dracut.html + +upload: dracut.html.sign + kup put dracut-$(VERSION).tar.xz dracut-$(VERSION).tar.sign /pub/linux/utils/boot/dracut/ + kup put dracut.html dracut.html.sign /pub/linux/utils/boot/dracut/ diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..9f7f1fb --- /dev/null +++ b/NEWS @@ -0,0 +1,1618 @@ +dracut-049 +========== +lsinitrd: +- record loaded kernel modules when hostonly mode is enabled + lsinitrd $image -f */lib/dracut/loaded-kernel-modules.txt +- allow to only unpack certain files + +kernel-modules: +- add gpio and pinctrl drivers for arm*/aarch64 +- add nfit + +kernel-network-modules: +- add vlan kernel modules + +ifcfg/write-ifcfg.sh: +- aggregate resolv.conf + +livenet: +- Enable OverlayFS overlay in sysroot.mount generator. + +dmsquash-live: +- Support a flattened squashfs.img + +dracut-systemd: +- Start systemd-vconsole-setup before dracut-cmdline-ask + +iscsi: +- do not install all of /etc/iscsi unless hostonly +- start iscsid even w/o systemd + +multipath: +- fixed shutdown + +network: +- configure NetworkManager to use dhclient + +mdraid: +- fixed uuid handling ":" versus "-" + +stratis: +- Add additional binaries + +new modules: +- 00warpclock +- 99squash + Adds support for building a squashed initramfs +- 35network-legacy + the old 40network +- 35network-manager + alternative to 35network-legacy +- 90kernel-modules-extra + adds out-of-tree kernel modules + +testsuite: +- now runs on travis +- support new qemu device options +- even runs without kvm now + +dracut-048 +========== + +dracut.sh: +- fixed finding of btrfs devices +- harden dracut against BASH_ENV environment variable +- no more prelinking +- scan and install "external" kernel modules +- fixed instmods with zero input +- rdsosreport: best effort to strip out passwords +- introduce tri-state hostonly mode + + Add a new option --hostonly-mode which accept an parameter, so we have a tri-state hostonly mode: + + * generic: by passing "--no-hostonly" or not passing anything. + "--hostonly-mode" has no effect in such case. + * sloppy: by passing "--hostonly --hostonly-mode sloppy". This + is also the default mode when only "--hostonly" is given. + * strict: by passing "--hostonly --hostonly-mode strict". + + Sloppy mode is the original hostonly mode, the new introduced strict + mode will allow modules to ignore more drivers or do some extra job to + save memory and disk space, while making the image less portable. + + Also introduced a helper function "optional_hostonly" to make it + easier for modules to leverage new hostonly mode. + + To force install modules only in sloppy hostonly mode, use the form: + + hostonly="$(optional_hostonly)" instmods + +dracut-install: +- don't error out, if no modules were installed +- support modules.softdep + +lsinitrd.sh: +- fixed zstd file signature + +kernel: +- include all pci/host modules +- add mmc/core for arm +- Include Intel Volume Management Device support + +plymouth: +- fix detection of plymouth directory + +drm: +- make failing installation of drm modules nonfatal +- include virtio DRM drivers in hostonly initramfs + +stratis: +- initial Stratis support + +crypt: +- correct s390 arch to include arch-specific crypto modules +- add cmdline rd.luks.partuuid +- add timeout option rd.luks.timeout + +shutdown: +- sleep a little, if a process was killed + +network: +- introduce ip=either6 option + +iscsi: +- replace iscsistart with iscsid + +qeth_rules: +- new module to copy qeth rules + +multipath-hostonly: +- merged back into multipath + +mdraid: +- fixed case if rd.md.uuid is in ID_FS_UUID format + +dracut-047 +========== +dracut.sh: +- sync initramfs to filesystem with fsfreeze +- introduce "--no-hostonly-default-device" +- disable lsinitrd logging when quiet +- add support for Zstandard compression +- fixed relative paths in --kerneldir +- if /boot/vmlinuz-$version exists use /boot/ as default output dir +- make qemu and qemu-net a default module in non-hostonly mode +- fixed relative symlinks +- support microcode updates for all AMD CPU families +- install all modules-load.d regardless of hostonly +- fixed parsing of "-i" and "--include" +- bump kmod version to >= 23 +- enable 'early_microcode' by default +- fixed check_block_and_slaves() for nvme + +lsinitrd.sh: +- dismiss "cat" error messages + +systemd-bootchart: +- removed + +i18n: +- install all keymaps for a given locale +- add correct fontmaps + +dmsquash-live: +- fixed systemd unit escape + +systemd: +- enable core dumps with systemd from initrd +- fixed setting of timeouts for device units +- emergency.service: use Type=idle and fixed task limit + +multipath: +- include files from /etc/multipath/conf.d +- do not fail startup on missing configuration +- start daemon after udev settle +- add shutdown script +- parse kernel commandline option 'multipath=off' +- start before local-fs-pre.target + +dracut-emergency: +- optionally print filesystem help + +network: +- fixed MTU for bond master +- fixed race condition when wait for networks + +fcoe: +- handle CNAs with DCB firmware support +- allow to specify the FCoE mode via the fcoe= parameter +- always set AUTO_VLAN for fcoemon +- add shutdown script +- fixup fcoe-genrules.sh for VN2VN mode +- switch back to using fipvlan for bnx2fc +- add timeout mechanism + +crypt: +- add basic LUKS detached header support +- escape backslashes for systemd unit names correctly +- put block_uuid.map into initramfs + +dmraid: +- do not delete partitions + +dasd_mod: +- do not set module parameters if dasd_cio_free is not present + +nfs: +- fix mount if IPv4 address is used in /etc/fstab +- support host being a DNS ALIAS + +fips: +- fixed creating path to .hmac of kernel based on BOOT_IMAGE + +lunmask: +- add module to handle LUN masking + +s390: +- add rd.cio_accept + +dcssblk: +- add new module for DCSS block devices + +zipl: +- add new module to update s390x configuration + +iscsi: +- no more iscsid, either iscsistart or iscsid + +integrity: +- support loading x509 into the trusted/builtin .evm keyring +- support X.509-only EVM configuration + +plymouth: +- improve distro compatibility + +dracut-046 +========== + +dracut.sh: +- bail out if module directory does not exist + if people want to build the initramfs without kernel modules, + then --no-kernel should be specified +- add early microcode support for AMD family 16h +- collect also all modaliases modules from sysfs for hostonly modules +- sync initramfs after creation + +network: +- wait for IPv6 RA if using none/static IPv6 assignment +- ipv6 improvements +- Handle curl using libnssckbi for TLS +- fix dhcp classless_static_routes +- dhclient: send client-identifier matching hardware address +- don't arping for point-to-point connections +- only bring up wired network interfaces (no wlan and wwan) + +mraid: +- mdraid: wait for rd.md.uuid specified devices to be assembled + +crypt: +- handle rd.luks.name + +crypt-gpg: +- For GnuPG >= 2.1 support OpenPGP smartcards + +kernel-install: +- Skip to create initrd if /etc/machine-id is missing or empty + +nfs: +- handle rpcbind /run/rpcbind directory + +s390: +- various fixes + +dmsquash-live: +- add NTFS support + +multipath: +- split out multipath-hostonly module + +lvmmerge: +- new module, see README.md in the module directory + +dracut-systemd: +- fixed dependencies + + +dracut-045 +========== + +Important: dracut now requires libkmod for the dracut-install binary helper, + which nows handles kernel module installing and filtering. + +dracut.sh: +- restorecon final image file +- fail hard, if we find modules and modules.dep is missing +- support --tmpdir as a relative path +- add default path for --uefi + +dracut-functions.sh: +- fix check_vol_slaves() volume group name stripping + +dracut-install: +- catch ldd message "cannot execute binary file" +- added kernel module handling with libkmod + Added parameters: + --module,-m + --mod-filter-path, -p + --mod-filter-nopath, -P + --mod-filter-symbol, -s + --mod-filter-nosymbol, -S + --mod-filter-noname, -N + --silent + --kerneldir + --firmwaredirs +- fallback to non-hostonly mode if lsmod fails + +lsinitrd: +- new option "--unpack" +- new option "--unpackearly" +- and "--verbose" + +general initramfs fixes: +- don't remove 99-cmdline-ask on 'hostonly' cleanup +- call dracut-cmdline-ask.service, if /etc/cmdline.d/*.conf exists +- break at switch_root only for bare rd.break +- add rd.emergency=[reboot|poweroff|halt] + specifies what action to execute in case of a critical failure +- rd.memdebug=4 gives information, about kernel module memory consumption + during loading + +dmsquash-live: +- fixed livenet-generator execution flag + and include only, if systemd is used +- fixed dmsquash-live-root.sh for cases where the fstype of the liveimage is squashfs +- fixed typo for rootfs.img +- enable the use of the OverlayFS for the LiveOS root filesystem + Patch notes: + Integrate the option to use an OverlayFS as the root filesystem + into the 90dmsquash-live module for testing purposes. + + The rd.live.overlay.overlayfs option allows one to request an + OverlayFS overlay. If a persistent overlay is detected at the + standard LiveOS path, the overlay & type detected will be used. + + Tested primarily with transient, in-RAM overlay boots on vfat- + formatted Live USB devices, with persistent overlay directories + on ext4-formatted Live USB devices, and with embedded, persistent + overlay directories on vfat-formatted devices. (Persistent overlay + directories on a vfat-formatted device must be in an embedded + filesystem that supports the creation of trusted.* extended + attributes, and must provide valid d_type in readdir responses.) + + The rd.live.overlay.readonly option, which allows a persistent + overlayfs to be mounted read only through a higher level transient + overlay directory, has been implemented through the multiple lower + layers feature of OverlayFS. + + The default transient DM overlay size has been adjusted up to 32 GiB. + This change supports comparison of transient Device-mapper vs. + transient OverlayFS overlay performance. A transient DM overlay + is a sparse file in memory, so this setting does not consume more + RAM for legacy applications. It does permit a user to use all of + the available root filesystem storage, and fails gently when it is + consumed, as the available free root filesystem storage on a typical + LiveOS build is only a few GiB. Thus, when booted on other- + than-small RAM systems, the transient DM overlay should not overflow. + + OverlayFS offers the potential to use all of the available free RAM + or all of the available free disc storage (on non-vfat-devices) + in its overlay, even beyond the root filesystem available space, + because the OverlayFS root filesystem is a union of directories on + two different partitions. + + This patch also cleans up some message spew at shutdown, shortens + the execution path in a couple of places, and uses persistent + DM targets where required. + +dmraid: +- added "nowatch" option in udev rule, otherwise udev would reread partitions for raid members +- allow booting from degraded MD RAID arrays + +shutdown: +- handle readonly /run on shutdown + +kernel-modules: +- add all HID drivers, regardless of hostonly mode + people swap keyboards sometimes and should be able to enter their disk password +- add usb-storage + To save the rdsosreport.txt to a USB stick, the usb-storage module is needed. +- add xennet +- add nvme + +systemd: +- add /etc/machine-info +- fixed systemd-escape call for names beginning with "-" +- install missing drop-in configuration files for + /etc/systemd/{journal.conf,system.conf} + +filesystems: +- add support to F2FS filesystem (fsck and modules) + +network: +- fix carrier detection +- correctly set mac address for ip=...:: +- fixed vlan, bonding, bridging, team logic + call ifup for the slaves and assemble afterwards +- add mtu to list of variables to store in override +- for rd.neednet=0 a bootdev is not needed anymore +- dhclient-script.sh: add classless-static-routes support +- support for iBFT IPv6 +- support macaddr in brackets [] (commit 740c46c0224a187d6b5a42b4aa56e173238884cc) +- use arping2, if available +- support multiple default gateways from DHCP server +- fixup VLAN handling +- enhance team support +- differ between ipv6 local and global tentative +- ipv6: wait for a router advertised route +- add 'mtu' parameter for bond options +- use 'ip' instead of 'brctl' + +nbd: +- add systemd generator +- use export names instead of port numbers, because port number based + exports are deprecated and were removed. + +fcoe: +- no more /dev/shm state copying + +multipath: +- check all /dev/mapper devices if they are multipath devices, not only mpath* + +fips: +- fixed .hmac installation in FIPS mode + +plymouth: +- also trigger the acpi subsystem + +syslog: +- add imjournal.so to read systemd journal +- move start from udev to initqueue/online + +caps: +- make it a non default module + +livenet: +- support nfs:// urls in livenet-generator + +nfs: +- install all nfs modules non-hostonly + +crypt: +- support keyfiles embedded in the initramfs + +testsuite: +- add TEST-70-BONDBRIDGETEAMVLAN +- make "-cpu host" the default + +dracut-044 +========== +creation: +- better udev & systemd dir detection +- split dracut-functions.sh in dracut-init.sh and dracut-functions.sh + dracut-functions.sh can now be sourced by external tools +- detect all btrfs devices needed +- added flag file if initqueue is needed +- don't overwrite anything, if initramfs image file creation failed +- if no compressor is specified, try to find a suitable one +- drop scanning kernel config for CONFIG_MICROCODE_*_EARLY +- remove "_EARLY" from CONFIG_MICROCODE_* checks +- dracut.sh: add command line option for install_i18_all + --no-hostonly-i18n -> install_i18n_all=yes + --hostonly-i18n -> install_i18n_all=no +- --no-reproducible to turn off reproducible mode +- dracut-function.sh can now be sourced from outside of dracut +- dracut-init.sh contains all functions, which only can be used from + within the dracut infrastructure +- support --mount with just mountpoint as a parameter +- removed action_on_fail support +- removed host_modalias concept +- do not create microcode, if no firmware is available +- skip gpg files in microcode generation + +initramfs: +- ensure pre-mount (and resume) run before root fsck +- add --online option to initqueue + +qemu: +- fixed virtual machine detection + +lvm: +- remove all quirk arguments for lvm >= 2.2.221 + +dmsquash: +- fixup for checkisomd5 +- increase timeout for checkisomd5 +- use non-persistent metadata snapshots for transient overlays. +- overflow support for persistent snapshot. +- use non-persistent metadata snapshots. +- avoid an overlay for persistent, uncompressed, read-write live installations. + +multipath: +- multipath.conf included in hostonly mode +- install all multipath path selector kernel modules + +iSCSI: +- use the iBFT initiator name, if found and set +- iscsid now present in the initramfs +- iscsistart is done with systemd-run asynchrone to do things in + paralllel. Also restarted for every new interface which shows up. +- If rd.iscsi.waitnet (default) is set, iscsistart is done only + after all interfaces are up. +- If not all interfaces are up and rd.iscsi.testroute (default) is set, + the route to a iscsi target IP is checked and skipped, if there is none. +- If all things fail, we issue a "dummy" interface iscsiroot to retry + everything in the initqueue/timeout. + +network: +- added DHCP RENEW/REBIND +- IPv4 DHCP lease time now optional (bootp) +- IPv6 nfs parsing +- fixed IPv6 route parsing +- rd.peerdns=0 parameter to disable DHCP nameserver setting +- detect duplicate IPv4 addresses for static addresses +- if interfaces are specified with its enx* name, bind the correspondent MAC to the interface name +- if multiple "ip=" are present on the kernel command line "rd.neednet=1" is assumed +- add options to tweak timeouts + rd.net.dhcp.retry= + If this option is set, dracut will try to connect via dhcp + times before failing. Default is 1. + + rd.net.timeout.dhcp= + If this option is set, dhclient is called with "-timeout ". + + rd.net.timeout.iflink= + Wait until link shows up. Default is 60 seconds. + + rd.net.timeout.ifup= + Wait until link has state "UP". Default is 20 seconds. + + rd.net.timeout.route= + Wait until route shows up. Default is 20 seconds. + + rd.net.timeout.ipv6dad= + Wait until IPv6 DAD is finished. Default is 50 seconds. + + rd.net.timeout.ipv6auto= + Wait until IPv6 automatic addresses are assigned. + Default is 40 seconds. + + rd.net.timeout.carrier= + Wait until carrier is recognized. Default is 5 seconds. + +IMA: +- load signed certificates in the IMA keyring, see modules.d/98integrity/README +- load EVM public key in the kernel _evm keyring + +FCoE: + fcoe: start with fcoemon instead of fipvlan + +dracut-043 +========== +- add missing dmsquash-generator + +dracut-042 +========== +- fixed dmsetup shutdown +- new kernel command line option "rd.live.overlay.thin" + This option changes the underlying mechanism for the overlay in the + dmsquash module. + Instead of a plain dm snapshot a dm thin snapshot is used. The advantage + of the thin snapshot is, that the TRIM command is recognized, which + means that at runtime, only the occupied blocks will be claimed from + memory, and freed blocks will really be freed in ram. +- dmsquash: Add squashfs support to rd.live.fsimg + Previously rd.live.fsimg only supported filesystems residing in + (compressed) archives. + Now rd.live.fsimg can also be used when a squashfs image is used. + This is achieved by extracting the rootfs image from the squashfs and + then continue with the default routines for rd.live.fsimg. +- lvm: add support for LVM system id +- split up the systemd dracut module + Basic systemd functionality is in 00systemd now. + Switching root and the initrd.target is in 00systemd-initrd. + Dracut additions to the systemd initrd are in 98dracut-systemd. +- support for creating a UEFI boot executable via argument "--uefi" + With an EFI stub, the kernel, the initramfs and a kernel cmdline can be + glued together to a single UEFI executable, which can be booted by a + UEFI BIOS. +- network: split out kernel-network-modules, now in 90kernel-network-modules +- support for ethernet point-to-point connections configured via DHCP +- kernel-modules: install all HID drivers +- dracut.pc pkg-config file +- mount /dev, /dev/shm and /run noexec + +dracut-041 +========== +- fixed the shutdown loop +- fixed gzip compression for versions, which do not have --rsyncable +- fixed ifcfg generation for persistent interface names +- multipath: + * new option to turn off multipath "rd.multipath=0" completly + * preload scsi dh modules + * start multipathd via systemd service +- do not fail, if user pressed ESC during media check +- fixed systemd-journal by symlinking /var/log to /run/initramfs/log +- initrd-release moved to /usr/lib +- lots of iSCSI fixes +- new "rd.timeout" to specify the systemd JobTimeoutSec for devices +- if $initrd/etc/cmdline.d/* has a "root=" and the kernel cmdline does not, + generate a mount unit for it +- increased the initqueue timeout for non systemd initramfs to 180s +- $initrd/etc/cmdline.d/ hostonly files are now generated for NFS +- make use of systemd-hibernate-resume, if available +- fixed ldconfig parsing for hwcap output +- network: add support for comma separated autoconf options like ip=eth0:auto6,dhcp +- new parameter "rd.live.overlay.size" to specify the overlay for live images +- changed the test suite for the new sfdisk syntax +- added cache tools for dm-cache setups + +dracut-040 +========== +- fixed dracut module dependency checks +- fixed test suite + +dracut-039 +========== +- DRACUT_PATH can now be used to specify the PATH used by dracut + to search for binaries instead of the default + /usr/sbin:/sbin:/usr/bin:/bin + This should be set in the distribution config file + /usr/lib/dracut/dracut.conf.d/01-dist.conf +- add "--loginstall " and loginstall="" options + to record all files, which are installed from the host fs +- "rd.writable.fsimg" - support for read/write filesystem images +- "rd.route" kernel command line parameter added +- "--install-optional" and install_optional_items added +- find plymouth pkglibdir on debian +- torrent support for live images + root=live:torrent://example.com/liveboot.img.torrent + and generally added as a download handler +- disable microcode, if the kernel does not support it +- speed up ldconfig_paths() +- more ARM modules +- fixed inst*() functions and "-H" handling +- fixed bridge setup +- added --force-drivers parameter and force_drivers=+ config option + to enforce driver loading at early boot time +- documented "iso-scan/filename" usage in grub +- various bugfixes + +dracut-038 +========== +- "rd.cmdline=ask" will ask the user on the console to enter additional + kernel command line parameters +- "rd.hostonly=0" removes all "hostonly" added custom files, + which is useful in combination with "rd.auto" or other specific parameters, + if you want to boot on the same hardware, but the compiled in configuration + does not match your setup anymore +- inst* functions and dracut-install now accept the "-H" flag, which logs all + installed files to /lib/dracut/hostonly-files. This is used to remove those + files, if rd.hostonly is given on the kernel command line +- strstr now only does literal string match, + please use strglob and strglobin for globs +- fixed unpacking of the microcode image on shutdown +- added systemd-gpt-auto-generator +- fcoe: wait for lldpad to be ready +- network: handle "ip=dhcp6" +- network: DCHPv6: set valid_lft and preferred_lft +- dm: support dm-cache +- fstab: do not mount and fsck from fstab if using systemd +- break at switch_root only for bare rd.break and not for any rd.break=... +- nbd: make use of "--systemd-mark", otherwise it gets killed on switch_root +- fcoe-uefi: fixed cmdline parameter generation +- iscsi: deprecate "ip=ibft", use "rd.iscsi.ibft[=1]" from now on +- "lsinitrd -m" now only lists the dracut modules of the image +- a lot of small bugfixes + +dracut-037 +========== +- dracut: hostonly_cmdline variable and command line switch + Toggle hostonly cmdline storing in the initramfs + --hostonly-cmdline: + Store kernel command line arguments needed in the initramfs + --no-hostonly-cmdline: + Do not store kernel command line arguments needed in the initramfs +- dracut: --mount now understands full fstab lines +- dracut now also includes drivers from the /lib/modules//updates directory +- dracut: only set the owner of files to 0:0, if generated as non-root +- dracut now directly writes to the initramfs file +- dracut: call lz4 with the legacy flag (linux kernel does not support the new format) +- systemd: rootfs-generator generates JobTimeout=0 units for the root device +- systemd: added the systemd-sysctl service +- systemd: add 80-net-setup-link.rules and .link files for persistent interface renaming +- systemd: make dracut-shutdown.service failure non-fatal +- network: various IPv6 fixes +- network: DCHCP for IPv6 +- network: understand ip=.....:: +- network: parse ibft nameserver settings +- shutdown: if kexec fails, just reboot +- lvm: handle one LV at a time with lvchange +- module-setup.sh: + New functions require_binaries() and require_any_binary() to be used + in the check() section of module-setup.sh. +- a lot of small bugfixes + +Contributions from: +Harald Hoyer +Alexander Tsoy +Till Maas +Amadeusz Żołnowski +Brian C. Lane +Colin Guthrie +Dave Young +WANG Chao +Shawn W Dunn + +dracut-036 +========== +- fixed skipcpio signature checking + +dracut-035 +========== +- changed dracut tarball compression to xz +- new argument "--rebuild" +- add lzo, lz4 compression +- install: install all binaries with found in PATH +- lsinitrd can now handle initramfs images with an early cpio prepended + (microcode, ACPI tables) +- mkinitrd-suse added as a compat stub for dracut +- lvm: install thin utils for non-hostonly +- resume: fix swap detection in hostonly +- avoid loading unnecessary 32-bit libraries for 64-bit initrds +- crypt: wait for systemd password agents +- crypt: skip crypt swaps with password files +- network: before doing dhcp, dracut now checks, if the link has a carrier +- network: dhclient-script.sh now sets the lease time +- network: include usbnet drivers +- network: include all ethernet drivers +- network: add rd.bootif=0 to ignore BOOTIF +- i18n: introduce i18n_install_all, to install everything i18n related +- support SuSE DASD configurations +- support SuSE zfcp configurations +- support SuSE compressed KEYMAP= setting +- usrmount: always install the module, + so always mount /usr from within the initramfs +- test/TEST-17-LVM-THIN: new test case for lvm thin pools +- "halt" the machine in systemd mode for die() + +dracut-034 +========== +- do not run dhcp on parts of assembled network interfaces (bond, bridge) +- add option to turn on/off prelinking + --prelink, --noprelink + do_prelink=[yes|no] +- add ACPI table overriding +- do not log to syslog/kmsg/journal for UID != 0 +- lvm/mdraid: Fix LVM on MD activation +- bcache module removed (now in bcache-tools upstream) +- mdadm: also install configs from /etc/mdadm.conf.d +- fixes for mdadm-3.2.6+ +- mkinitrd: better compat support for SUSE +- fcoe: add FCoE UEFI boot device support +- rootfs-block: add support for the rootfallback= kernel cmdline option + +Contributions from: +Thomas Renninger +Alexander Tsoy +Peter Rajnoha +WANG Chao +Harald Hoyer + + +dracut-033 +========== +- improved hostonly device recognition +- improved hostonly module recognition +- add dracut.css for dracut.html +- do not install udev rules from /etc in generic mode +- fixed LABEL= parsing for swap devices +- fixed iBFT network setup +- url-lib.sh: handle 0-size files with curl +- dracut.asc: document debugging dracut on shutdown +- if rd.md=0, use dmraid for imsm and ddf +- skip empty dracut modules +- removed caching of kernel cmdline +- fixed iso-scan, if the loop device driver is a kernel module +- bcache: support new blkid +- fixed ifup udev rules +- ifup with dhcp, if no "ip=" specified for the interface + +Contributions from: +WANG Chao +Colin Walters +Harald Hoyer + + +dracut-032 +========== +- add parameter --print-cmdline + This prints the kernel command line parameters for the current disk + layout. + $ dracut --print-cmdline + rd.luks.uuid=luks-e68c8906-6542-4a26-83c4-91b4dd9f0471 + rd.lvm.lv=debian/root rd.lvm.lv=debian/usr root=/dev/mapper/debian-root + rootflags=rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered + rootfstype=ext4 +- dracut.sh: add --persistent-policy option and persistent_policy conf option + --persistent-policy : + Use to address disks and partitions. + can be any directory name found in /dev/disk. + E.g. "by-uuid", "by-label" +- dracut now creates the initramfs without udevadm + that means the udev database does not have to populated + and the initramfs can be built in a chroot with + /sys /dev /proc mounted +- renamed dracut_install() to inst_multiple() for consistent naming +- if $libdirs is unset, fall back to ld.so.cache paths +- always assemble /usr device in initramfs +- bash module added (disable it, if you really want dash) +- continue to boot, if the main loop times out, in systemd mode +- removed inst*() shell pure versions, dracut-install binary is in charge now +- fixed ifcfg file generation for vlan +- do not include adjtime and localtime anymore +- fixed generation of zfcp.conf of CMS setups +- install vt102 terminfo + dracut_install() is still there for backwards compat +- do not strip files in FIPS mode +- fixed iBFT interface configuration +- fs-lib: install fsck and fsck.ext* +- shutdown: fixed killall_proc_mountpoint() +- network: also wait for ethernet interfaces to setup +- fixed checking for FIPS mode + +Contributions from: +Harald Hoyer +WANG Chao +Baoquan He +Daniel Schaal +Dave Young +James Lee +Radek Vykydal + + +dracut-031 +========== +- do not include the resume dracut module in hostonly mode, + if no swap is present +- don't warn twice about omitted modules +- use systemd-cat for logging on systemd systems, if logfile is unset +- fixed PARTUUID parsing +- support kernel module signing keys +- do not install the usrmount dracut module in hostonly mode, + if /sbin/init does not live in /usr +- add debian udev rule files +- add support for bcache +- network: handle bootif style interfaces + e.g. ip=77-77-6f-6f-64-73:dhcp +- add support for kmod static devnodes +- add vlan support for iBFT + +Contributions from: +Harald Hoyer +Amadeusz Żołnowski +Brandon Philips +Colin Walters +James Lee +Kyle McMartin +Peter Jones + +dracut-030 +========== +- support new persistent network interface names +- fix findmnt calls, prevents hang on stale NFS mounts +- add systemd.slice and slice.target units +- major shell cleanup +- support root=PARTLABEL= and root=PARTUUID= +- terminfo: only install l/linux v/vt100 and v/vt220 +- unset all LC_* and LANG, 10% faster +- fixed dependency loop for dracut-cmdline.service +- do not wait_for_dev for the root devices +- do not wait_for_dev for devices, if dracut-initqueue is not needed +- support early microcode loading with --early-microcode +- dmraid, let dmraid setup its own partitions +- sosreport renamed to rdsosreport + +Contributions from: +Harald Hoyer +Konrad Rzeszutek Wilk +WANG Chao + +dracut-029 +========== +- wait for IPv6 autoconfiguration +- i18n: make the default font configurable + To set the default font for your distribution, add + i18n_default_font="latarcyrheb-sun16" + to your /lib/dracut/dracut.conf.d/01-dist.conf distribution config. +- proper handle "rd.break" in systemd mode before switch-root +- systemd: make unit files symlinks +- build without dash requirement +- add dracut-shutdown.service.8 manpage +- handle MACs for "ip=" + "ip=77-77-6f-6f-64-73:dhcp" +- don't explode when mixing BOOTIF and ip= +- 90lvm/module-setup.sh: redirect error message of lvs to /dev/null + +Contributions from: +Harald Hoyer +Will Woods +Baoquan He + +dracut-028 +========== +- full integration of crypto devs in systemd logic +- support for bridge over team and vlan tagged team +- support multiple bonding interfaces +- new kernel command line param "rd.action_on_fail" + to control the emergency action +- support for bridge over a vlan tagged interface +- support for "iso-scan/filename" kernel parameter +- lsinitrd got some love and does not use "file" anymore +- fixed issue with noexec mounted tmp dirs +- FIPS mode fixed +- dracut_install got some love +- fixed some /usr mounting problems +- ifcfg dracut module got some love and fixes +- default installed font is now latarcyrheb-sun16 +- new parameters rd.live.dir and rd.live.squashimg +- lvm: add tools for thin provisioning +- also install non-hwcap libs +- setup correct system time and time zone in initrd +- s390: fixed cms setup +- add systemd-udevd persistent network interface naming + +Contributions from: +Harald Hoyer +Kamil Rytarowski +WANG Chao +Baoquan He +Adam Williamson +Colin Guthrie +Dan Horák +Dave Young +Dennis Gilmore +Dennis Schridde + +dracut-027 +========== +- dracut now has bash-completion +- require bash version 4 +- systemd module now requires systemd >= 199 +- dracut makes use of native systemd initrd units +- added hooks for new-kernel-pkg and kernel-install +- hostonly is now default for fedora +- comply with the BootLoaderSpec paths + http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec +- added rescue module +- host_fs_types is now a hashmap +- new dracut argument "--regenerate-all" +- new dracut argument "--noimageifnotneeded" +- new man page dracut.bootup +- install all host filesystem drivers +- use -D_FILE_OFFSET_BITS=64 to build dracut-install + +dracut-026 +========== +- introduce /usr/lib/dracut/dracut.conf.d/ drop-in directory + + /usr/lib/dracut/dracut.conf.d/*.conf can be overwritten by the same + filenames in /etc/dracut.conf.d. + + Packages should use /usr/lib/dracut/dracut.conf.d rather than + /etc/dracut.conf.d for drop-in configuration files. + + /etc/dracut.conf and /etc/dracut.conf.d belong to the system administrator. + +- uses systemd-198 native initrd units +- totally rely on the fstab-generator in systemd mode for block devices +- dracut systemd now uses dracut.target rather than basic.target +- dracut systemd services optimize themselves away +- fixed hostonly parameter generation +- turn off curl globbing (fixes IPv6) +- modify the udev rules on install and not runtime time +- enable initramfs building without kernel modules (fixed regression) +- in the initqueue/timeout, + reset the main loop counter, as we see new udev events or initqueue/work +- fixed udev rule installation + +dracut-025 +========== +- do not strip signed kernel modules +- add sosreport script and generate /run/initramfs/sosreport.txt +- make short uuid specification for allow-discards work +- turn off RateLimit for the systemd journal +- fixed MAC address assignment +- add systemd checkisomd5 service +- splitout drm kernel modules from plymouth module +- add 'swapoff' to initramfs to fix shutdown/reboot +- add team device support +- add pre-shutdown hook +- kill all processes in shutdown and report remaining ones +- "--device" changed to "--add-device" and "add_device=" added for conf files +- add memory usage trace to different hook points +- cope with optional field #7 in /proc/self/mountinfo +- lots of small bugfixes + +dracut-024 +========== +- new dracut option "--device" +- new dracut kernel command line options "rd.auto" +- new dracut kernel command line options "rd.noverifyssl" +- new dracut option "--kernel-cmdline" and "kernel_cmdline" option for default parameters +- fixes for systemd and crypto +- fix for kexec in shutdown, if not included in initramfs +- create the initramfs non-world readable +- prelink/preunlink in the initramfs +- strip binaries in the initramfs by default now +- various FIPS fixes +- various dracut-install fixes + +dracut-023 +========== +- resume from hibernate fixes +- -N option for --no-hostonly +- support for systemd crypto handling +- new dracut module "crypt-loop" +- deprecate the old kernel command line options +- more documentation +- honor CFLAGS for dracut-install build +- multipath fixes +- / is mounted according to rootflags parameter but forced ro at first. + Later it is remounted according to /etc/fstab + rootflags parameter + and "ro"/"rw". +- support for xfs / reiserfs separate journal device +- new "ro_mnt" option to force ro mount of / and /usr +- root on cifs support +- dracut-install: fixed issue for /var/tmp containing a symlink +- only lazy resolve with ldd, if the /var/tmp partition is not mounted with "noexec" +- i18n: fixed inclusion of "include" keymaps + +dracut-022 +========== +- fixed host-only kernel module bug + +dracut-021 +========== +- fixed systemd in the initramfs (requires systemd >= 187) +- dracut-install: massive speedup with /var on the same filesystem with COW copy +- dracut-install: moved to /usr/lib/dracut until it becomes a general purpose tool +- new options: "rd.usrmount.ro" and "rd.skipfsck" +- less mount/umount +- apply "ro" on the kernel command line also to /usr +- mount according to fstab, if neither "ro" or "rw" is specified +- skip fsck for xfs and btrfs. remount is enough +- give emergency_shell if /usr mount failed +- dracut now uses getopt: + * options can be position independent now!! + * we can now use --option= +- added option "--kver=", and the image location can be omitted + # dracut --kver 3.5.0-0.rc7.git1.2.fc18.x86_64 +- dracut.sh: for --include copy also the symbolic links +- man pages: lsinitrd and mkinitrd added +- network: We do not support renaming in the kernel namespace anymore (as udev does + that not anymore). So, if a user wants to use ifname, he has to rename + to a custom namespace. "eth[0-9]+" is not allowed anymore. !!!!! +- resume: moved the resume process to the initqueue. + This should prevent accidently mounting the root file system. +- testsuite: add support for: make V=1 TESTS="01 20 40" check + $ sudo make V=1 clean check + now runs the testsuite in verbose mode + + $ sudo make TESTS="01 20 40" clean check + now only runs the 01, 20 and 40 tests. + +dracut-020 +========== +- changed rd.dasd kernel parameter +- arm kernel modules added to kernel-modules +- make udevdir systemdutildir systemdsystemunitdir global vars + your distribution should ship those settings in + /etc/dracut.conf.d/01-distro.conf + see dracut.conf.d/fedora.conf.example +- kernel modules are now only handled with /sys/modules and modules.dep +- systemd fixups +- mdraid: wait for md devices to be clean, before shutdown +- ifup fixed for ipv6 +- add PARTUUID as root=PARTUUID= parameter +- fixed instmods() return code and set pipefail globally +- add 04watchdog dracut module +- dracut-shutdown.service: fixed ordering to be before shutdown.target +- make use of "ln -r" instead of shell functions, if new coreutils is installed +- network: support vlan tagged bonding +- new dracut module qemu and qemu-net to install all kernel driver +- fs-lib/fs-lib.sh: removed test mounting of btrfs and xfs +- no more "mknod" in the initramfs!! +- replaced all "tr" calls with "sed" +- speedup with lazy kernel module dependency resolving +- lots of speedup optimizations and last but not least +- dracut-install: + - new binary to significanlty speedup the installation process + - dracut-functions.sh makes use of it, if installed + + +dracut-019 +========== +- initqueue/online hook +- fixes for ifcfg write out +- rootfs-block: avoid remount when options don't change +- Debian multiarch support +- virtfs root filesystem support +- cope with systemd-udevd +- mount tmpfs with strictatime +- include all kernel/drivers/net/phy drivers +- add debug_on() and debug_off() functions +- add arguments for source_hook() and source_all() +- cleanup hook +- plymouth: get consoledev from /sys/class/tty/console/active +- experimental systemd dracut module for systemd in the initramfs +- install xhci-hcd kernel module +- dracut: new "--mount" option +- lsinitrd: new option --printsize +- ARM storage kernel modules added +- s390 cms conf file support +- /etc/initrd-release in the initrd +- vlan support +- full bonding and bridge support +- removed scsi_wait_scan kernel module from standard install +- support rd.luks.allow-discards and honor options in crypttab +- lots of bugfixes + +dracut-018 +========== +- lvm: ignore lvm mirrors +- lsinitrd: handle LZMA images +- iscsi: add rd.iscsi.param +- iscsi: add iscsi interface binding +- new module cms to read and handle z-Series cms config files +- fixed fstab.sys handling +- new dracut option "--tmpdir" +- new dracut option "--no-hostonly" +- nbd: name based nbd connects +- converted manpage and documentation source to asciidoc +- write-ifcfg fixes and cleanups +- ifup is now done in the initqueue +- netroot cleanup +- initqueue/online is now for hooks, which require network +- no more /tmp/root.info +- 98pollcdrom: factored out the ugly cdrom polling in the main loop +- simplified rd.luks.uuid testing +- removed "egrep" and "ls" calls +- speedup kernel module installation +- make bzip2 optional +- lots of bugfixes + +dracut-017 +========== +- a _lot_ faster than dracut-016 in image creation +- systemd service dracut-shutdown.service +- livenet fixes +- ssh-client module install fix +- root=iscsi:... fixed +- lots of restructuring and optimizing in dracut-functions.sh +- usrmount: honor fs_passno in /etc/fstab +- renamed all shell scripts to .sh +- new option "--omit-drivers" and config option "omit_drivers" +- hostonly mode fixups + +dracut-016 +========== +- fixed lsinitrd +- honor binaries in sbin first +- fixed usrmount module +- added systemd service for shutdown +- fixed terminfo on distros with /usr/share/terminfo +- reload udev rules after "pre-trigger" hook +- improved test suite +- new parameter "--omit-drivers" and new conf param omit_drivers +- "--offroot" support for mdraid +- new libs: net-lib.sh, nfs-lib.sh, url-lib.sh, img-lib.sh + full of functions to use in your dracut module + +dracut-015 +========== +- hostonly mode automatically adds command line options for root and /usr +- --add-fstab --mount parameters +- ssh-client module +- --ctty option: add job control +- cleanup /run/initramfs +- convertfs module +- /sbin/ifup can be called directly +- support kernel modules compressed with xz +- s390 iscsi modules added +- terminfo module +- lsinitrd can handle concatened images +- lsinitrd can sort by size + +dracut-014 +========== +- new dracut arguments: + --lvmconf + --nolvmconf + --fscks [LIST] + --nofscks +- new .conf options: + install_items + fscks + nofscks +- new kernel options: + rd.md.ddf + rd.md.waitclean + plymouth.enable +- dracut move from /sbin to /usr/bin +- dracut modules dir moved from /usr/share/dracut to /usr/lib/dracut +- profiling with "dracut --profile" +- new TEST-16-DMSQUASH, test for Fedora LiveCDs +- speedup of initramfs creation +- ask_for_password fallback to CLI +- mdraid completely switched to incremental assembly +- no more cdrom polling +- "switch_root" breakpoint is now very late +- /dev/live is gone +- /dev/root is gone +- fs-lib dracut module for fscks added +- xen dracut module removed +- usb mass storage kernel drivers now included +- usrmount dracut module added: + mount /usr if found in /sysroot/etc/fstab +- only include fsck helper needed for hostonly +- fcoe: support for bnx2fc +- support iSCSI drivers: qla4xxx, cxgb3i, cxgb4i, bnx2i, be2iscsi +- fips-aesni dracut module added +- add install_items to dracut.conf + install_items+=" [ ...] " +- speedup internal testsuite +- internal testsuite: store temporary data in a temporary dir + +dracut-013 +========== +- speedup of initramfs creation +- fixed inst_dir for symbolic links +- add unix kernel module + +dracut-012 +========== +- better fsck handling +- fixed wait condition for LVM volumes +- fix for hardlinks (welcome Debian! :-) +- shutdown bugfixes +- automatic busybox symlink creation +- try to mount /usr, if init points to a path in /usr +- btrfs with multiple devices +- "--force-add" option for dracut, to force-add dracut modules, + without hostonly checks +- lsinitrd also display the initramfs size in human readable form +- livenet module, to mount live-isos over http +- masterkey,ecryptfs,integrity security modules +- initqueue/timeout queue e.g. for starting degraded raids +- "make rpm" creates an rpm with an increasing release number from any + git checkout +- support lvm mirrors +- start degraded lvm mirrors after a timeout +- start degraded md raids after a timeout +- getarg() now returns wildcards without file matching to the current fs +- lots of bugfixes + +dracut-011 +========== +- use udev-168 features for shutting down udev +- introduce "--prefix" to put all initramfs files in e.g "/run/initramfs" +- new shutdown script (called by systemd >= 030) to disassemble the root device +- lots of bugfixes +- new module for gpg-encrypted keys - 91crypt-gpg + +dracut-010 +========== +- lots of bugfixes +- plymouth: use /run/plymouth/pid instead of /run/initramfs/plymouth +- add "/lib/firmware/updates" to default firmware path + +dracut-009 +========== +- dracut generator + - dracut-logger + - xz compression + - better argument handling + +- initramfs + - hooks moved to /lib/dracut/hooks in initramfs + - rd.driver.{blacklist|pre|post} accept comma separated driver list + - iSCSI: iSCSI Boot Firmware Table (iBFT) support + - support for /run + - live image: support for generic rootfs.img (instead of ext3fs.img) + - caps module + - FCoE: EDD support + +dracut-008 +========== +- removed --ignore-kernel-modules option (no longer necessary) +- renamed kernel command line arguments to follow the rd. naming scheme +- merged check, install, installkernel to module-setup.sh +- support for bzip2 and xz compressed initramfs images. +- source code beautification +- lots of documentation +- lsinitrd: "catinitrd" functionality +- dracut: --list-modules +- lvm: support for dynamic LVM SNAPSHOT root volume +- 95fstab-sys: mount all /etc/fstab.sys volumes before switch_root +- 96insmodpost dracut module +- rd.shell=1 per default +- rootfs-block:mount-root.sh add fsck +- busybox shell replacements module +- honor old "real_init=" +- 97biosdevname dracut module + +dracut-007 +========== +- module i18n is no longer fedora/red hat specific (Amadeusz Żołnowski) +- distribution specific conf file +- bootchartd support +- debug module now has fsck +- use "hardlink", if available, to save some space +- /etc/dracut.conf can be overwritten by settings in /etc/dracut.conf.d/*.conf +- gentoo splash module +- --ignore-kernel-modules option +- crypto keys on external devices support +- bugfixes + +dracut-006 +========== +- fixed mdraid with IMSM +- fixed dracut manpages +- dmraid parse different error messages +- add cdrom polling mechanism for slow cdroms +- add module btrfs +- add btrfsctl scan for btrfs multi-devices (raid) +- teach dmsquash live-root to use rootflags +- trigger udev with action=add +- fixed add_drivers handling +- add sr_mod +- use pigz instead of gzip, if available +- boot from LVM mirrors and snapshots +- iscsi: add support for multiple netroot=iscsi: +- Support old version of module-init-tools +- got rid of rdnetdebug +- fixed "ip=auto6" +- dracut.conf: use "+=" as default for config variables +- bugfixes + +dracut-005 +========== +- dcb support to dracut's FCoE support +- add readonly overlay support for dmsquash +- add keyboard kernel modules +- dracut.conf: added add_dracutmodules +- add /etc/dracut.conf.d +- add preliminary IPv6 support +- bugfixes + +dracut-004 +========== +- dracut-lib: read multiple lines from $init/etc/cmdline +- lsinitrd and mkinitrd +- dmsquash: add support for loopmounted *.iso files +- lvm: add rd_LVM_LV and "--poll n" +- user suspend support +- add additional drivers in host-only mode, too +- improved emergency shell +- support for compressed kernel modules +- support for loading Xen modules +- rdloaddriver kernel command line parameter +- man pages for dracut-catimages and dracut-gencmdline +- bugfixes + +dracut-003 +========== +- add debian package modules +- add dracut.conf manpage +- add module 90multipath +- add module 01fips +- crypt: ignore devices in /etc/crypttab (root is not in there) + unless rd_NO_CRYPTTAB is specified +- kernel-modules: add scsi_dh scsi_dh_rdac scsi_dh_emc +- add multinic support +- add s390 zfcp support +- add s390 dasd support +- add s390 network support +- fixed dracut-gencmdline for root=UUID or LABEL +- do not destroy assembled raid arrays if mdadm.conf present +- mount /dev/shm +- let udevd not resolve group and user names +- moved network from udev to initqueue +- improved debug output: specifying "rdinitdebug" now logs + to dmesg, console and /init.log +- strip kernel modules which have no x bit set +- redirect stdin, stdout, stderr all RW to /dev/console + so the user can use "less" to view /init.log and dmesg +- add new device mapper udev rules and dmeventd +- fixed dracut-gencmdline for root=UUID or LABEL +- do not destroy assembled raid arrays if mdadm.conf present +- mount /dev/shm +- let udevd not resolve group and user names +- preserve timestamps of tools on initramfs generation +- generate symlinks for binaries correctly +- moved network from udev to initqueue +- mount nfs3 with nfsvers=3 option and retry with nfsvers=2 +- fixed nbd initqueue-finished +- improved debug output: specifying "rdinitdebug" now logs + to dmesg, console and /init.log +- strip kernel modules which have no x bit set +- redirect stdin, stdout, stderr all RW to /dev/console + so the user can use "less" to view /init.log and dmesg +- make install of new dm/lvm udev rules optionally +- add new device mapper udev rules and dmeventd +- Fix LiveCD boot regression +- bail out if selinux policy could not be loaded and + selinux=0 not specified on kernel command line +- do not cleanup dmraids +- copy over lvm.conf + +dracut-002 +========== +- add ifname= argument for persistent netdev names +- new /initqueue-finished to check if the main loop can be left +- copy mdadm.conf if --mdadmconf set or mdadmconf in dracut.conf +- plymouth: use plymouth-populate-initrd +- add add_drivers for dracut and dracut.conf +- add modprobe scsi_wait_scan to be sure everything was scanned +- fix for several problems with md raid containers +- fix for selinux policy loading +- fix for mdraid for IMSM +- fix for bug, which prevents installing 61-persistent-storage.rules (bug #520109) +- fix for missing grep for md + +dracut-001 +========== +- better --hostonly checks +- better lvm/mdraid/dmraid handling +- fcoe booting support + Supported cmdline formats: + fcoe=: + fcoe=: + + Note currently only nodcb is supported, the dcb option is reserved for + future use. + + Note letters in the macaddress must be lowercase! + + Examples: + fcoe=eth0:nodcb + fcoe=4A:3F:4C:04:F8:D7:nodcb + +- Syslog support for dracut + This module provides syslog functionality in the initrd. + This is especially interesting when complex configuration being + used to provide access to the device the rootfs resides on. + + +dracut-0.9 +========== +- let plymouth attach to the terminal (nice text output now) +- new kernel command line parameter "rdinfo" show dracut output, even when + "quiet" is specified +- rd_LUKS_UUID is now handled correctly +- dracut-gencmdline: rd_LUKS_UUID and rd_MD_UUID is now correctly generated +- now generates initrd-generic with around 15MB +- smaller bugfixes + +dracut-0.8 +========== +- iSCSI with username and password +- support for live images (dmsquashed live images) +- iscsi_firmware fixes +- smaller images +- bugfixes + +dracut-0.7 +========== +- dracut: strip binaries in initramfs + + --strip + strip binaries in the initramfs (default) + + --nostrip + do not strip binaries in the initramfs +- dracut-catimages + + Usage: ./dracut-catimages [OPTION]... + [...] + Creates initial ramdisk image by concatenating several images from the + command + line and /boot/dracut/ + + -f, --force Overwrite existing initramfs file. + -i, --imagedir Directory with additional images to add + (default: /boot/dracut/) + -o, --overlaydir Overlay directory, which contains files that + will be used to create an additional image + --nooverlay Do not use the overlay directory + --noimagedir Do not use the additional image directory + -h, --help This message + --debug Output debug information of the build process + -v, --verbose Verbose output during the build process + +- s390 dasd support + +dracut-0.6 +========== +- dracut: add --kernel-only and --no-kernel arguments + + --kernel-only + only install kernel drivers and firmware files + + --no-kernel + do not install kernel drivers and firmware files + + All kernel module related install commands moved from "install" + to "installkernel". + + For "--kernel-only" all installkernel scripts of the specified + modules are used, regardless of any checks, so that all modules + which might be needed by any dracut generic image are in. + + The basic idea is to create two images. One image with the kernel + modules and one without. So if the kernel changes, you only have + to replace one image. + + Grub and the kernel can handle multiple images, so grub entry can + look like this: + + title Fedora (2.6.29.5-191.fc11.i586) + root (hd0,0) + kernel /vmlinuz-2.6.29.5-191.fc11.i586 ro rhgb quiet + initrd /initrd-20090722.img /initrd-kernel-2.6.29.5-191.fc11.i586.img /initrd-config.img + + initrd-20090722.img + the image provided by the initrd rpm + one old backup version is kept like with the kernel + + initrd-kernel-2.6.29.5-191.fc11.i586.img + the image provided by the kernel rpm + + initrd-config.img + optional image with local configuration files + +- dracut: add --kmoddir directory, where to look for kernel modules + + -k, --kmoddir [DIR] + specify the directory, where to look for kernel modules + + + +dracut-0.5 +========== +- more generic (all plymouth modules, all keyboards, all console fonts) +- more kernel command line parameters (see also man dracut(8)) +- a helper tool, which generates the kernel command line (dracut-gencmdline) +- bridged network boot +- a lot of new command line parameter + +dracut-0.4 +========== +- bugfixes +- firmware loading support +- new internal queue (initqueue) + initqueue now loops until /dev/root exists or root is mounted + + init now has the following points to inject scripts: + + /cmdline/*.sh + scripts for command line parsing + + /pre-udev/*.sh + scripts to run before udev is started + + /pre-trigger/*.sh + scripts to run before the main udev trigger is pulled + + /initqueue/*.sh + runs in parallel to the udev trigger + Udev events can add scripts here with /sbin/initqueue. + If /sbin/initqueue is called with the "--onetime" option, the script + will be removed after it was run. + If /initqueue/work is created and udev >= 143 then this loop can + process the jobs in parallel to the udevtrigger. + If the udev queue is empty and no root device is found or no root + filesystem was mounted, the user will be dropped to a shell after + a timeout. + Scripts can remove themselves from the initqueue by "rm $job". + + /pre-mount/*.sh + scripts to run before the root filesystem is mounted + NFS is an exception, because it has no device node to be created + and mounts in the udev events + + /mount/*.sh + scripts to mount the root filesystem + NFS is an exception, because it has no device node to be created + and mounts in the udev events + If the udev queue is empty and no root device is found or no root + filesystem was mounted, the user will be dropped to a shell after + a timeout. + + /pre-pivot/*.sh + scripts to run before the real init is executed and the initramfs + disappears + All processes started before should be killed here. + + The behaviour of the dmraid module demonstrates how to use the new + mechanism. If it detects a device which is part of a raidmember from a + udev rule, it installs a job to scan for dmraid devices, if the udev + queue is empty. After a scan, it removes itsself from the queue. + + + +dracut-0.3 +========== + +- first public version + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..05a32b0 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,38 @@ +pkgname=dracut-git +pkgver=1 +pkgrel=1 +pkgdesc="Initramfs generation utility" +arch=('i686' 'x86_64') +url="https://dracut.wiki.kernel.org/" +license=('GPL') +conflicts=('dracut' 'mkinitcpio') +provides=('dracut=9999' 'mkinitcpio=9999') +depends=('bash') +optdepends=('cryptsetup' 'lvm2') +makedepends=('libxslt') +backup=(etc/dracut.conf) +source=() +md5sums=() + +# out of tree builds disallowed for this PKGFILE +BUILDDIR="${PWD}" +PKGDEST="${PWD}" +SRCDEST="" +SRCPKGDEST="" +LOGDEST="" + +pkgver() { + cd .. + desc="$(git describe)" + printf "%s.%s.%s" ${desc//-/ } +} + +build() { + cd .. + make sysconfdir=/etc || return 1 +} + +package() { + cd .. + make DESTDIR="${pkgdir}" sysconfdir=/etc install || return 1 +} diff --git a/README b/README new file mode 100644 index 0000000..ff374af --- /dev/null +++ b/README @@ -0,0 +1,86 @@ +dracut +------ +dracut is an event driven initramfs infrastructure. + +dracut (the tool) is used to create an initramfs image by copying tools +and files from an installed system and combining it with the +dracut framework, usually found in /usr/lib/dracut/modules.d. + +Unlike existing initramfs's, this is an attempt at having as little as +possible hard-coded into the initramfs as possible. The initramfs has +(basically) one purpose in life -- getting the rootfs mounted so that +we can transition to the real rootfs. This is all driven off of +device availability. Therefore, instead of scripts hard-coded to do +various things, we depend on udev to create device nodes for us and +then when we have the rootfs's device node, we mount and carry on. +This helps to keep the time required in the initramfs as little as +possible so that things like a 5 second boot aren't made impossible as +a result of the very existence of an initramfs. It's likely that +we'll grow some hooks for running arbitrary commands in the flow of +the script, but it's worth trying to resist the urge as much as we can +as hooks are guaranteed to be the path to slow-down. + +Most of the initramfs generation functionality in dracut is provided by a bunch +of generator modules that are sourced by the main dracut script to install +specific functionality into the initramfs. They live in the modules.d +subdirectory, and use functionality provided by dracut-functions to do their +work. + +Some general rules for writing modules: + * Use one of the inst family of functions to actually install files + on to the initramfs. They handle mangling the pathnames and (for binaries, + scripts, and kernel modules) installing dependencies as appropriate so + you do not have to. + * Scripts that end up on the initramfs should be POSIX compliant. dracut + will try to use /bin/dash as /bin/sh for the initramfs if it is available, + so you should install it on your system -- dash aims for strict POSIX + compliance to the extent possible. + * Hooks MUST be POSIX compliant -- they are sourced by the init script, + and having a bashism break your user's ability to boot really sucks. + * Generator modules should have a two digit numeric prefix -- they run in + ascending sort order. Anything in the 90-99 range is stuff that dracut + relies on, so try not to break those hooks. + * Hooks must have a .sh extension. + * Generator modules are described in more detail in README.modules. + * We have some breakpoints for debugging your hooks. If you pass 'rdbreak' + as a kernel parameter, the initramfs will drop to a shell just before + switching to a new root. You can pass 'rdbreak=hookpoint', and the initramfs + will break just before hooks in that hookpoint run. + +Also, there is an attempt to keep things as distribution-agnostic as +possible. Every distribution has their own tool here and it's not +something which is really interesting to have separate across them. +So contributions to help decrease the distro-dependencies are welcome. + +Currently dracut lives on github.com and kernel.org. + +The tarballs can be found here: + http://www.kernel.org/pub/linux/utils/boot/dracut/ + ftp://ftp.kernel.org/pub/linux/utils/boot/dracut/ + +Git: + git://git.kernel.org/pub/scm/boot/dracut/dracut.git + http://git.kernel.org/pub/scm/boot/dracut/dracut.git + https://git.kernel.org/pub/scm/boot/dracut/dracut.git + + git@github.com:dracutdevs/dracut.git + +Git Web: + https://github.com/dracutdevs/dracut.git + + http://git.kernel.org/?p=boot/dracut/dracut.git + +Project Documentation: + http://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html + +Project Wiki: + http://dracut.wiki.kernel.org + +See the TODO file for things which still need to be done and HACKING for +some instructions on how to get started. There is also a mailing list +that is being used for the discussion -- initramfs@vger.kernel.org. +It is a typical vger list, send mail to majordomo@vger.kernel.org with body +of 'subscribe initramfs email@host.com' + + +Licensed under the GPLv2 diff --git a/README.generic b/README.generic new file mode 100644 index 0000000..58889ac --- /dev/null +++ b/README.generic @@ -0,0 +1,13 @@ +To build a generic initramfs, you have to install the following software packages: + * device-mapper + * cryptsetup-luks + * rpcbind nfs-utils + * lvm2 + * iscsi-initiator-utils + * nbd + * mdadm + * net-tools iproute + +Generic initramfs'es are huge (usually over 10 megs in size uncompressed), but +should be able to automatically boot any bootable configuration with appropriate +boot flags (root device, network configuration information, etc.) \ No newline at end of file diff --git a/README.kernel b/README.kernel new file mode 100644 index 0000000..69751eb --- /dev/null +++ b/README.kernel @@ -0,0 +1,3 @@ +"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/README.md b/README.md new file mode 100644 index 0000000..36ae7e1 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# dracut - master branch + +dracut is an initramfs infrastructure. + +## Travis + +[![Build Status](https://travis-ci.org/dracutdevs/dracut.svg?branch=master)](https://travis-ci.org/dracutdevs/dracut) + +## CentOS CI + +[![Build Status](https://ci.centos.org/job/dracut-push-master/badge/icon)](https://ci.centos.org/job/dracut-push-master/) + +- Test 01: [![Test 01](https://ci.centos.org/job/dracut-matrix-master/TESTS=01,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=01,label=dracut-ci-slave01/) +- Test 02: [![Test 02](https://ci.centos.org/job/dracut-matrix-master/TESTS=02,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=02,label=dracut-ci-slave01/) +- Test 03: [![Test 03](https://ci.centos.org/job/dracut-matrix-master/TESTS=03,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=03,label=dracut-ci-slave01/) +- Test 04: [![Test 04](https://ci.centos.org/job/dracut-matrix-master/TESTS=04,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=04,label=dracut-ci-slave01/) +- Test 10: [![Test 10](https://ci.centos.org/job/dracut-matrix-master/TESTS=10,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=10,label=dracut-ci-slave01/) +- Test 11: [![Test 11](https://ci.centos.org/job/dracut-matrix-master/TESTS=11,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=11,label=dracut-ci-slave01/) +- Test 12: [![Test 12](https://ci.centos.org/job/dracut-matrix-master/TESTS=12,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=12,label=dracut-ci-slave01/) +- Test 13: [![Test 13](https://ci.centos.org/job/dracut-matrix-master/TESTS=13,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=13,label=dracut-ci-slave01/) +- Test 14: [![Test 14](https://ci.centos.org/job/dracut-matrix-master/TESTS=14,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=14,label=dracut-ci-slave01/) +- Test 15: [![Test 15](https://ci.centos.org/job/dracut-matrix-master/TESTS=15,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=15,label=dracut-ci-slave01/) +- Test 16: [![Test 16](https://ci.centos.org/job/dracut-matrix-master/TESTS=16,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=16,label=dracut-ci-slave01/) +- Test 17: [![Test 17](https://ci.centos.org/job/dracut-matrix-master/TESTS=17,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=17,label=dracut-ci-slave01/) +- Test 20: [![Test 20](https://ci.centos.org/job/dracut-matrix-master/TESTS=20,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=20,label=dracut-ci-slave01/) +- Test 30: [![Test 30](https://ci.centos.org/job/dracut-matrix-master/TESTS=30,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=30,label=dracut-ci-slave01/) +- Test 31: [![Test 31](https://ci.centos.org/job/dracut-matrix-master/TESTS=31,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=31,label=dracut-ci-slave01/) +- Test 40: [![Test 40](https://ci.centos.org/job/dracut-matrix-master/TESTS=40,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=40,label=dracut-ci-slave01/) +- Test 50: [![Test 50](https://ci.centos.org/job/dracut-matrix-master/TESTS=50,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=50,label=dracut-ci-slave01/) +- Test 70: [![Test 70](https://ci.centos.org/job/dracut-matrix-master/TESTS=70,label=dracut-ci-slave01/badge/icon)](https://ci.centos.org/job/dracut-matrix-master/TESTS=70,label=dracut-ci-slave01/) diff --git a/README.modules b/README.modules new file mode 100644 index 0000000..a50bed5 --- /dev/null +++ b/README.modules @@ -0,0 +1,112 @@ +Most of the functionality that dracut implements are actually implemented +by dracut modules. dracut modules live in modules.d, and have the following +structure: + +dracut_install_dir/modules.d/ + 00modname/ + module-setup.sh + check + + +00modname: The name of the module prefixed by a two-digit numeric sort code. + The numeric code must be present and in the range of 00 - 99. + Modules with lower numbers are installed first. This is important + because the dracut install functions (which install files onto + the initrd) refuse to overwrite already installed files. This makes + it easy for an earlier module to override the functionality of a + later module, so that you can have a distro or system specific + module override or modify the functionality of a generic module + without having to patch the more generic module. + +module-setup.sh: + dracut sources this script to install the functionality that a + module implements onto the initrd. For the most part, this amounts + to copying files from the host system onto the initrd in a controlled + manner. + +install(): + This function of module-setup.sh is called to install all + non-kernel files. dracut supplies several install functions that are + specialized for different file types. Browse through dracut-functions + fore more details. dracut also provides a $moddir variable if you + need to install a file from the module directory, such as an initrd + hook, a udev rule, or a specialized executable. + +installkernel(): + This function of module-setup.sh is called to install all + kernel related files. + + +check(): + dracut calls this function to check and see if a module can be installed + on the initrd. + + When called without options, check should check to make sure that + any files it needs to install into the initrd from the host system + are present. It should exit with a 0 if they are, and a 1 if they are + not. + + When called with $hostonly set, it should perform the same check + that it would without it set, and it should also check to see if the + functionality the module implements is being used on the host system. + For example, if this module handles installing support for LUKS + encrypted volumes, it should return 0 if all the tools to handle + encrpted volumes are available and the host system has the root + partition on an encrypted volume, 1 otherwise. + +depends(): + This function should output a list of dracut modules + that it relies upon. An example would be the nfs and iscsi modules, + which rely on the network module to detect and configure network + interfaces. + +Any other files in the module will not be touched by dracut directly. + +You are encouraged to provide a README that describes what the module is for. + + +HOOKS +===== + +init has the following hook points to inject scripts: + +/lib/dracut/hooks/cmdline/*.sh + scripts for command line parsing + +/lib/dracut/hooks/pre-udev/*.sh + scripts to run before udev is started + +/lib/dracut/hooks/pre-trigger/*.sh + scripts to run before the main udev trigger is pulled + +/lib/dracut/hooks/initqueue/*.sh + runs in parallel to the udev trigger + Udev events can add scripts here with /sbin/initqueue. + If /sbin/initqueue is called with the "--onetime" option, the script + will be removed after it was run. + If /lib/dracut/hooks/initqueue/work is created and udev >= 143 then + this loop can process the jobs in parallel to the udevtrigger. + If the udev queue is empty and no root device is found or no root + filesystem was mounted, the user will be dropped to a shell after + a timeout. + Scripts can remove themselves from the initqueue by "rm $job". + +/lib/dracut/hooks/pre-mount/*.sh + scripts to run before the root filesystem is mounted + Network filesystems like NFS that do not use device files are an + exception. Root can be mounted already at this point. + +/lib/dracut/hooks/mount/*.sh + scripts to mount the root filesystem + If the udev queue is empty and no root device is found or no root + filesystem was mounted, the user will be dropped to a shell after + a timeout. + +/lib/dracut/hooks/pre-pivot/*.sh + scripts to run before latter initramfs cleanups + +/lib/dracut/hooks/cleanup/*.sh + scripts to run before the real init is executed and the initramfs + disappears + All processes started before should be killed here. + diff --git a/README.testsuite b/README.testsuite new file mode 100644 index 0000000..de6c7b8 --- /dev/null +++ b/README.testsuite @@ -0,0 +1,45 @@ +For the testsuite to work, you will have to install at least the following software packages: +dash \ +asciidoc \ +mdadm \ +lvm2 \ +dmraid \ +cryptsetup \ +nfs-utils \ +nbd \ +dhcp-server \ +scsi-target-utils \ +iscsi-initiator-utils \ +strace \ +syslinux \ +python-imgcreate \ +genisoimage \ +btrfs-progs \ +kmod-devel \ +gcc \ +bzip2 \ +xz \ +tar \ +wget \ +rpm-build \ +${NULL} + +TEST-04-FULL-SYSTEMD: systemd >= 187 + +How to run the testsuite: + +$ sudo make clean check + +in verbose mode: +$ sudo make V=1 clean check + +only specific test: +$ sudo make TESTS="01 20 40" clean check +only runs the 01, 20 and 40 tests. + +debug a specific test case: +$ cd TEST-01-BASIC +$ sudo make clean setup run +... change some kernel parameters ... +$ sudo make run +to run the test without doing the setup diff --git a/TODO b/TODO new file mode 100644 index 0000000..f4fc208 --- /dev/null +++ b/TODO @@ -0,0 +1,51 @@ +Current TODO list, broken into things which are relevant for the +initramfs itself (/init et al) vs the generator. +A lot of things are/should be marked with "FIXME" in the code. + +Items are ordered in priority. + +INITRAMFS TODO + +- search domain string +- allow dual stack configuration (IPv4, IPv6) for the same interface +- "bind-mount" kernel drivers in real root for the rescue image, + if the real root does not have any kernel modules for this kernel + https://bugzilla.redhat.com/show_bug.cgi?id=1046510 +- use info and warn prefix +- generate systemd unit dracut-initramfs-restore in /run/systemd dynamically +- put "root=" parsing hooks in separate hook dir +- call "root=" parsing hooks after getting new rootpath from dhcp +- put mount hook in main initqueue loop / careful about resume! +- the hard-coded list of udev rules that we care about is kind of lame. +- panic fallback +- progress indication for fsck https://bugzilla.redhat.com/show_bug.cgi?id=827118 +- domain, searchdomain https://bugzilla.redhat.com/show_bug.cgi?id=840778 +- probably fix "--include" https://bugzilla.redhat.com/show_bug.cgi?id=849338 + +GENERATOR TODO + +- report errors on missing files in check() +- remove wait for swap devs, if no "resume=" is given on the kernel command line +- remove wait for swap devs, if the "resume" dracut module is not included (omitted) +- add presets (predefined set of modules) +- add interpreter/plugin-scripts to be sourced at the beginning or end (can use dracut-functions) +- add mechanism for module specific command line options +- pkg-config integration, to make it easy for other packages to use us. +- default module specification could use some work +- udev rule copying, as mentioned above, is a bit too hard-coded + +- dracut-install parse LD_SHOW_AUXV="" AT_PLATFORM for lib install + +CODE TODO + +- document more functions +- make function vars local, and prefix with "_" + +Future Enhancement Requests + +- run ssh server to enter crypto password or perform debugging (supported by debian) +- https://bugzilla.redhat.com/show_bug.cgi?id=524727 - dracut + encrypted root + networking + +- lsinitrd --print-cmdline +- dracut --print-cmdline error if additional arguments +- library for cmdline diff --git a/configure b/configure new file mode 100755 index 0000000..b55fb60 --- /dev/null +++ b/configure @@ -0,0 +1,85 @@ +#!/bin/bash + +# We don't support srcdir != builddir +echo \#buildapi-variable-no-builddir >/dev/null + +prefix=/usr + +enable_documentation=yes + +PKG_CONFIG="${PKG_CONFIG:-pkg-config}" + +# 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 "$1" <<< "${BASH_REMATCH[1]}" + else + read "$1" <<< "$3" + # There is no way to shift our callers args, so + # return 1 to indicate they should do it instead. + return 1 + fi + return 0 +} + +while (($# > 0)); do + case "${1%%=*}" in + --prefix) read_arg prefix "$@" || shift;; + --libdir) read_arg libdir "$@" || shift;; + --datadir) read_arg datadir "$@" || shift;; + --sysconfdir) read_arg sysconfdir "$@" || shift;; + --sbindir) read_arg sbindir "$@" || shift;; + --mandir) read_arg mandir "$@" || shift;; + --disable-documentation) enable_documentation=no;; + --program-prefix) read_arg programprefix "$@" || shift;; + --exec-prefix) read_arg execprefix "$@" || shift;; + --bindir) read_arg bindir "$@" || shift;; + --includedir) read_arg includedir "$@" || shift;; + --libexecdir) read_arg libexecdir "$@" || shift;; + --localstatedir) read_arg localstatedir "$@" || shift;; + --sharedstatedir) read_arg sharedstatedir "$@" || shift;; + --infodir) read_arg infodir "$@" || shift;; + --systemdsystemunitdir) read_arg systemdsystemunitdir "$@" || shift;; + --bashcompletiondir) read_arg bashcompletiondir "$@" || shift;; + *) echo "Ignoring unknown option '$1'";; + esac + shift +done + +if ! ${PKG_CONFIG} --exists --print-errors " libkmod >= 23 "; then + echo "dracut needs pkg-config and libkmod >= 23." >&2 + exit 1 +fi + +cat > Makefile.inc.$$ <= 23 ") +KMOD_LIBS ?= $(${PKG_CONFIG} --libs " libkmod >= 23 ") +EOF + +{ + [[ $programprefix ]] && echo "programprefix ?= ${programprefix}" + [[ $execprefix ]] && echo "execprefix ?= ${execprefix}" + [[ $includedir ]] && echo "includedir ?= ${includedir}" + [[ $libexecdir ]] && echo "libexecdir ?= ${libexecdir}" + [[ $localstatedir ]] && echo "localstatedir ?= ${localstatedir}" + [[ $sharedstatedir ]] && echo "sharedstatedir ?= ${sharedstatedir}" + [[ $infodir ]] && echo "infodir ?= ${infodir}" + [[ $systemdsystemunitdir ]] && echo "systemdsystemunitdir ?= ${systemdsystemunitdir}" + [[ $bashcompletiondir ]] && echo "bashcompletiondir ?= ${bashcompletiondir}" +} >> Makefile.inc.$$ + +mv Makefile.inc.$$ Makefile.inc diff --git a/dracut-bash-completion.sh b/dracut-bash-completion.sh new file mode 100644 index 0000000..17374bf --- /dev/null +++ b/dracut-bash-completion.sh @@ -0,0 +1,78 @@ +# +# Copyright 2013 Red Hat, Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +__contains_word () { + local word=$1; shift + for w in $*; do [[ $w = $word ]] && return 0; done + return 1 +} + +_dracut() { + local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} + local -A OPTS=( + [STANDALONE]='-f -v -q -l -H -h -M -N + --ro-mnt --force --kernel-only --no-kernel --strip --nostrip + --hardlink --nohardlink --noprefix --mdadmconf --nomdadmconf + --lvmconf --nolvmconf --debug --profile --verbose --quiet + --local --hostonly --no-hostonly --fstab --help --bzip2 --lzma + --xz --zstd --no-compress --gzip --list-modules --show-modules --keep + --printsize --regenerate-all --noimageifnotneeded --early-microcode + --no-early-microcode --print-cmdline --reproducible --uefi' + + [ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers + --omit-drivers --modules --omit --drivers --filesystems --install + --fwdir --libdirs --fscks --add-fstab --mount --device --nofscks + --kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix + --kernel-cmdline --sshkey --persistent-policy --install-optional + --loginstall --uefi-stub --kernel-image + ' + ) + + if __contains_word "$prev" ${OPTS[ARG]}; then + case $prev in + --kmoddir|-k|--fwdir|--confdir|--tmpdir) + comps=$(compgen -d -- "$cur") + compopt -o filenames + ;; + -c|--conf|--sshkey|--add-fstab|--add-device|-I|--install|--install-optional) + comps=$(compgen -f -- "$cur") + compopt -o filenames + ;; + -a|-m|-o|--add|--modules|--omit) + comps=$(dracut --list-modules 2>/dev/null) + ;; + --persistent-policy) + comps=$(cd /dev/disk/; echo *) + ;; + --kver) + comps=$(cd /lib/modules; echo [0-9]*) + ;; + *) + return 0 + ;; + esac + COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) + return 0 + fi + + if [[ $cur = -* ]]; then + COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) + return 0 + fi +} + +complete -F _dracut dracut diff --git a/dracut-catimages.8.asc b/dracut-catimages.8.asc new file mode 100644 index 0000000..57f422c --- /dev/null +++ b/dracut-catimages.8.asc @@ -0,0 +1,59 @@ +DRACUT-CATIMAGES(8) +=================== +:doctype: manpage +:man source: dracut +:man manual: dracut + +NAME +---- +dracut-catimages - creates initial ramdisk image by concatenating images + +SYNOPSIS +-------- +**dracut-catimages** [_OPTION_...] __ [__...] + +DESCRIPTION +----------- +dracut-catimages creates an initial ramdisk image by concatenating several +images from the command line and /boot/dracut/*.img + +OPTIONS +------- +**-f, --force**:: + overwrite existing initramfs file. + +**-i, --imagedir**:: + Directory with additional images to add (default: /boot/dracut/) + +**-o, --overlaydir**:: + Overlay directory, which contains additional files that will be used to + create an additional image + +**--nooverlay**:: Do not use the overlay directory + +**--noimagedir**:: Do not use the additional image directory + +**-h, --help**:: display help text and exit. + +**--debug**:: output debug information of the build process + +**-v, --verbose**:: verbose output during the build process + +FILES +----- +_/boot/dracut/*.img_:: + images to work with + +AUTHORS +------- +Harald Hoyer + +AVAILABILITY +------------ +The dracut-catimages command is part of the dracut package and is available from +link:$$https://dracut.wiki.kernel.org$$[https://dracut.wiki.kernel.org] + +SEE ALSO +-------- +*dracut*(8) + diff --git a/dracut-catimages.sh b/dracut-catimages.sh new file mode 100755 index 0000000..1f53a2d --- /dev/null +++ b/dracut-catimages.sh @@ -0,0 +1,128 @@ +#!/bin/bash --norc +# +# Copyright 2009 Red Hat, Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +dwarning() { + echo "Warning: $@" >&2 +} + +dinfo() { + [[ $beverbose ]] && echo "$@" >&2 +} + +derror() { + echo "Error: $@" >&2 +} + +usage() { +# 80x25 linebreak here ^ + cat << EOF +Usage: $0 [OPTION]... [...] +Creates initial ramdisk image by concatenating several images from the command +line and /boot/dracut/ + + -f, --force Overwrite existing initramfs file. + -i, --imagedir Directory with additional images to add + (default: /boot/dracut/) + -o, --overlaydir Overlay directory, which contains files that + will be used to create an additional image + --nooverlay Do not use the overlay directory + --noimagedir Do not use the additional image directory + -h, --help This message + --debug Output debug information of the build process + -v, --verbose Verbose output during the build process +EOF +} + + +imagedir=/boot/dracut/ +overlay=/var/lib/dracut/overlay + +while (($# > 0)); do + case $1 in + -f|--force) force=yes;; + -i|--imagedir) imagedir=$2;shift;; + -o|--overlaydir) overlay=$2;shift;; + --nooverlay) no_overlay=yes;shift;; + --noimagedir) no_imagedir=yes;shift;; + -h|--help) usage; exit 1 ;; + --debug) debug="yes";; + -v|--verbose) beverbose="yes";; + -*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;; + *) break ;; + esac + shift +done + +outfile=$1; shift + +if [[ -z $outfile ]]; then + derror "No output file specified." + usage + exit 1 +fi + +baseimage=$1; shift + +if [[ -z $baseimage ]]; then + derror "No base image specified." + usage + exit 1 +fi + +if [[ -f $outfile && ! $force ]]; then + derror "Will not override existing initramfs ($outfile) without --force" + exit 1 +fi + +if [[ ! $no_imagedir && ! -d $imagedir ]]; then + derror "Image directory $overlay is not a directory" + exit 1 +fi + +if [[ ! $no_overlay && ! -d $overlay ]]; then + derror "Overlay $overlay is not a directory" + exit 1 +fi + +if [[ ! $no_overlay ]]; then + ofile="$imagedir/90-overlay.img" + dinfo "Creating image $ofile from directory $overlay" + type pigz &>/dev/null && gzip=pigz || gzip=gzip + ( cd "$overlay"; find . |cpio --quiet -H newc -o |$gzip -9 > "$ofile"; ) +fi + +if [[ ! $no_imagedir ]]; then + for i in "$imagedir/"*.img; do + [[ -f $i ]] && images+=("$i") + done +fi + +images+=($@) + +dinfo "Using base image $baseimage" +cat -- "$baseimage" > "$outfile" + +for i in "${images[@]}"; do + dinfo "Appending $i" + cat -- "$i" >> "$outfile" +done + +dinfo "Created $outfile" + +exit 0 diff --git a/dracut-functions.sh b/dracut-functions.sh new file mode 100755 index 0000000..1431dd1 --- /dev/null +++ b/dracut-functions.sh @@ -0,0 +1,709 @@ +#!/bin/bash +# +# functions used by dracut and other tools. +# +# Copyright 2005-2009 Red Hat, Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +export LC_MESSAGES=C + +# is_func +# Check whether $1 is a function. +is_func() { + [[ "$(type -t "$1")" = "function" ]] +} + + +# Generic substring function. If $2 is in $1, return 0. +strstr() { [[ $1 = *"$2"* ]]; } +# Generic glob matching function. If glob pattern $2 matches anywhere in $1, OK +strglobin() { [[ $1 = *$2* ]]; } +# Generic glob matching function. If glob pattern $2 matches all of $1, OK +strglob() { [[ $1 = $2 ]]; } +# returns OK if $1 contains literal string $2 at the beginning, and isn't empty +str_starts() { [ "${1#"$2"*}" != "$1" ]; } +# returns OK if $1 contains literal string $2 at the end, and isn't empty +str_ends() { [ "${1%*"$2"}" != "$1" ]; } + +# find a binary. If we were not passed the full path directly, +# search in the usual places to find the binary. +find_binary() { + if [[ -z ${1##/*} ]]; then + if [[ -x $1 ]] || { [[ "$1" == *.so* ]] && ldd "$1" &>/dev/null; }; then + printf "%s\n" "$1" + return 0 + fi + fi + + type -P "${1##*/}" +} + +ldconfig_paths() +{ + ldconfig -pN 2>/dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq +} + +# Version comparision function. Assumes Linux style version scheme. +# $1 = version a +# $2 = comparision op (gt, ge, eq, le, lt, ne) +# $3 = version b +vercmp() { + local _n1=(${1//./ }) _op=$2 _n2=(${3//./ }) _i _res + + for ((_i=0; ; _i++)) + do + if [[ ! ${_n1[_i]}${_n2[_i]} ]]; then _res=0 + elif ((${_n1[_i]:-0} > ${_n2[_i]:-0})); then _res=1 + elif ((${_n1[_i]:-0} < ${_n2[_i]:-0})); then _res=2 + else continue + fi + break + done + + case $_op in + gt) ((_res == 1));; + ge) ((_res != 2));; + eq) ((_res == 0));; + le) ((_res != 1));; + lt) ((_res == 2));; + ne) ((_res != 0));; + esac +} + +# Create all subdirectories for given path without creating the last element. +# $1 = path +mksubdirs() { + [[ -e ${1%/*} ]] || mkdir -m 0755 -p -- "${1%/*}" +} + +# Function prints global variables in format name=value line by line. +# $@ = list of global variables' name +print_vars() { + local _var _value + + for _var in "$@" + do + eval printf -v _value "%s" \""\$$_var"\" + [[ ${_value} ]] && printf '%s="%s"\n' "$_var" "$_value" + done +} + +# normalize_path +# Prints the normalized path, where it removes any duplicated +# and trailing slashes. +# Example: +# $ normalize_path ///test/test// +# /test/test +normalize_path() { + shopt -q -s extglob + set -- "${1//+(\/)//}" + shopt -q -u extglob + printf "%s\n" "${1%/}" +} + +# convert_abs_rel +# Prints the relative path, when creating a symlink to from . +# Example: +# $ convert_abs_rel /usr/bin/test /bin/test-2 +# ../../bin/test-2 +# $ ln -s $(convert_abs_rel /usr/bin/test /bin/test-2) /usr/bin/test +convert_abs_rel() { + local __current __absolute __abssize __cursize __newpath + local -i __i __level + + set -- "$(normalize_path "$1")" "$(normalize_path "$2")" + + # corner case #1 - self looping link + [[ "$1" == "$2" ]] && { printf "%s\n" "${1##*/}"; return; } + + # corner case #2 - own dir link + [[ "${1%/*}" == "$2" ]] && { printf ".\n"; return; } + + IFS="/" __current=($1) + IFS="/" __absolute=($2) + + __abssize=${#__absolute[@]} + __cursize=${#__current[@]} + + while [[ "${__absolute[__level]}" == "${__current[__level]}" ]] + do + (( __level++ )) + if (( __level > __abssize || __level > __cursize )) + then + break + fi + done + + for ((__i = __level; __i < __cursize-1; __i++)) + do + if ((__i > __level)) + then + __newpath=$__newpath"/" + fi + __newpath=$__newpath".." + done + + for ((__i = __level; __i < __abssize; __i++)) + do + if [[ -n $__newpath ]] + then + __newpath=$__newpath"/" + fi + __newpath=$__newpath${__absolute[__i]} + done + + printf "%s\n" "$__newpath" +} + + +# get_fs_env +# Get and the ID_FS_TYPE variable from udev for a device. +# Example: +# $ get_fs_env /dev/sda2 +# ext4 +get_fs_env() { + local evalstr + local found + + [[ $1 ]] || return + unset ID_FS_TYPE + ID_FS_TYPE=$(blkid -u filesystem -o export -- "$1" \ + | while read line || [ -n "$line" ]; do + if [[ "$line" == TYPE\=* ]]; then + printf "%s" "${line#TYPE=}"; + exit 0; + fi + done) + if [[ $ID_FS_TYPE ]]; then + printf "%s" "$ID_FS_TYPE" + return 0 + fi + return 1 +} + +# get_maj_min +# Prints the major and minor of a device node. +# Example: +# $ get_maj_min /dev/sda2 +# 8:2 +get_maj_min() { + local _maj _min _majmin + _majmin="$(stat -L -c '%t:%T' "$1" 2>/dev/null)" + printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))" +} + + +# get_devpath_block +# get the DEVPATH in /sys of a block device +get_devpath_block() { + local _majmin _i + _majmin=$(get_maj_min "$1") + + for _i in /sys/block/*/dev /sys/block/*/*/dev; do + [[ -e "$_i" ]] || continue + if [[ "$_majmin" == "$(<"$_i")" ]]; then + printf "%s" "${_i%/dev}" + return 0 + fi + done + return 1 +} + +# get a persistent path from a device +get_persistent_dev() { + local i _tmp _dev _pol + + _dev=$(get_maj_min "$1") + [ -z "$_dev" ] && return + + if [[ -n "$persistent_policy" ]]; then + _pol="/dev/disk/${persistent_policy}/*" + else + _pol= + fi + + for i in \ + $_pol \ + /dev/mapper/* \ + /dev/disk/by-uuid/* \ + /dev/disk/by-label/* \ + /dev/disk/by-partuuid/* \ + /dev/disk/by-partlabel/* \ + /dev/disk/by-id/* \ + /dev/disk/by-path/* \ + ; do + [[ -e "$i" ]] || continue + [[ $i == /dev/mapper/control ]] && continue + [[ $i == /dev/mapper/mpath* ]] && continue + _tmp=$(get_maj_min "$i") + if [ "$_tmp" = "$_dev" ]; then + printf -- "%s" "$i" + return + fi + done + printf -- "%s" "$1" +} + +expand_persistent_dev() { + local _dev=$1 + + case "$_dev" in + LABEL=*) + _dev="/dev/disk/by-label/${_dev#LABEL=}" + ;; + UUID=*) + _dev="${_dev#UUID=}" + _dev="${_dev,,}" + _dev="/dev/disk/by-uuid/${_dev}" + ;; + PARTUUID=*) + _dev="${_dev#PARTUUID=}" + _dev="${_dev,,}" + _dev="/dev/disk/by-partuuid/${_dev}" + ;; + PARTLABEL=*) + _dev="/dev/disk/by-partlabel/${_dev#PARTLABEL=}" + ;; + esac + printf "%s" "$_dev" +} + +shorten_persistent_dev() { + local _dev="$1" + case "$_dev" in + /dev/disk/by-uuid/*) + printf "%s" "UUID=${_dev##*/}";; + /dev/disk/by-label/*) + printf "%s" "LABEL=${_dev##*/}";; + /dev/disk/by-partuuid/*) + printf "%s" "PARTUUID=${_dev##*/}";; + /dev/disk/by-partlabel/*) + printf "%s" "PARTLABEL=${_dev##*/}";; + *) + printf "%s" "$_dev";; + esac +} + +# find_block_device +# Prints the major and minor number of the block device +# for a given mountpoint. +# Unless $use_fstab is set to "yes" the functions +# uses /proc/self/mountinfo as the primary source of the +# information and only falls back to /etc/fstab, if the mountpoint +# is not found there. +# Example: +# $ find_block_device /usr +# 8:4 +find_block_device() { + local _dev _majmin _find_mpt + _find_mpt="$1" + if [[ $use_fstab != yes ]]; then + [[ -d $_find_mpt/. ]] + findmnt -e -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | { \ + while read _majmin _dev || [ -n "$_dev" ]; do + if [[ -b $_dev ]]; then + if ! [[ $_majmin ]] || [[ $_majmin == 0:* ]]; then + _majmin=$(get_maj_min $_dev) + fi + if [[ $_majmin ]]; then + printf "%s\n" "$_majmin" + else + printf "%s\n" "$_dev" + fi + return 0 + fi + if [[ $_dev = *:* ]]; then + printf "%s\n" "$_dev" + return 0 + fi + done; return 1; } && return 0 + fi + # fall back to /etc/fstab + + findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | { \ + while read _majmin _dev || [ -n "$_dev" ]; do + if ! [[ $_dev ]]; then + _dev="$_majmin" + unset _majmin + fi + if [[ -b $_dev ]]; then + [[ $_majmin ]] || _majmin=$(get_maj_min $_dev) + if [[ $_majmin ]]; then + printf "%s\n" "$_majmin" + else + printf "%s\n" "$_dev" + fi + return 0 + fi + if [[ $_dev = *:* ]]; then + printf "%s\n" "$_dev" + return 0 + fi + done; return 1; } && return 0 + + return 1 +} + +# find_mp_fstype +# Echo the filesystem type for a given mountpoint. +# /proc/self/mountinfo is taken as the primary source of information +# and /etc/fstab is used as a fallback. +# No newline is appended! +# Example: +# $ find_mp_fstype /;echo +# ext4 +find_mp_fstype() { + local _fs + + if [[ $use_fstab != yes ]]; then + findmnt -e -v -n -o 'FSTYPE' --target "$1" | { \ + while read _fs || [ -n "$_fs" ]; do + [[ $_fs ]] || continue + [[ $_fs = "autofs" ]] && continue + printf "%s" "$_fs" + return 0 + done; return 1; } && return 0 + fi + + findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1" | { \ + while read _fs || [ -n "$_fs" ]; do + [[ $_fs ]] || continue + [[ $_fs = "autofs" ]] && continue + printf "%s" "$_fs" + return 0 + done; return 1; } && return 0 + + return 1 +} + +# find_dev_fstype +# Echo the filesystem type for a given device. +# /proc/self/mountinfo is taken as the primary source of information +# and /etc/fstab is used as a fallback. +# No newline is appended! +# Example: +# $ find_dev_fstype /dev/sda2;echo +# ext4 +find_dev_fstype() { + local _find_dev _fs + _find_dev="$1" + if ! [[ "$_find_dev" = /dev* ]]; then + [[ -b "/dev/block/$_find_dev" ]] && _find_dev="/dev/block/$_find_dev" + fi + + if [[ $use_fstab != yes ]]; then + findmnt -e -v -n -o 'FSTYPE' --source "$_find_dev" | { \ + while read _fs || [ -n "$_fs" ]; do + [[ $_fs ]] || continue + [[ $_fs = "autofs" ]] && continue + printf "%s" "$_fs" + return 0 + done; return 1; } && return 0 + fi + + findmnt --fstab -e -v -n -o 'FSTYPE' --source "$_find_dev" | { \ + while read _fs || [ -n "$_fs" ]; do + [[ $_fs ]] || continue + [[ $_fs = "autofs" ]] && continue + printf "%s" "$_fs" + return 0 + done; return 1; } && return 0 + + return 1 +} + +# find_mp_fsopts +# Echo the filesystem options for a given mountpoint. +# /proc/self/mountinfo is taken as the primary source of information +# and /etc/fstab is used as a fallback. +# No newline is appended! +# Example: +# $ find_mp_fsopts /;echo +# rw,relatime,discard,data=ordered +find_mp_fsopts() { + if [[ $use_fstab != yes ]]; then + findmnt -e -v -n -o 'OPTIONS' --target "$1" 2>/dev/null && return 0 + fi + + findmnt --fstab -e -v -n -o 'OPTIONS' --target "$1" +} + +# find_dev_fsopts +# Echo the filesystem options for a given device. +# /proc/self/mountinfo is taken as the primary source of information +# and /etc/fstab is used as a fallback. +# Example: +# $ find_dev_fsopts /dev/sda2 +# rw,relatime,discard,data=ordered +find_dev_fsopts() { + local _find_dev _opts + _find_dev="$1" + if ! [[ "$_find_dev" = /dev* ]]; then + [[ -b "/dev/block/$_find_dev" ]] && _find_dev="/dev/block/$_find_dev" + fi + + if [[ $use_fstab != yes ]]; then + findmnt -e -v -n -o 'OPTIONS' --source "$_find_dev" 2>/dev/null && return 0 + fi + + findmnt --fstab -e -v -n -o 'OPTIONS' --source "$_find_dev" +} + + +# finds the major:minor of the block device backing the root filesystem. +find_root_block_device() { find_block_device /; } + +# for_each_host_dev_fs +# Execute " " for every " " pair found +# in ${host_fs_types[@]} +for_each_host_dev_fs() +{ + local _func="$1" + local _dev + local _ret=1 + + [[ "${#host_fs_types[@]}" ]] || return 2 + + + for _dev in "${!host_fs_types[@]}"; do + $_func "$_dev" "${host_fs_types[$_dev]}" && _ret=0 + done + return $_ret +} + +host_fs_all() +{ + printf "%s\n" "${host_fs_types[@]}" +} + +# Walk all the slave relationships for a given block device. +# Stop when our helper function returns success +# $1 = function to call on every found block device +# $2 = block device in major:minor format +check_block_and_slaves() { + local _x + [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry. + if ! lvm_internal_dev $2; then "$1" $2 && return; fi + check_vol_slaves "$@" && return 0 + if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then + check_block_and_slaves $1 $(<"/sys/dev/block/$2/../dev") && return 0 + fi + [[ -d /sys/dev/block/$2/slaves ]] || return 1 + for _x in /sys/dev/block/$2/slaves/*; do + [[ -f $_x/dev ]] || continue + [[ $_x/subsystem -ef /sys/class/block ]] || continue + check_block_and_slaves $1 $(<"$_x/dev") && return 0 + done + return 1 +} + +check_block_and_slaves_all() { + local _x _ret=1 + [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry. + if ! lvm_internal_dev $2 && "$1" $2; then + _ret=0 + fi + check_vol_slaves_all "$@" && return 0 + if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then + check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=0 + fi + [[ -d /sys/dev/block/$2/slaves ]] || return 1 + for _x in /sys/dev/block/$2/slaves/*; do + [[ -f $_x/dev ]] || continue + [[ $_x/subsystem -ef /sys/class/block ]] || continue + check_block_and_slaves_all $1 $(<"$_x/dev") && _ret=0 + done + return $_ret +} +# for_each_host_dev_and_slaves +# Execute " " for every "" found +# in ${host_devs[@]} and their slaves +for_each_host_dev_and_slaves_all() +{ + local _func="$1" + local _dev + local _ret=1 + + [[ "${host_devs[@]}" ]] || return 2 + + for _dev in "${host_devs[@]}"; do + [[ -b "$_dev" ]] || continue + if check_block_and_slaves_all $_func $(get_maj_min $_dev); then + _ret=0 + fi + done + return $_ret +} + +for_each_host_dev_and_slaves() +{ + local _func="$1" + local _dev + + [[ "${host_devs[@]}" ]] || return 2 + + for _dev in "${host_devs[@]}"; do + [[ -b "$_dev" ]] || continue + check_block_and_slaves $_func $(get_maj_min $_dev) && return 0 + done + return 1 +} + +# ugly workaround for the lvm design +# There is no volume group device, +# so, there are no slave devices for volume groups. +# Logical volumes only have the slave devices they really live on, +# but you cannot create the logical volume without the volume group. +# And the volume group might be bigger than the devices the LV needs. +check_vol_slaves() { + local _lv _vg _pv _dm _majmin + _majmin="$2" + _lv="/dev/block/$_majmin" + _dm=/sys/dev/block/$_majmin/dm + [[ -f $_dm/uuid && $(<$_dm/uuid) =~ LVM-* ]] || return 1 + _vg=$(dmsetup splitname --noheadings -o vg_name $(<"$_dm/name") ) + # strip space + _vg="${_vg//[[:space:]]/}" + if [[ $_vg ]]; then + for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null) + do + check_block_and_slaves $1 $(get_maj_min $_pv) && return 0 + done + fi + return 1 +} + +check_vol_slaves_all() { + local _lv _vg _pv _majmin + _majmin="$2" + _lv="/dev/block/$_majmin" + _dm="/sys/dev/block/$_majmin/dm" + [[ -f $_dm/uuid && $(<$_dm/uuid) =~ LVM-* ]] || return 1 + _vg=$(dmsetup splitname --noheadings -o vg_name $(<"$_dm/name") ) + # strip space + _vg="${_vg//[[:space:]]/}" + if [[ $_vg ]]; then + for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null) + do + check_block_and_slaves_all $1 $(get_maj_min $_pv) + done + return 0 + fi + return 1 +} + + + +# fs_get_option +# search for a specific option in a bunch of filesystem options +# and return the value +fs_get_option() { + local _fsopts=$1 + local _option=$2 + local OLDIFS="$IFS" + IFS=, + set -- $_fsopts + IFS="$OLDIFS" + while [ $# -gt 0 ]; do + case $1 in + $_option=*) + echo ${1#${_option}=} + break + esac + shift + done +} + +check_kernel_config() +{ + local _config_opt="$1" + local _config_file + [[ -f /boot/config-$kernel ]] \ + && _config_file="/boot/config-$kernel" + [[ -f /lib/modules/$kernel/config ]] \ + && _config_file="/lib/modules/$kernel/config" + + # no kernel config file, so return true + [[ $_config_file ]] || return 0 + + grep -q -F "${_config_opt}=" "$_config_file" && return 0 + return 1 +} + + +# get_cpu_vendor +# Only two values are returned: AMD or Intel +get_cpu_vendor () +{ + if grep -qE AMD /proc/cpuinfo; then + printf "AMD" + fi + if grep -qE Intel /proc/cpuinfo; then + printf "Intel" + fi +} + +# get_host_ucode +# Get the hosts' ucode file based on the /proc/cpuinfo +get_ucode_file () +{ + local family=`grep -E "cpu family" /proc/cpuinfo | head -1 | sed s/.*:\ //` + local model=`grep -E "model" /proc/cpuinfo |grep -v name | head -1 | sed s/.*:\ //` + local stepping=`grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //` + + if [[ "$(get_cpu_vendor)" == "AMD" ]]; then + if [[ $family -ge 21 ]]; then + printf "microcode_amd_fam%xh.bin" $family + else + printf "microcode_amd.bin" + fi + fi + if [[ "$(get_cpu_vendor)" == "Intel" ]]; then + # The /proc/cpuinfo are in decimal. + printf "%02x-%02x-%02x" ${family} ${model} ${stepping} + fi +} + +# Get currently loaded modules +# sorted, and delimited by newline +get_loaded_kernel_modules () +{ + local modules=( ) + while read _module _size _used _used_by; do + modules+=( "$_module" ) + done <<< "$(lsmod | sed -n '1!p')" + printf '%s\n' "${modules[@]}" | sort +} + +# Not every device in /dev/mapper should be examined. +# If it is an LVM device, touch only devices which have /dev/VG/LV symlink. +lvm_internal_dev() { + local dev_dm_dir=/sys/dev/block/$1/dm + [[ ! -f $dev_dm_dir/uuid || $(<$dev_dm_dir/uuid) != LVM-* ]] && return 1 # Not an LVM device + local DM_VG_NAME DM_LV_NAME DM_LV_LAYER + eval $(dmsetup splitname --nameprefixes --noheadings --rows "$(<$dev_dm_dir/name)" 2>/dev/null) + [[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 0 # Better skip this! + [[ ${DM_LV_LAYER} ]] || [[ ! -L /dev/${DM_VG_NAME}/${DM_LV_NAME} ]] +} + +btrfs_devs() { + local _mp="$1" + btrfs device usage "$_mp" \ + | while read _dev _rest; do + str_starts "$_dev" "/" || continue + _dev=${_dev%,} + printf -- "%s\n" "$_dev" + done +} diff --git a/dracut-init.sh b/dracut-init.sh new file mode 100644 index 0000000..50d23e2 --- /dev/null +++ b/dracut-init.sh @@ -0,0 +1,1039 @@ +#!/bin/bash +# +# functions used only by dracut and dracut modules +# +# Copyright 2005-2009 Red Hat, Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +export LC_MESSAGES=C + +if [[ "$EUID" = "0" ]]; then + export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr" +else + export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr" +fi + +# is_func +# Check whether $1 is a function. +is_func() { + [[ "$(type -t "$1")" = "function" ]] +} + +if ! [[ $dracutbasedir ]]; then + dracutbasedir=${BASH_SOURCE[0]%/*} + [[ $dracutbasedir = dracut-functions* ]] && dracutbasedir="." + [[ $dracutbasedir ]] || dracutbasedir="." + dracutbasedir="$(readlink -f $dracutbasedir)" +fi + +if ! is_func dinfo >/dev/null 2>&1; then + . "$dracutbasedir/dracut-logger.sh" + dlog_init +fi + +if ! [[ $initdir ]]; then + dfatal "initdir not set" + exit 1 +fi + +if ! [[ -d $initdir ]]; then + mkdir -p "$initdir" +fi + +if ! [[ $kernel ]]; then + kernel=$(uname -r) + export kernel +fi + +srcmods="/lib/modules/$kernel/" + +[[ $drivers_dir ]] && { + if ! command -v kmod &>/dev/null && vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then + dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.' + exit 1 + fi + srcmods="$drivers_dir" +} +export srcmods + +[[ $DRACUT_FIRMWARE_PATH ]] || export DRACUT_FIRMWARE_PATH="/lib/firmware/updates:/lib/firmware:/lib/firmware/$kernel" + +# export standard hookdirs +[[ $hookdirs ]] || { + hookdirs="cmdline pre-udev pre-trigger netroot " + hookdirs+="initqueue initqueue/settled initqueue/online initqueue/finished initqueue/timeout " + hookdirs+="pre-mount pre-pivot cleanup mount " + hookdirs+="emergency shutdown-emergency pre-shutdown shutdown " + export hookdirs +} + +. $dracutbasedir/dracut-functions.sh + +# Detect lib paths +if ! [[ $libdirs ]] ; then + if [[ "$(ldd /bin/sh)" == */lib64/* ]] &>/dev/null \ + && [[ -d /lib64 ]]; then + libdirs+=" /lib64" + [[ -d /usr/lib64 ]] && libdirs+=" /usr/lib64" + else + libdirs+=" /lib" + [[ -d /usr/lib ]] && libdirs+=" /usr/lib" + fi + + libdirs+=" $(ldconfig_paths)" + + export libdirs +fi + +# helper function for check() in module-setup.sh +# to check for required installed binaries +# issues a standardized warning message +require_binaries() { + local _module_name="${moddir##*/}" + local _ret=0 + + if [[ "$1" = "-m" ]]; then + _module_name="$2" + shift 2 + fi + + for cmd in "$@"; do + if ! find_binary "$cmd" &>/dev/null; then + dinfo "dracut module '${_module_name#[0-9][0-9]}' will not be installed, because command '$cmd' could not be found!" + ((_ret++)) + fi + done + return $_ret +} + +require_any_binary() { + local _module_name="${moddir##*/}" + local _ret=1 + + if [[ "$1" = "-m" ]]; then + _module_name="$2" + shift 2 + fi + + for cmd in "$@"; do + if find_binary "$cmd" &>/dev/null; then + _ret=0 + break + fi + done + + if (( $_ret != 0 )); then + dinfo "$_module_name: Could not find any command of '$@'!" + return 1 + fi + + return 0 +} + +dracut_need_initqueue() { + >"$initdir/lib/dracut/need-initqueue" +} + +dracut_module_included() { + [[ " $mods_to_load $modules_loaded " == *\ $*\ * ]] +} + +if ! [[ $DRACUT_INSTALL ]]; then + DRACUT_INSTALL=$(find_binary dracut-install) +fi + +if ! [[ $DRACUT_INSTALL ]] && [[ -x $dracutbasedir/dracut-install ]]; then + DRACUT_INSTALL=$dracutbasedir/dracut-install +elif ! [[ $DRACUT_INSTALL ]] && [[ -x $dracutbasedir/install/dracut-install ]]; then + DRACUT_INSTALL=$dracutbasedir/install/dracut-install +fi + +if ! [[ -x $DRACUT_INSTALL ]]; then + dfatal "dracut-install not found!" + exit 10 +fi + +if [[ $hostonly == "-h" ]]; then + if ! [[ $DRACUT_KERNEL_MODALIASES ]] || ! [[ -f "$DRACUT_KERNEL_MODALIASES" ]]; then + export DRACUT_KERNEL_MODALIASES="${DRACUT_TMPDIR}/modaliases" + $DRACUT_INSTALL ${srcmods:+--kerneldir "$srcmods"} --modalias > "$DRACUT_KERNEL_MODALIASES" + fi +fi + +[[ $DRACUT_RESOLVE_LAZY ]] || export DRACUT_RESOLVE_DEPS=1 +inst_dir() { + [[ -e ${initdir}/"$1" ]] && return 0 # already there + $DRACUT_INSTALL ${initdir:+-D "$initdir"} -d "$@" + (($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} -d "$@" || : +} + +inst() { + local _hostonly_install + if [[ "$1" == "-H" ]]; then + _hostonly_install="-H" + shift + fi + [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there + $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" + (($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || : +} + +inst_simple() { + local _hostonly_install + if [[ "$1" == "-H" ]]; then + _hostonly_install="-H" + shift + fi + [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there + [[ -e $1 ]] || return 1 # no source + $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@" + (($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@" || : +} + +inst_symlink() { + local _hostonly_install + if [[ "$1" == "-H" ]]; then + _hostonly_install="-H" + shift + fi + [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there + [[ -L $1 ]] || return 1 + $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" + (($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || : +} + +inst_multiple() { + local _ret + $DRACUT_INSTALL ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" + _ret=$? + (($_ret != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || : + return $_ret +} + +dracut_install() { + inst_multiple "$@" +} + +dracut_instmods() { + local _silent=0; + local i; + [[ $no_kernel = yes ]] && return + for i in "$@"; do + [[ $i == "--silent" ]] && _silent=1 + done + + $DRACUT_INSTALL \ + ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@" + (($? != 0)) && (($_silent == 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@" || : +} + +inst_library() { + local _hostonly_install + if [[ "$1" == "-H" ]]; then + _hostonly_install="-H" + shift + fi + [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there + [[ -e $1 ]] || return 1 # no source + $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" + (($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || : +} + +inst_binary() { + $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" + (($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || : +} + +inst_script() { + $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" + (($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || : +} + +inst_fsck_help() { + local _helper="/run/dracut/fsck/fsck_help_$1.txt" + $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" $_helper + (($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" $_helper || : +} + +# Use with form hostonly="$(optional_hostonly)" inst_xxxx +# If hosotnly mode is set to "strict", hostonly restrictions will still +# be applied, else will ignore hostonly mode and try to install all +# given modules. +optional_hostonly() { + if [[ $hostonly_mode = "strict" ]]; then + printf -- "$hostonly" + else + printf "" + fi +} + +mark_hostonly() { + for i in "$@"; do + echo "$i" >> "$initdir/lib/dracut/hostonly-files" + done +} + +# find symlinks linked to given library file +# $1 = library file +# Function searches for symlinks by stripping version numbers appended to +# library filename, checks if it points to the same target and finally +# prints the list of symlinks to stdout. +# +# Example: +# rev_lib_symlinks libfoo.so.8.1 +# output: libfoo.so.8 libfoo.so +# (Only if libfoo.so.8 and libfoo.so exists on host system.) +rev_lib_symlinks() { + [[ ! $1 ]] && return 0 + + local fn="$1" orig="$(readlink -f "$1")" links='' + + [[ ${fn} == *.so.* ]] || return 1 + + until [[ ${fn##*.} == so ]]; do + fn="${fn%.*}" + [[ -L ${fn} && $(readlink -f "${fn}") == ${orig} ]] && links+=" ${fn}" + done + + echo "${links}" +} + +# attempt to install any programs specified in a udev rule +inst_rule_programs() { + local _prog _bin + + for _prog in $(sed -nr 's/.*PROGRAM==?"([^ "]+).*/\1/p' "$1"); do + _bin="" + if [ -x ${udevdir}/$_prog ]; then + _bin=${udevdir}/$_prog + elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then + _bin=$(find_binary "$_prog") || { + dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found" + continue; + } + fi + + [[ $_bin ]] && inst_binary "$_bin" + done + for _prog in $(sed -nr 's/.*RUN[+=]=?"([^ "]+).*/\1/p' "$1"); do + _bin="" + if [ -x ${udevdir}/$_prog ]; then + _bin=${udevdir}/$_prog + elif [[ "${_prog/\$env\{/}" == "$_prog" ]] && [[ "${_prog}" != "/sbin/initqueue" ]]; then + _bin=$(find_binary "$_prog") || { + dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found" + continue; + } + fi + + [[ $_bin ]] && inst_binary "$_bin" + done + for _prog in $(sed -nr 's/.*IMPORT\{program\}==?"([^ "]+).*/\1/p' "$1"); do + _bin="" + if [ -x ${udevdir}/$_prog ]; then + _bin=${udevdir}/$_prog + elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then + _bin=$(find_binary "$_prog") || { + dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found" + continue; + } + fi + + [[ $_bin ]] && dracut_install "$_bin" + done +} + +# attempt to install any programs specified in a udev rule +inst_rule_group_owner() { + local i + + for i in $(sed -nr 's/.*OWNER=?"([^ "]+).*/\1/p' "$1"); do + if ! grep -Eq "^$i:" "$initdir/etc/passwd" 2>/dev/null; then + grep -E "^$i:" /etc/passwd 2>/dev/null >> "$initdir/etc/passwd" + fi + done + for i in $(sed -nr 's/.*GROUP=?"([^ "]+).*/\1/p' "$1"); do + if ! grep -Eq "^$i:" "$initdir/etc/group" 2>/dev/null; then + grep -E "^$i:" /etc/group 2>/dev/null >> "$initdir/etc/group" + fi + done +} + +inst_rule_initqueue() { + if grep -q -F initqueue "$1"; then + dracut_need_initqueue + fi +} + +# udev rules always get installed in the same place, so +# create a function to install them to make life simpler. +inst_rules() { + local _target=/etc/udev/rules.d _rule _found + + inst_dir "${udevdir}/rules.d" + inst_dir "$_target" + for _rule in "$@"; do + if [ "${_rule#/}" = "$_rule" ]; then + for r in ${udevdir}/rules.d ${hostonly:+/etc/udev/rules.d}; do + [[ -e $r/$_rule ]] || continue + _found="$r/$_rule" + inst_rule_programs "$_found" + inst_rule_group_owner "$_found" + inst_rule_initqueue "$_found" + inst_simple "$_found" + done + fi + for r in '' $dracutbasedir/rules.d/; do + # skip rules without an absolute path + [[ "${r}$_rule" != /* ]] && continue + [[ -f ${r}$_rule ]] || continue + _found="${r}$_rule" + inst_rule_programs "$_found" + inst_rule_group_owner "$_found" + inst_rule_initqueue "$_found" + inst_simple "$_found" "$_target/${_found##*/}" + done + [[ $_found ]] || dinfo "Skipping udev rule: $_rule" + done +} + +inst_rules_wildcard() { + local _target=/etc/udev/rules.d _rule _found + + inst_dir "${udevdir}/rules.d" + inst_dir "$_target" + for _rule in ${udevdir}/rules.d/$1 ${dracutbasedir}/rules.d/$1 ; do + [[ -e $_rule ]] || continue + inst_rule_programs "$_rule" + inst_rule_group_owner "$_rule" + inst_rule_initqueue "$_rule" + inst_simple "$_rule" + _found=$_rule + done + if [[ -n ${hostonly} ]] ; then + for _rule in ${_target}/$1 ; do + [[ -f $_rule ]] || continue + inst_rule_programs "$_rule" + inst_rule_group_owner "$_rule" + inst_rule_initqueue "$_rule" + inst_simple "$_rule" + _found=$_rule + done + fi + [[ $_found ]] || dinfo "Skipping udev rule: $_rule" +} + +prepare_udev_rules() { + [ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version) + + for f in "$@"; do + f="${initdir}/etc/udev/rules.d/$f" + [ -e "$f" ] || continue + while read line || [ -n "$line" ]; do + if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then + if [ $UDEVVERSION -ge 174 ]; then + printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}" + else + printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}" + fi + elif [ "${line%%IMPORT BLKID}" != "$line" ]; then + if [ $UDEVVERSION -ge 176 ]; then + printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}" + else + printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}" + fi + else + echo "$line" + fi + done < "${f}" > "${f}.new" + mv "${f}.new" "$f" + done +} + +# install function specialized for hooks +# $1 = type of hook, $2 = hook priority (lower runs first), $3 = hook +# All hooks should be POSIX/SuS compliant, they will be sourced by init. +inst_hook() { + if ! [[ -f $3 ]]; then + dfatal "Cannot install a hook ($3) that does not exist." + dfatal "Aborting initrd creation." + exit 1 + elif ! [[ "$hookdirs" == *$1* ]]; then + dfatal "No such hook type $1. Aborting initrd creation." + exit 1 + fi + inst_simple "$3" "/lib/dracut/hooks/${1}/${2}-${3##*/}" +} + +# install any of listed files +# +# If first argument is '-d' and second some destination path, first accessible +# source is installed into this path, otherwise it will installed in the same +# path as source. If none of listed files was installed, function return 1. +# On first successful installation it returns with 0 status. +# +# Example: +# +# inst_any -d /bin/foo /bin/bar /bin/baz +# +# Lets assume that /bin/baz exists, so it will be installed as /bin/foo in +# initramfs. +inst_any() { + local to f + + [[ $1 = '-d' ]] && to="$2" && shift 2 + + for f in "$@"; do + [[ -e $f ]] || continue + [[ $to ]] && inst "$f" "$to" && return 0 + inst "$f" && return 0 + done + + return 1 +} + + +# inst_libdir_file [-n ] [...] +# Install a located on a lib directory to the initramfs image +# -n install matching files +inst_libdir_file() { + local _files + if [[ "$1" == "-n" ]]; then + local _pattern=$2 + shift 2 + for _dir in $libdirs; do + for _i in "$@"; do + for _f in "$_dir"/$_i; do + [[ "$_f" =~ $_pattern ]] || continue + [[ -e "$_f" ]] && _files+="$_f " + done + done + done + else + for _dir in $libdirs; do + for _i in "$@"; do + for _f in "$_dir"/$_i; do + [[ -e "$_f" ]] && _files+="$_f " + done + done + done + fi + [[ $_files ]] && inst_multiple $_files +} + + +# install function decompressing the target and handling symlinks +# $@ = list of compressed (gz or bz2) files or symlinks pointing to such files +# +# Function install targets in the same paths inside overlay but decompressed +# and without extensions (.gz, .bz2). +inst_decompress() { + local _src _cmd + + for _src in $@ + do + case ${_src} in + *.gz) _cmd='gzip -f -d' ;; + *.bz2) _cmd='bzip2 -d' ;; + *) return 1 ;; + esac + inst_simple ${_src} + # Decompress with chosen tool. We assume that tool changes name e.g. + # from 'name.gz' to 'name'. + ${_cmd} "${initdir}${_src}" + done +} + +# It's similar to above, but if file is not compressed, performs standard +# install. +# $@ = list of files +inst_opt_decompress() { + local _src + + for _src in $@; do + inst_decompress "${_src}" || inst "${_src}" + done +} + +# module_check +# execute the check() function of module-setup.sh of +# or the "check" script, if module-setup.sh is not found +# "check $hostonly" is called +module_check() { + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1} | { read a b; echo "$a"; }) + local _ret + local _forced=0 + local _hostonly=$hostonly + [ $# -eq 2 ] && _forced=$2 + [[ -d $_moddir ]] || return 1 + if [[ ! -f $_moddir/module-setup.sh ]]; then + # if we do not have a check script, we are unconditionally included + [[ -x $_moddir/check ]] || return 0 + [ $_forced -ne 0 ] && unset hostonly + $_moddir/check $hostonly + _ret=$? + else + unset check depends cmdline install installkernel + check() { true; } + . $_moddir/module-setup.sh + is_func check || return 0 + [ $_forced -ne 0 ] && unset hostonly + moddir=$_moddir check $hostonly + _ret=$? + unset check depends cmdline install installkernel + fi + hostonly=$_hostonly + return $_ret +} + +# module_check_mount +# execute the check() function of module-setup.sh of +# or the "check" script, if module-setup.sh is not found +# "mount_needs=1 check 0" is called +module_check_mount() { + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1} | { read a b; echo "$a"; }) + local _ret + mount_needs=1 + [[ -d $_moddir ]] || return 1 + if [[ ! -f $_moddir/module-setup.sh ]]; then + # if we do not have a check script, we are unconditionally included + [[ -x $_moddir/check ]] || return 0 + mount_needs=1 $_moddir/check 0 + _ret=$? + else + unset check depends cmdline install installkernel + check() { false; } + . $_moddir/module-setup.sh + moddir=$_moddir check 0 + _ret=$? + unset check depends cmdline install installkernel + fi + unset mount_needs + return $_ret +} + +# module_depends +# execute the depends() function of module-setup.sh of +# or the "depends" script, if module-setup.sh is not found +module_depends() { + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1} | { read a b; echo "$a"; }) + local _ret + [[ -d $_moddir ]] || return 1 + if [[ ! -f $_moddir/module-setup.sh ]]; then + # if we do not have a check script, we have no deps + [[ -x $_moddir/check ]] || return 0 + $_moddir/check -d + return $? + else + unset check depends cmdline install installkernel + depends() { true; } + . $_moddir/module-setup.sh + moddir=$_moddir depends + _ret=$? + unset check depends cmdline install installkernel + return $_ret + fi +} + +# module_cmdline +# execute the cmdline() function of module-setup.sh of +# or the "cmdline" script, if module-setup.sh is not found +module_cmdline() { + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1} | { read a b; echo "$a"; }) + local _ret + [[ -d $_moddir ]] || return 1 + if [[ ! -f $_moddir/module-setup.sh ]]; then + [[ -x $_moddir/cmdline ]] && . "$_moddir/cmdline" + return $? + else + unset check depends cmdline install installkernel + cmdline() { true; } + . $_moddir/module-setup.sh + moddir=$_moddir cmdline + _ret=$? + unset check depends cmdline install installkernel + return $_ret + fi +} + +# module_install +# execute the install() function of module-setup.sh of +# or the "install" script, if module-setup.sh is not found +module_install() { + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1} | { read a b; echo "$a"; }) + local _ret + [[ -d $_moddir ]] || return 1 + if [[ ! -f $_moddir/module-setup.sh ]]; then + [[ -x $_moddir/install ]] && . "$_moddir/install" + return $? + else + unset check depends cmdline install installkernel + install() { true; } + . $_moddir/module-setup.sh + moddir=$_moddir install + _ret=$? + unset check depends cmdline install installkernel + return $_ret + fi +} + +# module_installkernel +# execute the installkernel() function of module-setup.sh of +# or the "installkernel" script, if module-setup.sh is not found +module_installkernel() { + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1} | { read a b; echo "$a"; }) + local _ret + [[ -d $_moddir ]] || return 1 + if [[ ! -f $_moddir/module-setup.sh ]]; then + [[ -x $_moddir/installkernel ]] && . "$_moddir/installkernel" + return $? + else + unset check depends cmdline install installkernel + installkernel() { true; } + . $_moddir/module-setup.sh + moddir=$_moddir installkernel + _ret=$? + unset check depends cmdline install installkernel + return $_ret + fi +} + +# check_mount +# check_mount checks, if a dracut module is needed for the given +# device and filesystem types in "${host_fs_types[@]}" +check_mount() { + local _mod=$1 + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1} | { read a b; echo "$a"; }) + local _ret + local _moddep + + [ "${#host_fs_types[@]}" -le 0 ] && return 1 + + # If we are already scheduled to be loaded, no need to check again. + [[ " $mods_to_load " == *\ $_mod\ * ]] && return 0 + [[ " $mods_checked_as_dep " == *\ $_mod\ * ]] && return 1 + + # This should never happen, but... + [[ -d $_moddir ]] || return 1 + + [[ $2 ]] || mods_checked_as_dep+=" $_mod " + + if [[ " $omit_dracutmodules " == *\ $_mod\ * ]]; then + return 1 + fi + + if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then + module_check_mount $_mod; ret=$? + + # explicit module, so also accept ret=255 + [[ $ret = 0 || $ret = 255 ]] || return 1 + else + # module not in our list + if [[ $dracutmodules = all ]]; then + # check, if we can and should install this module + module_check_mount $_mod || return 1 + else + # skip this module + return 1 + fi + fi + + for _moddep in $(module_depends $_mod); do + # handle deps as if they were manually added + [[ " $dracutmodules " == *\ $_mod\ * ]] \ + && [[ " $dracutmodules " != *\ $_moddep\ * ]] \ + && dracutmodules+=" $_moddep " + [[ " $add_dracutmodules " == *\ $_mod\ * ]] \ + && [[ " $add_dracutmodules " != *\ $_moddep\ * ]] \ + && add_dracutmodules+=" $_moddep " + [[ " $force_add_dracutmodules " == *\ $_mod\ * ]] \ + && [[ " $force_add_dracutmodules " != *\ $_moddep\ * ]] \ + && force_add_dracutmodules+=" $_moddep " + # if a module we depend on fail, fail also + if ! check_module $_moddep; then + derror "dracut module '$_mod' depends on '$_moddep', which can't be installed" + return 1 + fi + done + + [[ " $mods_to_load " == *\ $_mod\ * ]] || \ + mods_to_load+=" $_mod " + + return 0 +} + +# check_module [] +# check if a dracut module is to be used in the initramfs process +# if is set, then the process also keeps track +# that the modules were checked for the dependency tracking process +check_module() { + local _mod=$1 + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1} | { read a b; echo "$a"; }) + local _ret + local _moddep + # If we are already scheduled to be loaded, no need to check again. + [[ " $mods_to_load " == *\ $_mod\ * ]] && return 0 + [[ " $mods_checked_as_dep " == *\ $_mod\ * ]] && return 1 + + # This should never happen, but... + [[ -d $_moddir ]] || return 1 + + [[ $2 ]] || mods_checked_as_dep+=" $_mod " + + if [[ " $omit_dracutmodules " == *\ $_mod\ * ]]; then + dinfo "dracut module '$_mod' will not be installed, because it's in the list to be omitted!" + return 1 + fi + + if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then + if [[ " $dracutmodules $force_add_dracutmodules " == *\ $_mod\ * ]]; then + module_check $_mod 1; ret=$? + else + module_check $_mod 0; ret=$? + fi + # explicit module, so also accept ret=255 + [[ $ret = 0 || $ret = 255 ]] || return 1 + else + # module not in our list + if [[ $dracutmodules = all ]]; then + # check, if we can and should install this module + module_check $_mod; ret=$? + if [[ $ret != 0 ]]; then + [[ $2 ]] && return 1 + [[ $ret != 255 ]] && return 1 + fi + else + # skip this module + return 1 + fi + fi + + for _moddep in $(module_depends $_mod); do + # handle deps as if they were manually added + [[ " $dracutmodules " == *\ $_mod\ * ]] \ + && [[ " $dracutmodules " != *\ $_moddep\ * ]] \ + && dracutmodules+=" $_moddep " + [[ " $add_dracutmodules " == *\ $_mod\ * ]] \ + && [[ " $add_dracutmodules " != *\ $_moddep\ * ]] \ + && add_dracutmodules+=" $_moddep " + [[ " $force_add_dracutmodules " == *\ $_mod\ * ]] \ + && [[ " $force_add_dracutmodules " != *\ $_moddep\ * ]] \ + && force_add_dracutmodules+=" $_moddep " + # if a module we depend on fail, fail also + if ! check_module $_moddep; then + derror "dracut module '$_mod' depends on '$_moddep', which can't be installed" + return 1 + fi + done + + [[ " $mods_to_load " == *\ $_mod\ * ]] || \ + mods_to_load+=" $_mod " + + return 0 +} + +# for_each_module_dir +# execute " 1" +for_each_module_dir() { + local _modcheck + local _mod + local _moddir + local _func + _func=$1 + for _moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do + [[ -d $_moddir ]] || continue; + [[ -e $_moddir/install || -e $_moddir/installkernel || \ + -e $_moddir/module-setup.sh ]] || continue + _mod=${_moddir##*/}; _mod=${_mod#[0-9][0-9]} + $_func $_mod 1 + done + + # Report any missing dracut modules, the user has specified + _modcheck="$add_dracutmodules $force_add_dracutmodules" + [[ $dracutmodules != all ]] && _modcheck="$_modcheck $dracutmodules" + for _mod in $_modcheck; do + [[ " $mods_to_load " == *\ $_mod\ * ]] && continue + + [[ " $force_add_dracutmodules " != *\ $_mod\ * ]] \ + && [[ " $dracutmodules " != *\ $_mod\ * ]] \ + && [[ " $omit_dracutmodules " == *\ $_mod\ * ]] \ + && continue + + derror "dracut module '$_mod' cannot be found or installed." + [[ " $force_add_dracutmodules " == *\ $_mod\ * ]] && exit 1 + [[ " $dracutmodules " == *\ $_mod\ * ]] && exit 1 + [[ " $add_dracutmodules " == *\ $_mod\ * ]] && exit 1 + done +} + +# Install a single kernel module along with any firmware it may require. +# $1 = full path to kernel module to install +install_kmod_with_fw() { + # no need to go further if the module is already installed + + [[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] \ + && return 0 + + if [[ $omit_drivers ]]; then + local _kmod=${1##*/} + _kmod=${_kmod%.ko*} + _kmod=${_kmod/-/_} + if [[ "$_kmod" =~ $omit_drivers ]]; then + dinfo "Omitting driver $_kmod" + return 0 + fi + if [[ "${1##*/lib/modules/$kernel/}" =~ $omit_drivers ]]; then + dinfo "Omitting driver $_kmod" + return 0 + fi + fi + + if [[ $silent_omit_drivers ]]; then + local _kmod=${1##*/} + _kmod=${_kmod%.ko*} + _kmod=${_kmod/-/_} + [[ "$_kmod" =~ $silent_omit_drivers ]] && return 0 + [[ "${1##*/lib/modules/$kernel/}" =~ $silent_omit_drivers ]] && return 0 + fi + + inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" + ret=$? + (($ret != 0)) && return $ret + + local _modname=${1##*/} _fwdir _found _fw + _modname=${_modname%.ko*} + for _fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do + _found='' + for _fwdir in $fw_dir; do + [[ -d $_fwdir && -f $_fwdir/$_fw ]] || continue + inst_simple "$_fwdir/$_fw" "/lib/firmware/$_fw" + _found=yes + done + if [[ $_found != yes ]]; then + if ! [[ -d $(echo /sys/module/${_modname//-/_}|{ read a b; echo $a; }) ]]; then + dinfo "Possible missing firmware \"${_fw}\" for kernel module" \ + "\"${_modname}.ko\"" + else + dwarn "Possible missing firmware \"${_fw}\" for kernel module" \ + "\"${_modname}.ko\"" + fi + fi + done + return 0 +} + +# Do something with all the dependencies of a kernel module. +# Note that kernel modules depend on themselves using the technique we use +# $1 = function to call for each dependency we find +# It will be passed the full path to the found kernel module +# $2 = module to get dependencies for +# rest of args = arguments to modprobe +# _fderr specifies FD passed from surrounding scope +for_each_kmod_dep() { + local _func=$1 _kmod=$2 _cmd _modpath _options + shift 2 + modprobe "$@" --ignore-install --show-depends $_kmod 2>&${_fderr} | ( + while read _cmd _modpath _options || [ -n "$_cmd" ]; do + [[ $_cmd = insmod ]] || continue + $_func ${_modpath} || exit $? + done + ) +} + +dracut_kernel_post() { + for _f in modules.builtin.bin modules.builtin modules.order; do + [[ -e $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f" + done + + # generate module dependencies for the initrd + if [[ -d $initdir/lib/modules/$kernel ]] && \ + ! depmod -a -b "$initdir" $kernel; then + dfatal "\"depmod -a $kernel\" failed." + exit 1 + fi + +} + +instmods() { + # instmods [-c [-s]] [ ... ] + # instmods [-c [-s]] + # install kernel modules along with all their dependencies. + # can be e.g. "=block" or "=drivers/usb/storage" + # -c check + # -s silent + local _optional="-o" + local _silent + local _ret + + [[ $no_kernel = yes ]] && return + + if [[ $1 = '-c' ]]; then + unset _optional + shift + fi + if [[ $1 = '-s' ]]; then + _silent=1 + shift + fi + + if (($# == 0)); then + read -r -d '' -a args + set -- "${args[@]}" + fi + + if (($# == 0)); then + return 0 + fi + + $DRACUT_INSTALL \ + ${initdir:+-D "$initdir"} \ + ${loginstall:+-L "$loginstall"} \ + ${hostonly:+-H} \ + ${omit_drivers:+-N "$omit_drivers"} \ + ${srcmods:+--kerneldir "$srcmods"} \ + ${_optional:+-o} \ + ${_silent:+--silent} \ + -m "$@" + _ret=$? + + if (($_ret != 0)) && [[ -z "$_silent" ]]; then + derror "FAILED: " \ + $DRACUT_INSTALL \ + ${initdir:+-D "$initdir"} \ + ${loginstall:+-L "$loginstall"} \ + ${hostonly:+-H} \ + ${omit_drivers:+-N "$omit_drivers"} \ + ${srcmods:+--kerneldir "$srcmods"} \ + ${_optional:+-o} \ + ${_silent:+--silent} \ + -m "$@" + fi + + [[ "$optional" ]] && return 0 + return $_ret +} + +if [[ "$(ln --help)" == *--relative* ]]; then + ln_r() { + ln -sfnr "${initdir}/$1" "${initdir}/$2" + } +else + ln_r() { + local _source=$1 + local _dest=$2 + [[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/} + ln -sfn -- "$(convert_abs_rel "${_dest}" "${_source}")" "${initdir}/${_dest}" + } +fi diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh new file mode 100644 index 0000000..9479480 --- /dev/null +++ b/dracut-initramfs-restore.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +# do some sanity checks first +[ -e /run/initramfs/bin/sh ] && exit 0 +[ -e /run/initramfs/.need_shutdown ] || exit 0 + +KERNEL_VERSION="$(uname -r)" + +[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut +SKIP="$dracutbasedir/skipcpio" +[[ -x $SKIP ]] || SKIP=cat + +[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id + +mount -o ro /boot &>/dev/null || true + +if [[ $MACHINE_ID ]] && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then + IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd" +fi +[[ -f $IMG ]] || IMG="/boot/initramfs-${KERNEL_VERSION}.img" + +cd /run/initramfs + +[ -f .need_shutdown -a -f "$IMG" ] || exit 1 + +if $SKIP "$IMG" | zcat | cpio -id --no-absolute-filenames --quiet >/dev/null; then + rm -f -- .need_shutdown +elif $SKIP "$IMG" | xzcat | cpio -id --no-absolute-filenames --quiet >/dev/null; then + rm -f -- .need_shutdown +elif $SKIP "$IMG" | lz4 -d -c | cpio -id --no-absolute-filenames --quiet >/dev/null; then + rm -f -- .need_shutdown +elif $SKIP "$IMG" | zstd -d -c | cpio -id --no-absolute-filenames --quiet >/dev/null; then + rm -f -- .need_shutdown +else + # something failed, so we clean up + echo "Unpacking of $IMG to /run/initramfs failed" >&2 + rm -f -- /run/initramfs/shutdown + exit 1 +fi + +exit 0 diff --git a/dracut-logger.sh b/dracut-logger.sh new file mode 100755 index 0000000..e72716f --- /dev/null +++ b/dracut-logger.sh @@ -0,0 +1,441 @@ +#!/bin/bash +# +# logging faciality module for dracut both at build- and boot-time +# +# Copyright 2010 Amadeusz Żołnowski +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +__DRACUT_LOGGER__=1 + + +## @brief Logging facility module for dracut both at build- and boot-time. +# +# @section intro Introduction +# +# The logger takes a bit from Log4j philosophy. There are defined 6 logging +# levels: +# - TRACE (6) +# The TRACE Level designates finer-grained informational events than the +# DEBUG. +# - DEBUG (5) +# The DEBUG Level designates fine-grained informational events that are most +# useful to debug an application. +# - INFO (4) +# The INFO level designates informational messages that highlight the +# progress of the application at coarse-grained level. +# - WARN (3) +# The WARN level designates potentially harmful situations. +# - ERROR (2) +# The ERROR level designates error events that might still allow the +# application to continue running. +# - FATAL (1) +# The FATAL level designates very severe error events that will presumably +# lead the application to abort. +# Descriptions are borrowed from Log4j documentation: +# http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html +# +# @section usage Usage +# +# First of all you have to start with dlog_init() function which initializes +# required variables. Don't call any other logging function before that one! +# If you're ready with this, you can use following functions which corresponds +# clearly to levels listed in @ref intro Introduction. Here they are: +# - dtrace() +# - ddebug() +# - dinfo() +# - dwarn() +# - derror() +# - dfatal() +# They take all arguments given as a single message to be logged. See dlog() +# function for details how it works. Note that you shouldn't use dlog() by +# yourself. It's wrapped with above functions. +# +# @see dlog_init() dlog() +# +# @section conf Configuration +# +# Logging is controlled by following global variables: +# - @var stdloglvl - logging level to standard error (console output) +# - @var sysloglvl - logging level to syslog (by logger command) +# - @var fileloglvl - logging level to file +# - @var kmsgloglvl - logging level to /dev/kmsg (only for boot-time) +# - @var logfile - log file which is used when @var fileloglvl is higher +# than 0 +# and two global variables: @var maxloglvl and @var syslogfacility which must +# not be overwritten. Both are set by dlog_init(). @var maxloglvl holds +# maximum logging level of those three and indicates that dlog_init() was run. +# @var syslogfacility is set either to 'user' (when building initramfs) or +# 'daemon' (when booting). +# +# Logging level set by the variable means that messages from this logging level +# and above (FATAL is the highest) will be shown. Logging levels may be set +# independently for each destination (stderr, syslog, file, kmsg). +# +# @see dlog_init() + + +## @brief Initializes dracut Logger. +# +# @retval 1 if something has gone wrong +# @retval 0 on success. +# +# @note This function need to be called before any other from this file. +# +# If any of the variables is not set, this function set it to default: +# - @var stdloglvl = 4 (info) +# - @var sysloglvl = 0 (no logging) +# - @var fileloglvl is set to 4 when @var logfile is set too, otherwise it's +# - @var kmsgloglvl = 0 (no logging) +# set to 0 +# +# @warning Function sets global variables @var maxloglvl and @syslogfacility. +# See file doc comment for details. +dlog_init() { + local __oldumask + local ret=0; local errmsg + [ -z "$stdloglvl" ] && stdloglvl=4 + [ -z "$sysloglvl" ] && sysloglvl=0 + [ -z "$kmsgloglvl" ] && kmsgloglvl=0 + # Skip initialization if it's already done. + [ -n "$maxloglvl" ] && return 0 + + if [ -z "$fileloglvl" ]; then + [ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0 + elif (( $fileloglvl > 0 )); then + if [[ $logfile ]]; then + __oldumask=$(umask) + umask 0377 + ! [ -e "$logfile" ] && >"$logfile" + umask $__oldumask + if [ -w "$logfile" -a -f "$logfile" ]; then + # Mark new run in the log file + echo >>"$logfile" + if command -v date >/dev/null; then + echo "=== $(date) ===" >>"$logfile" + else + echo "===============================================" >>"$logfile" + fi + echo >>"$logfile" + else + # We cannot log to file, so turn this facility off. + fileloglvl=0 + ret=1 + errmsg="'$logfile' is not a writable file" + fi + fi + fi + + if (( $UID != 0 )); then + kmsgloglvl=0 + sysloglvl=0 + fi + + if (( $sysloglvl > 0 )); then + if [[ -d /run/systemd/journal ]] \ + && type -P systemd-cat &>/dev/null \ + && systemctl --quiet is-active systemd-journald.socket &>/dev/null \ + && { echo "dracut-$DRACUT_VERSION" | systemd-cat -t 'dracut' &>/dev/null; } ; then + readonly _systemdcatfile="$DRACUT_TMPDIR/systemd-cat" + mkfifo "$_systemdcatfile" + readonly _dlogfd=15 + systemd-cat -t 'dracut' --level-prefix=true <"$_systemdcatfile" & + exec 15>"$_systemdcatfile" + elif ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null; then + # We cannot log to syslog, so turn this facility off. + kmsgloglvl=$sysloglvl + sysloglvl=0 + ret=1 + errmsg="No '/dev/log' or 'logger' included for syslog logging" + fi + fi + + if (($sysloglvl > 0)) || (($kmsgloglvl > 0 )); then + if [ -n "$dracutbasedir" ]; then + readonly syslogfacility=user + else + readonly syslogfacility=daemon + fi + export syslogfacility + fi + + local lvl; local maxloglvl_l=0 + for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do + (( $lvl > $maxloglvl_l )) && maxloglvl_l=$lvl + done + readonly maxloglvl=$maxloglvl_l + export maxloglvl + + + if (($stdloglvl < 6)) && (($kmsgloglvl < 6)) && (($fileloglvl < 6)) && (($sysloglvl < 6)); then + unset dtrace + dtrace() { :; }; + fi + + if (($stdloglvl < 5)) && (($kmsgloglvl < 5)) && (($fileloglvl < 5)) && (($sysloglvl < 5)); then + unset ddebug + ddebug() { :; }; + fi + + if (($stdloglvl < 4)) && (($kmsgloglvl < 4)) && (($fileloglvl < 4)) && (($sysloglvl < 4)); then + unset dinfo + dinfo() { :; }; + fi + + if (($stdloglvl < 3)) && (($kmsgloglvl < 3)) && (($fileloglvl < 3)) && (($sysloglvl < 3)); then + unset dwarn + dwarn() { :; }; + unset dwarning + dwarning() { :; }; + fi + + if (($stdloglvl < 2)) && (($kmsgloglvl < 2)) && (($fileloglvl < 2)) && (($sysloglvl < 2)); then + unset derror + derror() { :; }; + fi + + if (($stdloglvl < 1)) && (($kmsgloglvl < 1)) && (($fileloglvl < 1)) && (($sysloglvl < 1)); then + unset dfatal + dfatal() { :; }; + fi + + [ -n "$errmsg" ] && derror "$errmsg" + + return $ret +} + +## @brief Converts numeric logging level to the first letter of level name. +# +# @param lvl Numeric logging level in range from 1 to 6. +# @retval 1 if @a lvl is out of range. +# @retval 0 if @a lvl is correct. +# @result Echoes first letter of level name. +_lvl2char() { + case "$1" in + 1) echo F;; + 2) echo E;; + 3) echo W;; + 4) echo I;; + 5) echo D;; + 6) echo T;; + *) return 1;; + esac +} + +## @brief Converts numeric level to logger priority defined by POSIX.2. +# +# @param lvl Numeric logging level in range from 1 to 6. +# @retval 1 if @a lvl is out of range. +# @retval 0 if @a lvl is correct. +# @result Echoes logger priority. +_lvl2syspri() { + printf $syslogfacility. + case "$1" in + 1) echo crit;; + 2) echo error;; + 3) echo warning;; + 4) echo info;; + 5) echo debug;; + 6) echo debug;; + *) return 1;; + esac +} + +## @brief Converts dracut-logger numeric level to syslog log level +# +# @param lvl Numeric logging level in range from 1 to 6. +# @retval 1 if @a lvl is out of range. +# @retval 0 if @a lvl is correct. +# @result Echoes kernel console numeric log level +# +# Conversion is done as follows: +# +# +# none -> LOG_EMERG (0) +# none -> LOG_ALERT (1) +# FATAL(1) -> LOG_CRIT (2) +# ERROR(2) -> LOG_ERR (3) +# WARN(3) -> LOG_WARNING (4) +# none -> LOG_NOTICE (5) +# INFO(4) -> LOG_INFO (6) +# DEBUG(5) -> LOG_DEBUG (7) +# TRACE(6) / +# +# +# @see /usr/include/sys/syslog.h +_dlvl2syslvl() { + local lvl + + case "$1" in + 1) lvl=2;; + 2) lvl=3;; + 3) lvl=4;; + 4) lvl=6;; + 5) lvl=7;; + 6) lvl=7;; + *) return 1;; + esac + + [ "$syslogfacility" = user ] && echo $((8+$lvl)) || echo $((24+$lvl)) +} + +## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg +# given message with given level (priority). +# +# @param lvl Numeric logging level. +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +# +# @note This function is not supposed to be called manually. Please use +# dtrace(), ddebug(), or others instead which wrap this one. +# +# This is core logging function which logs given message to standard error, file +# and/or syslog (with POSIX shell command logger) and/or to /dev/kmsg. +# The format is following: +# +# X: some message +# +# where @c X is the first letter of logging level. See module description for +# details on that. +# +# Message to syslog is sent with tag @c dracut. Priorities are mapped as +# following: +# - @c FATAL to @c crit +# - @c ERROR to @c error +# - @c WARN to @c warning +# - @c INFO to @c info +# - @c DEBUG and @c TRACE both to @c debug +_do_dlog() { + local lvl="$1"; shift + local lvlc=$(_lvl2char "$lvl") || return 0 + local msg="$*" + local lmsg="$lvlc: $*" + + (( $lvl <= $stdloglvl )) && printf -- 'dracut: %s\n' "$msg" >&2 + + if (( $lvl <= $sysloglvl )); then + if [[ "$_dlogfd" ]]; then + printf -- "<%s>%s\n" "$(($(_dlvl2syslvl $lvl) & 7))" "$msg" >&$_dlogfd + else + logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) -- "$msg" + fi + fi + + if (( $lvl <= $fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then + echo "$lmsg" >>"$logfile" + fi + + (( $lvl <= $kmsgloglvl )) && \ + echo "<$(_dlvl2syslvl $lvl)>dracut[$$] $msg" >/dev/kmsg +} + +## @brief Internal helper function for _do_dlog() +# +# @param lvl Numeric logging level. +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +# +# @note This function is not supposed to be called manually. Please use +# dtrace(), ddebug(), or others instead which wrap this one. +# +# This function calls _do_dlog() either with parameter msg, or if +# none is given, it will read standard input and will use every line as +# a message. +# +# This enables: +# dwarn "This is a warning" +# echo "This is a warning" | dwarn +dlog() { + [ -z "$maxloglvl" ] && return 0 + (( $1 <= $maxloglvl )) || return 0 + + if (( $# > 1 )); then + _do_dlog "$@" + else + while read line || [ -n "$line" ]; do + _do_dlog "$1" "$line" + done + fi +} + +## @brief Logs message at TRACE level (6) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +dtrace() { + set +x + dlog 6 "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief Logs message at DEBUG level (5) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +ddebug() { + set +x + dlog 5 "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief Logs message at INFO level (4) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +dinfo() { + set +x + dlog 4 "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief Logs message at WARN level (3) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +dwarn() { + set +x + dlog 3 "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief It's an alias to dwarn() function. +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +dwarning() { + set +x + dwarn "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief Logs message at ERROR level (2) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +derror() { + set +x + dlog 2 "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief Logs message at FATAL level (1) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +dfatal() { + set +x + dlog 1 "$@" + [ -n "$debug" ] && set -x || : +} diff --git a/dracut.8.asc b/dracut.8.asc new file mode 100644 index 0000000..2e974fb --- /dev/null +++ b/dracut.8.asc @@ -0,0 +1,577 @@ +DRACUT(8) +========= +:doctype: manpage +:man source: dracut +:man manual: dracut + +NAME +---- +dracut - low-level tool for generating an initramfs/initrd image + +SYNOPSIS +-------- +*dracut* [__OPTION...__] [____ [____]] + +DESCRIPTION +----------- + +Create an initramfs for the kernel with the version . +If is omitted, then the version of the actual running +kernel is used. If is omitted or empty, then the default location +/boot/initramfs-.img is used. + +dracut creates an initial image used by the kernel for preloading the block +device modules (such as IDE, SCSI or RAID) which are needed to access the root +filesystem, mounting the root filesystem and booting into the real system. + +At boot time, the kernel unpacks that archive into RAM disk, mounts and uses it +as initial root file system. All finding of the root device happens in this +early userspace. + +Initramfs images are also called "initrd". + +For a complete list of kernel command line options see *dracut.cmdline*(7). + +If you are dropped to an emergency shell, while booting your initramfs, +the file _/run/initramfs/rdsosreport.txt_ is created, which can be saved to a +(to be mounted by hand) partition (usually /boot) or a USB stick. +Additional debugging info can be produced by adding **rd.debug** to the kernel +command line. _/run/initramfs/rdsosreport.txt_ contains all logs and the output +of some tools. It should be attached to any report about dracut problems. + +USAGE +----- + +include::dracut.usage.asc[] + +OPTIONS +------- +**--kver** __:: + set the kernel version. This enables to specify the kernel version, without + specifying the location of the initramfs image. For example: +---- +# dracut --kver 3.5.0-0.rc7.git1.2.fc18.x86_64 +---- + +**-f, --force**:: + overwrite existing initramfs file. + +**-a, --add** __:: + add a space-separated list of dracut modules to the default set of modules. + This parameter can be specified multiple times. ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --add "module1 module2" ... +---- +=============================== + +**--force-add** __:: + force to add a space-separated list of dracut modules to the default set of + modules, when -H is specified. This parameter can be specified multiple + times. ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --force-add "module1 module2" ... +---- +=============================== + +**-o, --omit** __:: + omit a space-separated list of dracut modules. This parameter can be + specified multiple times. ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --omit "module1 module2" ... +---- +=============================== + +**-m, --modules** __:: + specify a space-separated list of dracut modules to call when building the + initramfs. Modules are located in _/usr/lib/dracut/modules.d_. This + parameter can be specified multiple times. + This option forces dracut to only include the specified dracut modules. + In most cases the "--add" option is what you want to use. ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --modules "module1 module2" ... +---- +=============================== + +**-d, --drivers** __:: + specify a space-separated list of kernel modules to exclusively include + in the initramfs. The kernel modules have to be specified without the ".ko" + suffix. This parameter can be specified multiple times. ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --drivers "kmodule1 kmodule2" ... +---- +=============================== + +**--add-drivers** __:: + specify a space-separated list of kernel modules to add to the initramfs. + The kernel modules have to be specified without the ".ko" suffix. This + parameter can be specified multiple times. ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --add-drivers "kmodule1 kmodule2" ... +---- +=============================== + +**--force-drivers** __:: + See add-drivers above. But in this case it is ensured that the drivers + are tried to be loaded early via modprobe. ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --force-drivers "kmodule1 kmodule2" ... +---- +=============================== + +**--omit-drivers** __:: + specify a space-separated list of kernel modules not to add to the + initramfs. + The kernel modules have to be specified without the ".ko" suffix. This + parameter can be specified multiple times. ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --omit-drivers "kmodule1 kmodule2" ... +---- +=============================== + +**--filesystems** __:: + specify a space-separated list of kernel filesystem modules to exclusively + include in the generic initramfs. This parameter can be specified multiple + times. ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --filesystems "filesystem1 filesystem2" ... +---- +=============================== + +**-k, --kmoddir** __:: + specify the directory, where to look for kernel modules + +**--fwdir** _[:...]++_:: + specify additional directories, where to look for firmwares. This parameter + can be specified multiple times. + +**--kernel-cmdline **:: + specify default kernel command line parameters + + +**--kernel-only**:: + only install kernel drivers and firmware files + +**--no-kernel**:: + do not install kernel drivers and firmware files + +**--early-microcode**:: + Combine early microcode with ramdisk + +**--no-early-microcode**:: + Do not combine early microcode with ramdisk + +**--print-cmdline**:: + print the kernel command line for the current disk layout + +**--mdadmconf**:: + include local _/etc/mdadm.conf_ + +**--nomdadmconf**:: + do not include local _/etc/mdadm.conf_ + +**--lvmconf**:: + include local _/etc/lvm/lvm.conf_ + +**--nolvmconf**:: + do not include local _/etc/lvm/lvm.conf_ + +**--fscks** [LIST]:: + add a space-separated list of fsck tools, in addition to _dracut.conf_'s + specification; the installation is opportunistic (non-existing tools are + ignored) ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --fscks "fsck.foo barfsck" ... +---- +=============================== + +**--nofscks**:: + inhibit installation of any fsck tools + +**--strip**:: + strip binaries in the initramfs (default) + +**--nostrip**:: + do not strip binaries in the initramfs + +**--hardlink**:: + hardlink files in the initramfs (default) + +**--nohardlink**:: + do not hardlink files in the initramfs + +**--prefix** __:: + prefix initramfs files with the specified directory + +**--noprefix**:: + do not prefix initramfs files (default) + +**-h, --help**:: + display help text and exit. + +**--debug**:: + output debug information of the build process + +**-v, --verbose**:: + increase verbosity level (default is info(4)) + +**-q, --quiet**:: decrease verbosity level (default is info(4)) + +**-c, --conf** __:: + specify configuration file to use. ++ +Default: + _/etc/dracut.conf_ + +**--confdir** __:: + specify configuration directory to use. ++ +Default: + _/etc/dracut.conf.d_ + +**--tmpdir** __:: + specify temporary directory to use. ++ +Default: + _/var/tmp_ + +**--sshkey** __:: ssh key file used with ssh-client module. + +**--logfile** __:: logfile to use; overrides any setting from + the configuration files. ++ +Default: + _/var/log/dracut.log_ + +**-l, --local**:: + activates the local mode. dracut will use modules from the current working + directory instead of the system-wide installed modules in + _/usr/lib/dracut/modules.d_. + This is useful when running dracut from a git checkout. + +**-H, --hostonly**:: + Host-Only mode: Install only what is needed for booting the local host + instead of a generic host and generate host-specific configuration. ++ +[WARNING] +==== +If chrooted to another root other than the real root device, use "--fstab" and +provide a valid _/etc/fstab_. +==== + +**-N, --no-hostonly**:: + Disable Host-Only mode + +**--hostonly-cmdline**: + Store kernel command line arguments needed in the initramfs + +**--no-hostonly-cmdline**: + Do not store kernel command line arguments needed in the initramfs + +**--no-hostonly-default-device**: + Do not generate implicit host devices like root, swap, fstab, etc. + Use "--mount" or "--add-device" to explicitly add devices as needed. + +**--hostonly-i18n**: + Install only needed keyboard and font files according to the host configuration (default). + +**--no-hostonly-i18n**: + Install all keyboard and font files available. + +**--persistent-policy** __:: + Use __ to address disks and partitions. + __ can be any directory name found in /dev/disk. + E.g. "by-uuid", "by-label" + +**--fstab**:: + Use _/etc/fstab_ instead of _/proc/self/mountinfo_. + +**--add-fstab** __:: + Add entries of __ to the initramfs /etc/fstab. + +**--mount** "__ __ __ [__ [__ [__]]]":: + Mount __ on __ with __ in the + initramfs. __, __ and __ can + be specified, see fstab manpage for the details. + The default __ is "defaults". + The default __ is "0". + the default __ is "2". + +**--mount** "__":: + Like above, but __, __ and __ + are determined by looking at the current mounts. + +**--add-device** __ :: + Bring up __ in initramfs, __ should be the device name. + This can be useful in hostonly mode for resume support when your swap is on + LVM or an encrypted partition. + [NB --device can be used for compatibility with earlier releases] + +**-i, --include** __ __:: + include the files in the SOURCE directory into the + TARGET directory in the final initramfs. If SOURCE is a file, it will be + installed to TARGET in the final initramfs. This parameter can be specified + multiple times. + +**-I, --install** __:: + install the space separated list of files into the initramfs. ++ +[NOTE] +=============================== +If [LIST] has multiple arguments, then you have to put these in quotes. For +example: +---- +# dracut --install "/bin/foo /sbin/bar" ... +---- +=============================== + +**--install-optional** __:: + install the space separated list of files into the initramfs, if they exist. + +**--gzip**:: + Compress the generated initramfs using gzip. This will be done by default, + unless another compression option or --no-compress is passed. Equivalent to + "--compress=gzip -9" + +**--bzip2**:: + Compress the generated initramfs using bzip2. ++ +[WARNING] +==== +Make sure your kernel has bzip2 decompression support compiled in, otherwise you +will not be able to boot. Equivalent to "--compress=bzip2" +==== + +**--lzma**:: + Compress the generated initramfs using lzma. ++ +[WARNING] +==== +Make sure your kernel has lzma decompression support compiled in, otherwise you +will not be able to boot. Equivalent to "lzma --compress=lzma -9" +==== + +**--xz**:: + Compress the generated initramfs using xz. ++ +[WARNING] +==== +Make sure your kernel has xz decompression support compiled in, otherwise you +will not be able to boot. Equivalent to +"lzma --compress=xz --check=crc32 --lzma2=dict=1MiB" +==== + +**--lzo**:: + Compress the generated initramfs using lzop. +[WARNING] +==== +Make sure your kernel has lzo decompression support compiled in, otherwise you +will not be able to boot. +==== + +**--lz4**:: + Compress the generated initramfs using lz4. +[WARNING] +==== +Make sure your kernel has lz4 decompression support compiled in, otherwise you +will not be able to boot. +==== + +**--zstd**:: + Compress the generated initramfs using Zstandard. +[WARNING] +==== +Make sure your kernel has zstd decompression support compiled in, otherwise you +will not be able to boot. +==== + +**--compress** __:: + Compress the generated initramfs using the passed compression program. If + you pass it just the name of a compression program, it will call that + program with known-working arguments. If you pass a quoted string with + arguments, it will be called with exactly those arguments. Depending on what + you pass, this may result in an initramfs that the kernel cannot decompress. + The default value can also be set via the _INITRD_COMPRESS_ environment variable. + +**--no-compress**:: + Do not compress the generated initramfs. This will override any other + compression options. + +**--reproducible**:: + Create reproducible images. + +**--no-reproducible**:: + Do not create reproducible images. + +**--list-modules**:: + List all available dracut modules. + +**-M, --show-modules**:: + Print included module's name to standard output during build. + +**--keep**:: + Keep the initramfs temporary directory for debugging purposes. + +**--printsize**:: + Print out the module install size + +**--profile**: + Output profile information of the build process + +**--ro-mnt**: + Mount / and /usr read-only by default. + +**-L, --stdlog** __:: + [0-6] Specify logging level (to standard error) +---- + 0 - suppress any messages + 1 - only fatal errors + 2 - all errors + 3 - warnings + 4 - info + 5 - debug info (here starts lots of output) + 6 - trace info (and even more) +---- + +**--regenerate-all**:: + Regenerate all initramfs images at the default location with the kernel + versions found on the system. Additional parameters are passed through. + +**--loginstall __**:: + Log all files installed from the host to __. + +**--uefi**:: + Instead of creating an initramfs image, dracut will create an UEFI executable, + which can be executed by an UEFI BIOS. The default output filename is + _/EFI/Linux/linux-$kernel$--.efi_. might be + _/efi_, _/boot_ or _/boot/efi_ depending on where the ESP partition is mounted. + The is taken from BUILD_ID in _/usr/lib/os-release_ or if it exists + _/etc/os-release_ and is left out, if BUILD_ID is non-existant or empty. + +**--no-machineid**:: + affects the default output filename of **--uefi** and will discard the + part. + +**--uefi-stub __**:: + Specifies the UEFI stub loader, which will load the attached kernel, initramfs and + kernel command line and boots the kernel. The default is + _$prefix/lib/systemd/boot/efi/linux.efi.stub_ + or _$prefix/lib/gummiboot/linux.efi.stub_ + +**--kernel-image __**:: + Specifies the kernel image, which to include in the UEFI executable. The default is + _/lib/modules//vmlinuz_ or _/boot/vmlinuz-_ + +ENVIRONMENT +----------- + +_INITRD_COMPRESS_:: + sets the default compression program. See **--compress**. + +FILES +----- +_/var/log/dracut.log_:: + logfile of initramfs image creation + +_/tmp/dracut.log_:: + logfile of initramfs image creation, if _/var/log/dracut.log_ is not + writable + +_/etc/dracut.conf_:: + see dracut.conf5 + +_/etc/dracut.conf.d/*.conf_:: + see dracut.conf5 + +_/usr/lib/dracut/dracut.conf.d/*.conf_:: + see dracut.conf5 + +Configuration in the initramfs +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +_/etc/conf.d/_:: + Any files found in _/etc/conf.d/_ will be sourced in the initramfs to + set initial values. Command line options will override these values + set in the configuration files. + +_/etc/cmdline_:: + Can contain additional command line options. Deprecated, better use + /etc/cmdline.d/*.conf. + +_/etc/cmdline.d/*.conf_:: + Can contain additional command line options. + +AVAILABILITY +------------ +The dracut command is part of the dracut package and is available from +link:$$https://dracut.wiki.kernel.org$$[https://dracut.wiki.kernel.org] + +AUTHORS +------- +Harald Hoyer + +Victor Lowther + +Philippe Seewer + +Warren Togami + +Amadeusz Żołnowski + +Jeremy Katz + +David Dillow + +Will Woods + +SEE ALSO +-------- +*dracut.cmdline*(7) *dracut.conf*(5) *lsinitrd*(1) diff --git a/dracut.asc b/dracut.asc new file mode 100644 index 0000000..f2470e0 --- /dev/null +++ b/dracut.asc @@ -0,0 +1,185 @@ +dracut +====== +Harald Hoyer +v3.0, October 2013 + +:language: bash + += Introduction +This section is a modified version of +http://en.wikipedia.org/wiki/Initrd which is licensed under the +Creative Commons Attribution/Share-Alike License. + +== Definition +An _initial ramdisk_ is a temporary file system used in the boot process of the +Linux kernel. _initrd_ and _initramfs_ refer to slightly different schemes for +loading this file system into memory. Both are commonly used to make +preparations before the real root file system can be mounted. + +== Rationale +Many Linux distributions ship a single, generic kernel image that is intended to +boot as wide a variety of hardware as possible. The device drivers for this +generic kernel image are included as loadable modules, as it is not possible to +statically compile them all into the one kernel without making it too large to +boot from computers with limited memory or from lower-capacity media like floppy +disks. + +This then raises the problem of detecting and loading the modules necessary to +mount the root file system at boot time (or, for that matter, deducing where or +what the root file system is). + +To further complicate matters, the root file system may be on a software RAID +volume, LVM, NFS (on diskless workstations), or on an encrypted partition. All +of these require special preparations to mount. + +Another complication is kernel support for hibernation, which suspends the +computer to disk by dumping an image of the entire system to a swap partition or +a regular file, then powering off. On next boot, this image has to be made +accessible before it can be loaded back into memory. + +To avoid having to hardcode handling for so many special cases into the kernel, +an initial boot stage with a temporary root file system +—now dubbed early user space— is used. This root file system would contain +user-space helpers that would do the hardware detection, module loading and +device discovery necessary to get the real root file system mounted. + +== Implementation +An image of this initial root file system (along with the kernel image) must be +stored somewhere accessible by the Linux bootloader or the boot firmware of the +computer. This can be: + +* The root file system itself +* A boot image on an optical disc +* A small ext2/ext3 or FAT-formatted partition on a local disk + (a _boot partition_) +* A TFTP server (on systems that can boot from Ethernet) + +The bootloader will load the kernel and initial root file system image into +memory and then start the kernel, passing in the memory address of the image. + +Depending on which algorithms were compiled statically into it, the kernel can +currently unpack initrd/initramfs images compressed with gzip, bzip2 and LZMA. + +== Mount preparations +dracut can generate a customized initrams image which contains only whatever is +necessary to boot some particular computer, such as ATA, SCSI and filesystem +kernel modules (host-only mode). + +dracut can also generate a more generic initramfs image (default mode). + +dracut's initramfs starts only with the device name of the root file system (or +its UUID) and must discover everything else at boot time. A complex cascade of +tasks must be performed to get the root file system mounted: + +* Any hardware drivers that the boot process depends on must be loaded. All +kernel modules for common storage devices are packed onto the initramfs and then +udev pulls in modules matching the computer's detected hardware. + +* On systems which display a boot rd.splash screen, the video hardware must be +initialized and a user-space helper started to paint animations onto the display +in lockstep with the boot process. + +* If the root file system is on NFS, dracut does then: +** Bring up the primary network interface. +** Invoke a DHCP client, with which it can obtain a DHCP lease. +** Extract the name of the NFS share and the address of the NFS server from the +lease. +** Mount the NFS share. + +* If the root file system appears to be on a software RAID device, there is no +way of knowing which devices the RAID volume spans; the standard MD utilities +must be invoked to scan all available block devices with a raid signature and +bring the required ones online. + +* If the root file system appears to be on a logical volume, the LVM utilities +must be invoked to scan for and activate the volume group containing it. + +* If the root file system is on an encrypted block device: +** Invoke a helper script to prompt the user to type in a passphrase and/or +insert a hardware token (such as a smart card or a USB security dongle). + +* Create a decryption target with the device mapper. + +dracut uses udev, an event-driven hotplug agent, which invokes helper programs +as hardware devices, disk partitions and storage volumes matching certain rules +come online. This allows discovery to run in parallel, and to progressively +cascade into arbitrary nestings of LVM, RAID or encryption to get at the root +file system. + +When the root file system finally becomes visible: + +* Any maintenance tasks which cannot run on a mounted root file system +are done. +* The root file system is mounted read-only. +* Any processes which must continue running (such as the rd.splash screen helper +and its command FIFO) are hoisted into the newly-mounted root file system. + +The final root file system cannot simply be mounted over /, since that would +make the scripts and tools on the initial root file system inaccessible for any +final cleanup tasks. On an initramfs, the initial root file system cannot be +rotated away. Instead, it is simply emptied and the final root file system +mounted over the top. + +If the systemd module is used in the initramfs, the ordering of the services +started looks like <>. + +== Dracut on shutdown + +On a systemd driven system, the dracut initramfs is also used for the shutdown +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 +* 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 + +This ensures, that all devices are disassembled and unmounted cleanly. + += User Manual + +:leveloffset: 1 +include::dracut.8.asc[] + +:leveloffset: 1 +[[dracutconf5]] +include::dracut.conf.5.asc[] + +[[dracutcmdline7]] +include::dracut.cmdline.7.asc[] + +[[lsinitrd1]] +include::lsinitrd.1.asc[] + +[[mkinitrd8]] +include::mkinitrd.8.asc[] + += Developer Manual + +:leveloffset: 1 +[[dracutmodules7]] +include::dracut.modules.7.asc[] + +[[dracutbootup7]] +include::dracut.bootup.7.asc[] + +:leveloffset: 0 +[appendix] +License +------- +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/dracut.bootup.7.asc b/dracut.bootup.7.asc new file mode 100644 index 0000000..d7edc1e --- /dev/null +++ b/dracut.bootup.7.asc @@ -0,0 +1,123 @@ +DRACUT.BOOTUP(7) +================ +:doctype: manpage +:man source: dracut +:man manual: dracut + +NAME +---- +dracut.bootup - boot ordering in the initramfs + +DESCRIPTION +----------- + +This flow chart illustrates the ordering of the services, if systemd is used in +the dracut initramfs. +---- + + systemd-journal.socket + | + v + dracut-cmdline.service + | + v + dracut-pre-udev.service + | + v + systemd-udevd.service + | + v +local-fs-pre.target dracut-pre-trigger.service + | | + v v + (various mounts) (various swap systemd-udev-trigger.service + | devices...) | (various low-level (various low-level + | | | services: seed, API VFS mounts: + v v v tmpfiles, random mqueue, configfs, + local-fs.target swap.target dracut-initqueue.service sysctl, ...) debugfs, ...) + | | | | | + \_______________|____________________ | ___________________|____________________/ + \|/ + v + sysinit.target + | + _________________/|\___________________ + / | \ + | | | + v | v + (various | rescue.service + sockets...) | | + | | v + v | rescue.target + sockets.target | + | | + \_________________ | emergency.service + \| | + v v + basic.target emergency.target + | + ______________________/| + / | + | v + | dracut-pre-mount.service + | | + | v + | sysroot.mount + | | + | v + | initrd-root-fs.target + (custom initrd services) | + | v + | dracut-mount.service + | | + | v + | initrd-parse-etc.service + | | + | v + | (sysroot-usr.mount and + | various mounts marked + | with fstab option + | x-initrd.mount) + | | + | v + | initrd-fs.target + \______________________ | + \| + v + initrd.target + | + v + dracut-pre-pivot.service + | + v + initrd-cleanup.service + isolates to + initrd-switch-root.target + | + v + ______________________/| + / | + | initrd-udevadm-cleanup-db.service + | | + (custom initrd services) | + | | + \______________________ | + \| + v + initrd-switch-root.target + | + v + initrd-switch-root.service + | + v + switch-root +---- + + +AUTHOR +------ +Harald Hoyer + +SEE ALSO +-------- +*dracut*(8) *bootup*(7) diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc new file mode 100644 index 0000000..3cee5a0 --- /dev/null +++ b/dracut.cmdline.7.asc @@ -0,0 +1,1277 @@ +DRACUT.CMDLINE(7) +================= +:doctype: manpage +:man source: dracut +:man manual: dracut + +NAME +---- +dracut.cmdline - dracut kernel command line options + +DESCRIPTION +----------- +The root device used by the kernel is specified in the boot configuration +file on the kernel command line, as always. + +The traditional _root=/dev/sda1_ style device specification is allowed, but not +encouraged. The root device should better be identified by LABEL or UUID. If a +label is used, as in _root=LABEL=_ the initramfs will search all +available devices for a filesystem with the appropriate label, and mount that +device as the root filesystem. _root=UUID=_ will mount the partition +with that UUID as the root filesystem. + +In the following all kernel command line parameters, which are processed by +dracut, are described. + +"rd.*" parameters mentioned without "=" are boolean parameters. They can be +turned on/off by setting them to {0|1}. If the assignment with "=" is missing +"=1" is implied. For example _rd.info_ can be turned off with _rd.info=0_ or +turned on with _rd.info=1_ or _rd.info_. The last value in the kernel command +line is the value, which is honored. + +Standard +~~~~~~~~ +**init=**____:: + specify the path to the init program to be started after the initramfs has + finished + +**root=**____:: + specify the block device to use as the root filesystem. ++ +[listing] +.Example +-- +root=/dev/sda1 +root=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1 +root=/dev/disk/by-label/Root +root=LABEL=Root +root=/dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7 +root=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7 +root=PARTUUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7 +-- + +**rootfstype=**____:: "auto" if not specified. ++ +[listing] +.Example +-- +rootfstype=ext3 +-- + +**rootflags=**____:: + specify additional mount options for the root filesystem. If not set, + _/etc/fstab_ of the real root will be parsed for special mount options and + mounted accordingly. + +**ro**:: + force mounting _/_ and _/usr_ (if it is a separate device) read-only. If + none of ro and rw is present, both are mounted according to _/etc/fstab_. + +**rw**:: + force mounting _/_ and _/usr_ (if it is a separate device) read-write. + See also ro option. + +**rootfallback=**____:: + specify the block device to use as the root filesystem, if the normal root + cannot be found. This can only be a simple block device with a simple file + system, for which the filesystem driver is either compiled in, or added + manually to the initramfs. This parameter can be specified multiple times. + +**rd.auto** **rd.auto=1**:: + enable autoassembly of special devices like cryptoLUKS, dmraid, mdraid or + lvm. Default is off as of dracut version >= 024. + +**rd.hostonly=0**:: + removes all compiled in configuration of the host system the initramfs image + was built on. This helps booting, if any disk layout changed, especially in + combination with rd.auto or other parameters specifying the layout. + +**rd.cmdline=ask**:: + prompts the user for additional kernel command line parameters + +**rd.fstab=0**:: + do not honor special mount options for the root filesystem found in + _/etc/fstab_ of the real root. + +**resume=**____:: + resume from a swap partition ++ +[listing] +.Example +-- +resume=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1 +resume=/dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7 +resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7 +-- + +**rd.skipfsck**:: + skip fsck for rootfs and _/usr_. If you're mounting _/usr_ read-only and + the init system performs fsck before remount, you might want to use this + option to avoid duplication. + +iso-scan/filename +~~~~~~~~~~~~~~~~~ + +Using iso-scan/filename with a Fedora/Red Hat/CentOS Live iso should just work +by copying the original kernel cmdline parameters. + +[listing] +.Example +-- +menuentry 'Live Fedora 20' --class fedora --class gnu-linux --class gnu --class os { + set isolabel=Fedora-Live-LXDE-x86_64-20-1 + set isofile="/boot/iso/Fedora-Live-LXDE-x86_64-20-1.iso" + loopback loop $isofile + linux (loop)/isolinux/vmlinuz0 boot=isolinux iso-scan/filename=$isofile root=live:LABEL=$isolabel ro rd.live.image quiet rhgb + initrd (loop)/isolinux/initrd0.img +} +-- + +Misc +~~~~ +**rd.emergency=**__[reboot|poweroff|halt]__:: + specify, what action to execute in case of a critical failure. rd.shell=0 also + be specified. + +**rd.driver.blacklist=**____[,____,...]:: + do not load kernel module . This parameter can be specified + multiple times. + +**rd.driver.pre=**____[,____,...]:: + force loading kernel module . This parameter can be specified + multiple times. + +**rd.driver.post=**____[,____,...]:: + force loading kernel module after all automatic loading modules + have been loaded. This parameter can be specified multiple times. + +**rd.retry=**____:: + specify how long dracut should retry the initqueue to configure devices. + The default is 30 seconds. After 2/3 of the time, degraded raids are force + started. If you have hardware, which takes a very long time to announce its + drives, you might want to extend this value. + +**rd.timeout=**____:: + specify how long dracut should wait for devices to appear. The + default is '0', which means 'forever'. Note that this timeout + should be longer than rd.retry to allow for proper configuration. + +**rd.noverifyssl**:: + accept self-signed certificates for ssl downloads. + +**rd.ctty=**____:: + specify the controlling terminal for the console. + This is useful, if you have multiple "console=" arguments. + +[[dracutkerneldebug]] +Debug +~~~~~ +If you are dropped to an emergency shell, the file +_/run/initramfs/rdsosreport.txt_ is created, which can be saved to a (to be +mounted by hand) partition (usually /boot) or a USB stick. Additional debugging +info can be produced by adding **rd.debug** to the kernel command line. +_/run/initramfs/rdsosreport.txt_ contains all logs and the output of some tools. +It should be attached to any report about dracut problems. + +**rd.info**:: + print informational output though "quiet" is set + +**rd.shell**:: + allow dropping to a shell, if root mounting fails + +**rd.debug**:: + set -x for the dracut shell. + If systemd is active in the initramfs, all output is logged to the systemd + journal, which you can inspect with "journalctl -ab". + If systemd is not active, the logs are written to dmesg and + _/run/initramfs/init.log_. + If "quiet" is set, it also logs to the console. + +**rd.memdebug=[0-4]**:: + Print memory usage info at various points, set the verbose level from 0 to 4. ++ + Higher level means more debugging output: ++ +---- + 0 - no output + 1 - partial /proc/meminfo + 2 - /proc/meminfo + 3 - /proc/meminfo + /proc/slabinfo + 4 - /proc/meminfo + /proc/slabinfo + tracekomem + NOTE: tracekomem is a shell script utilizing kernel trace to track + the rough total memory consumption of kernel modules during + loading. It may override other trace configurations. +---- + +**rd.break**:: + drop to a shell at the end + +**rd.break=**__{cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot|cleanup}__:: + drop to a shell on defined breakpoint + +**rd.udev.info**:: + set udev to loglevel info + +**rd.udev.debug**:: + set udev to loglevel debug + +I18N +~~~~ +**rd.vconsole.keymap=**____:: + keyboard translation table loaded by loadkeys; taken from keymaps directory; + will be written as KEYMAP to _/etc/vconsole.conf_ in the initramfs. ++ +[listing] +.Example +-- +rd.vconsole.keymap=de-latin1-nodeadkeys +-- + +**rd.vconsole.keymap.ext=**____:: + list of extra keymaps to bo loaded (sep. by space); will be written as + EXT_KEYMAP to _/etc/vconsole.conf_ in the initramfs + +**rd.vconsole.unicode**:: + boolean, indicating UTF-8 mode; will be written as UNICODE to + _/etc/vconsole.conf_ in the initramfs + +**rd.vconsole.font=**____:: + console font; taken from consolefonts directory; will be written as FONT to + _/etc/vconsole.conf_ in the initramfs. ++ +[listing] +.Example +-- +rd.vconsole.font=LatArCyrHeb-16 +-- + +**rd.vconsole.font.map=**____:: + see description of '-m' parameter in setfont manual; taken from consoletrans + directory; will be written as FONT_MAP to _/etc/vconsole.conf_ in the + initramfs + +**rd.vconsole.font.unimap=**____:: + see description of '-u' parameter in setfont manual; taken from unimaps + directory; will be written as FONT_UNIMAP to _/etc/vconsole.conf_ in the + initramfs + +**rd.locale.LANG=**____:: + taken from the environment; if no UNICODE is defined we set its value in + basis of LANG value (whether it ends with ".utf8" (or similar) or not); will + be written as LANG to _/etc/locale.conf_ in the initramfs. ++ +[listing] +.Example +-- +rd.locale.LANG=pl_PL.utf8 +-- + +**rd.locale.LC_ALL=**____:: + taken from the environment; will be written as LC_ALL to _/etc/locale.conf_ + in the initramfs + +LVM +~~~ +**rd.lvm=0**:: + disable LVM detection + +**rd.lvm.vg=**____:: + only activate the volume groups with the given name. rd.lvm.vg can be + specified multiple times on the kernel command line. + +**rd.lvm.lv=**____:: + only activate the logical volumes with the given name. rd.lvm.lv can be + specified multiple times on the kernel command line. + +**rd.lvm.conf=0**:: + remove any _/etc/lvm/lvm.conf_, which may exist in the initramfs + +crypto LUKS +~~~~~~~~~~~ +**rd.luks=0**:: + disable crypto LUKS detection + +**rd.luks.uuid=**____:: + only activate the LUKS partitions with the given UUID. Any "luks-" of the + LUKS UUID is removed before comparing to __. + The comparisons also matches, if __ is only the beginning of the + LUKS UUID, so you don't have to specify the full UUID. + This parameter can be specified multiple times. + +**rd.luks.allow-discards=**____:: + Allow using of discards (TRIM) requests for LUKS partitions with the given + UUID. Any "luks-" of the LUKS UUID is removed before comparing to + __. The comparisons also matches, if __ is only the + beginning of the LUKS UUID, so you don't have to specify the full UUID. + This parameter can be specified multiple times. + +**rd.luks.allow-discards**:: + Allow using of discards (TRIM) requests on all LUKS partitions. + +**rd.luks.crypttab=0**:: + do not check, if LUKS partition is in _/etc/crypttab_ + +**rd.luks.timeout=**____:: + specify how long dracut should wait when waiting for the user to enter the + password. This avoid blocking the boot if no password is entered. It does + not apply to luks key. The default is '0', which means 'forever'. + +crypto LUKS - key on removable device support +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +**rd.luks.key=**____:____:____:: + _keypath_ is a path to key file to look for. It's REQUIRED. When _keypath_ + ends with '.gpg' it's considered to be key encrypted symmetrically with GPG. + You will be prompted for password on boot. GPG support comes with + 'crypt-gpg' module which needs to be added explicitly. ++ +_keydev_ is a device on which key file resides. It might be kernel name of +devices (should start with "/dev/"), UUID (prefixed with "UUID=") or label +(prefix with "LABEL="). You don't have to specify full UUID. Just its beginning +will suffice, even if its ambiguous. All matching devices will be probed. +This parameter is recommended, but not required. If not present, all block +devices will be probed, which may significantly increase boot time. ++ +If _luksdev_ is given, the specified key will only be applied for that LUKS +device. Possible values are the same as for _keydev_. Unless you have several +LUKS devices, you don't have to specify this parameter. The simplest usage is: ++ +[listing] +.Example +-- +rd.luks.key=/foo/bar.key +-- ++ +As you see, you can skip colons in such a case. ++ +[NOTE] +=============================== +dracut pipes key to cryptsetup with _-d -_ argument, therefore you need to pipe +to crypsetup luksFormat with _-d -_, too! + +Here follows example for key encrypted with GPG: + +[listing] +-- +gpg --quiet --decrypt rootkey.gpg | \ +cryptsetup -d - -v --cipher serpent-cbc-essiv:sha256 \ +--key-size 256 luksFormat /dev/sda3 +-- + +If you use plain keys, just add path to _-d_ option: + +[listing] +-- +cryptsetup -d rootkey.key -v --cipher serpent-cbc-essiv:sha256 \ + --key-size 256 luksFormat /dev/sda3 +-- +=============================== + +MD RAID +~~~~~~~ +**rd.md=0**:: + disable MD RAID detection + +**rd.md.imsm=0**:: + disable MD RAID for imsm/isw raids, use DM RAID instead + +**rd.md.ddf=0**:: + disable MD RAID for SNIA ddf raids, use DM RAID instead + +**rd.md.conf=0**:: + ignore mdadm.conf included in initramfs + +**rd.md.waitclean=1**:: + wait for any resync, recovery, or reshape activity to finish before + continuing + +**rd.md.uuid=**____:: + only activate the raid sets with the given UUID. This parameter can be + specified multiple times. + +DM RAID +~~~~~~~ +**rd.dm=0**:: + disable DM RAID detection + +**rd.dm.uuid=**____:: + only activate the raid sets with the given UUID. This parameter can be + specified multiple times. + +MULTIPATH +~~~~~~~~~ +**rd.multipath=0**:: + disable multipath detection + +FIPS +~~~~ +**rd.fips**:: + enable FIPS + +**boot=**____:: + specify the device, where /boot is located. ++ +[listing] +.Example +-- +boot=/dev/sda1 +boot=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1 +boot=UUID= +boot=LABEL=