summaryrefslogtreecommitdiffstats
path: root/source/a/mkinitrd/mkinitrd
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2011-04-25 13:37:00 +0000
committer Eric Hameleers <alien@slackware.com>2018-05-31 22:45:18 +0200
commit75a4a592e5ccda30715f93563d741b83e0dcf39e (patch)
tree502f745607e77a2c4386ad38d818ddcafe81489c /source/a/mkinitrd/mkinitrd
parentb76270bf9e6dd375e495fec92140a79a79415d27 (diff)
downloadcurrent-75a4a592e5ccda30715f93563d741b83e0dcf39e.tar.gz
current-75a4a592e5ccda30715f93563d741b83e0dcf39e.tar.xz
Slackware 13.37slackware-13.37
Mon Apr 25 13:37:00 UTC 2011 Slackware 13.37 x86_64 stable is released! Thanks to everyone who pitched in on this release: the Slackware team, the folks producing upstream code, and linuxquestions.org for providing a great forum for collaboration and testing. The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. Please consider supporting the Slackware project by picking up a copy from store.slackware.com. We're taking pre-orders now, and offer a discount if you sign up for a subscription. As always, thanks to the Slackware community for testing, suggestions, and feedback. :-) Have fun!
Diffstat (limited to '')
-rw-r--r--source/a/mkinitrd/mkinitrd144
-rwxr-xr-xsource/a/mkinitrd/mkinitrd.SlackBuild37
-rw-r--r--source/a/mkinitrd/mkinitrd.conf.522
-rw-r--r--source/a/mkinitrd/mkinitrd.conf.sample3
-rw-r--r--source/a/mkinitrd/mkinitrd_command_generator.sh70
5 files changed, 173 insertions, 103 deletions
diff --git a/source/a/mkinitrd/mkinitrd b/source/a/mkinitrd/mkinitrd
index 4cd97296b..1a5b7731f 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, 2010 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2007, 2008, 2009, 2010, 2011 Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -43,7 +43,14 @@
# load-kernel-modules if that file is executable.
# Yada yada yada.
-MKINITRD_VERSION=1.4.5
+MKINITRD_VERSION=1.4.6
+
+# Don't include these things from /lib/udev/ in the initrd image
+LIBUDEV_BLACKLIST="\
+ ipod-set-info \
+ check-mtp-camera \
+ check-ptp-camera \
+ udev-configure-printer"
print_usage() {
cat << EOF
@@ -90,6 +97,7 @@ initrd, and the script is easy to modify. Be creative. :-)
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
+ -M Add the files in /etc/modprobe.d/ to the initrd
-R Add support for RAID partitions
-V Display version number
@@ -97,15 +105,15 @@ 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.6-smp kernel
-modules for a system with an ext3 root partition on /dev/hdb3:
+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.29.6-smp -m mbcache:jbd:ext3 -f ext3 -r /dev/hdb3
+ 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/hdb3 as your /
-partition, and it is running ext3, this command works just the same:
+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 ext3
+ 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
@@ -187,7 +195,7 @@ unify_libs() {
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/
+ 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
@@ -197,11 +205,18 @@ copy_libs() {
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
+ 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
+ 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
@@ -218,6 +233,11 @@ copy_libs() {
rm ${PRFX}*
}
+copy_modconf() {
+ mkdir -p $SOURCE_TREE/etc
+ cp -a /etc/modprobe.d $SOURCE_TREE/etc
+}
+
# If --help is given, print_usage and exit:
if echo $* | grep -wq '\--help' ; then
print_usage
@@ -302,10 +322,8 @@ while [ ! -z "$1" ]; do
shift 2
;;
-o)
- OUTPUT_IMAGE="$2"
- if [ ! "$(echo $OUTPUT_IMAGE | cut -b1)" = "/" ]; then
- OUTPUT_IMAGE=$(pwd)/$OUTPUT_IMAGE
- fi
+ # canonicalize filename:
+ OUTPUT_IMAGE="$(readlink -m $2)"
shift 2
;;
-r)
@@ -313,7 +331,8 @@ while [ ! -z "$1" ]; do
shift 2
;;
-s)
- SOURCE_TREE="$2"
+ # canonicalize filename:
+ SOURCE_TREE="$(readlink -m $2)"
shift 2
;;
-u)
@@ -337,6 +356,10 @@ while [ ! -z "$1" ]; do
LVM=1
shift
;;
+ -M)
+ MODCONF=1
+ shift
+ ;;
-R)
RAID=1
shift
@@ -449,6 +472,10 @@ fi
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
+ rm -f $SOURCE_TREE/lib/udev/$file ;
+ done
fi
# Include LVM support in initrd
@@ -457,7 +484,7 @@ if [ ! -z "$LVM" ]; then
mkdir -p $SOURCE_TREE/sbin
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/
+ find /lib /lib64 -name "libdevmapper*so*" 2> /dev/null | xargs -I'{}' cp -P --parents '{}' $SOURCE_TREE/
( cd $SOURCE_TREE/sbin
ln -s lvm vgchange 2>/dev/null
ln -s lvm vgscan 2>/dev/null )
@@ -505,12 +532,12 @@ fi
# 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)"
+ 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 "#insmod /lib/modules/2.6.18.8-smp/reiserfs.ko" $SOURCE_TREE/load_kernel_modules ; 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
@@ -522,8 +549,7 @@ if [ ! -z "$MODULE_LIST" ]; then
# 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 |tr -s ':' '\n' |awk '!x[$0]++' |tr '\n' ':')
MODULE_LIST=$(echo ${MODULE_LIST%:}) # Weed out a trailing ':'
# Count number of modules
@@ -542,55 +568,63 @@ 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
+ # 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 insmod lines
+ # 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 -q "$SRCMOD" $SOURCE_TREE/load_kernel_modules 2>/dev/null ; then
- LINE="$(echo "insmod -v $SRCMOD" | sed -e "s/$KERNEL_VERSION/\$(uname -r)/")"
+ if ! grep -q "$(basename $SRCMOD .ko)" $SOURCE_TREE/load_kernel_modules 2>/dev/null ; then
+ LINE="$(echo "modprobe -v $(basename $SRCMOD .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
- if [ ! -f ${SOURCE_TREE}${SRCMOD} ]; then
- # We did not yet copy this module into the initrd-tree
+ # 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."
else
echo "WARNING: Could not find module \"$SRCMOD\""
fi
- fi
+ done
done
-done
+ # Pregenerate the module dependency information
+ depmod -a -b $SOURCE_TREE ${KERNEL_VERSION}
+
+ # Copy /etc/modprobe.d/* if desired
+ if [ ! -z $MODCONF ]; then
+ copy_modconf
+ fi
fi
diff --git a/source/a/mkinitrd/mkinitrd.SlackBuild b/source/a/mkinitrd/mkinitrd.SlackBuild
index 7beba6c63..953d3cf87 100755
--- a/source/a/mkinitrd/mkinitrd.SlackBuild
+++ b/source/a/mkinitrd/mkinitrd.SlackBuild
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright 2007, 2008, 2009, 2010 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2007, 2008, 2009, 2010, 2011 Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -21,10 +21,9 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-VERSION=${VERSION:-1.4.5}
-BB=1.15.3
-NUMJOBS=${NUMJOBS:--j7}
-BUILD=${BUILD:-2}
+VERSION=${VERSION:-1.4.6}
+BB=1.18.4
+BUILD=${BUILD:-11}
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
@@ -36,6 +35,7 @@ if [ -z "$ARCH" ]; then
esac
fi
+NUMJOBS=${NUMJOBS:--j7}
CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-mkinitrd
@@ -51,14 +51,9 @@ 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.?z* || exit 1
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
-
chown -R root:root .
sed -e \
's#^CONFIG_PREFIX=.*#CONFIG_PREFIX="'$PKG'/usr/share/mkinitrd/initrd-tree"#' \
@@ -71,9 +66,12 @@ make install || exit 1
rm -f $PKG/usr/share/mkinitrd/initrd-tree/linuxrc
# Copying additional files:
-cp $CWD/mkinitrd_command_generator.sh $PKG/usr/share/mkinitrd
+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 $CWD/keymaps.tar.gz $PKG/usr/share/mkinitrd
+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
@@ -85,11 +83,16 @@ rm -rf $PKG/usr/share/mkinitrd/initrd-tree
# Add busybox docs:
mkdir -p $PKG/usr/doc/busybox-$BB
-cp -a AUTHORS INSTALL LICENSE README \
+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
-cat $CWD/mkinitrd > $PKG/sbin/mkinitrd
+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}
@@ -97,7 +100,9 @@ cat $CWD/mkinitrd.8 | gzip -9c > $PKG/usr/man/man8/mkinitrd.8.gz
cat $CWD/mkinitrd.conf.5 | gzip -9c > $PKG/usr/man/man5/mkinitrd.conf.5.gz
mkdir -p $PKG/etc
-cat $CWD/mkinitrd.conf.sample > $PKG/etc/mkinitrd.conf.sample
+cp -a $CWD/mkinitrd.conf.sample $PKG/etc/mkinitrd.conf.sample
+chown root:root $PKG/etc/mkinitrd.conf.sample
+chmod 644 $PKG/etc/mkinitrd.conf.sample
mkdir -p $PKG/usr/doc/mkinitrd-$VERSION
cp -a $CWD/README.initrd $PKG/usr/doc/mkinitrd-$VERSION
diff --git a/source/a/mkinitrd/mkinitrd.conf.5 b/source/a/mkinitrd/mkinitrd.conf.5
index 7b316d0f1..6cfef91ad 100644
--- a/source/a/mkinitrd/mkinitrd.conf.5
+++ b/source/a/mkinitrd/mkinitrd.conf.5
@@ -1,5 +1,5 @@
.\" mkinitrd.5 Robby Workman <rworkman@slackware.com>
-.\" 19 December 2009 "
+.\" 28 August 2010 "
.TH MKINITRD.CONF 5 "27 March 2010" "Slackware 13.1"
.SH NAME
@@ -172,7 +172,11 @@ LVM="1" # Add LVM support to initrd
.I UDEV
Use UDEV in the initrd.
.br
-Example: UDEV="1"
+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
@@ -188,6 +192,20 @@ 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
+
.SH FILES
.I /etc/mkinitrd.conf
.br
diff --git a/source/a/mkinitrd/mkinitrd.conf.sample b/source/a/mkinitrd/mkinitrd.conf.sample
index 4838354b5..9bb9f14c6 100644
--- a/source/a/mkinitrd/mkinitrd.conf.sample
+++ b/source/a/mkinitrd/mkinitrd.conf.sample
@@ -6,7 +6,7 @@
#OUTPUT_IMAGE="/boot/initrd.gz"
#KERNEL_VERSION="$(uname -r)"
#KEYMAP="us"
-#MODULE_LIST="ext3"
+#MODULE_LIST="ext4"
#LUKSDEV="/dev/sda2"
#LUKSKEY="LABEL=TRAVELSTICK:/keys/alienbob.luks"
#ROOTDEV="/dev/sda1"
@@ -15,4 +15,5 @@
#RAID="0"
#LVM="0"
#UDEV="1"
+#MODCONF="0"
#WAIT="1"
diff --git a/source/a/mkinitrd/mkinitrd_command_generator.sh b/source/a/mkinitrd/mkinitrd_command_generator.sh
index b26d9109c..04c0c2a03 100644
--- a/source/a/mkinitrd/mkinitrd_command_generator.sh
+++ b/source/a/mkinitrd/mkinitrd_command_generator.sh
@@ -1,7 +1,9 @@
#!/bin/sh
-# $Id: mkinitrd_command_generator.sh,v 1.40 2008/12/18 23:32:56 eha Exp eha $
-# Copyright 2008, 2009 by Eric Hameleers <alien@slackware.com>, Eindhoven, Netherlands
-# Copyright 2008, 2009 by PiterPUNK <piterpunk@slackware.com>, Sao Paulo, SP, Brazil
+# $Id: mkinitrd_command_generator.sh,v 1.45 2011/02/17 09:27:05 eha Exp eha $
+# 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
@@ -31,7 +33,7 @@
# -----------------------------------------------------------------------------
# The script's revision number will be displayed in the help text:
-REV=$( echo "$Revision: 1.40 $" | cut -d' ' -f2 )
+REV=$( echo "$Revision: 1.45 $" | cut -d' ' -f2 )
# Define some essential parameter values:
USING_LVM=""
@@ -47,7 +49,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}
+UDEV=${UDEV:-1}
WAIT=${WAIT:-1}
# A basic explanation of the commandline parameters:
@@ -117,7 +119,7 @@ extended_usage() {
EOT
- echo " \$($(basename $0) --run /boot/vmlinuz-generic-smp-2.6.24.5-smp)"
+ echo " \$($(basename $0) --run /boot/vmlinuz-generic-smp-2.6.35.11-smp)"
cat <<-EOT
@@ -130,7 +132,7 @@ extended_usage() {
EOT
- echo " $(basename $0) --lilo /boot/vmlinuz-generic-smp-2.6.24.5-smp >>/etc/lilo.conf"
+ echo " $(basename $0) --lilo /boot/vmlinuz-generic-smp-2.6.35.11-smp >>/etc/lilo.conf"
cat <<-EOT
@@ -138,11 +140,11 @@ extended_usage() {
'/etc/lilo.conf' file (example for my hardware):
# Linux bootable partition config begins
- # initrd created with 'mkinitrd -c -k 2.6.24.5-smp -m ata_generic:pata_amd:mbcache:jbd:ext3 -f ext3 -r /dev/hda7'
- image = /boot/vmlinuz-generic-smp-2.6.24.5-smp
+ # 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.24.5-smp
+ label = 2.6.35.11-smp
read-only
# Linux bootable partition config ends
@@ -156,7 +158,7 @@ extended_usage() {
# Find the device that holds the root partition:
get_root_device() {
if [ -e $FSTAB ]; then
- RD=$(cat $FSTAB | tr '\t' ' ' | tr -s ' ' | grep ' / ' | cut -f1 -d' ')
+ 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"
@@ -171,11 +173,13 @@ get_root_device() {
# Get the root fs information:
get_rootfs_type() {
- if $(type vol_id 1>/dev/null 2>&1) ; then
- vol_id $ROOTDEV | grep ID_FS_TYPE | cut -f2 -d=
+ 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
- # Alternatively, use:
- cat $FSTAB | tr '\t' ' ' | tr -s ' ' | grep ' / ' | cut -f3 -d' '
+ # As a fallback, use:
+ cat $FSTAB |tr '\t' ' ' |grep -v '^ *#' |tr -s ' ' |grep ' / ' |cut -f3 -d' '
fi
}
@@ -195,14 +199,16 @@ add_rootfs_module() {
determine_blockdev_drivers() {
# Walk the /sys tree to find kernel modules that are
# required for our storage devices.
- # Thanks to PiterPUNK for this piece of code.
+ # Thanks to PiterPUNK for help with this code.
local MLIST
- MLIST=$(for i in $(find /sys/block -name "device" -exec ls -l {} \; | sed -ne 's:.*/\(devices.*\)/[a-zA-Z]\+[.0-9]\+/.*:/sys/\1:p' | sort -u); do
- for j in $(find $i -name "modalias"); do
- /sbin/modprobe --set-version $KVER --show-depends $(cat $j) 2>/dev/null | while read LINE ; do
+ 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
done)
MLIST=$( echo $MLIST | tr ' ' ':' )
echo $MLIST
@@ -223,7 +229,7 @@ function add_usb_keyboard() {
# Determine what USB Host Controller is in use
function add_usb_hcd() {
local USBMOD
- for i in `ls -Ld /sys/module/*_hcd/drivers/*`; do
+ for i in $(ls -Ld /sys/module/*_hcd/drivers/*); do
if ls -L $i | grep -q "[0-9a-f]*:" ; then
USBMOD=$( echo $i | cut -f4 -d/ | tr "_" "-")
[ -n "$MLIST" ] && MLIST="$MLIST:$USBMOD" \
@@ -239,7 +245,7 @@ check_luks_lvm_raid() {
# Our root partition is on a LV:
USING_LVM=1
# Search the Physical Volume of our Logical Volume:
- MYVG=$( echo $(lvdisplay -c $ROOTDEV) | cut -d: -f2 )
+ 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
@@ -260,7 +266,7 @@ check_luks_lvm_raid() {
REALDEV=$( cryptsetup status $ROOTDEV | grep 'device: ' | tr -d ' ' | cut -d: -f2 )
ROOTDEV=$(basename $ROOTDEV)
# Check for LVM:
- for LV in $(lvdisplay -c | tr -d ' ' | cut -f1 -d:) ; do
+ 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
@@ -272,7 +278,7 @@ check_luks_lvm_raid() {
# 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) | cut -d: -f2 )
+ 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
@@ -312,7 +318,7 @@ while [ ! -z "$1" ]; do
exit 0
;;
-a)
- MKINIT_PARAMS=$2
+ MKINIT_PARAMS="$2"
shift 2
;;
-c|--conf)
@@ -427,6 +433,12 @@ 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 to module list
MLIST=$(add_usb_keyboard)
@@ -533,8 +545,8 @@ 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)
+"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 1 && echo on || echo off) )
if [ "$?" != "0" ]; then
exit 1
fi
@@ -786,8 +798,8 @@ if [ -n "$WAIT" -a $WAIT -ne 1 ]; then
# Add non-default wait time:
MKINIT="$MKINIT -w $WAIT"
fi
-if ! echo "$MKINIT_PARAMS" | grep -q ' -o ' ; then
- # Add non-default output filename:
+if ! echo "$MKINIT_PARAMS" | grep -q -- '-o ' ; then
+ # Add default output filename:
MKINIT="$MKINIT -o $IMGFILE"
fi
if [ -n "$MKINIT_PARAMS" ]; then