diff options
Diffstat (limited to '')
-rw-r--r-- | source/a/mkinitrd/mkinitrd | 143 | ||||
-rw-r--r-- | source/a/mkinitrd/mkinitrd.8 | 7 | ||||
-rw-r--r-- | source/a/mkinitrd/mkinitrd.8.orig | 287 | ||||
-rwxr-xr-x | source/a/mkinitrd/mkinitrd.SlackBuild | 8 | ||||
-rw-r--r-- | source/a/mkinitrd/mkinitrd_command_generator.8 | 2 | ||||
-rw-r--r-- | source/a/mkinitrd/mkinitrd_command_generator.sh | 21 |
6 files changed, 393 insertions, 75 deletions
diff --git a/source/a/mkinitrd/mkinitrd b/source/a/mkinitrd/mkinitrd index 7c2f7629f..6f4ff3c19 100644 --- a/source/a/mkinitrd/mkinitrd +++ b/source/a/mkinitrd/mkinitrd @@ -51,6 +51,8 @@ # Modified by Patrick Volkerding <volkerdi@slackware.com> 12 July 2017 # Add support for including Slackware and kernel versions in the # output filename. Thanks to SeB. +# Modified by Patrick Volkerding <volkerdi@slackware.com> 04 Feb 2019 +# Allow specifying more than one kernel version. MKINITRD_VERSION=1.4.11 @@ -148,8 +150,10 @@ EOF create_new_source_tree() { mkdir -p $SOURCE_TREE - # Make sure a kernel module directory exists: - mkdir -p $SOURCE_TREE/lib/modules/${KERNEL_VERSION} + # Make sure the kernel module directories exist: + for kver in $(echo ${KERNEL_VERSION} | tr ':' '\n') ; do + mkdir -p $SOURCE_TREE/lib/modules/${kver} + done # 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: @@ -445,10 +449,12 @@ if echo "$OUTPUT_IMAGE" | grep -qE "%KVER%|%SLACKVER%" ; then fi # 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 +for kver in $(echo ${KERNEL_VERSION} | tr ':' '\n') ; do + if [ ! -d /lib/modules/$kver ]; then + echo "ERROR: No /lib/modules/$kver kernel modules tree found for kernel \"$kver\"" + exit 1 + fi +done # If clearing source tree was requested, do that first if [ "$CLEAR_TREE" = "1" ]; then @@ -644,10 +650,12 @@ if [ ! -z "$CRYPT" -o ! -z "$LVM" ]; then $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 +# Make module directories: +for kver in $(echo ${KERNEL_VERSION} | tr ':' '\n') ; do + if [ ! -d $SOURCE_TREE/lib/modules/$kver ]; then + mkdir -p $SOURCE_TREE/lib/modules/$kver + fi +done # Copy kmod/modprobe stuff to initrd: for i in kmod depmod insmod lsmod modinfo modprobe rmmod ; do @@ -656,8 +664,10 @@ for i in kmod depmod insmod lsmod modinfo modprobe rmmod ; do 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 +for kver in $(echo ${KERNEL_VERSION} | tr ':' '\n') ; do + cp /lib/modules/$kver/modules.{builtin,order} \ + $SOURCE_TREE/lib/modules/$kver +done # If an executable $SOURCE_TREE/load_kernel_modules already exists, then # we assume you will want to load the kernel modules mentioned in there. @@ -699,67 +709,72 @@ if [ ! -z "$MODULE_LIST" ]; then 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 + # Repeat these tasks for all kernel versions support has been requested for: + for kver in $(echo ${KERNEL_VERSION} | tr ':' '\n') ; do + + # 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 + # Get MODULE deps and prepare modprobe lines + /sbin/modprobe --set-version $kver --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)" )" + 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 + # 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 + fi - if ! grep -qx "$LINE" $SOURCE_TREE/load_kernel_modules ; then - echo "$LINE" >> $SOURCE_TREE/load_kernel_modules - 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 + # 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 - done - # Pregenerate the module dependency information - /sbin/depmod -a -b $SOURCE_TREE ${KERNEL_VERSION} + # Pregenerate the module dependency information + /sbin/depmod -a -b $SOURCE_TREE $kver + + done # repeat for all kernel versions # Copy /{etc,lib}/modprobe.d/* if desired if [ ! -z $MODCONF ]; then diff --git a/source/a/mkinitrd/mkinitrd.8 b/source/a/mkinitrd/mkinitrd.8 index 7e0247a09..1874d8144 100644 --- a/source/a/mkinitrd/mkinitrd.8 +++ b/source/a/mkinitrd/mkinitrd.8 @@ -25,7 +25,7 @@ mkinitrd \- create or rebuilt an initrd (initial ramdisk) using initramfs (simpl .B \-h hibernate_partition ] [ -.B \-k kernel_version +.B \-k kernel_version1:kernel_version2:kernel_version3... ] [ .B \-m module1:module2:module3... @@ -105,9 +105,10 @@ Display a help summary. .B \-h hibernate_partition Specify the swap partition holding the hibernation image. .TP -.B \-k kernel version +.B \-k kernel version list Use kernel modules from the specified kernel version. mkinitrd will look -for them in /lib/modules/(kernel version). +for them in /lib/modules/(kernel version). This may be a single kernel version, +or it may be a colon-delimited list of kernel versions. .TP .B \-l keymap Load an alternative keyboard mapping. All supported keyboard mappings diff --git a/source/a/mkinitrd/mkinitrd.8.orig b/source/a/mkinitrd/mkinitrd.8.orig new file mode 100644 index 000000000..7e0247a09 --- /dev/null +++ b/source/a/mkinitrd/mkinitrd.8.orig @@ -0,0 +1,287 @@ +.\" -*- 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 to load kernel +kernel modules in order to access the root partition. An initrd might also +be required to unlock an encrypted device. Usually these modules are +required to support the filesystem used by the root partition (e.g., ext4, +jfs, 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 +.BI \-r \ root_device +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. +.I root_device +can be a device node path, UUID, or LABEL. See examples for \fB\-C\fR below. +.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 +.BI \-C \ device_list +A colon (:) delimited list of luks encrypted block devices to be unlocked by +the initrd using cryptsetup. +.I device_list +may include any of: device node path, UUID, or LABEL. All devices that must be +unlocked in order to access the root filesystem must be specified. For example: + + -C /dev/sda2:/dev/sda3 +.br + -C UUID=ec6dea40-c8d8-4590-850a-a757be60e45a +.br + -C LABEL=darkstar + +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 node path. For example: + + /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/source/a/mkinitrd/mkinitrd.SlackBuild b/source/a/mkinitrd/mkinitrd.SlackBuild index 4e298baec..8aaa9b273 100755 --- a/source/a/mkinitrd/mkinitrd.SlackBuild +++ b/source/a/mkinitrd/mkinitrd.SlackBuild @@ -24,8 +24,8 @@ cd $(dirname $0) ; CWD=$(pwd) PKGNAM=mkinitrd VERSION=${VERSION:-1.4.11} -BB=1.28.3 -BUILD=${BUILD:-11} +BB=1.30.1 +BUILD=${BUILD:-12} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then @@ -60,7 +60,7 @@ rm -rf $PKG mkdir -p $TMP $PKG cd $TMP rm -rf busybox-$BB -tar xvf $CWD/busybox-$BB.tar.bz2 || exit 1 +tar xvf $CWD/busybox-$BB.tar.bz2 || tar xvf $CWD/busybox-$BB.tar.?z || exit 1 cd busybox-$BB || exit 1 if [ -d $CWD/fixes-$BB ]; then @@ -103,7 +103,7 @@ 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* \ +cp -a AUTHORS COPYING* INSTALL LICENSE README* TODO* \ $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 diff --git a/source/a/mkinitrd/mkinitrd_command_generator.8 b/source/a/mkinitrd/mkinitrd_command_generator.8 index 954fab484..d64b6d541 100644 --- a/source/a/mkinitrd/mkinitrd_command_generator.8 +++ b/source/a/mkinitrd/mkinitrd_command_generator.8 @@ -63,7 +63,7 @@ Show more detailed information/examples\&. .PP \fB\-k \fR\fB\fIkernelversion\fR\fR .RS 4 -Use specific kernel version\&. +Use specific kernel version\&. This may also be a colon-delimited list of kernel versions to use\&. .RE .PP \fB\-m \fR\fB\fIadditional mods\fR\fR diff --git a/source/a/mkinitrd/mkinitrd_command_generator.sh b/source/a/mkinitrd/mkinitrd_command_generator.sh index df6f24c9c..489225be5 100644 --- a/source/a/mkinitrd/mkinitrd_command_generator.sh +++ b/source/a/mkinitrd/mkinitrd_command_generator.sh @@ -72,7 +72,9 @@ basic_usage() { -i | --interactive Navigate through menus instead of using commandline arguments. --longhelp Show more detailed information/examples. - -k <kernelversion> Use specific kernel version. + -k <kernelversion> Use specific kernel version. Or, support + more than one kernel version by passing a + list of versions separated by colons (:). -m <"additional mods"> Additional modules to pass to mkinitrd, separated by colons (:). -l | --lilo Only show lilo.conf section @@ -345,7 +347,7 @@ while [ ! -z "$1" ]; do echo "Error: -k requires a kernel version." exit 1 fi - KVER=$2 + KVERLIST=$2 shift 2 ;; -m) @@ -411,6 +413,15 @@ fi # Determine kernel version to use, # and check if modules for this kernel are actually present: +if [ ! -z $KVERLIST ]; then + for kernel_version in $(echo $KVERLIST | tr ":" "\n") ; do + KVER=$kernel_version + if [ ! -d /lib/modules/$KVER ]; then + echo "Modules for kernel $KVER aren't installed." + exit 1 + fi + done +fi if [ -z "$KVER" ]; then if [ -n "$KFILE" ]; then KVER="$(strings $KFILE | grep '([^ ]*@[^ ]*) #' | cut -f1 -d' ')" @@ -775,7 +786,11 @@ if [ -n "$MKINIT_MODS" ]; then fi # Constructing the mkinitrd command: -MKINIT="mkinitrd -c -k $KVER -f $ROOTFS -r $ROOTDEV" +if [ -z $KVERLIST ]; then + MKINIT="mkinitrd -c -k $KVER -f $ROOTFS -r $ROOTDEV" +else + MKINIT="mkinitrd -c -k $KVERLIST -f $ROOTFS -r $ROOTDEV" +fi # If we have a module list, add them: if ! [ -z "$MLIST" -o "$MLIST" = ":" ]; then |