summaryrefslogtreecommitdiffstats
path: root/patches/source/mkinitrd/mkinitrd
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2018-05-25 23:29:36 +0000
committer Eric Hameleers <alien@slackware.com>2018-05-31 15:18:32 -0700
commit8ff4f2f51a6cf07fc33742ce3bee81328896e49b (patch)
tree4a166b8389404be98a6c098babaa444e2dec8f48 /patches/source/mkinitrd/mkinitrd
parent76fc4757ac91ac7947a01fb7b53dddf9a78a01d1 (diff)
downloadcurrent-8ff4f2f51a6cf07fc33742ce3bee81328896e49b.tar.gz
current-8ff4f2f51a6cf07fc33742ce3bee81328896e49b.tar.xz
Fri May 25 23:29:36 UTC 201814.1
patches/packages/glibc-zoneinfo-2018e-noarch-2_slack14.1.txz: Rebuilt. Handle removal of US/Pacific-New timezone. If we see that the machine is using this, it will be automatically switched to US/Pacific.
Diffstat (limited to '')
-rw-r--r--patches/source/mkinitrd/mkinitrd740
-rw-r--r--patches/source/mkinitrd/mkinitrd.8279
-rwxr-xr-xpatches/source/mkinitrd/mkinitrd.SlackBuild146
-rw-r--r--patches/source/mkinitrd/mkinitrd.conf.5244
-rw-r--r--patches/source/mkinitrd/mkinitrd.conf.sample21
-rw-r--r--patches/source/mkinitrd/mkinitrd_command_generator.8187
-rw-r--r--patches/source/mkinitrd/mkinitrd_command_generator.sh872
7 files changed, 2489 insertions, 0 deletions
diff --git a/patches/source/mkinitrd/mkinitrd b/patches/source/mkinitrd/mkinitrd
new file mode 100644
index 000000000..ed8f3247b
--- /dev/null
+++ b/patches/source/mkinitrd/mkinitrd
@@ -0,0 +1,740 @@
+#!/bin/sh
+# Copyright 2004 Slackware Linux, Inc., Concord, CA, USA
+# Copyright 2004 Patrick J. Volkerding, Concord, CA, USA
+# Copyright 2007, 2008, 2009, 2010, 2011, 2015, 2016, 2017 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Modified by Robby Workman <rworkman@slackware.com> 26 November 2007
+# to add support for mkinitrd.conf - No additional license terms added
+# Modified by Alan Hicks <alan@slackware.com> 27 November 2007 to enable
+# passing arguments to kernel modules - No additional license terms added
+# volkerdi - feel free to remove these :)
+# Modified by Eric Hameleers <alien@slackware.com> 3 April 2008
+# to add support custom keymaps - No additional license terms added
+# Modified by Patrick Volkerding <volkerdi@slackware.com> 17 Dec 2008
+# Added support to bail out if kernel modules are requested for a kernel
+# version that is not installed (thanks to Eric Hameleers), be more
+# verbose about showing modules added to the initrd (thanks to
+# Ellington Santos), and if "mount" returns /dev/root as the root device,
+# use readlink to resolve the device pointed to by the /dev/root
+# symlink, changed modprobe to use --ignore-install to avoid catching
+# custom "install" lines and causing /sbin/modprobe to be copied to the
+# initrd (thanks to Ken Milmore).
+# Of course, license terms remain unchanged.
+# Modified by Eric Hameleers <alien@slackware.com> 3 March 2010
+# Add lukskey option (-K). Automatically add kernel modules listed in
+# load-kernel-modules if that file is executable.
+# Yada yada yada.
+# Modified by Patrick Volkerding <volkerdi@slackware.com> 21 August 2012
+# Add Btrfs multi-device filesystem support option (-B).
+# Modified by Robby Workman <rworkman@slackware.com> 08 March 2017
+# to add support for TRIM on LUKS root devs
+# Modified by Patrick Volkerding <volkerdi@slackware.com> 29 June 2017
+# Add support for prepending a microcode update archive (-P).
+
+MKINITRD_VERSION=1.4.10
+
+# Don't include these things from /lib/udev/ in the initrd image
+LIBUDEV_BLACKLIST="\
+ ipod-set-info \
+ iphone-set-info \
+ check-mtp-device \
+ check-ptp-camera \
+ udev-configure-printer \
+ rules.d/60-openobex.rules \
+ rules.d/85-regulatory.rules \
+ "
+
+print_usage() {
+ cat << EOF
+Usage: mkinitrd [OPTION]
+
+mkinitrd creates an initial ramdisk (actually an initramfs cpio+gzip
+archive) used to load kernel modules that are needed to mount the
+root filesystem, or other modules that might be needed before the
+root filesystem is available. Other binaries may be added to the
+initrd, and the script is easy to modify. Be creative. :-)
+
+ -F Use the contents of /etc/mkinitrd.conf (optional)
+ If this is used in conjunction with any other options passed
+ on the command line, the command-line options will override
+ the config file options. See mkinitrd.conf(5) for details.
+ -c Clear the existing initrd tree first
+ -f Filesystem to use for root partition (must be used with -r)
+ --help Display this message
+ -h Device to resume from hibernation. Needs to be the name of
+ the swap partition holding the hibernation image.
+ -k Kernel version to use
+ -l Custom keymap to load. Like, 'nl' or 'de-latin1-nodeadkeys'
+ -m A colon (:) delimited list of kernel modules to load.
+ Additional options may be added to use when loading the
+ kernel modules (but in this case the entire list must be
+ wrapped with double quotes). Any dependencies of requested
+ modules will also be added to the initrd.
+ -o Output image (default /boot/initrd.gz)
+ -r Root partition device (must be used with -f)
+ -s Initrd source tree (default /boot/initrd-tree/)
+ -u Include udev in the initrd
+ -w Time to wait until all disks are detected
+ -C A colon (:) delimited list of luks encrypted block devices to be
+ unlocked by the initrd using cryptsetup. All devices that must
+ be unlocked in order to access the root filesystem must be
+ specified. (Use with '-r' parameter).
+ -T A colon (:) delimited list of luks encrypted block devices to be
+ passed the "--allow-discards" option when unlocked by the initrd
+ using cryptsetup. This has the effect of allowing TRIM on SSD drives.
+ Be sure your SSD supports this feature (correctly) before enabling
+ it. See fstrim(8) for more information.
+ -L Add support for LVM partitions
+ -K Use a USB key (fat-formatted) to unlock the root LUKS volume
+ The parameter value is filename of a keyfile, as well as the label
+ (or uuid) of the partition this file is on. This way, you can unlock
+ your computer automatically if you have a USB stick with your LUKS
+ key inserted at boot. A passphrase will still be asked if the LUKS
+ key can not be found.
+ For example, if your USB thumb drive has a FAT partition with label
+ "TRAVELSTICK" and the actual keyfile is called "/keys/alien.luks",
+ then you need to pass: -K LABEL=TRAVELSTICK:/keys/alien.luks
+ -B Add /sbin/btrfs to enable scanning for a root filesystem that is
+ part of a Btrfs multi-device filesystem.
+ -M Add the files in /etc/modprobe.d/ and /lib/modprobe.d/ to the initrd
+ -P Prepend the output image with the microcode CPIO archive given in arguments.
+ -R Add support for RAID partitions
+ -V Display version number
+
+A simple example: Build an initrd for a reiserfs root partition:
+
+ mkinitrd -c -m reiserfs
+
+Another example: Build an initrd image using Linux 2.6.35.4-smp kernel
+modules for a system with an ext4 root partition on /dev/sdb3:
+
+ mkinitrd -c -k 2.6.35.4-smp -m mbcache:jbd:ext4 -f ext4 -r /dev/sdb3
+
+Note that if you are already logged in with /dev/sdb3 as your /
+partition, and it is running ext4, this command works just the same:
+
+ mkinitrd -c -m ext4
+
+If run without options, mkinitrd will rebuild an initrd image using
+the contents of the $SOURCE_TREE directory, or, if that directory
+does not exist it will be created and populated, and then mkinitrd
+will exit.
+
+EOF
+}
+
+create_new_source_tree() {
+ mkdir -p $SOURCE_TREE
+ # Make sure a kernel module directory exists:
+ mkdir -p $SOURCE_TREE/lib/modules/${KERNEL_VERSION}
+ # Add the initrd-tree skeleton:
+ ( cd $SOURCE_TREE ; tar xzf /usr/share/mkinitrd/initrd-tree.tar.gz )
+ # Make sure we have any block devices that might be needed:
+
+ SLOPPY_DEV_LIST=$(cat /proc/partitions)
+ for device in $SLOPPY_DEV_LIST ; do
+ if [ ! -r $SOURCE_TREE/dev/$device ]; then
+ if [ -b /dev/$device ]; then
+ if [ -L /dev/$device ]; then
+ cp -a --parents $(readlink -e /dev/$device) $SOURCE_TREE
+ fi
+ cp -a --parents /dev/$device $SOURCE_TREE
+ fi
+ fi
+ done
+}
+
+clear_source_tree() {
+ if [ -d "$SOURCE_TREE" ]; then
+ rm -rf $SOURCE_TREE
+ fi
+}
+
+build_initrd_image() {
+ # Make sure we have any block devices that might be needed:
+ SLOPPY_DEV_LIST=$(cat /proc/partitions)
+ for device in $SLOPPY_DEV_LIST ; do
+ if [ ! -r $SOURCE_TREE/dev/$device ]; then
+ if [ -b /dev/$device ]; then
+ if [ -L /dev/$device ]; then
+ cp -a --parents $(readlink -e /dev/$device) $SOURCE_TREE
+ fi
+ cp -a --parents /dev/$device $SOURCE_TREE
+ fi
+ fi
+ done
+ # Use the output image name written in the initrd-tree if present:
+ if [ ! -z "$(cat $SOURCE_TREE/initrd-name)" ]; then
+ OUTPUT_IMAGE=$(cat $SOURCE_TREE/initrd-name)
+ if [ "$OUTPUT_IMAGE" = "$(basename $OUTPUT_IMAGE)" ]; then
+ OUTPUT_IMAGE=/boot/$OUTPUT_IMAGE
+ fi
+ mkdir -p $(dirname $OUTPUT_IMAGE)
+ fi
+ # Wrap the initrd as an initramfs image and move it into place:
+ ( cd $SOURCE_TREE
+ rm -f $OUTPUT_IMAGE
+ find . | cpio -o -H newc | gzip -9c > $OUTPUT_IMAGE
+ )
+
+ if [ ! -z "${MICROCODE_ARCH}" ] ; then
+ cat ${MICROCODE_ARCH} ${OUTPUT_IMAGE} > ${OUTPUT_IMAGE}.2
+ mv ${OUTPUT_IMAGE}.2 ${OUTPUT_IMAGE}
+ fi
+ echo "$OUTPUT_IMAGE created."
+ echo "Be sure to run lilo again if you use it."
+}
+
+badconf_file() {
+ # This won't really help with what's *wrong* with the file,
+ # but it will at least give them a clue that there's a problem
+ echo "/etc/mkinitrd.conf is bad or does not exist."
+ echo "If the file does not exist, do not pass -F to mkinitrd."
+ exit 1
+}
+
+
+unify_libs() {
+ awk '/=. \// { print $3 }' | sort -u
+}
+
+copy_libs() {
+ # First copy the essential glibc files:
+ find /lib /lib64 -name "ld-*so*" -o -name "libnss_files*so*" -o -name "libnss_compat*so*" 2> /dev/null | xargs -I'{}' cp -P --parents '{}' $SOURCE_TREE/
+
+ # Then copy all remaining libs our initrd files link against:
+ COUNT=1
+ PRFX=$(tempfile --prefix ldd-)
+ TMPFILE=${PRFX}${COUNT}
+
+ find $SOURCE_TREE -type f -exec ldd {} 2>/dev/null \; | unify_libs > $TMPFILE
+ while [ "$COUNT" != "0" ]; do
+ COUNT=$((COUNT+1))
+ for i in $(cat ${TMPFILE}) ; do
+ ldd $i 2>/dev/null
+ done | unify_libs > ${PRFX}${COUNT}
+ if [ $(cat $TMPFILE ${PRFX}${COUNT} | sort |uniq -u | wc -l) -eq 0 ]; then
+ COUNT=0
+ else
+ TMPFILE=${PRFX}${COUNT}
+ fi
+ # emergency eject lever:
+ if [ "$COUNT" = "42" ]; then
+ COUNT=0
+ fi
+ done
+
+ for i in $(cat ${PRFX}* | sort -u) ; do
+ cp -P --parents ${i}* $SOURCE_TREE
+ done
+
+ (
+ cd $SOURCE_TREE
+ for i in $(find -L . -type l -exec readlink -m /{} \; 2>/dev/null ) ; do
+ cp -P --parents ${i} $SOURCE_TREE
+ done
+ )
+
+ rm ${PRFX}*
+}
+
+copy_modconf() {
+ mkdir -p $SOURCE_TREE/etc $SOURCE_TREE/lib
+ cp -a /etc/modprobe.d $SOURCE_TREE/etc
+ cp -a /lib/modprobe.d $SOURCE_TREE/lib/
+}
+
+# If --help is given, print_usage and exit:
+if echo $* | grep -wq '\--help' ; then
+ print_usage
+ exit 0
+fi
+
+# If -V given, print version and exit:
+if echo $* | grep -wq '\-V' ; then
+ echo "mkinitrd version $MKINITRD_VERSION"
+ exit 0
+fi
+
+# Default values if these aren't previously set.
+# Might be set from config file or by -s and -o options too.
+SOURCE_TREE=${SOURCE_TREE:-/boot/initrd-tree}
+OUTPUT_IMAGE=${OUTPUT_IMAGE:-""}
+KERNEL_VERSION=${KERNEL_VERSION:-"$(uname -r)"}
+# The initrd requires udev to function correctly:
+UDEV=1
+
+# Default actions without options:
+if [ -z "$1" ]; then
+ # We need a sensible default for this special case:
+ OUTPUT_IMAGE=${OUTPUT_IMAGE:-/boot/initrd.gz}
+ # If the output tree doesn't exist, create it and then exit:
+ if [ ! -d $SOURCE_TREE ]; then
+ echo "Nothing found at location $SOURCE_TREE, so we will create an"
+ echo -n "initrd directory structure there... "
+ create_new_source_tree
+ echo "done."
+ echo
+ echo "Now cd to $SOURCE_TREE and install some modules in your"
+ echo "module directory (lib/modules/${KERNEL_VERSION}). Then see init"
+ echo "for more information (there are a few other files to edit)."
+ echo "Finally, run mkinitrd again once the initrd-tree is ready,"
+ echo "and $OUTPUT_IMAGE will be created from it."
+ echo
+ exit 0
+ else
+ # If the source tree does exist, the default is to build the initrd
+ # image from it and then exit:
+ build_initrd_image
+ exit 0
+ fi
+fi # default no-option actions
+
+# Parse for the use config file option first or else the other command
+# line options can not override /etc/mkinitrd.conf.
+for opt in "$@"; do
+ if [ "$opt" = "-F" ]; then
+ if [ -e /etc/mkinitrd.conf ]; then
+ . /etc/mkinitrd.conf || badconf_file
+ else
+ badconf_file
+ fi
+ fi
+done
+
+# Parse options:
+while [ ! -z "$1" ]; do
+ case $1 in
+ -c)
+ CLEAR_TREE=1
+ shift
+ ;;
+ -f)
+ ROOTFS="$2"
+ shift 2
+ ;;
+ -h)
+ RESUMEDEV="$2"
+ shift 2
+ ;;
+ -k)
+ KERNEL_VERSION="$2"
+ shift 2
+ ;;
+ -l)
+ KEYMAP="$2"
+ shift 2
+ ;;
+ -m)
+ MODULE_LIST="$2"
+ shift 2
+ ;;
+ -o)
+ # canonicalize filename:
+ OUTPUT_IMAGE="$(readlink -m $2)"
+ shift 2
+ ;;
+ -r)
+ ROOTDEV="$2"
+ shift 2
+ ;;
+ -s)
+ # canonicalize filename:
+ SOURCE_TREE="$(readlink -m $2)"
+ shift 2
+ ;;
+ -u)
+ UDEV=1
+ shift
+ ;;
+ -w)
+ WAIT="$2"
+ shift 2
+ ;;
+ -C)
+ CRYPT=1
+ LUKSDEV="$2"
+ shift 2
+ ;;
+ -K)
+ LUKSKEY="$2"
+ shift 2
+ ;;
+ -T)
+ LUKSTRIM="$2"
+ shift 2
+ ;;
+ -L)
+ LVM=1
+ shift
+ ;;
+ -B)
+ BTRFS=1
+ shift
+ ;;
+ -M)
+ MODCONF=1
+ shift
+ ;;
+ -P)
+ # canonicalize filename:
+ MICROCODE_ARCH="$(readlink -m $2)"
+ if [ ! -e "${MICROCODE_ARCH}" ] ; then
+ echo "Error, the microcode cpio archive ${MICROCODE_ARCH} does not exist."
+ exit 1
+ fi
+ shift 2
+ ;;
+
+ -R)
+ RAID=1
+ shift
+ ;;
+ *) # unknown, prevent infinite loop
+ shift
+ ;;
+ esac
+done
+
+# If kernel modules are needed but the kernel version is absent, exit now:
+if [ ! -d /lib/modules/$KERNEL_VERSION ]; then
+ echo "ERROR: No /lib/modules/$KERNEL_VERSION kernel modules tree found for kernel \"$KERNEL_VERSION\""
+ exit 1
+fi
+
+# If clearing source tree was requested, do that first
+if [ "$CLEAR_TREE" = "1" ]; then
+ clear_source_tree
+fi
+
+# If there's no $SOURCE_TREE, make one now:
+if [ ! -d "$SOURCE_TREE" ]; then
+ create_new_source_tree
+fi
+
+# If $ROOTDEV and $ROOTFS are not set, assume we want the
+# values for the currently mounted /
+# (unless we find that values are already set in the initrd-tree):
+if [ -z "$ROOTDEV" -a -z "$(cat $SOURCE_TREE/rootdev 2>/dev/null)" ]; then
+ ROOTDEV=$(mount | grep ' on / ' | cut -f 1 -d ' ')
+ if [ "$ROOTDEV" = "/dev/root" ]; then # find real root device
+ ROOTDEV="/dev/$(readlink /dev/root)"
+ fi
+fi
+if [ -z "$ROOTFS" -a -z "$(cat $SOURCE_TREE/rootfs 2>/dev/null)" ]; then
+ ROOTFS=$(mount | grep ' on / ' | cut -f 5 -d ' ')
+fi
+# If needed, write them in the initrd-tree:
+if [ ! -z "$ROOTDEV" ]; then
+ echo $ROOTDEV > $SOURCE_TREE/rootdev
+fi
+if [ ! -z "$ROOTFS" ]; then
+ echo $ROOTFS > $SOURCE_TREE/rootfs
+fi
+
+# If $WAIT is not set, assume we need only one second
+# to have all devices done
+# (unless we find that value is already set in the initrd-tree):
+if [ -z "$WAIT" -a -z "$(cat $SOURCE_TREE/wait-for-root)" ]; then
+ WAIT=1
+ # ARM devices need even more time:
+ case "$( uname -m )" in
+ arm*) WAIT=4;;
+ esac
+fi
+if [ ! -z "$WAIT" ]; then
+ echo $WAIT > $SOURCE_TREE/wait-for-root
+fi
+
+# If no OUTPUT_IMAGE was specified, read it from the SOURCE_TREE if possible:
+OUTPUT_IMAGE=${OUTPUT_IMAGE:-"$(cat $SOURCE_TREE/initrd-name)"}
+# If we still have no value, apply the default:
+OUTPUT_IMAGE=${OUTPUT_IMAGE:-"/boot/initrd.gz"}
+# Finally, write the image name into the SOURCE_TREE:
+echo "$OUTPUT_IMAGE" > $SOURCE_TREE/initrd-name
+
+# Fill /resumedev with the swap partition holding the hibernation image
+if [ ! -z "$RESUMEDEV" ]; then
+ echo $RESUMEDEV > $SOURCE_TREE/resumedev
+fi
+
+# Add custom keymap support if one was given
+if [ ! -z "$KEYMAP" ]; then
+ echo $KEYMAP > $SOURCE_TREE/keymap
+ cp /usr/share/mkinitrd/keymaps.tar.gz $SOURCE_TREE/etc/
+fi
+
+# If LUKSDEV was set in the config file, then we need to set CRYPT=1
+if [ ! -z "$LUKSDEV" ]; then
+ CRYPT=1
+fi
+
+# Check for LUKSTRIM
+if [ ! -z "$LUKSTRIM" ]; then
+ echo $LUKSTRIM > $SOURCE_TREE/lukstrim
+fi
+
+# If LUKSKEY was set in the config file, then give it a warm welcome:
+if [ ! -z "$LUKSKEY" ]; then
+ # $SOURCE_TREE/wait-for-root may have been configured earlier in the script,
+ # but we require at least 5 seconds for the USB stick to settle
+ # after insertion :
+ if [ ! -s $SOURCE_TREE/wait-for-root ] || [ $(cat $SOURCE_TREE/wait-for-root) -lt 5 ]; then
+ echo 5 > $SOURCE_TREE/wait-for-root
+ fi
+
+ # Several extra modules are needed to support a vfat formatted USB stick...
+ # assuming here we are using a western codepage.
+ # This possibly adds doublures, but we clean up the MODULE_LIST further down!
+ MODULE_LIST="${MODULE_LIST}:xhci-pci:ohci-pci:ehci-pci:xhci-hcd:ohci-hcd:ehci-hcd:uhci-hcd:usb-storage:hid:usbhid:fat:nls_cp437:nls_iso8859-1:msdos:vfat"
+
+ # Finally, write the lukskey to the initrd-tree:
+ echo $LUKSKEY > $SOURCE_TREE/lukskey
+fi
+
+# Include RAID support in initrd
+if [ ! -z "$RAID" ]; then
+ if [ -r /sbin/mdadm -a -r /sbin/mdmon ]; then
+ mkdir -p $SOURCE_TREE/sbin
+ cp /sbin/mdadm $SOURCE_TREE/sbin/mdadm
+ cp /sbin/mdmon $SOURCE_TREE/sbin/mdmon
+ chmod 0755 $SOURCE_TREE/sbin/mdadm
+ chmod 0755 $SOURCE_TREE/sbin/mdmon
+ mkdir -p $SOURCE_TREE/lib/udev/rules.d
+ echo 'KERNEL=="dm-[0-9]*", OPTIONS+="db_persist"' > \
+ $SOURCE_TREE/lib/udev/rules.d/95-dm-initrd.rules
+ if [ -r /etc/mdadm.conf ] ; then
+ cp /etc/mdadm.conf $SOURCE_TREE/etc
+ fi
+ else
+ echo "ERROR: mdadm and/or mdmon binary is missing, RAID support not installed"
+ fi
+fi
+
+# Include Btrfs support in initrd
+if [ ! -z "$BTRFS" ]; then
+ if [ -r /sbin/btrfs ]; then
+ mkdir -p $SOURCE_TREE/sbin
+ cp /sbin/btrfs $SOURCE_TREE/sbin/btrfs
+ chmod 0755 $SOURCE_TREE/sbin/btrfs
+ else
+ echo "ERROR: btrfs binary is missing, Btrfs support not installed"
+ fi
+fi
+
+# Include udev in initrd
+if [ ! -z "$UDEV" ]; then
+ cp /sbin/udev* $SOURCE_TREE/sbin/
+ cp -a /lib/udev $SOURCE_TREE/lib/
+ # But we don't want all of /lib/udev
+ for file in $(echo $LIBUDEV_BLACKLIST) ; do
+ # Replace with a null script (avoids error spew):
+ cat << EOF > $SOURCE_TREE/lib/udev/$file
+#!/bin/ash
+# This space is intentionally left blank
+EOF
+ done
+fi
+
+# Include LVM support in initrd
+if [ ! -z "$LVM" ]; then
+ if [ -f /sbin/lvm ]; then
+ mkdir -p $SOURCE_TREE/sbin
+ cp /sbin/lvm $SOURCE_TREE/sbin/lvm
+ ( cd $SOURCE_TREE/sbin
+ ln -s lvm vgchange 2>/dev/null
+ ln -s lvm vgscan 2>/dev/null )
+ else
+ echo "LVM binary is missing, LVM support isn't installed"
+ LVM=""
+ fi
+fi
+
+# Include cryptsetup (LUKS) support in initrd
+if [ ! -z "$CRYPT" ]; then
+ if [ -e /usr/sbin/cryptsetup ]; then
+ mkdir -p $SOURCE_TREE/sbin
+ cp /usr/sbin/cryptsetup $SOURCE_TREE/sbin/cryptsetup
+ if [ ! -e $SOURCE_TREE/sbin/udevadm ]; then
+ cat << EOF > $SOURCE_TREE/sbin/udevadm
+#!/bin/sh
+sleep 3
+EOF
+ chmod 0755 $SOURCE_TREE/sbin/udevadm
+ fi
+
+ # Write the underlying luks device to the initrd-tree:
+ echo $LUKSDEV > $SOURCE_TREE/luksdev
+ else
+ echo "Cryptsetup binary is missing, CRYPT support isn't installed"
+ CRYPT=""
+ fi
+fi
+
+# Include device mapper in initrd (needed for LUKS and LVM)
+if [ ! -z "$CRYPT" -o ! -z "$LVM" ]; then
+ cp /sbin/dmsetup $SOURCE_TREE/sbin/dmsetup
+ find /lib /lib64 -name "libdevmapper*so*" 2> /dev/null | xargs -I'{}' cp -P --parents '{}' $SOURCE_TREE/
+ if [ -z "${MODULE_LIST}" ] ; then
+ MODULE_LIST="dm-mod"
+ elif ! echo ${MODULE_LIST} | grep -q dm-mod ; then
+ MODULE_LIST="$MODULE_LIST:dm-mod"
+ fi
+ mkdir -p $SOURCE_TREE/lib/udev/rules.d
+ echo 'KERNEL=="dm-[0-9]*", OPTIONS+="db_persist"' > \
+ $SOURCE_TREE/lib/udev/rules.d/95-dm-initrd.rules
+fi
+
+# Make module directory:
+if [ ! -d $SOURCE_TREE/lib/modules/$KERNEL_VERSION ]; then
+ mkdir -p $SOURCE_TREE/lib/modules/$KERNEL_VERSION
+fi
+
+# Copy kmod/modprobe stuff to initrd:
+for i in kmod depmod insmod lsmod modinfo modprobe rmmod ; do
+ rm -f $SOURCE_TREE/sbin/$i ;
+ cp -a /sbin/$i $SOURCE_TREE/sbin ;
+done
+
+# Make sure modules.builtin and modules.order are there (for kmod):
+cp /lib/modules/$KERNEL_VERSION/modules.{builtin,order} \
+ $SOURCE_TREE/lib/modules/$KERNEL_VERSION
+
+# If an executable $SOURCE_TREE/load_kernel_modules already exists, then
+# we assume you will want to load the kernel modules mentioned in there.
+# This means, you do not have to explicitly add those on the commandline:
+if [ -x $SOURCE_TREE/load_kernel_modules ]; then
+ MODULE_LIST="${MODULE_LIST}:$(cat $SOURCE_TREE/load_kernel_modules |grep "^modprobe" |rev |cut -d/ -f1 |rev |cut -d. -f1)"
+fi
+
+# If the module list is not empty, copy the modules into place:
+if [ ! -z "$MODULE_LIST" ]; then
+ if grep -q "#modprobe reiserfs" $SOURCE_TREE/load_kernel_modules ; then
+ rm -f $SOURCE_TREE/load_kernel_modules
+ touch $SOURCE_TREE/load_kernel_modules
+ chmod 755 $SOURCE_TREE/load_kernel_modules
+ echo "# This is a script used to load the kernel modules." >> $SOURCE_TREE/load_kernel_modules
+ echo "# To use it, chmod it 755, and then add the insmod" >> $SOURCE_TREE/load_kernel_modules
+ echo "# lines needed to load your modules, like this:" >> $SOURCE_TREE/load_kernel_modules
+ echo >> $SOURCE_TREE/load_kernel_modules
+ fi
+
+ # Sanitize the modules list first, before any further processing.
+ # The awk command eliminates doubles without changing the order:
+ MODULE_LIST=$(echo $MODULE_LIST |tr -s ':' '\n' |awk '!x[$0]++' |tr '\n' ':')
+ MODULE_LIST=$(echo ${MODULE_LIST%:}) # Weed out a trailing ':'
+
+ # Count number of modules
+ # This INDEX number gives us an easy way to find individual
+ # modules and their arguments, as well as tells us how many
+ # times to run through the list
+ if ! echo $MODULE_LIST | grep ':' > /dev/null ; then # only 1 module specified
+ INDEX=1
+ else
+ # Trim excess ':' which will screw this routine:
+ MODULE_LIST=$(echo $MODULE_LIST | tr -s ':')
+ INDEX=1
+ while [ ! "$(echo "$MODULE_LIST" | cut -f $INDEX -d ':' )" = "" ]; do
+ INDEX=$(expr $INDEX + 1)
+ done
+ INDEX=$(expr $INDEX - 1) # Don't include the null value
+ fi
+
+ # Wrap everything in a while loop
+ i=0
+ while [ $i -ne $INDEX ]; do
+ i=$(( $i + 1 ))
+
+ # FULL_MOD is the module plus any arguments (if any)
+ # MODULE is the module name
+ # ARGS is any optional arguments to be passed to the kernel
+ FULL_MOD="$(echo "$MODULE_LIST" | cut -d ':' -f $i)"
+ MODULE="$(echo "$FULL_MOD" | cut -d ' ' -f 1 )"
+ # Test for arguments
+ if echo "$FULL_MOD" | grep ' ' > /dev/null; then
+ ARGS=" $(echo "$FULL_MOD" | cut -d ' ' -f 2- )"
+ else
+ unset ARGS
+ fi
+
+ # Get MODULE deps and prepare modprobe lines
+ /sbin/modprobe --set-version $KERNEL_VERSION --show-depends --ignore-install $MODULE 2>/dev/null \
+ | grep "^insmod " | cut -f 2 -d ' ' | while read SRCMOD; do
+
+ if ! grep -Eq " $(basename $SRCMOD .ko)(\.| |$)" $SOURCE_TREE/load_kernel_modules 2>/dev/null ; then
+ LINE="$(echo "modprobe -v $(basename ${SRCMOD%%.gz} .ko)" )"
+
+ # Test to see if arguments should be passed
+ # Over-ride the previously defined LINE variable if so
+ if [ "$(basename $SRCMOD .ko)" = "$MODULE" ]; then
+ # SRCMOD and MODULE are same, ARGS can be passed
+ LINE="$LINE$ARGS"
+ fi
+
+ fi
+
+ if ! grep -qx "$LINE" $SOURCE_TREE/load_kernel_modules ; then
+ echo "$LINE" >> $SOURCE_TREE/load_kernel_modules
+ fi
+
+ # Try to add the module to the initrd-tree. This should be done
+ # even if it exists there already as we may have changed compilers
+ # or otherwise caused the modules in the initrd-tree to need
+ # replacement.
+ if cp -a --parents $SRCMOD $SOURCE_TREE 2>/dev/null; then
+ echo "OK: $SRCMOD added."
+ # If a module needs firmware, copy that too
+ /sbin/modinfo -F firmware "$SRCMOD" | sed 's/^/\/lib\/firmware\//' |
+ while read SRCFW; do
+ if cp -a --parents "$SRCFW" $SOURCE_TREE 2>/dev/null; then
+ echo "OK: $SRCFW added."
+ else
+ echo "WARNING: Could not find firmware \"$SRCFW\""
+ fi
+ done
+ else
+ echo "WARNING: Could not find module \"$SRCMOD\""
+ fi
+
+ done
+ done
+
+ # Pregenerate the module dependency information
+ depmod -a -b $SOURCE_TREE ${KERNEL_VERSION}
+
+ # Copy /{etc,lib}/modprobe.d/* if desired
+ if [ ! -z $MODCONF ]; then
+ copy_modconf
+ fi
+
+fi
+
+# Copy needed libraries
+copy_libs
+
+# Make sure all libraries have symlinks:
+/sbin/ldconfig $(readlink -f $SOURCE_TREE)/lib/ 2> /dev/null
+/sbin/ldconfig $(readlink -f $SOURCE_TREE)/lib64/ 2> /dev/null
+/sbin/ldconfig
+
+# And finally, build the initrd:
+build_initrd_image
+
diff --git a/patches/source/mkinitrd/mkinitrd.8 b/patches/source/mkinitrd/mkinitrd.8
new file mode 100644
index 000000000..64dad3f43
--- /dev/null
+++ b/patches/source/mkinitrd/mkinitrd.8
@@ -0,0 +1,279 @@
+.\" -*- nroff -*-
+.ds g \" empty
+.ds G \" empty
+.\" Like TP, but if specified indent is more than half
+.\" the current line-length - indent, use the default indent.
+.de Tp
+.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
+.el .TP "\\$1"
+..
+.TH MKINITRD 8 "27 March 2010" "Slackware Version 13.1"
+.SH NAME
+mkinitrd \- create or rebuilt an initrd (initial ramdisk) using initramfs (simple cpio+gzip).
+.SH SYNOPSIS
+.B mkinitrd
+[
+.B \-F
+]
+[
+.B \-c
+]
+[
+.B \-f filesystem
+]
+[
+.B \-h hibernate_partition
+]
+[
+.B \-k kernel_version
+]
+[
+.B \-m module1:module2:module3...
+]
+[
+.B \-o output_file
+]
+[
+.B \-r root_device
+]
+[
+.B \-s source_tree
+]
+[
+.B \-u
+]
+[
+.B \-w wait_time
+]
+[
+.B \-C device1:device2:device3...
+]
+[
+.B \-K luks_keyfile
+]
+[
+.B \-P microcode_archive
+]
+[
+.B \-B
+]
+[
+.B \-L
+]
+[
+.B \-R
+]
+[
+.B \-V
+]
+.SH DESCRIPTION
+.B mkinitrd
+is used to build an initial ramdisk. An initial ramdisk is a very small
+set of files that are loaded into RAM and "mounted" (as initramfs doesn't
+actually use a filesystem) as the kernel boots (before the main root
+filesystem is mounted). The usual reason to use an initrd is because
+you need to load kernel modules before mounting the root partition.
+Usually these modules are required to support the filesystem used by the
+root partition (ext3, reiserfs, xfs), or perhaps the controller that the
+hard drive is attached to (SCSI, RAID, etc). Essentially, there are so many
+different options available in modern Linux kernels that it isn't practical
+to try to ship many different kernels to try to cover everyone's needs.
+It's a lot more flexible to ship a generic kernel and a set of kernel
+modules for it.
+.SH OPTIONS
+.TP
+.B \-F
+Use the contents of /etc/mkinitrd.conf as options to mkinitrd (optional).
+If this is used in conjunction with any other options passed on the command
+line, the command-line options will override the config file options.
+.br
+See mkinitrd.conf(5) for details.
+.TP
+.B \-c
+Clear the existing initrd tree (by default in /boot/initrd-tree/) first.
+If this is not done, running mkinitrd will add additional modules to the
+existing initrd.
+.TP
+.B \-f filesystem
+Specify the filesystem to use for the root partition. If this isn't given,
+mount will usually figure it out. This option must be used together with the
+\-r option in order to be beneficial.
+.TP
+.B \--help
+Display a help summary.
+.TP
+.B \-h hibernate_partition
+Specify the swap partition holding the hibernation image.
+.TP
+.B \-k kernel version
+Use kernel modules from the specified kernel version. mkinitrd will look
+for them in /lib/modules/(kernel version).
+.TP
+.B \-l keymap
+Load an alternative keyboard mapping. All supported keyboard mappings
+can be found in /usr/share/mkinitrd/keymaps.tar.gz
+Leave the '.bmap' out when you supply this parameter. E.g. '-l nl' will
+add support for dutch keyboard mapping to the initrd.
+.TP
+.B \-m module list
+This is a list of colon-delimited modules to build into the initrd.
+Any dependencies of requested modules will also be added to the initrd.
+Additional options may be added to use when loading the kernel modules
+(but in this case the entire list must be wrapped with double quotes).
+.TP
+.B \-o output image
+The file to write the initrd to. (default: /boot/initrd.gz)
+.TP
+.B \-r root partition
+Specify the device to be used as the root partition. If this isn't given, the
+kernel default will be used (which is usually fine). This option must be used
+together with the \-f option in order to be beneficial.
+.TP
+.B \-s source tree
+The directory to use as the source for the initrd. (default: /boot/initrd-tree/)
+.TP
+.B \-u
+Include udev in the initrd.
+.TP
+.B \-w
+The -w option specifies how long to wait in seconds before assuming that all the
+drives are spun up and ready to go.
+.TP
+.B \-C device list
+A colon (:) delimited list of luks encrypted block devices to be unlocked by
+the initrd using cryptsetup. All devices that must be unlocked in order to
+access the root filesystem must be specified. e.g.
+
+ -C /dev/sda2:/dev/sda3
+
+Each unlocked device will be assigned an automatically generated luks device
+name of the form luks<device> where '<device>' will be the basename of the
+encrypted device. e.g.
+
+ /dev/mapper/lukssda2
+
+As a convenience to users, where -r specifies one of the device names listed
+on the -C option it will be automatically adjusted to use the correct luks
+device name. i.e.
+
+ "-C /dev/sda2 -r /dev/sda2" and
+ "-C /dev/sda2 -r /dev/mapper/lukssda2"
+
+are equivalent.
+.br
+(Use with '-r' option).
+.TP
+.B \-K luks_keyfile
+When using cryptsetup to encrypt your partition, you can use a keyfile instead
+of a passphrase to unlock the LUKS volume. The LUKSKEY variable holds the
+filename of a keyfile, as well as the label (or uuid) of the partition this
+file is on. This way, you can unlock your computer automatically if you have a
+USB stick with your LUKS key inserted at boot. A passphrase will still be asked
+if the LUKS key can not be found.
+.br
+For example, if your USB thumb drive has a FAT partition with label
+"TRAVELSTICK" and the actual keyfile is called "/keys/alien.luks", then
+you need to set:
+
+ -K LABEL=TRAVELSTICK:/keys/alien.luks
+.TP
+.B \-T device list
+A colon (:) delimited list of luks encrypted block devices to be passed the
+"--allow-discards" option when unlocked by the initrd using cryptsetup, e.g.
+
+ -T /dev/sda2:/dev/sda4
+
+This has the effect of allowing TRIM on SSD drives. Be sure your SSD supports
+this feature (correctly) before enabling it. See fstrim(8) for more information.
+.TP
+.B \-P microcode_archive
+This option specifies a cpio archive containing updated microcode for your CPU.
+CPU manufacturers occasionally release such updates to fix bugs in the microcode
+currently embedded in the CPU. The microcode archive will be prepended to the
+output initrd, where the kernel will find it for early patching:
+
+ -P /boot/intel-ucode.cpio
+
+.TP
+.B \-B
+This option adds the btrfs utility to the initrd so that multi-device filesystems
+will be picked up by a scan (/sbin/btrfs device scan). This is needed if the
+root filesystem is a Btrfs multi-device filesystem.
+.TP
+.B \-L
+This option adds LVM support to the initrd, if the tools are
+available on the system.
+.TP
+.B \-R
+This option adds RAID support to the initrd, if a static mdadm binary is
+available on the system.
+.TP
+.B \-V
+Display version information and exit.
+.SH EXAMPLES
+A simple example: Build an initrd for a reiserfs root partition:
+
+ mkinitrd -c -m reiserfs
+
+Another example: Build an initrd image using Linux 2.6.33.1 kernel
+modules for a system with an ext3 root partition on /dev/sdb3:
+
+ mkinitrd -c -k 2.6.33.1 -m ext3 -f ext3 -r /dev/sdb3
+
+An example of a single encrypted partition setup:
+.br
+As a user convenience, the value for the "-r" option may also be specified as
+"/dev/sda2" in this example:
+
+ mkinitrd -c -k 2.6.33.1 \\
+ -m ext4:ehci-hcd:uhci-hcd:usbhid \\
+ -f ext4 -r /dev/mapper/lukssda2 \\
+ -C /dev/sda2 \\
+ -l uk
+
+Finally, A more complex example:
+.br
+This one is for a LVM Volume Group (rootvg) comprising of two LVM Physical
+Volumes, each of which is on a LUKS encrypted partition that will need to be
+unlocked before the root filesystem (/dev/rootvg/lvroot) can be accessed.
+
+ mkinitrd -c -k 2.6.29.6 \\
+ -m ext4:ehci-hcd:uhci-hcd:usbhid \\
+ -f ext4 -r /dev/rootvg/lvroot \\
+ -L -C /dev/sda2:/dev/sdb2 \\
+ -l uk
+
+If run without options, mkinitrd will rebuild an initrd image using
+the contents of the $SOURCE_TREE directory, or, if that directory
+does not exist it will be created and populated, and then mkinitrd
+will exit. These options are handy for building an initrd mostly
+by hand. After creating /boot/initrd-tree/, you can add modules and
+edit files by hand, and then rerun mkinitrd to create the initrd.
+
+Once the initrd is created, you'll need to tell your boot loader
+to load it. If you boot with LILO, you will need to add an initrd
+line to /etc/lilo.conf. Here's a section of lilo.conf that shows
+how to set this up:
+
+ # Linux bootable partition config begins
+ image = /boot/vmlinuz-generic-2.6.33.1
+ initrd = /boot/initrd.gz
+ root = /dev/sda3
+ label = Linux26331
+ read-only
+ # Linux bootable partition config ends
+
+Note that the line "root = /dev/sda3" is not needed if the root device
+has been configured in the initrd image.
+
+Once you've created the initrd and editing /etc/lilo.conf, you will
+need to run 'lilo' to write out the changed boot block. The next
+time you reboot the initrd should be loaded along with the kernel.
+
+Have fun!
+
+.SH SEE ALSO
+mkinitrd.conf (5)
+
+.SH AUTHOR
+Patrick J. Volkerding <volkerdi@slackware.com>
diff --git a/patches/source/mkinitrd/mkinitrd.SlackBuild b/patches/source/mkinitrd/mkinitrd.SlackBuild
new file mode 100755
index 000000000..f94b034db
--- /dev/null
+++ b/patches/source/mkinitrd/mkinitrd.SlackBuild
@@ -0,0 +1,146 @@
+#!/bin/sh
+
+# Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016, 2017 Patrick J. Volkerding, Sebeka, MN, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+VERSION=${VERSION:-1.4.10}
+BB=1.20.2
+BUILD=${BUILD:-1_slack14.1}
+
+# Automatically determine the architecture we're building on:
+if [ -z "$ARCH" ]; then
+ case "$( uname -m )" in
+ i?86) export ARCH=i486 ;;
+ arm*) export ARCH=arm ;;
+ # Unless $ARCH is already set, use uname -m for all other archs:
+ *) export ARCH=$( uname -m ) ;;
+ esac
+fi
+
+NUMJOBS=${NUMJOBS:--j7}
+CWD=$(pwd)
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-mkinitrd
+
+# Write a warning to stdout if the mkinitrd script has a different version:
+eval $( grep "^MKINITRD_VERSION=" $CWD/mkinitrd )
+if [ "$VERSION" != "$MKINITRD_VERSION" ]; then
+ echo "The version of this package ($VERSION) is not equal to the version of the mkinitrd script ($MKINITRD_VERSION)."
+ sleep 5
+fi
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+cd $TMP
+rm -rf busybox-$BB
+tar xvf $CWD/busybox-$BB.tar.?z* || exit 1
+cd busybox-$BB
+
+if [ -d $CWD/fixes-$BB ]; then
+ for pfile in $CWD/fixes-$BB/*.patch ; do
+ patch -p1 < $pfile || exit 1
+ done
+fi
+
+chown -R root:root .
+sed -e \
+ 's#^CONFIG_PREFIX=.*#CONFIG_PREFIX="'$PKG'/usr/share/mkinitrd/initrd-tree"#' \
+ $CWD/busybox-dot-config > .config
+make oldconfig
+make $NUMJOBS || make || exit 1
+
+mkdir -p $PKG/usr/share/mkinitrd/initrd-tree/{bin,sbin}
+make install || exit 1
+rm -f $PKG/usr/share/mkinitrd/initrd-tree/linuxrc
+
+# Copying additional files:
+cp -a $CWD/mkinitrd_command_generator.sh $PKG/usr/share/mkinitrd
+chown root:root $PKG/usr/share/mkinitrd/mkinitrd_command_generator.sh
+chmod 755 $PKG/usr/share/mkinitrd/mkinitrd_command_generator.sh
+cp -a $CWD/keymaps.tar.gz $PKG/usr/share/mkinitrd
+chown root:root $PKG/usr/share/mkinitrd/keymaps.tar.gz
+chmod 644 $PKG/usr/share/mkinitrd/keymaps.tar.gz
+
+# Zip up the initrd-tree:
+( cd $PKG/usr/share/mkinitrd/initrd-tree
+ tar xf $CWD/_initrd-tree.tar.gz
+ cat $CWD/init > init
+
+ # These are useful for ARM:
+ mknod -m 644 dev/random c 1 8
+ mknod -m 644 dev/urandom c 1 9
+
+ tar czf ../initrd-tree.tar.gz .
+)
+rm -rf $PKG/usr/share/mkinitrd/initrd-tree
+
+# Add busybox docs:
+mkdir -p $PKG/usr/doc/busybox-$BB
+cp -a AUTHORS COPYING* INSTALL LICENSE README* \
+ $PKG/usr/doc/busybox-$BB
+cp -a e2fsprogs/README $PKG/usr/doc/busybox-$BB/README.e2fsprogs
+cp -a libbb/README $PKG/usr/doc/busybox-$BB/README.libbb
+cp -a shell/README $PKG/usr/doc/busybox-$BB/README.shell
+cp -a testsuite/README $PKG/usr/doc/busybox-$BB/README.testsuite
+
+mkdir -p $PKG/sbin
+cp -a $CWD/mkinitrd $PKG/sbin/mkinitrd
+chown root:root $PKG/sbin/mkinitrd
+chmod 755 $PKG/sbin/mkinitrd
+
+mkdir -p $PKG/usr/man/man{5,8}
+cat $CWD/mkinitrd.conf.5 | gzip -9c > $PKG/usr/man/man5/mkinitrd.conf.5.gz
+cat $CWD/mkinitrd.8 | gzip -9c > $PKG/usr/man/man8/mkinitrd.8.gz
+cat $CWD/mkinitrd_command_generator.8 | gzip -9c > $PKG/usr/man/man8/mkinitrd_command_generator.8.gz
+
+mkdir -p $PKG/etc
+cp -a $CWD/mkinitrd.conf.sample $PKG/etc/mkinitrd.conf.sample
+# ARM systems often need more time to find devices:
+case "$( uname -m )" in
+ arm*) sed -e 's@#WAIT="1"@#WAIT="4"@g' \
+ -i $PKG/etc/mkinitrd.conf.sample;;
+esac
+chown root:root $PKG/etc/mkinitrd.conf.sample
+chmod 644 $PKG/etc/mkinitrd.conf.sample
+
+mkdir -p $PKG/usr/doc/mkinitrd-$VERSION
+sed $CWD/README.initrd \
+ -e "s,@DATE@,$(date),g" \
+ -e "s,@KERNEL_VERSION@,$(uname -r),g" \
+ -e "s,@PACKAGE_VERSION@,$(uname -r | tr - _),g" \
+ -e "s,@LILO_KERNEL_NAME@,$(echo $(uname -r) | tr -d . | tr -d - ),g" \
+ -e "s,@MKINITRD_VERSION@,$VERSION,g" \
+ -e "s,@ARCH@,$ARCH,g" \
+ -e "s,@BUILD@,$BUILD,g" \
+ > $PKG/usr/doc/mkinitrd-$VERSION/README.initrd
+
+mkdir $PKG/boot
+ln -sf /usr/doc/mkinitrd-$VERSION/README.initrd $PKG/boot/README.initrd
+
+find $PKG | xargs file | grep -e "executable" -e "shared object" \
+ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/mkinitrd-$VERSION-$ARCH-$BUILD.txz
+
diff --git a/patches/source/mkinitrd/mkinitrd.conf.5 b/patches/source/mkinitrd/mkinitrd.conf.5
new file mode 100644
index 000000000..65c180185
--- /dev/null
+++ b/patches/source/mkinitrd/mkinitrd.conf.5
@@ -0,0 +1,244 @@
+.\" mkinitrd.5 Robby Workman <rworkman@slackware.com>
+.\" 28 August 2010 "
+
+.TH MKINITRD.CONF 5 "27 March 2010" "Slackware 13.1"
+.SH NAME
+.B mkinitrd.conf(5)
+.SH SYNOPSIS
+.B mkinitrd.conf - optional configuration file for
+.I mkinitrd(8)
+
+.SH DESCRIPTION
+The
+.I mkinitrd.conf
+file contains options to be passed to
+.I mkinitrd(8)
+on every run if mkinitrd is executed with the -F flag.
+.br
+It is intended as a fast and easy way for the system administrator to
+pass options to mkinitrd without having to type them on each execution.
+
+Options passed to
+.I mkinitrd(8)
+on the command line will override any
+values set in the config file.
+
+.SH OPTIONS AND SYNTAX
+
+All options are in the format of OPTION="value"
+.br
+Unset variables have no effect.
+
+.TP 5
+.I SOURCE_TREE
+This is the location for the initrd's source tree.
+.br
+Defaults to "/boot/initrd-tree"
+
+.TP 5
+.I CLEAR_TREE
+This option specifies whether to clear the initrd source tree prior to
+creating the initrd.
+.br
+This requires a value of either "0" or "1" where 0=no and 1=yes
+.br
+Examples:
+.br
+CLEAR_TREE="0" # Do not clear initrd tree first
+.br
+CLEAR_TREE="1" # Clear initrd tree first
+
+It is recommended to leave this unset and pass "-c" on the command line
+when clearing the tree is desired. Clearing the tree is not desirable
+if you wish to build support for more than one kernel into the initrd
+image.
+
+.TP 5
+.I OUTPUT_IMAGE
+This is the location for the initrd image that is created.
+.br
+Defaults to "/boot/initrd.gz"
+
+.TP 5
+.I KERNEL_VERSION
+This is the kernel version for which the initrd should be created.
+.br
+Defaults to "$(uname -r)"
+
+.TP 5
+.I KEYMAP
+This is the custom keyboard map that should be loaded instead of the
+default 'us' keymap.
+.br
+The file /usr/share/mkinitrd/keymaps.tar.gz contains all possible keymaps
+to choose from (omit the '.bmap' extension in the mkinitrd command)
+.br
+Example: KEYMAP="nl"
+
+.TP 5
+.I MODULE_LIST
+This should be a colon-separated list of modules you wish to be included
+in the initrd image.
+.br
+Example: MODULE_LIST="ext3:mbcache:jbd"
+
+If you have loadtime options that you need to specify when loading kernel
+modules, those can be added here as well.
+.br
+Example: MODULE_LIST="module1:module2 option=1:module3"
+
+.TP 5
+.I LUKSDEV
+Contains a colon (:) delimited list of luks encrypted block devices to be
+unlocked by the initrd using cryptsetup. All devices that must be unlocked
+in order to access the root filesystem must be specified.
+.br
+Example: LUKSDEV="/dev/sda2:/dev/sda3"
+
+Each unlocked device will be assigned an automatically generated luks device
+name of the form luks<device> where '<device>' will be the basename of the
+encrypted device. e.g.
+
+ /dev/mapper/lukssda2
+
+As a convenience to users, if
+.I ROOTDEV
+(see below) specifies one of the device names listed in the
+.I LUKSDEV
+option, then it will be automatically adjusted to use the correct luks
+device name. i.e. when specifying
+.I "LUKSDEV=/dev/sda2"
+then
+.I "ROOTDEV=/dev/sda2"
+and
+.I "ROOTDEV=/dev/mapper/lukssda2"
+are equivalent.
+
+.TP 5
+.I LUKSKEY
+When using cryptsetup to encrypt your partition, you can use a keyfile instead
+of a passphrase to unlock the LUKS volume. The LUKSKEY variable holds the
+filename of a keyfile, as well as the label (or uuid) of the partition this
+file is on. This way, you can unlock your computer automatically if you have a
+USB stick with your LUKS key inserted at boot. A passphrase will still be asked
+if the LUKS key can not be found.
+.br
+For example, if your USB thumb drive has a FAT partition with label
+"TRAVELSTICK" and the actual keyfile is called "/keys/alien.luks", then
+you need to set:
+.br
+LUKSKEY="LABEL=TRAVELSTICK:/keys/alien.luks"
+
+.TP 5
+.I LUKSTRIM
+Contains a colon (:) delimited list of luks encrypted block devices to be
+passed the "--allow-discards" option when unlocked by the initrd using
+cryptsetup. This has the effect of allowing TRIM on SSD drives. Be sure
+your SSD supports this feature (correctly) before enabling it.
+.br
+See fstrim(8) for more information.
+.br
+Example: LUKSTRIM="/dev/sda2:/dev/sda4"
+
+.TP 5
+.I ROOTDEV
+The device on which your root filesystem is located.
+.br
+Example: ROOTDEV="/dev/sda2"
+
+If you are using cryptsetup and an encrypted root filesystem, be sure to
+read the option above for LUKSDEV or Bad Things will happen.
+
+.TP 5
+.I ROOTFS
+The filesystem type of your root filesystem
+.br
+Example: ROOTFS="ext3"
+
+.TP 5
+.I RAID
+This option adds the mdadm binary to the initrd to support RAID.
+Additional modules may be required, depending on your kernel
+configuration. If you wish to add LVM support to the initrd, then
+set this to 1; otherwise, leave it unset or set it to 0.
+.br
+Examples:
+.br
+RAID="0" # Do not add RAID support to initrd
+.br
+RAID="1" # Add RAID support to initrd
+
+.TP 5
+.I LVM
+This option adds support for LVM partitions into the initrd.
+If you wish to add LVM support to the initrd, then set this to 1;
+otherwise, leave it unset or set it to 0.
+.br
+Examples:
+.br
+LVM="0" # Do not add LVM support to initrd
+.br
+LVM="1" # Add LVM support to initrd
+
+.TP 5
+.I UDEV
+Use UDEV in the initrd.
+.br
+Examples:
+.br
+UDEV="0" # Do not use udev in the initrd
+.br
+UDEV="1" # Use udev in the initrd (this is the default)
+
+.TP 5
+.I WAIT
+This defines the time to wait, in seconds, until all disks are detected.
+.br
+This is useful for allowing extra time that might be needed for slow usb disks or systems with large amounts of storage to become ready.
+.br
+If not defined, the default is 1 second.
+
+.TP 5
+.I RESUMEDEV
+The swap partition holding your hibernation image.
+.br
+Example: RESUMEDEV="/dev/sda2"
+
+.TP 5
+.I MODCONF
+This option defines whether to copy the module-init-tools config files
+from /etc/modprobe.d/ into the initrd. This will not usually be necessary,
+but if you need certain modules to be loaded with special options, and you
+have this configured in a file in /etc/modprobe.d/, this is one way to
+accomplish the desired goal.
+.br
+Examples:
+.br
+MODCONF="0" # Do not add /etc/modprobe.d/* to the initrd
+.br
+MODCONF="1" # Add /etc/modprobe.d/* to the initrd
+
+.TP 5
+.I MICROCODE_ARCH
+This option specifies a cpio archive containing updated microcode for your CPU.
+CPU manufacturers occasionally release such updates to fix bugs in the microcode
+currently embedded in the CPU. The microcode archive will be prepended to the
+output initrd, where the kernel will find it for early patching.
+.br
+Examples:
+.br
+MICROCODE_ARCH="/boot/intel-ucode.cpio"
+
+.SH FILES
+.I /etc/mkinitrd.conf
+.br
+See /etc/mkinitrd.conf.sample
+
+.SH "SEE ALSO"
+.BR mkinitrd "(8)"
+
+.SH BUGS
+None known :-)
+
+.SH MISCELLANEOUS
+Support for mkinitrd.conf was added in mkinitrd-1.3.0
diff --git a/patches/source/mkinitrd/mkinitrd.conf.sample b/patches/source/mkinitrd/mkinitrd.conf.sample
new file mode 100644
index 000000000..70256ef38
--- /dev/null
+++ b/patches/source/mkinitrd/mkinitrd.conf.sample
@@ -0,0 +1,21 @@
+# mkinitrd.conf.sample
+# See "man mkinitrd.conf" for details on the syntax of this file
+#
+#SOURCE_TREE="/boot/initrd-tree"
+#CLEAR_TREE="0"
+#OUTPUT_IMAGE="/boot/initrd.gz"
+#KERNEL_VERSION="$(uname -r)"
+#KEYMAP="us"
+#MODULE_LIST="ext4"
+#LUKSDEV="/dev/sda2"
+#LUKSTRIM="/dev/sda2" # verify support with 'hdparm -I $dev | grep TRIM'
+#LUKSKEY="LABEL=TRAVELSTICK:/keys/alienbob.luks"
+#ROOTDEV="/dev/sda1"
+#ROOTFS="ext4"
+#RESUMEDEV="/dev/sda2"
+#RAID="0"
+#LVM="0"
+#UDEV="1"
+#MODCONF="0"
+#MICROCODE_ARCH="/boot/intel-ucode.cpio"
+#WAIT="1"
diff --git a/patches/source/mkinitrd/mkinitrd_command_generator.8 b/patches/source/mkinitrd/mkinitrd_command_generator.8
new file mode 100644
index 000000000..954fab484
--- /dev/null
+++ b/patches/source/mkinitrd/mkinitrd_command_generator.8
@@ -0,0 +1,187 @@
+'\" t
+.\" Title: mkinitrd_command_generator
+.\" Author: Eric Hameleers
+.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
+.\" Date: 2016-02-07
+.\" Manual: Slackware Tools
+.\" Source: http://www.slackware.com 1.40
+.\" Language: English
+.\"
+.TH "MKINITRD_COMMAND_GEN" "8" "2016-02-07" "http://www\&.slackware\&.com" "Slackware Tools"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+mkinitrd_command_generator \- mkinitrd the easy way
+.SH "SYNOPSIS"
+.sp
+.nf
+mkinitrd_command_generator\&.sh [ \fIoptions\fR ] [ \fIkernel_filename\fR ]
+.fi
+.SH "OPTIONS"
+.PP
+\fB\-a \fR\fB\fIadditional params\fR\fR
+.RS 4
+Additional parameters to pass to mkinitrd\&.
+.RE
+.PP
+\fB\-c | \-\-conf\fR
+.RS 4
+Show a suitable mkinitrd configuration file\&.
+.RE
+.PP
+\fB\-h | \-\-help\fR
+.RS 4
+Show this help\&.
+.RE
+.PP
+\fB\-i | \-\-interactive\fR
+.RS 4
+Navigate through menus instead of using commandline arguments\&.
+.RE
+.PP
+\fB\-\-longhelp\fR
+.RS 4
+Show more detailed information/examples\&.
+.RE
+.PP
+\fB\-k \fR\fB\fIkernelversion\fR\fR
+.RS 4
+Use specific kernel version\&.
+.RE
+.PP
+\fB\-m \fR\fB\fIadditional mods\fR\fR
+.RS 4
+Additional modules to pass to mkinitrd, separated by colons (:)\&.
+.RE
+.PP
+\fB\-l | \-\-lilo\fR
+.RS 4
+Only show lilo\&.conf section (requires a kernel_filename)\&.
+.RE
+.PP
+\fB\-r | \-\-run\fR
+.RS 4
+Only show
+\fImkinitrd\fR
+command\&.
+.RE
+.SH "DESCRIPTION"
+.sp
+This script is useful in situations where you require an initrd image to boot your computer\&.
+.sp
+For instance, when booting a kernel that does not have support for your storage or root filesystem built in (such as the Slackware \fIgeneric\fR kernels)\&.
+.sp
+When you run the script without parameters, it will examine your running system, your current kernel version and will output an example of a \fImkinitrd\fR commandline that you can use to generate an initrd image containing enough driver support to boot the computer\&.
+.sp
+You can make it more specific: when you add the filename of a kernel as parameter to the script, it will determine the kernel version from that kernel, and also give an example of the lines that you should add to your \fI/etc/lilo\&.conf\fR file\&.
+.sp
+If you want your initrd image to have a custom name instead of the default \fI/boot/initrd\&.gz\fR you can add it as another parameter to the script, as follows:
+.sp
+mkinitrd_command_generator\&.sh \-a "\-o \fI/boot/custom\&.gz\fR"
+.sp
+The arguments to the \fI\-a\fR parameter will be used as additional arguments to the \fImkinitrd\fR command\&.
+.sp
+If you need additional modules in the initrd image, apart from what the script determines, you can pass then to the script using the \fI\-m\fR parameter as follows:
+.sp
+mkinitrd_command_generator\&.sh \-m "uhci\-hcd:usbhid:hid:hid\-generic"
+.sp
+The above example adds support for USB keyboards to the initrd \- you may need that if you have encrypted your root partition and need to enter a passphrase using a USB keyboard\&.
+.sp
+Instead of copying and pasting the script\(cqs output, you can create an initrd by directly executing the output, like in this example:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+$(mkinitrd_command_generator\&.sh \-\-run /boot/vmlinuz\-generic\-4\&.4\&.1)
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+That used the \fI\-r\fR or \fI\-\-run\fR switch to make the script only write the \fImkinitrd\fR commandline to the terminal\&.
+.sp
+When you want to add a section for a specific kernel to \fI/etc/lilo\&.conf\fR directly, use the \fI\-l\fR or \fI\-\-lilo\fR switch and use a command like in this example:
+.sp
+mkinitrd_command_generator\&.sh \-\-lilo /boot/vmlinuz\-generic\-smp\-4\&.4\&.1 >>/etc/lilo\&.conf
+.sp
+That command will result in the following lines being added to your \fI/etc/lilo\&.conf\fR file (example for my hardware):
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fI# Linux bootable partition config begins\fR
+\fI# initrd created with \*(Aqmkinitrd \-c \-k 4\&.4\&.1 \-m mbcache:jbd2:ext4 \-f ext4 \-r /dev/sda7 \-u \-o /boot/initrd\&.gz\fR\*(Aq
+image = /boot/vmlinuz\-generic\-4\&.4\&.1
+initrd = /boot/initrd\&.gz
+root = /dev/sda7
+label = 4\&.4\&.1
+read\-only
+\fI# Linux bootable partition config ends\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The last two examples show how easy it is to configure your computer for the use of an initrd if you need one\&. The only thing left to do afterwards is running \fIlilo\fR\&.
+.SH "EXIT STATUS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB0\fR Success
+\fB1\fR Failure
+.fi
+.if n \{\
+.RE
+.\}
+.SH "FILES"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+/usr/share/mkinitrd/mkinitrd_command_generator\&.sh
+.fi
+.if n \{\
+.RE
+.\}
+.SH "BUGS"
+.sp
+Report bugs to Eric Hameleers <alien@slackware\&.com>
+.SH "SEE ALSO"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+mkinitrd(1), lilo\&.conf(1)
+.fi
+.if n \{\
+.RE
+.\}
+.SH "AUTHOR"
+.PP
+\fBEric Hameleers\fR
+.RS 4
+Author.
+.RE
diff --git a/patches/source/mkinitrd/mkinitrd_command_generator.sh b/patches/source/mkinitrd/mkinitrd_command_generator.sh
new file mode 100644
index 000000000..33d9c9de3
--- /dev/null
+++ b/patches/source/mkinitrd/mkinitrd_command_generator.sh
@@ -0,0 +1,872 @@
+#!/bin/sh
+# $Id: mkinitrd_command_generator.sh,v 1.45 2011/02/17 09:27:05 eha Exp eha $
+# Copyright 2013 Patrick J. Volkerding, Sebeka, Minnesota, USA
+# Copyright 2008, 2009, 2010, 2011 Eric Hameleers, Eindhoven, Netherlands
+# Contact: <alien@slackware.com>
+# Copyright 2008, 2009 PiterPUNK, Sao Paulo, SP, Brazil
+# Contact: <piterpunk@slackware.com>
+# All rights reserved.
+#
+# Permission to use, copy, modify, and distribute this software for
+# any purpose with or without fee is hereby granted, provided that
+# the above copyright notice and this permission notice appear in all
+# copies.
+#
+# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+# -----------------------------------------------------------------------------
+#
+# Create an initrd which fits the system.
+# Take into account the use of LVM/LUKS/RAID.
+# Find out about any hardware drivers the system may need in an initrd when
+# booting from a generic lightweight kernel.
+#
+# -----------------------------------------------------------------------------
+
+# The script's revision number will be displayed in the help text:
+REV=$( echo "$Revision: 1.45 $" | cut -d' ' -f2 )
+
+# Define some essential parameter values:
+USING_LVM=""
+USING_LUKS=""
+USING_RAID=""
+MLIST=""
+REALDEV="" # The device that contains the LUKS volume
+BASEDEV="" # Lowest level device (raw block device or RAID volume)
+
+FSTAB=${FSTAB:-"/etc/fstab"} # so we can test with alternate fstab files
+
+# These are needed by -c and -i options:
+SOURCE_TREE=${SOURCE_TREE:-"/boot/initrd-tree"}
+CLEAR_TREE=${CLEAR_TREE:-1}
+KEYMAP=${KEYMAP:-"us"}
+UDEV=${UDEV:-1}
+# ARM devices need more time:
+case "$( uname -m )" in
+ arm*) WAIT_DEFAULT=4;;
+ *) WAIT_DEFAULT=1;;
+esac
+WAIT=${WAIT:-$WAIT_DEFAULT}
+
+# A basic explanation of the commandline parameters:
+basic_usage() {
+ cat <<-EOT
+
+ *** $(basename $0) revision $REV ***
+ Usage:
+ $(basename $0) [ options ] [ kernel_filename ]
+ Options:
+ -a <"additional params"> Additional parameters to pass to mkinitrd.
+ -c | --conf Show a suitable mkinitrd configuration file.
+ -h | --help Show this help.
+ -i | --interactive Navigate through menus instead of using
+ commandline arguments.
+ --longhelp Show more detailed information/examples.
+ -k <kernelversion> Use specific kernel version.
+ -m <"additional mods"> Additional modules to pass to mkinitrd,
+ separated by colons (:).
+ -l | --lilo Only show lilo.conf section
+ (requires a kernel_filename).
+ -r | --run Only show 'mkinitrd' command.
+ EOT
+}
+
+# More of a tutorial here:
+extended_usage() {
+ cat <<-EOT
+
+ This script is useful in situations where you require an initrd image
+ to boot your computer.
+ For instance, when booting a kernel that does not have support for your
+ storage or root filesystem built in (such as the Slackware 'generic'
+ kernels').
+
+ * When you run the script without parameters, it will examine your
+ running system, your current kernel version and will output an example
+ of a 'mkinitrd' commandline that you can use to generate an initrd
+ image containing enough driver support to boot the computer.
+
+ * You can make it more specific: when you add the filename of a kernel
+ as parameter to the script, it will determine the kernel version from
+ that kernel, and also give an example of the lines that you should add
+ to your '/etc/lilo.conf' file.
+
+ * If you want your initrd image to have a custom name instead of the
+ default '/boot/initrd.gz' you can add it as another parameter to the
+ script, as follows:
+
+ $(basename $0) -a "-o /boot/custom.gz"
+
+ The arguments to the '-a' parameter will be used as additional arguments
+ to the 'mkinitrd' command.
+
+ * If you need additional modules in the initrd image, apart from what
+ the script determines, you can pass then to the script using the '-m'
+ parameter as follows:
+
+ $(basename $0) -m "uhci-hcd:usbhid:hid_generic"
+
+ The above example adds support for USB keyboards to the initrd - you
+ may need that if you have encrypted your root partition and need to
+ enter a passphrase using a USB keyboard.
+
+ * Instead of copying and pasting the script's output, you can create
+ an initrd by directly executing the output, like in this example:
+
+ EOT
+
+ echo " \$($(basename $0) --run /boot/vmlinuz-generic-smp-2.6.35.11-smp)"
+
+ cat <<-EOT
+
+ That used the '-r' or '--run' switch to make the script only write
+ the 'mkinitrd' commandline to the terminal.
+
+ * When you want to add a section for a specific kernel to
+ '/etc/lilo.conf' directly, use the '-l' or '--lilo' switch and use a
+ command like in this example:
+
+ EOT
+
+ echo " $(basename $0) --lilo /boot/vmlinuz-generic-smp-2.6.35.11-smp >>/etc/lilo.conf"
+
+ cat <<-EOT
+
+ That command will result in the following lines being added to your
+ '/etc/lilo.conf' file (example for my hardware):
+
+ # Linux bootable partition config begins
+ # initrd created with 'mkinitrd -c -k 2.6.35.11-smp -m ata_generic:pata_amd:mbcache:jbd:ext3 -f ext3 -r /dev/hda7'
+ image = /boot/vmlinuz-generic-smp-2.6.35.11-smp
+ initrd = /boot/initrd.gz
+ root = /dev/hda7
+ label = 2.6.35.11-smp
+ read-only
+ # Linux bootable partition config ends
+
+ The last two examples show how easy it is to configure your computer
+ for the use of an initrd if you need one. The only thing left to do
+ afterwards is running 'lilo'.
+
+ EOT
+}
+
+# Find the device that holds the root partition:
+get_root_device() {
+ if [ -e $FSTAB ]; then
+ RD=$(cat $FSTAB |tr '\t' ' ' |grep -v '^ *#' |tr -s ' ' |grep ' / ' |cut -f1 -d' ')
+ if [ "$(echo $RD | cut -f1 -d=)" = "LABEL" -o "$(echo $RD | cut -f1 -d=)" = "UUID" ]; then
+ DKEY=$(echo $RD | cut -f1 -d=)
+ # The value can be LABEL=foo or LABEL='foo' or LABEL="foo"
+ DVAL=$(echo $RD | cut -f2 -d= | tr -d "'\042")
+ RD=$(/sbin/blkid | grep -w $DKEY | grep -w $DVAL | cut -f1 -d:)
+ fi
+ else
+ RD=$(grep -m1 "^/dev/.*[[:blank:]]/[[:blank:]]" /proc/mounts | cut -f1 -d' ')
+ fi
+ echo $RD
+}
+
+# Get the root fs information:
+get_rootfs_type() {
+ if $(type blkid 1>/dev/null 2>&1) ; then
+ blkid -s TYPE -o value $ROOTDEV
+ elif $(type vol_id 1>/dev/null 2>&1) ; then
+ vol_id $ROOTDEV | grep ID_FS_TYPE | cut -f2 -d=
+ else
+ # As a fallback, use:
+ cat $FSTAB |tr '\t' ' ' |grep -v '^ *#' |tr -s ' ' |grep ' / ' |cut -f3 -d' '
+ fi
+}
+
+# Add the module(s) needed for the root filesystem:
+add_rootfs_module() {
+ local FSMOD
+ FSMOD=$(/sbin/modprobe --set-version $KVER --show-depends ${ROOTFS} 2>/dev/null | while read LINE; do
+ echo $(basename $(echo $LINE | cut -d' ' -f2) .ko )
+ done)
+ if [ -n "$FSMOD" ]; then
+ [ -n "$MLIST" ] && echo "$MLIST:$(echo $FSMOD | tr ' ' ':')" \
+ || echo $FSMOD | tr ' ' ':'
+ fi
+}
+
+# Determine the list of kernel modules needed to support the root device:
+determine_blockdev_drivers() {
+ # Walk the /sys tree to find kernel modules that are
+ # required for our storage devices.
+ # Thanks to PiterPUNK for help with this code.
+ local MLIST
+ MLIST=$(for i in $(find /sys/block/*/ -name "device" -print0 | xargs -0 -i'{}' readlink -f '{}' | sort -u); do
+ /sbin/udevadm info --query=all --path=$i --attribute-walk | \
+ sed -ne 's/^[[:blank:]]\+DRIVER[S]*=="\([^"]\+\)"$/\1/p' | \
+ xargs -I@ /sbin/modprobe --set-version $KVER --show-depends @ \
+ 2>/dev/null | grep -v "builtin " | \
+ while read LINE ; do
+ echo $(basename $(echo $LINE | cut -d' ' -f2) .ko )
+ done
+ done)
+ MLIST=$( echo $MLIST | tr ' ' ':' )
+ echo $MLIST
+}
+
+# Search for USB keyboards:
+function add_usb_keyboard() {
+ local USBMOD
+ if cat /proc/bus/input/devices | sed -e 's/^$/\$/g' | \
+ tr "\n$" " \n" | grep -q " Phys=.*usb.* .*Handlers=.*kbd.*B:"; then
+ USBMOD="xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch"
+ [ -n "$MLIST" ] && MLIST="$MLIST:$USBMOD" \
+ || MLIST="$USBMOD"
+ fi
+ echo $MLIST
+}
+
+# Determine what USB Host Controller is in use
+function add_usb_hcd() {
+ local USBMOD
+ for i in $(ls -Ld /sys/module/*_hcd/drivers/* 2> /dev/null); do
+ if ls -L $i | grep -q "[0-9a-f]*:" ; then
+ USBMOD=$( echo $i | cut -f4 -d/ | tr "_" "-")
+ [ -n "$MLIST" ] && MLIST="$MLIST:$USBMOD" \
+ || MLIST="$USBMOD"
+ fi
+ done
+ echo $MLIST
+}
+
+# Is the root partition on a (combination of) LVM/LUKS volume?
+check_luks_lvm_raid() {
+ if $( lvdisplay -c $ROOTDEV 1>/dev/null 2>/dev/null ); then
+ # Our root partition is on a LV:
+ USING_LVM=1
+ # Search the Physical Volume of our Logical Volume:
+ MYVG=$( echo $(lvdisplay -c $ROOTDEV 2>/dev/null) | cut -d: -f2 )
+ for LINE in $(pvdisplay -c) ; do
+ VG=$(echo $LINE | cut -d: -f2)
+ [ "$VG" = "$MYVG" ] && break
+ done
+ PV=$(echo $LINE | cut -d: -f1)
+ # Check if there is a LUKS device underneath:
+ if $( cryptsetup status $PV 1>/dev/null 2>/dev/null ) ; then
+ # Our root partition's LV is on a LUKS volume:
+ USING_LUKS=1
+ REALDEV=$( cryptsetup status $PV | grep 'device: ' | tr -d ' ' | cut -d: -f2 )
+ BASEDEV=$REALDEV
+ else
+ BASEDEV=$PV
+ fi
+ elif $( cryptsetup status $ROOTDEV 1>/dev/null 2>/dev/null ) ; then
+ # Our root device is on a LUKS volume:
+ USING_LUKS=1
+ REALDEV=$( cryptsetup status $ROOTDEV | grep 'device: ' | tr -d ' ' | cut -d: -f2 )
+ ROOTDEV=$(basename $ROOTDEV)
+ # Check for LVM:
+ for LV in $(lvdisplay -c 2>/dev/null | tr -d ' ' | cut -f1 -d:) ; do
+ # Note: cryptsetup shows the real device, whereas
+ # lvdisplay requires the /dev/<myvg>/... symlink to the real device.
+ if [ "$(readlink $LV)" = "$REALDEV" ]; then
+ REALDEV=$LV
+ break
+ fi
+ done
+ if $( lvdisplay -c $REALDEV 1>/dev/null 2>/dev/null ); then
+ # Our root partition's LUKS device is on a LV:
+ USING_LVM=1
+ # Search the Physical Volume of our Logical Volume:
+ MYVG=$( echo $(lvdisplay -c $REALDEV 2>/dev/null) | cut -d: -f2 )
+ for LINE in $(pvdisplay -c) ; do
+ VG=$(echo $LINE | cut -d: -f2)
+ [ "$VG" = "$MYVG" ] && break
+ done
+ PV=$(echo $LINE | cut -d: -f1)
+ BASEDEV=$PV
+ else
+ BASEDEV=$REALDEV
+ fi
+ else
+ BASEDEV=$ROOTDEV
+ fi
+
+ # Finally, we should check if base device is
+ # a real block device or a RAID volume:
+ for MD in $(cat /proc/mdstat | grep -w active | cut -d' ' -f1) ; do
+ if [ "$BASEDEV" = "/dev/$MD" ]; then
+ USING_RAID=1
+ break
+ fi
+ done
+}
+
+# Before we start
+[ -x /bin/id ] && CMD_ID="/bin/id" || CMD_ID="/usr/bin/id"
+if [ "$($CMD_ID -u)" != "0" ]; then
+ echo "You need to be root to run $(basename $0)."
+ exit 1
+fi
+
+# Parse the commandline parameters:
+while [ ! -z "$1" ]; do
+ case $1 in
+ --longhelp)
+ basic_usage
+ extended_usage
+ exit 0
+ ;;
+ -a)
+ MKINIT_PARAMS="$2"
+ shift 2
+ ;;
+ -c|--conf)
+ [ -n "$EMIT" ] && { echo "Do not mix incompatible parameters!"; exit 1; }
+ EMIT="conf"
+ shift
+ ;;
+ -h|--help)
+ basic_usage
+ exit 0
+ ;;
+ -i|--interactive)
+ INTERACTIVE=1
+ shift
+ ;;
+ -k)
+ KVER=$2
+ shift 2
+ ;;
+ -m)
+ MKINIT_MODS=$2
+ shift 2
+ ;;
+ -l|--lilo)
+ [ -n "$EMIT" ] && { echo "Do not mix incompatible parameters!"; exit 1; }
+ EMIT="lilo"
+ shift
+ ;;
+ -L|--fromlilo)
+ FROMLILO=1
+ shift
+ ;;
+ -r|--run)
+ [ -n "$EMIT" ] && { echo "Do not mix incompatible parameters!"; exit 1; }
+ EMIT="run"
+ shift
+ ;;
+ -R|--rootdev)
+ ROOTDEV=$2
+ shift 2
+ ;;
+ -*)
+ echo "Unsupported parameter '$1'!"
+ exit 1
+ ;;
+ *) # Everything else but switches (which start with '-') follows:
+ if [ -f $1 ]; then
+ KFILE=$1
+ # Construction of KFILE's full filename:
+ KFILEPATH=$(cd $(dirname $KFILE) && pwd)
+ if [ -L $KFILE ]; then
+ KFILE=$(readlink $KFILE)
+ else
+ KFILE=$(basename $KFILE)
+ fi
+ KFILE=${KFILEPATH}/$KFILE
+ if [ -z "$(file $KFILE | grep -E 'Linux kernel x86 boot|x86 boot sector')" ]; then
+ echo "File '$KFILE' does not look like it is a kernel file!"
+ exit 1
+ fi
+ else
+ echo "File $1 not found!"
+ exit 1
+ fi
+ shift
+ ;;
+ esac
+done
+
+# Determine what to show as output (other options may have set EMIT already)
+EMIT=${EMIT:-"all"}
+
+# An EMIT value of 'lilo' requires a kernel filename as script parameter:
+if [ "$EMIT" = "lilo" ]; then
+ if [ -z "$KFILE" ]; then
+ echo "A kernel_filename is required with the '-l|--lilo' option!"
+ exit 1
+ fi
+fi
+
+# Determine kernel version to use,
+# and check if modules for this kernel are actually present:
+if [ -z "$KVER" ]; then
+ if [ -n "$KFILE" ]; then
+ KVER="$(strings $KFILE | grep '([^ ]*@[^ ]*) #' | cut -f1 -d' ')"
+ else
+ KVER="$(uname -r)"
+ fi
+fi
+if [ ! -d /lib/modules/$KVER ]; then
+ echo "Modules for kernel $KVER aren't installed."
+ exit 1
+fi
+
+# Determine whether the user passed an alternate filename for the initrd:
+if [ -n "$MKINIT_PARAMS" ]; then
+ SRCHLIST="$MKINIT_PARAMS"
+ for ELEM in $MKINIT_PARAMS ; do
+ SRCHLIST=$(echo $SRCHLIST | cut -d' ' -f2-) # cut ELEM from the list
+ if [ "$ELEM" = "-o" ]; then
+ IMGFILE=$(echo $SRCHLIST | cut -d' ' -f1)
+ break
+ fi
+ done
+fi
+IMGFILE=${IMGFILE:-"/boot/initrd.gz"}
+
+# Get information about the root device / root filesystem:
+ROOTDEV=${ROOTDEV:-$(get_root_device)}
+ROOTFS=$(get_rootfs_type)
+
+# Determine the list of kernel modules needed to support the root device:
+MLIST=$(determine_blockdev_drivers)
+
+# Check if we are running in a kvm guest with virtio block device driver
+# (add all virtio modules, we sort out the doubles later):
+if echo $MLIST | grep -q "virtio"; then
+ MLIST="$MLIST:virtio:virtio_balloon:virtio_blk:virtio_ring:virtio_pci:virtio_net"
+fi
+
+# Determine if a USB keyboard is in use and include usbhid and hid_generic
+# to module list
+MLIST=$(add_usb_keyboard)
+
+# If we use any USB module, try to determine the Host Controller
+if echo $MLIST | grep -q "usb"; then
+ MLIST=$(add_usb_hcd)
+fi
+
+# Check what combination of LUKS/LVM/RAID we have to support:
+# This sets values for USING_LUKS, USING_LVM, USING_RAID, REALDEV and BASEDEV.
+check_luks_lvm_raid
+
+# This is the interactive part:
+if [ "$INTERACTIVE" = "1" ]; then
+ if [ "$FROMLILO" != "1" ]; then
+ dialog --stdout --title "WELCOME TO MKINITRD COMMAND GENERATOR" --msgbox "\
+The main goal of this utility is to create a good initrd to \
+fit your needs. It can detect what kernel you are running, \
+what is your root device, root filesystem, if you use encryption, \
+LVM, RAID, etc. \
+\n\n\
+Usually the probed values are OK and they will be the \
+defaults in all subsequent dialogs, but maybe you want \
+to change something. \n\
+If in doubt, leave the defaults." 0 0
+
+ KVER=$( ls -d1 --indicator-style=none /lib/modules/* | \
+ awk -F/ -vVER=$KVER '{
+ if ( VER == $NF ) {
+ ONOFF="on"
+ } else {
+ ONOFF="off"
+ } ; printf("%s \"\" %s\n",$NF,ONOFF) }' | \
+ xargs dialog --stdout --title "CHOOSE KERNEL VERSION" \
+ --default-item $KVER --radiolist "\
+Please, select the kernel version you want to create this initrd for." 0 0 4 )
+ [ -z "$KVER" ] && exit 1
+
+ OLDROOTDEV=$ROOTDEV
+ ROOTDEV=$( dialog --stdout --title "SELECT ROOT DEVICE" --inputbox "\
+Enter your root device. Root device is the one where your '/' filesystem \
+is mounted." 0 0 "$ROOTDEV" )
+ [ -z "$ROOTDEV" ] && exit 1
+
+ # We need to re-check our defaults in case the user changed the default
+ # value for ROOTDEV:
+ [ "$OLDROOTDEV" != "$ROOTDEV" ] && check_luks_lvm_raid
+ ROOTFS=$(get_rootfs_type)
+
+ ROOTFS=$( dialog --stdout --title "SELECT ROOT FILESYSTEM" --inputbox "\
+Enter the type of your root filesystem." 0 0 "$ROOTFS" )
+ [ -z "$ROOTFS" ] && exit 1
+ fi
+
+ MLIST=$(add_rootfs_module)
+
+ LLR=$( dialog --stdout --title "LVM/LUKS/RAID" --checklist "\
+Do you use some of those in your root filesystem? \
+If this is the case, please select one or more options." 12 45 3 \
+"LVM" "Logical Volume Manager" $([ "$USING_LVM" = "1" ] && echo on || echo off) \
+"LUKS" "Linux Unified Key Setup" $([ "$USING_LUKS" = "1" ] && echo on || echo off) \
+"RAID" "Linux Software RAID" $([ "$USING_RAID" = "1" ] && echo on || echo off))
+
+ if [ "$?" != "0" ]; then
+ exit 1
+ fi
+
+ echo $LLR | grep -q LUKS && USING_LUKS="1"
+ echo $LLR | grep -q LVM && USING_LVM="1"
+ echo $LLR | grep -q RAID && USING_RAID="1"
+
+ if [ "$USING_LUKS" = "1" ]; then
+ REALDEV=$( dialog --stdout --title "LUKS ROOT DEVICE" --inputbox "\
+Please, enter your LUKS root device:" 0 0 "$REALDEV" )
+ [ -z "$REALDEV" ] && exit 1
+ fi
+fi
+
+# Step out of the interactive loop for a moment. The next block needs to be
+# executed in all cases.
+
+# We need to 'undouble' the MLIST array. Some people report that walking the
+# /sys tree produces duplicate modules in the list.
+# The awk command elimitates doubles without changing the order:
+MLIST=$( echo $MLIST | tr ':' '\n' | awk '!x[$0]++' | tr '\n' ' ' )
+MLIST=$( echo $MLIST | tr ' ' ':' )
+MLIST=$(echo ${MLIST%:}) # To weed out a trailing ':' which was reported once.
+
+# Back to the interactive part:
+
+if [ "$INTERACTIVE" = "1" ]; then
+ MLIST=$( dialog --stdout --title "INITRD'S MODULE LIST" --inputbox "\
+The list here shows all modules needed to support your root filesystem \
+and boot from it. But you can change the list to use some alternative \
+or additional modules. If you don't know what to do, the default is safe." \
+0 0 "$MLIST" )
+ if [ "$?" != "0" ]; then
+ exit 1
+ fi
+
+ EXTRA=$( dialog --stdout --title "EXTRA CONFIGURATION" --checklist "\
+Now is your chance for some additional configuration. All of these \
+configurations are optional and you can stick to the defaults." 11 72 3 \
+"KEYMAP" "Select keyboard layout (default: US)" \
+ $([ $USING_LUKS = 1 ] && echo on || echo off) \
+"RESUMEDEV" "Select device for 'suspend-to-disk' feature" off \
+"UDEV" "Use UDEV in the initrd for device configuration" $(test $UDEV -eq 1 && echo on || echo off) \
+"WAIT" "Add delay to allow detection of slow disks at boot" $(test $WAIT -gt $WAIT_DEFAULT && echo on || echo off) )
+ if [ "$?" != "0" ]; then
+ exit 1
+ fi
+
+ if echo $EXTRA | grep -q KEYMAP ; then
+ KEYMAP=$( dialog --stdout --title "KEYBOARD LAYOUT SELECTION" \
+ --cancel-label "Skip" \
+ --menu "You may select one of the following keyboard layouts. \
+If you do not select a keyboard map, 'us.map' \
+(the US keyboard layout) is the default. Use the UP/DOWN \
+arrow keys and PageUp/PageDown to scroll \
+through the whole list of choices." \
+22 55 11 \
+"qwerty/us.map" "" \
+"azerty/azerty.map" "" \
+"azerty/be-latin1.map" "" \
+"azerty/fr-latin0.map" "" \
+"azerty/fr-latin1.map" "" \
+"azerty/fr-latin9.map" "" \
+"azerty/fr-old.map" "" \
+"azerty/fr-pc.map" "" \
+"azerty/fr.map" "" \
+"azerty/wangbe.map" "" \
+"azerty/wangbe2.map" "" \
+"dvorak/ANSI-dvorak.map" "" \
+"dvorak/dvorak-l.map" "" \
+"dvorak/dvorak-r.map" "" \
+"dvorak/dvorak.map" "" \
+"dvorak/no-dvorak.map" "" \
+"fgGIod/tr_f-latin5.map" "" \
+"fgGIod/trf-fgGIod.map" "" \
+"olpc/es-olpc.map" "" \
+"olpc/pt-olpc.map" "" \
+"qwerty/bg-cp1251.map" "" \
+"qwerty/bg-cp855.map" "" \
+"qwerty/bg_bds-cp1251.map" "" \
+"qwerty/bg_bds-utf8.map" "" \
+"qwerty/bg_pho-cp1251.map" "" \
+"qwerty/bg_pho-utf8.map" "" \
+"qwerty/br-abnt.map" "" \
+"qwerty/br-abnt2.map" "" \
+"qwerty/br-latin1-abnt2.map" "" \
+"qwerty/br-latin1-us.map" "" \
+"qwerty/by-cp1251.map" "" \
+"qwerty/by.map" "" \
+"qwerty/bywin-cp1251.map" "" \
+"qwerty/cf.map" "" \
+"qwerty/cz-cp1250.map" "" \
+"qwerty/cz-lat2-prog.map" "" \
+"qwerty/cz-lat2.map" "" \
+"qwerty/cz-qwerty.map" "" \
+"qwerty/defkeymap.map" "" \
+"qwerty/defkeymap_V1.0.map" "" \
+"qwerty/dk-latin1.map" "" \
+"qwerty/dk.map" "" \
+"qwerty/emacs.map" "" \
+"qwerty/emacs2.map" "" \
+"qwerty/es-cp850.map" "" \
+"qwerty/es.map" "" \
+"qwerty/et-nodeadkeys.map" "" \
+"qwerty/et.map" "" \
+"qwerty/fi-latin1.map" "" \
+"qwerty/fi-latin9.map" "" \
+"qwerty/fi-old.map" "" \
+"qwerty/fi.map" "" \
+"qwerty/gr-pc.map" "" \
+"qwerty/gr.map" "" \
+"qwerty/hu101.map" "" \
+"qwerty/il-heb.map" "" \
+"qwerty/il-phonetic.map" "" \
+"qwerty/il.map" "" \
+"qwerty/is-latin1-us.map" "" \
+"qwerty/is-latin1.map" "" \
+"qwerty/it-ibm.map" "" \
+"qwerty/it.map" "" \
+"qwerty/it2.map" "" \
+"qwerty/jp106.map" "" \
+"qwerty/kazakh.map" "" \
+"qwerty/kyrgyz.map" "" \
+"qwerty/la-latin1.map" "" \
+"qwerty/lt.baltic.map" "" \
+"qwerty/lt.l4.map" "" \
+"qwerty/lt.map" "" \
+"qwerty/mk-cp1251.map" "" \
+"qwerty/mk-utf.map" "" \
+"qwerty/mk.map" "" \
+"qwerty/mk0.map" "" \
+"qwerty/nl.map" "" \
+"qwerty/nl2.map" "" \
+"qwerty/no-latin1.map" "" \
+"qwerty/no.map" "" \
+"qwerty/pc110.map" "" \
+"qwerty/pl.map" "" \
+"qwerty/pl1.map" "" \
+"qwerty/pl2.map" "" \
+"qwerty/pl3.map" "" \
+"qwerty/pl4.map" "" \
+"qwerty/pt-latin1.map" "" \
+"qwerty/pt-latin9.map" "" \
+"qwerty/pt.map" "" \
+"qwerty/ro.map" "" \
+"qwerty/ro_std.map" "" \
+"qwerty/ru-cp1251.map" "" \
+"qwerty/ru-ms.map" "" \
+"qwerty/ru-yawerty.map" "" \
+"qwerty/ru.map" "" \
+"qwerty/ru1.map" "" \
+"qwerty/ru2.map" "" \
+"qwerty/ru3.map" "" \
+"qwerty/ru4.map" "" \
+"qwerty/ru_win.map" "" \
+"qwerty/ruwin_alt-CP1251.map" "" \
+"qwerty/ruwin_alt-KOI8-R.map" "" \
+"qwerty/ruwin_alt-UTF-8.map" "" \
+"qwerty/ruwin_cplk-CP1251.map" "" \
+"qwerty/ruwin_cplk-KOI8-R.map" "" \
+"qwerty/ruwin_cplk-UTF-8.map" "" \
+"qwerty/ruwin_ct_sh-CP1251.map" "" \
+"qwerty/ruwin_ct_sh-KOI8-R.map" "" \
+"qwerty/ruwin_ct_sh-UTF-8.map" "" \
+"qwerty/ruwin_ctrl-CP1251.map" "" \
+"qwerty/ruwin_ctrl-KOI8-R.map" "" \
+"qwerty/ruwin_ctrl-UTF-8.map" "" \
+"qwerty/se-fi-ir209.map" "" \
+"qwerty/se-fi-lat6.map" "" \
+"qwerty/se-ir209.map" "" \
+"qwerty/se-lat6.map" "" \
+"qwerty/se-latin1.map" "" \
+"qwerty/sk-prog-qwerty.map" "" \
+"qwerty/sk-qwerty.map" "" \
+"qwerty/speakup-jfw.map" "" \
+"qwerty/speakupmap.map" "" \
+"qwerty/sr-cy.map" "" \
+"qwerty/sv-latin1.map" "" \
+"qwerty/tr_q-latin5.map" "" \
+"qwerty/tralt.map" "" \
+"qwerty/trf.map" "" \
+"qwerty/trq.map" "" \
+"qwerty/ttwin_alt-UTF-8.map.gz" "" \
+"qwerty/ttwin_cplk-UTF-8.map.gz" "" \
+"qwerty/ttwin_ct_sh-UTF-8.map.gz" "" \
+"qwerty/ttwin_ctrl-UTF-8.map.gz" "" \
+"qwerty/ua-cp1251.map.gz" "" \
+"qwerty/ua-utf-ws.map" "" \
+"qwerty/ua-utf.map" "" \
+"qwerty/ua-ws.map" "" \
+"qwerty/ua.map" "" \
+"qwerty/uk.map" "" \
+"qwerty/us-acentos.map" "" \
+"qwerty/us.map" "" \
+"qwertz/croat.map" "" \
+"qwertz/cz-us-qwertz.map" "" \
+"qwertz/cz.map" "" \
+"qwertz/de-latin1-nodeadkeys.map" "" \
+"qwertz/de-latin1.map" "" \
+"qwertz/de.map" "" \
+"qwertz/de_CH-latin1.map" "" \
+"qwertz/fr_CH-latin1.map" "" \
+"qwertz/fr_CH.map" "" \
+"qwertz/hu.map" "" \
+"qwertz/sg-latin1-lk450.map" "" \
+"qwertz/sg-latin1.map" "" \
+"qwertz/sg.map" "" \
+"qwertz/sk-prog-qwertz.map" "" \
+"qwertz/sk-qwertz.map" "" \
+"qwertz/slovene.map" "" )
+ [ -n "$KEYMAP" ] && KEYMAP=$(basename $KEYMAP .map)
+ fi
+
+ if echo $EXTRA | grep -q UDEV ; then
+ UDEV=1
+ fi
+
+ if echo $EXTRA | grep -q RESUMEDEV ; then
+ # Print information about swap partitions:
+ FREERAM=$(free -k | grep "^Mem:" | tr -s ' ' | cut -d' ' -f2)
+ SWPINFO=""
+ for SWPDEV in $(grep -w swap $FSTAB | cut -d' ' -f1) ; do
+ SWPINFO="$SWPINFO $SWPDEV Linux swap partition $(fdisk -s $SWPDEV) KB \\n"
+ [ $(fdisk -s $SWPDEV) -gt $FREERAM ] && RESUMEDEV=$SWPDEV
+ done
+ FREERAM=$(free -m | grep "^Mem:" | tr -s ' ' | cut -d' ' -f2)
+ RESUMEDEV=$( dialog --stdout --no-collapse --title "HIBERNATE RESUME DEVICE" --inputbox "\
+When using suspend-to-disk feature (hibernate), your computer's RAM is copied \
+to a swap device when it shuts down. The kernel will resume from that RAM \
+image at boot. This means that the swap partition must not be smaller than \
+the amount of RAM you have ($FREERAM MB). \n\
+$SWPINFO \n\
+Please specify a swap partition to be used for hibernation:" \
+0 0 "$RESUMEDEV")
+ [ -z "$RESUMEDEV" ] && exit 1
+ fi
+
+ if echo $EXTRA | grep -q WAIT ; then
+ WAIT=$( dialog --stdout --title "WAIT FOR ROOT DEVICE" --inputbox "\
+Some block devices are too slow to be detected properly at boot. USB storage \
+devices and some disk arrays have this 'feature'. To make your machine \
+boot properly, you can add some delay here, to wait until all your disks are \
+probed and detected. The time is in seconds:" 0 0 "$WAIT")
+ [ -z "$WAIT" ] && exit 1
+ fi
+
+ IMGFILE=$( dialog --stdout --title "INITRD IMAGE NAME" --inputbox "\
+Enter your initrd image filename." 0 0 "$IMGFILE" )
+ [ -z "$IMGFILE" ] && exit 1
+
+else
+ MLIST=$(add_rootfs_module)
+fi
+
+# Add any modules passed along on the commandline:
+if [ -n "$MKINIT_MODS" ]; then
+ [ -n "$MLIST" ] && MLIST="$MLIST:$(echo $MKINIT_MODS | tr ' ' ':')" \
+ || MLIST="$(echo $MKINIT_MODS | tr ' ' ':')"
+fi
+
+# Constructing the mkinitrd command:
+MKINIT="mkinitrd -c -k $KVER -f $ROOTFS -r $ROOTDEV"
+
+# If we have a module list, add them:
+if ! [ -z "$MLIST" -o "$MLIST" = ":" ]; then
+ MKINIT="$MKINIT -m $MLIST"
+fi
+
+# Deal with LUKS/LVM/RAID:
+if [ "$USING_LUKS" = "1" ]; then
+ MKINIT="$MKINIT -C $REALDEV"
+fi
+if [ "$USING_LVM" = "1" ]; then
+ MKINIT="$MKINIT -L"
+fi
+if [ "$USING_RAID" = "1" ]; then
+ MKINIT="$MKINIT -R"
+fi
+
+if [ -n "$RESUMEDEV" ]; then
+ # Add hibernation partition:
+ MKINIT="$MKINIT -h $RESUMEDEV"
+fi
+if [ -n "$KEYMAP" -a "$KEYMAP" != "us" ]; then
+ # Add non-us keyboard mapping:
+ MKINIT="$MKINIT -l $KEYMAP"
+fi
+if [ $UDEV -eq 1 ]; then
+ # Add UDEV support:
+ MKINIT="$MKINIT -u"
+fi
+if [ -n "$WAIT" -a $WAIT -ne $WAIT_DEFAULT ]; then
+ # Add non-default wait time:
+ MKINIT="$MKINIT -w $WAIT"
+fi
+if ! echo "$MKINIT_PARAMS" | grep -q -- '-o ' ; then
+ # Add default output filename:
+ MKINIT="$MKINIT -o $IMGFILE"
+fi
+if [ -n "$MKINIT_PARAMS" ]; then
+ # Add user-supplied additional parameters:
+ MKINIT="$MKINIT $MKINIT_PARAMS"
+fi
+
+# Notify the user:
+if [ "$EMIT" = "all" ]; then
+ cat <<-EOT
+ #
+ # $(basename $0) revision $REV
+ #
+ # This script will now make a recommendation about the command to use
+ # in case you require an initrd image to boot a kernel that does not
+ # have support for your storage or root filesystem built in
+ # (such as the Slackware 'generic' kernels').
+ # A suitable 'mkinitrd' command will be:
+
+ $MKINIT
+ EOT
+elif [ "$EMIT" = "run" ]; then
+ echo "$MKINIT"
+elif [ "$EMIT" = "conf" ]; then
+ cat <<-EOT
+ SOURCE_TREE="$SOURCE_TREE"
+ CLEAR_TREE="$CLEAR_TREE"
+ OUTPUT_IMAGE="$IMGFILE"
+ KERNEL_VERSION="$KVER"
+ KEYMAP="$KEYMAP"
+ MODULE_LIST="$(echo $MLIST | cut -f2 -d\ )"
+ LUKSDEV="$REALDEV"
+ ROOTDEV="$ROOTDEV"
+ ROOTFS="$ROOTFS"
+ RESUMEDEV="$RESUMEDEV"
+ RAID="$USING_RAID"
+ LVM="$USING_LVM"
+ UDEV="$UDEV"
+ WAIT="$WAIT"
+ EOT
+fi
+
+if [ -n "$KFILE" ]; then
+ if [ "$EMIT" = "all" ]; then
+ cat <<-EOT
+ # An entry in 'etc/lilo.conf' for kernel '$KFILE' would look like this:
+ EOT
+ fi
+ if [ "$EMIT" = "all" -o "$EMIT" = "lilo" ]; then
+ # Compensate for the syntax used for the LUKS-on-LVM case:
+ [ "$(basename $ROOTDEV)" = "$ROOTDEV" ] && BASE="/dev/mapper/" || BASE=""
+ cat <<-EOT
+ # Linux bootable partition config begins
+ # initrd created with '$MKINIT'
+ image = $KFILE
+ initrd = $IMGFILE
+ root = $BASE$ROOTDEV
+ label = $KVER
+ read-only
+ # Linux bootable partition config ends
+ EOT
+ fi
+fi