]> git.pld-linux.org Git - projects/geninitrd.git/blobdiff - geninitrd
- swsusp support from mis@pld-linux
[projects/geninitrd.git] / geninitrd
index 44b254b7d3218eca5b390661e6aad429bf64d251..ea7d438e56abd1086cc8fec876b239626602f9fe 100755 (executable)
--- a/geninitrd
+++ b/geninitrd
@@ -17,6 +17,7 @@ PROGRAM=${0##*/}
 # 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=""
@@ -46,7 +47,7 @@ proc_partitions=no
 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]"
@@ -115,7 +116,7 @@ die() {
 # find program from specified paths
 find_tool() {
        local x p b n
-       local paths="$initrd_dir /bin /sbin /usr/bin /usr/sbin"
+       local paths="$initrd_dirs /bin /sbin /usr/bin /usr/sbin"
        for x in "$@"; do
                debug "find_tool: checking $x"
                if [ -x "$x" ]; then
@@ -202,6 +203,25 @@ mount_dev() {
        EOF
 }
 
+# load font
+load_font() {
+       local font
+       [ ! -r /etc/sysconfig/console ] && return
+       . /etc/sysconfig/console
+       if [ -n "$CONSOLEFONT" ]; then
+               font=$(ls -1 /lib/kbd/consolefonts/${CONSOLEFONT}*.gz 2> /dev/null)
+               if [ -n "$font" ]; then
+                       verbose "Loading font $font"
+                       busybox_applet loadfont
+                       inst_d "/lib/kbd/consolefonts"
+                       cp -a "$font" "$DESTDIR/lib/kbd/consolefonts/"
+                       gunzip ${DESTDIR}/lib/kbd/consolefonts/${CONSOLEFONT}*.gz
+                       font=${font%.gz}
+                       echo "loadfont < $font" | add_linuxrc
+               fi
+       fi
+}
+
 # generate code to mount /proc on initrd
 # can be called multiple times
 mount_proc() {
@@ -254,7 +274,7 @@ mount_run() {
        fi
 
        run_mounted=yes
-       echo "mount -t tmpfs run /run" | add_linuxrc
+       echo "mount -t tmpfs run /run -o mode=0755,noexec,nosuid,nodev" | add_linuxrc
 }
 
 # unmount all mountpoints mounted by geninitrd
@@ -268,8 +288,7 @@ umount_all() {
 
        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
@@ -412,6 +431,13 @@ find_depmod() {
                        # XXX: find a away to autodetect
                        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)
                                        find_depmod "-crct10dif-pclmul"
                                        find_depmod "-crct10dif"
@@ -479,17 +505,18 @@ inst() {
        set -- $src
        local parentDir=$(dirname $DESTDIR$dest)
        if [ ! -d "$parentDir" ]; then
-               verbose "+ mkdir -p $parentDir"
+               verbose "+ mkdir -p DESTDIR${parentDir#$DESTDIR}"
                mkdir -p $parentDir
        fi
-       verbose "+ cp $* $DESTDIR$dest"
-       cp -HR "$@" "$DESTDIR$dest"
+       verbose "+ cp $* DESTDIR$dest"
+       cp -HRp "$@" "$DESTDIR$dest"
 }
 
 inst_d() {
        if [ $# = 0 ]; then
                die 'Usage: inst_d <destination> <destination>'
        fi
+       local dir
        for dir in "$@"; do
                install -d "$DESTDIR$dir"
        done
@@ -511,35 +538,44 @@ inst_exec() {
 
        inst "$@" $dest
 
-       local obj lib libs
+       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)
+                       /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
-                       if [ ! -f "$DESTDIR/$_lib/${lib##*/}" ]; then
-                               inst_d /$_lib
-                               inst_exec $lib /$_lib
+
+               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
+                               inst_exec $lib $libdir
                        fi
                done
        done
 
        # hack for uclibc linked binaries requiring this fixed path
        # XXX: shouldn't rpath be used here instead so th
-       if [ -f $DESTDIR/$_lib/libc.so.0 ]; then
-               local lib=$DESTDIR/$_lib/libc.so.0
-               lib=$(ldd "$lib" | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
-               local libdir=$(cd $(dirname "$lib"); pwd)
-               if [ ! -e $DESTDIR$libdir ]; then
-                       libdir=$(dirname "$libdir")
-                       inst_d $libdir
-                       verbose "+ ln -s /$_lib $DESTDIR$libdir"
-                       ln -s /$_lib $DESTDIR$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" 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")
+                               inst_d $libdir
+                               verbose "+ ln -s /$_lib $DESTDIR$libdir"
+                               ln -s /$_lib $DESTDIR$libdir
+                               break
+                       fi
                fi
-       fi
+       done
 }
 
 # output modules.conf / modprobe.conf
@@ -636,6 +672,16 @@ find_modules_for_devpath() {
                return
        fi
 
+       if [[ "$devpath" == /dev/nvme* ]]; then
+               find_module "nvme"
+               return
+       fi
+
+       if [[ "$devpath" == /dev/bcache* ]]; then
+               find_modules_bcache "$devpath"
+               return
+       fi
+
        if [[ "$devpath" == /dev/rd/* ]]; then
                find_module "DAC960"
                rootdev_add=/dev/rd/
@@ -716,6 +762,13 @@ firmware_install_module() {
                inst_d /lib/firmware
 cat << 'EOF' >> "$DESTDIR/lib/firmware/firmware.sh"
 #!/bin/sh -e
+# handle only firmware add requests
+if [ "$SUBSYSTEM" != "firmware" ]; then
+       exit 0
+fi
+if [ "$ACTION" != "add" ]; then
+       exit 0
+fi
 echo 1 > /sys$DEVPATH/loading
 cat "/lib/firmware/$FIRMWARE" > /sys$DEVPATH/data
 echo 0 > /sys$DEVPATH/loading
@@ -752,9 +805,22 @@ modules_install() {
                MODULEDIR=${mod%/*}
                inst_d "/lib/modules/$kernel/$MODULEDIR"
                cp -a "/lib/modules/$kernel/$mod" "$DESTDIR/lib/modules/$kernel/$mod"
-               gunzip "$DESTDIR/lib/modules/$kernel/$mod" 2> /dev/null
+               case $mod in
+                       *.gz)
+                               gunzip "$DESTDIR/lib/modules/$kernel/$mod" || die "Can't uncompress gz"
+                               mod=${mod%.gz}
+                               ;;
+                       *.xz)
+                               xz -d "$DESTDIR/lib/modules/$kernel/$mod" || die "Can't uncompress xz"
+                               mod=${mod%.xz}
+                               ;;
+                       *.bz2)
+                               bzip2 -d "$DESTDIR/lib/modules/$kernel/$mod" || die "Can't uncompress bz2"
+                               mod=${mod%.bz2}
+                               ;;
+               esac
                if [ "$STRIP" ] && [ -x "$STRIP" ]; then
-                       $STRIP -g --remove-section=.comment "$DESTDIR/lib/modules/$kernel/${mod%.gz}"
+                       $STRIP -g --remove-section=.comment "$DESTDIR/lib/modules/$kernel/${mod}"
                fi
        done
 }
@@ -765,6 +831,8 @@ modules_add_linuxrc() {
        for mod in "$@"; do
                # module path without optional compression
                modpath=${mod%.gz}
+               modpath=${modpath%.xz}
+               modpath=${modpath%.bz2}
 
                # name of the module
                local module=${modpath##*/}; module=${module%$modext}
@@ -842,11 +910,17 @@ initrd_gen_setrootdev() {
        add_linuxrc <<-'EOF'
                if [ "${ROOT##/dev/}" != "${ROOT}" ]; then
                        rootnr="$(busybox awk -v rootnode="${ROOT##/dev/}" '$4 == rootnode { print 256 * $1 + $2 }' /proc/partitions)"
-                       # fallback to ls
-                       if [ -z "$rootnr" -a -e "$ROOT" ]; then
+                       # fallback to ls, try two different formats
+                       # http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2014-May/023915.html
+                       if [ "${rootnr:-0}" = 0 -a -e "$ROOT" ]; then
+                               # busybox up to 1.22
                                rootnr="$(busybox ls -lL ${ROOT} | busybox awk '{if (/^b/) { print 256 * $3 + $4; }}')"
                        fi
-                       if [ -n "$rootnr" ]; then
+                       if [ "${rootnr:-0}" = 0 -a -e "$ROOT" ]; then
+                               # busybox 1.22 and upwards
+                               rootnr="$(busybox ls -lL ${ROOT} | busybox awk '{if (/^b/) { print 256 * $5 + $6; }}')"
+                       fi
+                       if [ "${rootnr:-0}" -gt 0 ]; then
                                echo "$rootnr" > /proc/sys/kernel/real-root-dev
                        fi
                fi
@@ -877,62 +951,43 @@ initrd_gen_initramfs_switchroot() {
        add_linuxrc <<-'EOF'
                device=
                eval "$(busybox awk -v root="$ROOT" '
-                       # http://9fans.net/archive/2006/09/261
-                       function h2d(str, hstr, res, num, n, digit, i) {
-                               hstr = "0123456789abdcef";
-                               res = 0;
+                       function h2d(str, hstr, res, num, n, digit, i) {        # http://9fans.net/archive/2006/09/261
+                               hstr = "0123456789abdcef"; res = 0;
                                n = split(tolower(str), digit, "");
 
                                for (i = 1; i <= n; i++) {
                                        num = index(hstr, digit[i]) - 1;
                                        res = res + (num * 16 ^ (n - i));
                                }
-
                                return res;
                        }
                        BEGIN {
-
                                num_pattern_short = "[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]";
                                num_pattern = "[0-9a-fA-F]" num_pattern_short;
                                dev_pattern = "[hms][a-z][a-z]([0-9])+";
-                               partition = "";
-                               min = -1; maj = -1;
-
-                               # see if we have /dev/hdX or hdX, we can just take partition name
-                               if (root ~ "^\/dev\/" dev_pattern "$" || root ~ "^" dev_pattern "$") {
-                                       partition = root
-                                       sub("^/dev/", "", partition);
-
-                               } else {
-                                       # unify values first
-                                       if (root ~ "^" num_pattern_short "$")  {
-                                               # change "303" => "0x0303"
+                               partition = ""; min = -1; maj = -1;
+
+                               if (root ~ "^\/dev\/" dev_pattern "$" || root ~ "^" dev_pattern "$") {  # see if we have /dev/hdX or hdX, we can just take partition name
+                                       partition = root; sub("^/dev/", "", partition);
+                               } else {        # unify values first
+                                       if (root ~ "^" num_pattern_short "$")  {        # change "303" => "0x0303"
                                                root = "0x0" root
-                                       } else if (root ~ "^" num_pattern "$")  {
-                                               # change "0303" => "0x0303"
+                                       } else if (root ~ "^" num_pattern "$")  {       # change "0303" => "0x0303"
                                                root = "0x" root
                                        }
-
                                        maj = h2d(substr(root, 3, 2));
                                        min = h2d(substr(root, 5, 2));
                                }
                        }
-
                        partition && $4 == partition { maj = $1; min = $2; }
                        $1 == maj && $2 == min { partition = $4; }
-
                        END {
-                               if (maj >= 0 && min >= 0) {
-                                       printf("maj=%s; min=%s;\n", maj, min);
-                               }
-                               if (partition) {
-                                       printf("device=/dev/%s;\n", partition);
-                               }
-                       }
-                       ' /proc/partitions)"
+                               if (maj >= 0 && min >= 0) {     printf("maj=%s; min=%s;\n", maj, min);  }
+                               if (partition) {                printf("device=/dev/%s;\n", partition); }
+                       }' /proc/partitions)"
 
                if [ -z "$device" ]; then
-                       if [ "$DEBUGINITRD" ]; then
+                       if [ "$DEBUGINITRD" -a "$DEBUGINITRD" != 'sh' ]; then
                                cat /proc/partitions
                        fi
                        device=$ROOT
@@ -942,6 +997,16 @@ initrd_gen_initramfs_switchroot() {
                        mknod -m 660 $device b $maj $min
                fi
 
+               # XXX hack, fallback to rootdev from geninitrd time
+               if [ ! -e "$device" ]; then
+       EOF
+       add_linuxrc <<-EOF
+                       device="$rootdev"
+       EOF
+       add_linuxrc <<-'EOF'
+                       echo "DEVICE set to $device based on fstab entry from initrd gen time"
+               fi
+
                # XXX hack, if no device, try to parse it from /proc/partitions using /proc/sys/kernel/real-root-dev
                if [ ! -e "$device" ]; then
                        rrd=$(cat /proc/sys/kernel/real-root-dev)
@@ -959,9 +1024,9 @@ initrd_gen_initramfs_switchroot() {
                        done < /proc/partitions
                fi
 
-               [ -n "$ROOTFSFLAGS" ] && ROOTFSFLAGS="-o $ROOTFSFLAGS"
+               [ -n "$ROOTFLAGS" ] && ROOTFLAGS="-o $ROOTFLAGS"
 
-               mount -t $ROOTFS -r $device $ROOTFSFLAGS /newroot || echo "Mount of rootfs failed."
+               mount -t $ROOTFS -r $device $ROOTFLAGS /newroot || echo "Mount of rootfs failed."
                init=$INIT
                if [ -z "$init" -o ! -x "/newroot$init" ]; then
                        init=/sbin/init
@@ -971,7 +1036,7 @@ initrd_gen_initramfs_switchroot() {
        busybox_applet dmesg
        busybox_applet tail
        add_linuxrc <<-'EOF'
-               if [ "$DEBUGINITRD" ]; then
+               if [ "$DEBUGINITRD" -a "$DEBUGINITRD" != 'sh' ]; then
                        echo "Last 20 lines of dmesg:"
                        dmesg | tail -n 20
                fi
@@ -995,6 +1060,14 @@ initrd_gen_initramfs_switchroot() {
                        [ "$DEBUGINITRD" ] || usleep 10000000
                fi
 
+               # systemd[1]: /usr appears to be on its own filesytem and is not
+               # already mounted. This is not a supported setup. Some things will
+               # probably break (sometimes even silently) in mysterious ways. Consult
+               # http://freedesktop.org/wiki/Software/systemd/separate-usr-is-broken
+               # for more information.
+               echo trying to mount /usr
+               chroot /newroot mount -n /usr
+
                exec switch_root /newroot $init ${1:+"$@"}
 
                # FIXME: this code is never executed, as "exec" does not return!
@@ -1023,14 +1096,13 @@ sym_exists() {
                return 1
        fi
 
-       awk -vc=1 -vsymbol="$symbol" '$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"
-       # fastest initrd decompression speed is first
-       local compressors='lzo gzip xz lzma bzip2'
+       local compressors='zstd xz lzma bzip2 gzip lzo'
 
        # a specified one, take it
        if ! is_yes "$mode"; then
@@ -1062,6 +1134,10 @@ find_compressor() {
                        sym=unlzo
                        prog=/usr/bin/lzop
                        ;;
+               zstd)
+                       sym=zstd
+                       prog=/usr/bin/zstd
+                       ;;
                none|no)
                        # any existing sym will work
                        sym=initrd_load
@@ -1104,6 +1180,9 @@ compress_image() {
        lzo)
                lzop -9 < "$IMAGE" > "$tmp" || return $?
                ;;
+       zstd)
+               zstd -9 < "$IMAGE" > "$tmp" || return $?
+               ;;
        none|no)
                cat < "$IMAGE" > "$tmp" || return $?
                ;;
@@ -1112,6 +1191,16 @@ compress_image() {
        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
@@ -1120,7 +1209,7 @@ if [ ! -f /proc/mounts ]; then
        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
+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
@@ -1156,6 +1245,9 @@ while [ $# -gt 0 ]; do
        --without-fbcondecor)
                FB_CON_DECOR=no
                ;;
+       --without-swsusp)
+               USE_SWSUSP=no
+               ;;
        --with-suspend)
                USE_SUSPEND=yes
                ;;
@@ -1291,18 +1383,17 @@ if [ "$(id -u)" != 0 ]; then
        die "You need to be root to generate initrd"
 fi
 
-if [ -d /lib64 -a -d /usr/lib64 ]; then
-       _lib=lib64
-else
-       _lib=lib
-fi
+for dir in libx32 lib64 lib; do
+       initrd_dir=/usr/$dir/initrd
+       if [ -d "$initrd_dir" ]; then
+               initrd_dirs="$initrd_dirs $initrd_dir"
+       fi
+done
 
-initrd_dir=/usr/$_lib/initrd
 kernel_version=$(echo "$kernel" | awk -F. '{gsub(/[_-].*/, "", $0); print sprintf("%03d%03d",$1,$2)}')
 kernel_version_long=$(echo "$kernel" | awk -F. '{gsub(/[_-].*/, "", $0); print sprintf("%03d%03d%03d",$1,$2,$3)}')
 
 verbose "# geninitrd $VERSION"
-debug "Using _lib: $_lib"
 debug "Using initrd_dir: $initrd_dir"
 
 busybox=$(find_tool $initrd_dir/busybox $initrd_dir/initrd-busybox /bin/initrd-busybox) || die "Couldn't find busybox suitable for initrd"
@@ -1328,24 +1419,46 @@ if [ -z "$INITRDFS" ]; then
        fi
 fi
 
-case "$INITRDFS" in
-  ext2)
-       [ -x /sbin/mke2fs ] || die "/sbin/mke2fs is missing"
-       ;;
-  rom|romfs)
-       [ -x /sbin/genromfs ] || die "/sbin/genromfs is missing"
-       ;;
-  cram|cramfs)
-       [ -x /sbin/mkcramfs ] || die "/sbin/mkcramfs is missing"
-       ;;
-  initramfs)
-       [ -x /bin/cpio ] || die "/bin/cpio is missing"
-       [ -x /usr/bin/find ] || die "/usr/bin/find is missing"
-       ;;
-  *)
-       die "Filesystem $INITRDFS on initrd is not supported"
-       ;;
-esac
+check_initrd_fs() {
+       local s sfound sym p prog map=/boot/System.map-$kernel
+       case "$INITRDFS" in
+               ext2)
+                       # TODO: symbols to check in case of ext2 used via ext3/4 subsystem
+                       sym=init_ext2_fs
+                       prog=/sbin/mke2fs
+                       ;;
+               rom|romfs)
+                       sym=init_romfs_fs
+                       prog=/sbin/genromfs
+                       ;;
+               cram|cramfs)
+                       sym=init_cramfs_fs
+                       prog=/sbin/mkcramfs
+                       ;;
+               initramfs)
+                       sym=__initramfs_start
+                       prog="/bin/cpio /usr/bin/find"
+                       ;;
+               *)
+                       die "Filesystem $INITRDFS on initrd is not supported by geninitrd"
+                       ;;
+       esac
+
+       # only one is needed (for cases like ext2 via ext2 or via ext3 or via ext4 subsysytem)
+       sfound=0
+       for s in $sym; do
+               sym_exists $map $s && sfound=1
+               break
+       done
+       if [ "$sfound" -eq "0" ]; then
+               die "Filesystem $INITRDFS on initrd is not supported by kernel"
+       fi
+
+       for p in $prog; do
+               [ ! -x "$p" ] && die "$prog is missing"
+       done
+}
+check_initrd_fs
 
 if [ -L "$target" ]; then
        target=$(readlink -f "$target")
@@ -1398,6 +1511,10 @@ if is_yes "$USE_SUSPEND"; then
        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"
 
@@ -1419,6 +1536,7 @@ if is_yes "$USE_TUXONICE"; then
        find_module "-lzf"
 fi
 
+find_modules_uvesafb
 find_modules_fbsplash
 
 if [ -n "$ifneeded" -a -z "$MODULES" ]; then
@@ -1434,7 +1552,7 @@ chmod a+rx "$RCFILE"
 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"
 
@@ -1458,11 +1576,16 @@ add_linuxrc <<EOF
 # on $(LC_ALL=C date)
 
 EOF
+load_font
 mount_proc
 
 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
@@ -1480,6 +1603,12 @@ add_linuxrc <<-'EOF'
                if [ "${arg##root=}" != "${arg}" ]; then
                        ROOT=${arg##root=}
                fi
+               if [ "${arg##rootfs=}" != "${arg}" ]; then
+                       ROOTFS=${arg##rootfs=}
+               fi
+               if [ "${arg##rootflags=}" != "${arg}" ]; then
+                       ROOTFLAGS=${arg##rootflags=}
+               fi
                if [ "${arg##rootfsflags=}" != "${arg}" ]; then
                        ROOTFSFLAGS=${arg##rootfsflags=}
                fi
@@ -1488,9 +1617,18 @@ add_linuxrc <<-'EOF'
                fi
        done
 
+       # handling of invalid, rootfsflags, option
+       if [ -n "$ROOTFSFLAGS" ]; then
+               if [ -n "$ROOTFLAGS" ]; then
+                       ROOTFLAGS="$ROOTFLAGS,$ROOTFSFLAGS"
+               else
+                       ROOTFLAGS="$ROOTFSFLAGS"
+               fi
+       fi
+
        if [ "$DEBUGINITRD" = "sh" ]; then
                # export some vars to subshell for debug to work
-               export CMDLINE ROOT ROOTFS ROOTDEV ROOTFSFLAGS DEBUGINITRD INIT
+               export CMDLINE ROOT ROOTFS ROOTDEV ROOTFLAGS DEBUGINITRD INIT
                export LVM_ROOTVG LVM_SUSPENDVG LVM_VGVOLUMES
                export rootnr attrs majmin major minor device
 
@@ -1519,7 +1657,9 @@ add_linuxrc <<-'EOF'
        fi
 EOF
 
-find_modules_uvesafb
+# mount early
+mount_tmp
+mount_run
 
 modules_add_linuxrc $MODULES
 
@@ -1544,7 +1684,6 @@ else
 fi
 
 initrd_gen_uvesafb
-
 initrd_gen_luks
 initrd_gen_dmraid
 initrd_gen_multipath
@@ -1555,6 +1694,7 @@ if is_yes "$have_nfs"; then
 else
        initrd_gen_md
        initrd_gen_lvm
+       initrd_gen_bcache
        initrd_gen_blkid
        initrd_gen_luks
        initrd_gen_setrootdev
@@ -1570,6 +1710,7 @@ initrd_gen_stop_uvesafb
 # resume after killing local processes
 initrd_gen_tuxonice
 initrd_gen_suspend
+initrd_gen_swsusp
 
 # clean up env
 add_linuxrc <<-'EOF'
@@ -1654,14 +1795,16 @@ case "$INITRDFS" in
        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
@@ -1682,6 +1825,14 @@ else
        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"
 
This page took 0.060515 seconds and 4 git commands to generate.