# list of geninitrd modules which need setup routine after commandline args parsing
GENINITRD_MODS=""
COMPRESS=yes
+LILO_MICROCODE=yes
STRIP=/usr/bin/strip
target=""
kernel=""
usage() {
echo "Usage: $PROGRAM [--version] [-v] [-f] [--ifneeded] [--preload <module>]"
echo " [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]"
- echo " [--compress=yes|xz|lzma|bzip2|gzip|lzo]"
+ echo " [--compress=yes|zstd|xz|lzma|bzip2|gzip|lzo]"
echo " [--nostrip ] [--strip PATH/strip] [--strip=PATH/strip]"
echo " [--initrdfs=rom|initramfs|ext2|cram] [--modules-conf=<modules.conf>]"
echo " [--with-bootsplash] [--without-bootsplash]"
if is_yes "$run_mounted"; then
add_linuxrc <<-EOF
- mount --bind /run /newroot/run
- umount /run
+ mount -n --move /run /newroot/run
EOF
run_mounted=no
fi
smodule=$(basename_module $modpath)
case "$smodule" in
btrfs)
+ warn "mounting multidevice btrfs volume requires rootfsflags=device=/dev/...,device=/dev/... kernel option"
+ find_depmod "-libcrc32c"
+ ;;
+ ext4)
find_depmod "-libcrc32c"
;;
crc-t10dif)
inst "$@" $dest
- local obj lib libs libdir
+ local obj lib libs libs_additional libdir
for obj in "$@"; do
case "$obj" in
/lib/ld-linux.so.2 | /lib64/ld-linux-x86-64.so.2 | /libx32/ld-linux-x32.so.2)
continue
+ ;;
+ /lib/libpthread.so* | /lib64/libpthread.so* | /libx32/libpthread.so*)
+ libs_additional="${obj%/libpthread*}/libgcc_s.so.1"
+ ;;
esac
- libs=$(ldd "$obj" | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
- for lib in $libs; do
+
+ libs=$(ldd "$obj" 2> /dev/null | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
+ for lib in $libs $libs_additional; do
libdir=$(cd $(dirname "$lib"); pwd)
if [ ! -f "$DESTDIR/$lib" ]; then
inst_d $libdir
for _lib in $(get_libdir LIBDIR); do
if [ -f $DESTDIR/$_lib/libc.so.0 ]; then
lib=$DESTDIR/$_lib/libc.so.0
- lib=$(ldd "$lib" | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
+ lib=$(ldd "$lib" 2> /dev/null | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
libdir=$(cd $(dirname "$lib"); pwd)
if [ ! -e $DESTDIR$libdir ]; then
libdir=$(dirname "$libdir")
return
fi
+ if [[ "$devpath" == /dev/nvme* ]]; then
+ find_module "nvme"
+ return
+ fi
+
if [[ "$devpath" == /dev/bcache* ]]; then
find_modules_bcache "$devpath"
return
return 1
fi
- awk -vc=1 -vsymbol="$symbol" '($2 == "T" || $2 == "t") && $3 == symbol {c = 0} END {exit c}' $mapfile
+ awk -vc=1 -vsymbol="$symbol" '(tolower($2) == "t" || tolower($2) == "d") && $3 == symbol {c = 0} END {exit c}' $mapfile
}
# find best compressor (or forced one) for initrd
find_compressor() {
local mode="$1"
- local compressors='xz lzma bzip2 gzip lzo'
+ local compressors='zstd xz lzma bzip2 gzip lzo'
# a specified one, take it
if ! is_yes "$mode"; then
sym=unlzo
prog=/usr/bin/lzop
;;
+ zstd)
+ sym=zstd
+ prog=/usr/bin/zstd
+ ;;
none|no)
# any existing sym will work
sym=initrd_load
lzo)
lzop -9 < "$IMAGE" > "$tmp" || return $?
;;
+ zstd)
+ zstd -9 < "$IMAGE" > "$tmp" || return $?
+ ;;
none|no)
cat < "$IMAGE" > "$tmp" || return $?
;;
mv -f "$tmp" "$target"
}
+# prepend file to image
+prepend_file_to_image() {
+ local file="$1" target="$2" tmp
+ tmp=$(mktemp "$target".XXXXXX) || die "mktemp failed"
+
+ cat "$file" "$target" > "$tmp" || return $?
+
+ mv -f "$tmp" "$target"
+}
+
if [ -r /etc/sysconfig/geninitrd ]; then
. /etc/sysconfig/geninitrd
fi
warn "/proc filesystem not mounted, may cause wrong results or failure."
fi
-geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd bcache
+geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev swsusp tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd bcache
while [ $# -gt 0 ]; do
case $1 in
--without-fbcondecor)
FB_CON_DECOR=no
;;
+ --without-swsusp)
+ USE_SWSUSP=no
+ ;;
--with-suspend)
USE_SUSPEND=yes
;;
find_modules_suspend
fi
+if is_yes "$USE_SWSUSP"; then
+ find_modules_swsusp
+fi
+
find_root "$fstab" || exit
verbose "Using $rootdev as device for rootfs"
ln -s linuxrc $DESTDIR/init
# create dirs that we really need
-inst_d /{lib,bin,etc,dev{,/pts,/shm},loopfs,var,proc,run,sys}
+inst_d /{lib,bin,sbin,etc,dev{,/pts,/shm},loopfs,var,proc,run,sys,tmp}
modules_install "$MODULES"
kmsg "geninitrd/$VERSION starting"
+inst_d /lib/geninitrd/
+inst /lib/geninitrd/functions.initrd /lib/geninitrd/functions.initrd
+
add_linuxrc <<-EOF
+ . /lib/geninitrd/functions.initrd
# builtin defaults from geninitrd
ROOT=$rootdev
ROOTFS=$rootFs
fi
EOF
+# mount early
+mount_tmp
+mount_run
+
modules_add_linuxrc $MODULES
# TODO: rewrite for busybox
# resume after killing local processes
initrd_gen_tuxonice
initrd_gen_suspend
+initrd_gen_swsusp
# clean up env
add_linuxrc <<-'EOF'
die "Filesystem $INITRDFS not supported by $PROGRAM"
esac
-CONFIG_BLK_DEV_RAM_SIZE=$(ikconfig | awk -F= '/^CONFIG_BLK_DEV_RAM_SIZE/{print $2}')
-if [ -z "$CONFIG_BLK_DEV_RAM_SIZE" ]; then
- CONFIG_BLK_DEV_RAM_SIZE=4096
- warn "No CONFIG_BLK_DEV_RAM_SIZE detected, fallback to $CONFIG_BLK_DEV_RAM_SIZE"
-fi
+if [ "$INITRDFS" != "initramfs" ]; then
+ CONFIG_BLK_DEV_RAM_SIZE=$(ikconfig | awk -F= '/^CONFIG_BLK_DEV_RAM_SIZE/{print $2}')
+ if [ -z "$CONFIG_BLK_DEV_RAM_SIZE" ]; then
+ CONFIG_BLK_DEV_RAM_SIZE=4096
+ warn "No CONFIG_BLK_DEV_RAM_SIZE detected, fallback to $CONFIG_BLK_DEV_RAM_SIZE"
+ fi
-if [ "$IMAGESIZE" -gt $CONFIG_BLK_DEV_RAM_SIZE ]; then
- warn "Your image size is larger than $CONFIG_BLK_DEV_RAM_SIZE, Be sure to boot kernel with ramdisk_size=$IMAGESIZE!"
+ if [ "$IMAGESIZE" -gt $CONFIG_BLK_DEV_RAM_SIZE ]; then
+ warn "Your image size is larger than $CONFIG_BLK_DEV_RAM_SIZE, Be sure to boot kernel with ramdisk_size=$IMAGESIZE!"
+ fi
fi
if ! is_no "$COMPRESS"; then
cp -a "$IMAGE" "$target"
fi
+# microcode support for lilo
+if ! is_no "$LILO_MICROCODE"; then
+ if [ -x /sbin/lilo -a -f "/boot/intel-ucode.img" ]; then
+ verbose "Prepending $target with microcode image /boot/intel-ucode.img for LILO"
+ prepend_file_to_image "/boot/intel-ucode.img" "$target"
+ fi
+fi
+
# XXX. check if bootsplash can output data to tmp dir not directly to initramfs image.
initrd_gen_bootsplash "$target"