diff options
Diffstat (limited to '')
-rw-r--r-- | source/a/mkinitrd/mkinitrd | 230 | ||||
-rw-r--r-- | source/a/mkinitrd/mkinitrd.8 | 96 | ||||
-rwxr-xr-x | source/a/mkinitrd/mkinitrd.SlackBuild | 28 | ||||
-rw-r--r-- | source/a/mkinitrd/mkinitrd.conf.5 | 55 | ||||
-rw-r--r-- | source/a/mkinitrd/mkinitrd.conf.sample | 8 | ||||
-rw-r--r-- | source/a/mkinitrd/mkinitrd_command_generator.sh | 11 | ||||
-rw-r--r-- | source/a/mkinitrd/mkinitrd_kernelcheck.diff | 15 |
7 files changed, 325 insertions, 118 deletions
diff --git a/source/a/mkinitrd/mkinitrd b/source/a/mkinitrd/mkinitrd index 8f77725fe..4cd97296b 100644 --- a/source/a/mkinitrd/mkinitrd +++ b/source/a/mkinitrd/mkinitrd @@ -1,7 +1,7 @@ #!/bin/sh # Copyright 2004 Slackware Linux, Inc., Concord, CA, USA # Copyright 2004 Patrick J. Volkerding, Concord, CA, USA -# Copyright 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2007, 2008, 2009, 2010 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -22,24 +22,28 @@ # 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 +# 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 :) +# 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 +# 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. - -MKINITRD_VERSION=1.3.4 +# 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. + +MKINITRD_VERSION=1.4.5 print_usage() { cat << EOF @@ -70,22 +74,22 @@ initrd, and the script is easy to modify. Be creative. :-) -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 Use cryptsetup to unlock the underlying device of an - encrypted root filesystem (must be used with '-r' parameter). - Two scenarios are possible. (1) root filesystem was created on the - encrypted disk/LVM partition, example: - -C /dev/sda2 -r cryptroot - where /dev/sda2 is the encrypted partition and - the actual root device name in /etc/fstab is: - /dev/mapper/cryptroot - (2) the encrypted partition contains a LVM volume which holds the - root filesystem, example: - -C /dev/sda2 -r /dev/vg/root - where /dev/sda2 is the encrypted partition and - the actual root device name in /etc/fstab is: - /dev/vg/root + -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). -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 -R Add support for RAID partitions -V Display version number @@ -93,10 +97,10 @@ 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.29.3-smp kernel +Another example: Build an initrd image using Linux 2.6.29.6-smp kernel modules for a system with an ext3 root partition on /dev/hdb3: - mkinitrd -c -k 2.6.29.3-smp -m mbcache:jbd:ext3 -f ext3 -r /dev/hdb3 + mkinitrd -c -k 2.6.29.6-smp -m mbcache:jbd:ext3 -f ext3 -r /dev/hdb3 Note that if you are already logged in with /dev/hdb3 as your / partition, and it is running ext3, this command works just the same: @@ -151,11 +155,21 @@ build_initrd_image() { 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 ) + echo "$OUTPUT_IMAGE created." + echo "Be sure to run lilo again if you use it." } badconf_file() { @@ -166,6 +180,44 @@ badconf_file() { exit 1 } + +unify_libs() { + awk '/=. \// { print $3 }' | sort -u +} + +copy_libs() { + # First copy the essential glibc files: + find /lib* -name "ld-*so*" -o -name "libnss_files*so*" -o -name "libnss_compat*so*" | 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} + TMPFILE=${PRFX}${COUNT} + [ $(cat $TMPFILE | wc -l) -eq 0 ] && COUNT=0 + 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}* +} + # If --help is given, print_usage and exit: if echo $* | grep -wq '\--help' ; then print_usage @@ -181,11 +233,13 @@ 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:-/boot/initrd.gz} +OUTPUT_IMAGE=${OUTPUT_IMAGE:-""} KERNEL_VERSION=${KERNEL_VERSION:-"$(uname -r)"} # 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" @@ -204,8 +258,6 @@ if [ -z "$1" ]; then # If the source tree does exist, the default is to build the initrd # image from it and then exit: build_initrd_image - echo "$OUTPUT_IMAGE created." - echo "Be sure to run lilo again if you use it." exit 0 fi fi # default no-option actions @@ -264,6 +316,10 @@ while [ ! -z "$1" ]; do SOURCE_TREE="$2" shift 2 ;; + -u) + UDEV=1 + shift + ;; -w) WAIT="$2" shift 2 @@ -273,6 +329,10 @@ while [ ! -z "$1" ]; do LUKSDEV="$2" shift 2 ;; + -K) + LUKSKEY="$2" + shift 2 + ;; -L) LVM=1 shift @@ -306,13 +366,13 @@ 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 +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 +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: @@ -333,9 +393,12 @@ if [ ! -z "$WAIT" ]; then echo $WAIT > $SOURCE_TREE/wait-for-root fi -# Useful to know which initrd is running: -INITRD_NAME=$(basename $OUTPUT_IMAGE) -echo $INITRD_NAME > $SOURCE_TREE/initrd-name +# 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 @@ -353,49 +416,73 @@ if [ ! -z "$LUKSDEV" ]; then CRYPT=1 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}: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 ]; then mkdir -p $SOURCE_TREE/sbin cp /sbin/mdadm $SOURCE_TREE/sbin/mdadm - chmod 755 $SOURCE_TREE/sbin/mdadm + chmod 0755 $SOURCE_TREE/sbin/mdadm else echo "ERROR: mdadm binary is missing, RAID 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/ +fi + # Include LVM support in initrd if [ ! -z "$LVM" ]; then - if [ -f /sbin/lvm.static ]; then + if [ -f /sbin/lvm ]; then mkdir -p $SOURCE_TREE/sbin - cp /sbin/lvm.static $SOURCE_TREE/sbin/lvm.static - cp /sbin/dmsetup.static $SOURCE_TREE/sbin/dmsetup.static + cp /sbin/lvm $SOURCE_TREE/sbin/lvm + cp /sbin/dmsetup $SOURCE_TREE/sbin/dmsetup + find /lib* -name "libdevmapper*so*" | xargs -I'{}' cp -P --parents '{}' $SOURCE_TREE/ ( cd $SOURCE_TREE/sbin - ln -s lvm.static vgchange 2>/dev/null - ln -s lvm.static vgscan 2>/dev/null ) + ln -s lvm vgchange 2>/dev/null + ln -s lvm vgscan 2>/dev/null ) 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 else - echo "LVM static binary is missing, LVM support isn't installed" + echo "LVM binary is missing, LVM support isn't installed" fi fi # Include cryptsetup (LUKS) support in initrd if [ ! -z "$CRYPT" ]; then - if [ -e /sbin/cryptsetup.static ]; then + if [ -e /usr/sbin/cryptsetup ]; then mkdir -p $SOURCE_TREE/sbin - cp /sbin/cryptsetup.static $SOURCE_TREE/sbin/cryptsetup.static - ( cd $SOURCE_TREE/sbin - ln -s cryptsetup.static cryptsetup 2>/dev/null - ) - cat << EOF > $SOURCE_TREE/sbin/udevadm + 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 + chmod 0755 $SOURCE_TREE/sbin/udevadm + fi if [ -z "${MODULE_LIST}" ] ; then MODULE_LIST="dm-mod" @@ -405,7 +492,7 @@ EOF # Write the underlying luks device to the initrd-tree: echo $LUKSDEV > $SOURCE_TREE/luksdev else - echo "Cryptsetup static binary is missing, CRYPT support isn't installed" + echo "Cryptsetup binary is missing, CRYPT support isn't installed" fi fi @@ -414,7 +501,14 @@ if [ ! -d $SOURCE_TREE/lib/modules/$KERNEL_VERSION ]; then mkdir -p $SOURCE_TREE/lib/modules/$KERNEL_VERSION fi -# If a module list was given, copy the modules into place: +# 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 "^insmod" |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 "#insmod /lib/modules/2.6.18.8-smp/reiserfs.ko" $SOURCE_TREE/load_kernel_modules ; then rm -f $SOURCE_TREE/load_kernel_modules @@ -426,6 +520,12 @@ if [ ! -z "$MODULE_LIST" ]; then 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 | tr ' ' ':') + 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 @@ -433,6 +533,8 @@ if [ ! -z "$MODULE_LIST" ]; then 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) @@ -458,7 +560,7 @@ while [ $i -ne $INDEX ]; do fi # Get MODULE deps and prepare insmod lines - /sbin/modprobe --set-version $KERNEL_VERSION --show-depends --ignore-install $MODULE 2> /dev/null \ + /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 -q "$SRCMOD" $SOURCE_TREE/load_kernel_modules 2>/dev/null ; then @@ -477,10 +579,13 @@ while [ $i -ne $INDEX ]; do echo "$LINE" >> $SOURCE_TREE/load_kernel_modules fi - if cp -a --parents $SRCMOD $SOURCE_TREE 2> /dev/null; then - echo "OK: $SRCMOD added." - else - echo "WARNING: Could not find module \"$SRCMOD\"" + if [ ! -f ${SOURCE_TREE}${SRCMOD} ]; then + # We did not yet copy this module into the initrd-tree + if cp -a --parents $SRCMOD $SOURCE_TREE 2>/dev/null; then + echo "OK: $SRCMOD added." + else + echo "WARNING: Could not find module \"$SRCMOD\"" + fi fi done @@ -489,6 +594,9 @@ done fi +# Copy needed libraries +copy_libs + # And finally, build the initrd: build_initrd_image diff --git a/source/a/mkinitrd/mkinitrd.8 b/source/a/mkinitrd/mkinitrd.8 index 5fa957218..be4e9d42d 100644 --- a/source/a/mkinitrd/mkinitrd.8 +++ b/source/a/mkinitrd/mkinitrd.8 @@ -7,7 +7,7 @@ .ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP .el .TP "\\$1" .. -.TH MKINITRD 8 "04 March 2008" "Slackware Version 12.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 @@ -40,7 +40,16 @@ mkinitrd \- create or rebuilt an initrd (initial ramdisk) using initramfs (simpl .B \-s source_tree ] [ -.B \-C crypt_device +.B \-u +] +[ +.B \-w wait_time +] +[ +.B \-C device1:device2:device3... +] +[ +.B \-K luks_keyfile ] [ .B \-L @@ -117,29 +126,50 @@ together with the \-f option in order to be beneficial. .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 -Use cryptsetup to enable the underlying device of an encrypted root partition. -Requires '-r' parameter. Two scenarios are possible. -.br -(1) root filesystem was created on the encrypted disk/LVM partition, example: +.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 -r cryptroot + -C /dev/sda2:/dev/sda3 -where /dev/sda2 is the encrypted partition and the actual root device name in /etc/fstab is: +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/cryptroot + /dev/mapper/lukssda2 -(2) the encrypted partition contains a LVM volume which holds the root filesystem, example: +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/vg/root + "-C /dev/sda2 -r /dev/sda2" and + "-C /dev/sda2 -r /dev/mapper/lukssda2" -where /dev/sda2 is the encrypted partition and the actual root device name in /etc/fstab is: +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: - /dev/vg/root + -K LABEL=TRAVELSTICK:/keys/alien.luks .TP .B \-L This option adds LVM support to the initrd, if the tools are @@ -156,10 +186,33 @@ 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.24.5 kernel -modules for a system with an ext3 root partition on /dev/hdb3: +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.24.5 -m ext3 -f ext3 -r /dev/hdb3 + 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 @@ -174,13 +227,16 @@ 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.24.5 + image = /boot/vmlinuz-generic-2.6.33.1 initrd = /boot/initrd.gz - root = /dev/hda6 - label = Linux26245 + 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. diff --git a/source/a/mkinitrd/mkinitrd.SlackBuild b/source/a/mkinitrd/mkinitrd.SlackBuild index 10e70b997..7beba6c63 100755 --- a/source/a/mkinitrd/mkinitrd.SlackBuild +++ b/source/a/mkinitrd/mkinitrd.SlackBuild @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2007, 2008, 2009, 2010 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -21,16 +21,32 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -VERSION=1.3.4 -BB=1.12.1 -ARCH=${ARCH:-x86_64} +VERSION=${VERSION:-1.4.5} +BB=1.15.3 NUMJOBS=${NUMJOBS:--j7} -BUILD=${BUILD:-3} +BUILD=${BUILD:-2} + +# 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 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 @@ -41,7 +57,7 @@ cd busybox-$BB #zcat $CWD/busybox-${BB}.remove_warning.diff.gz | patch -p1 --verbose || exit 1 #zcat $CWD/busybox-${BB}.no-gc-sections.diff.gz | patch -p1 --verbose || exit 1 # Needed with 2.6.27 kernel: -zcat $CWD/busybox-1.12.1_inotify.diff.gz | patch -p1 --verbose || exit 1 +#zcat $CWD/busybox-1.12.1_inotify.diff.gz | patch -p1 --verbose || exit 1 chown -R root:root . sed -e \ diff --git a/source/a/mkinitrd/mkinitrd.conf.5 b/source/a/mkinitrd/mkinitrd.conf.5 index 5890e2462..7b316d0f1 100644 --- a/source/a/mkinitrd/mkinitrd.conf.5 +++ b/source/a/mkinitrd/mkinitrd.conf.5 @@ -1,7 +1,7 @@ .\" mkinitrd.5 Robby Workman <rworkman@slackware.com> -.\" 25 November 2007 " +.\" 19 December 2009 " -.TH MKINITRD.CONF 5 "05 Februrary 2008" "Slackware 12.1" +.TH MKINITRD.CONF 5 "27 March 2010" "Slackware 13.1" .SH NAME .B mkinitrd.conf(5) .SH SYNOPSIS @@ -89,21 +89,44 @@ Example: MODULE_LIST="module1:module2 option=1:module3" .TP 5 .I LUKSDEV -When using cryptsetup with an encrypted root partition, use this variable to -define the *actual* device name of the encrypted root partition and define the -*mapped* device name as ROOTDEV. +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 -For example, if your actual root device name in /etc/fstab is: -.br -.I /dev/mapper/cryptroot -on -.I /dev/sda2 +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 -Then you'll need to set: +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 -LUKSDEV="/dev/sda2" +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 -ROOTDEV="cryptroot" +LUKSKEY="LABEL=TRAVELSTICK:/keys/alien.luks" .TP 5 .I ROOTDEV @@ -146,6 +169,12 @@ LVM="0" # Do not add LVM support to initrd LVM="1" # Add LVM support to initrd .TP 5 +.I UDEV +Use UDEV in the initrd. +.br +Example: UDEV="1" + +.TP 5 .I WAIT This defines the time to wait, in seconds, until all disks are detected. .br diff --git a/source/a/mkinitrd/mkinitrd.conf.sample b/source/a/mkinitrd/mkinitrd.conf.sample index 29e56f5f0..4838354b5 100644 --- a/source/a/mkinitrd/mkinitrd.conf.sample +++ b/source/a/mkinitrd/mkinitrd.conf.sample @@ -7,10 +7,12 @@ #KERNEL_VERSION="$(uname -r)" #KEYMAP="us" #MODULE_LIST="ext3" -#LUKSDEV="/dev/hda1" -#ROOTDEV="/dev/hda1" +#LUKSDEV="/dev/sda2" +#LUKSKEY="LABEL=TRAVELSTICK:/keys/alienbob.luks" +#ROOTDEV="/dev/sda1" #ROOTFS="ext3" -#RESUMEDEV="/dev/hda2" +#RESUMEDEV="/dev/sda2" #RAID="0" #LVM="0" +#UDEV="1" #WAIT="1" diff --git a/source/a/mkinitrd/mkinitrd_command_generator.sh b/source/a/mkinitrd/mkinitrd_command_generator.sh index d3cdfb731..b26d9109c 100644 --- a/source/a/mkinitrd/mkinitrd_command_generator.sh +++ b/source/a/mkinitrd/mkinitrd_command_generator.sh @@ -47,6 +47,7 @@ FSTAB=${FSTAB:-"/etc/fstab"} # so we can test with alternate fstab files SOURCE_TREE=${SOURCE_TREE:-"/boot/initrd-tree"} CLEAR_TREE=${CLEAR_TREE:-1} KEYMAP=${KEYMAP:-"us"} +UDEV=${UDEV:-0} WAIT=${WAIT:-1} # A basic explanation of the commandline parameters: @@ -532,6 +533,7 @@ 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" off \ "WAIT" "Add delay to allow detection of slow disks at boot" off) if [ "$?" != "0" ]; then exit 1 @@ -702,6 +704,10 @@ through the whole list of choices." \ [ -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) @@ -772,6 +778,10 @@ 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 1 ]; then # Add non-default wait time: MKINIT="$MKINIT -w $WAIT" @@ -815,6 +825,7 @@ elif [ "$EMIT" = "conf" ]; then RESUMEDEV="$RESUMEDEV" RAID="$USING_RAID" LVM="$USING_LVM" + UDEV="$UDEV" WAIT="$WAIT" EOT fi diff --git a/source/a/mkinitrd/mkinitrd_kernelcheck.diff b/source/a/mkinitrd/mkinitrd_kernelcheck.diff deleted file mode 100644 index e1302f54e..000000000 --- a/source/a/mkinitrd/mkinitrd_kernelcheck.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- mkinitrd.orig 2008-11-30 15:35:58.000000000 +0100 -+++ mkinitrd 2008-12-11 11:16:37.000000000 +0100 -@@ -277,6 +277,12 @@ - esac - done - -+# If kernel modules are needed but the kernel version is absent, exit now: -+if [ ! -d /lib/modules/$KERNEL_VERSION ]; then -+ echo "No 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 |