Add kernel commandline args with dracut ... not showing up in /proc/cmdline

I am trying to install the system76-driver package. At the end of install, this info/note is emitted:

   The System76 Driver package provides the following system services:  
  
       system76.service             System76 airplane-mode hotkey and LED support  
  
   (!) To use system76.service, you must add "ec_sys.write_support=1" to your kernel command line  

Since this is a new install using dracut, I figured that it would be as simple as:

[root@my-host dracut.conf.d]# cat /etc/dracut.conf.d/system76-kernel.conf 
# Needed for system76.service
# See: https://support.system76.com/articles/system76-software/
kernel_cmdline+=" ec_sys.write_support=1 "

[root@my-host dracut.conf.d]# dracut-rebuild

And then a reboot.

But after a reboot, I don’t see the command line in /proc/cmdline. I got curious and started looking into how dracut-rebuild worked:

[root@my-host dracut.conf.d]# cat $(which dracut-rebuild)
#!/usr/bin/env bash
#
# Rebuild all the initrds using dracut

# This finds the best token for systemd-boot
find_token() {
    if [[ -s /etc/kernel/entry-token ]] ; then
        cat /etc/kernel/entry-token
    elif [[ -s /etc/machine-id ]] ; then
        cat /etc/machine-id
    elif [[ $(grep "^IMAGE_ID=" /etc/os-release) ]] ; then
        grep "^IMAGE_ID=" /etc/os-release | awk -F"=" '{print $2}'
    elif [[ $(grep "^ID=" /etc/os-release) ]] ; then
        grep "^ID=" /etc/os-release | awk -F"=" '{print $2}'
    fi
}

[[ -f /etc/kernel-install-for-dracut.conf ]] && source /etc/kernel-install-for-dracut.conf
ESP=$(bootctl --print-esp-path)
TOKEN=$(find_token)
while read -r pkgbase; do
    kernelversion=$(basename "${pkgbase%/pkgbase}")
    kernelname=$(cat "${pkgbase}")
    INITRD_PATH="${ESP}/${TOKEN}/${kernelversion}"
    if [[ ! -d "$INITRD_PATH" ]] ; then
        echo 'Failed to build initrds, use "sudo reinstall-kernels" instead' 1>&2
        exit 1
    fi
    echo "Running dracut for ${kernelname}-${kernelversion}"
    [[ ${DRACUT_QUIET} == "true" ]] && DRACUT_EXTRA_PARAMS=" --quiet"
    dracut --force --hostonly --no-hostonly-cmdline${DRACUT_EXTRA_PARAMS} "${INITRD_PATH}/initrd" "${kernelversion}"
    [[ ${NO_DRACUT_FALLBACK} != "true" ]] && dracut --force --no-hostonly${DRACUT_EXTRA_PARAMS} "${INITRD_PATH}/initrd-fallback" "${kernelversion}"
done < <(find /usr/lib/modules -maxdepth 2 -type f -name pkgbase)

The docs offer seemingly conflicting details about the --hostonly and ``-no-hostonly-cmdline` options.

My question:

  1. What do i need to do to add kernel commandline args?

Edit /etc/kernel/cmdline and then run sudo reinstall-kernels

2 Likes

Not that I have anything to tell - but…

There’s probably a difference between

And

Maybe the syntax is correct, I can’t tell, but it caught my eye… :v:

That did the trick! Just curious, WHY is the change done here and not via the dracut conf files?

Because we manage our kernel command lines via our bootloaders. As for why, I don’t think it was a conscious choice. It was the way it worked when we were using mkinitcpio and we continued to do it once we switched to dracut.

That being said, I am not sure there is a significant difference either way.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.