Skip to content

Commit

Permalink
dracut: Add support for dracut-created initrds
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <[email protected]>
  • Loading branch information
mcb30 committed Jun 30, 2021
1 parent 3e3526c commit 451daaf
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 1 deletion.
17 changes: 16 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ AM_INIT_AUTOMAKE([foreign subdir-objects tar-ustar])

# Define distribution selections
#
AC_ARG_ENABLE([redhat],
AS_HELP_STRING([--enable-redhat],
[enable all Red Hat features]))
AC_ARG_ENABLE([ubuntu],
AS_HELP_STRING([--enable-ubuntu],
[enable all Ubuntu features]))
Expand All @@ -25,26 +28,33 @@ AC_ARG_ENABLE([initramfs],

# Determine current distribution if none explicitly specified
#
AS_IF([test "x$enable_ubuntu" = "x"], [
AS_IF([test "x$enable_redhat$enable_ubuntu" = "x"], [
AS_IF([test -e /etc/lsb-release], [source /etc/lsb-release])
AS_IF(AS_EXECUTABLE_P([/usr/bin/lsb_release]),
[DISTRIB_ID=$(/usr/bin/lsb_release -s -i)])
AS_IF([test -e /etc/redhat-release], [default_redhat=yes])
AS_IF([test "x$DISTRIB_ID" = "xUbuntu"], [default_ubuntu=yes])
])

# Test for individual distribution selections
#
AS_IF([test "x$enable_redhat" = "x"],
[enable_redhat=$default_redhat])
AS_IF([test "x$enable_ubuntu" = "x"],
[enable_ubuntu=$default_ubuntu])

# Disable all features by default
#
default_dracut=no
default_finalrd=no
default_grub_initrd_fallback=no
default_initramfs=no

# Set feature defaults per distribution
#
AS_IF([test "x$enable_redhat" = "xyes"], [
default_dracut=yes
])
AS_IF([test "x$enable_ubuntu" = "xyes"], [
default_finalrd=yes
default_grub_initrd_fallback=yes
Expand All @@ -53,6 +63,8 @@ AS_IF([test "x$enable_ubuntu" = "xyes"], [

# Test for individual feature selections
#
AS_IF([test "x$enable_dracut" = "x"],
[enable_dracut=$default_dracut])
AS_IF([test "x$enable_finalrd" = "x"],
[enable_finalrd=$default_finalrd])
AS_IF([test "x$enable_grub_initrd_fallback" = "x"],
Expand All @@ -62,6 +74,8 @@ AS_IF([test "x$enable_initramfs" = "x"],

# Define automake conditionals
#
AM_CONDITIONAL([DRACUT],
[test "x$enable_dracut" = "xyes"])
AM_CONDITIONAL([FINALRD],
[test "x$enable_finalrd" = "xyes"])
AM_CONDITIONAL([GRUBINITRDFALLBACK],
Expand All @@ -74,6 +88,7 @@ AM_CONDITIONAL([INITRAMFS],
AC_CONFIG_FILES([
Makefile
src/Makefile
src/dracut/Makefile
src/finalrd/Makefile
src/grub-initrd-fallback/Makefile
src/initramfs/Makefile
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SUBDIRS =
SUBDIRS += dracut
SUBDIRS += finalrd
SUBDIRS += grub-initrd-fallback
SUBDIRS += initramfs
4 changes: 4 additions & 0 deletions src/dracut/50-sanbootable.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ensure that initrd includes network and iSCSI drivers even if built
# while booted from a local disk
#
hostonly="no"
10 changes: 10 additions & 0 deletions src/dracut/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if DRACUT

dracutconfdir = @prefix@/lib/dracut/dracut.conf.d
dracutmoddir = @prefix@/lib/dracut/modules.d/95sanbootable

dist_dracutconf_DATA = 50-sanbootable.conf

dist_dracutmod_SCRIPTS = module-setup.sh sanbootable-cmdline.sh

endif
13 changes: 13 additions & 0 deletions src/dracut/module-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

check() {
return 0
}

depends() {
return 0
}

install() {
inst_hook cmdline 89 "$moddir/sanbootable-cmdline.sh"
}
12 changes: 12 additions & 0 deletions src/dracut/sanbootable-cmdline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

# At boot time, check for an iBFT and force an iSCSI boot if one is
# detected.

modprobe iscsi_ibft

if [ -d /sys/firmware/ibft ] ; then
echo "Attempting iSCSI boot via iBFT:" \
$(cat /sys/firmware/ibft/target*/target-name) > /dev/console
echo "rd.iscsi.ibft rd.iscsi.firmware " > /etc/cmdline.d/50-sanbootable.conf
fi

0 comments on commit 451daaf

Please sign in to comment.