1
0
Fork 0
mirror of git://slackware.nl/current.git synced 2025-01-29 08:36:40 +01:00
slackware-current/source/a/mkinitrd/setup.01.mkinitrd

68 lines
2.3 KiB
Text
Raw Normal View History

#!/bin/sh
#BLURB="Generate an initrd for the kernel"
# Load defaults:
if [ -r etc/default/geninitrd ]; then
. etc/default/geninitrd
fi
# This was the old name for $KERNEL, so allow it still:
KERNEL=$KERNEL_SYMLINK
if [ -z "$KERNEL" ]; then
# If we weren't told anything else, then use the newest kernel:
KERNEL="$(find /boot -name "vmlinuz-*" -type f | xargs ls -t | head -n 1)"
fi
# In case this is a symlink, get the real file:
KERNEL="$(readlink -f $KERNEL)"
# Find the kernel version:
if [ -r $KERNEL ]; then
if file $KERNEL | grep -wq "Linux kernel" ; then
KERNEL_VERSION=$(strings $KERNEL | grep '([^ ]*@[^ ]*) #' | cut -f1 -d' ')
else
echo "error: $KERNEL is not a Linux kernel."
fi
else
echo "error: was not given a KERNEL to make an initrd."
exit 1
fi
# Sometimes mkinitrd_command_generator.sh does not detect LVM properly. Until I
# get to the bottom of that, it's safer to just always include LVM support.
LVM_OPTION="-L"
# Generate the initrd:
if [ -z "$GENINITRD_SILENT" ]; then
dialog --title "GENERATING INITIAL RAMDISK" --infobox \
"Generating an initial ramdisk for use with the $KERNEL_VERSION kernel. \
The initial ramdisk contains kernel modules needed to mount the \
root partition, and must be regenerated whenever the kernel is updated. To \
regenerate the initrd, select this setup script from within pkgtool, or run \
'geninitrd' which will produce an initial ramdisk (/boot/initrd.gz) for the \
installed kernel." 8 70
fi
chroot . /usr/share/mkinitrd/mkinitrd_command_generator.sh -k $KERNEL_VERSION -a "$LVM_OPTION -o /boot/initrd-${KERNEL_VERSION}.img" | chroot . bash 1> /dev/null 2> /dev/null
if [ "$GENINITRD_NAMED_SYMLINK" = "true" ]; then
# Make initrd symlinks for all matching kernel symlinks:
( cd boot
for symlink in $(find . -type l -name "vmlinuz-*") ; do
SYMLINK_VERSION=$(strings $symlink | grep '([^ ]*@[^ ]*) #' | cut -f1 -d' ')
if [ "$SYMLINK_VERSION" = "$KERNEL_VERSION" ]; then
KERNEL_NAME="$(echo $symlink | cut -f 2- -d -)"
rm -f initrd-${KERNEL_NAME}.img
ln -sf initrd-${KERNEL_VERSION}.img initrd-${KERNEL_NAME}.img
fi
done
)
fi
if [ "$GENINITRD_INITRD_GZ_SYMLINK" = "true" ]; then
( cd boot
rm -f initrd.gz
ln -sf initrd-${KERNEL_VERSION}.img initrd.gz
)
fi