diff --git a/diskimage_builder/elements/disable-nouveau/dracut.conf.d/disable-nouveau.conf b/diskimage_builder/elements/disable-nouveau/dracut.conf.d/disable-nouveau.conf new file mode 100644 index 00000000..32c5e6d7 --- /dev/null +++ b/diskimage_builder/elements/disable-nouveau/dracut.conf.d/disable-nouveau.conf @@ -0,0 +1 @@ +omit_drivers+=" nouveau " diff --git a/diskimage_builder/elements/dracut-regenerate/README.rst b/diskimage_builder/elements/dracut-regenerate/README.rst index 759d6b11..9649b494 100644 --- a/diskimage_builder/elements/dracut-regenerate/README.rst +++ b/diskimage_builder/elements/dracut-regenerate/README.rst @@ -16,3 +16,7 @@ a yaml blob with the following format:: - By default, this element will bring lvm and crypt modules. + +Also adds the ability to copy specific files into /etc/dracut.conf.d directory +to allow any dracut settings to be configured. To achieve that the files to be +copied need to be placed inside an specific dracut.d directory of the element. diff --git a/diskimage_builder/elements/dracut-regenerate/extra-data.d/50-dracut-conf b/diskimage_builder/elements/dracut-regenerate/extra-data.d/50-dracut-conf new file mode 100755 index 00000000..b02c0bed --- /dev/null +++ b/diskimage_builder/elements/dracut-regenerate/extra-data.d/50-dracut-conf @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-1} -gt 1 ]; then + set -x +fi +set -eu +set -o pipefail + +if [ ! -d $TMP_MOUNT_PATH/etc/dracut.conf.d ]; then + sudo mkdir -p $TMP_MOUNT_PATH/etc/dracut.conf.d +fi + +eval declare -A image_elements=($(get_image_element_array)) + +for i in "${!image_elements[@]}"; do + element=$i + element_dir=${image_elements[$i]} + + if [ -d "${element_dir}/dracut.conf.d/" ]; then + echo "Copying dracut config from ${element_dir}" + sudo cp ${element_dir}/dracut.conf.d/*.conf $TMP_MOUNT_PATH/etc/dracut.conf.d/ + fi +done diff --git a/diskimage_builder/elements/dracut-regenerate/finalise.d/50-dracut-regenerate b/diskimage_builder/elements/dracut-regenerate/finalise.d/50-dracut-regenerate index e30de8a7..7bf8d172 100755 --- a/diskimage_builder/elements/dracut-regenerate/finalise.d/50-dracut-regenerate +++ b/diskimage_builder/elements/dracut-regenerate/finalise.d/50-dracut-regenerate @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. +import glob import logging import os import re @@ -52,8 +53,10 @@ def main(): # second, compose the list of modules to boot modules_to_boot.append(dracut_object.get('name', None)) - # regenerate dracut with the list of installed modules - if len(modules_to_boot) > 0: + conf_overrides = glob.glob('/etc/dracut.conf.d/*.conf') + + # regenerate dracut with the list of installed modules and conf overrides + if modules_to_boot or conf_overrides: cmdline = ["select-boot-kernel-initrd"] logging.debug("Calling: %s" % cmdline) subp = subprocess.Popen(cmdline, stdout=subprocess.PIPE) @@ -67,10 +70,12 @@ def main(): kernel_search = re.match("vmlinuz-(.*)", kernel_set[0]) kernel_version = "%s" % kernel_search.groups(1) ramdisk_path = "/boot/%s" % kernel_set[1].strip() - modules_to_boot = ' ' .join(modules_to_boot) - cmdline = ['dracut', '--force', '--add', modules_to_boot, - '-f', ramdisk_path, kernel_version] + cmdline = ['dracut', '--force'] + if modules_to_boot: + modules_to_boot = ' ' .join(modules_to_boot) + cmdline += ['--add', modules_to_boot] + cmdline += ['-f', ramdisk_path, kernel_version] logging.debug("Calling: %s" % cmdline) subp = subprocess.Popen(cmdline, stdout=subprocess.PIPE) out, err = subp.communicate()