https://blue-build.org/ logo
akmods on bluebuild images
# questions
b
I was looking for a way to be able to control my case fans with software (not from bios) and I saw that for my motherboard I have to use the nct6687d kernel module: https://github.com/Fred78290/nct6687d. This is included in the akmods module but since ublue deprecated the sway atomic image I switched to
quay.io/fedora-ostree-desktops/sway-atomic
, and in the docs it says the akmods module is only supported on ublue base images. I'm a bit lost here, I've never done anything with kernel modules, if I could get any example I could modify to make the kernel module work in my image it would really help me. This is my image: https://github.com/obispobruno/ublue
a
message has been deleted
g
I believe it's because ublue pins the kernel version for their images and for akmods builds
They also sign the modules with their secure boot key
If you need, you can create a script to build it on your own https://github.com/Fred78290/nct6687d
b
Just running a script in the recipe that builds and installs like in the readme should work? something like:
Copy code
bash
#!/usr/bin/env bash
git clone https://github.com/Fred78290/nct6687d
cd nct6687d
make akmod
sorry if the question is too basic, as I said I'm a bit lost with kernel mods
g
Looks like it. You'll probably want to also delete the repo from your image in the same script so that its remnants aren't in your final image
b
ok, thanks! I will try
g
Do you use secure boot?
b
I don't
is that a problem?
g
Nope, actually that makes your process way easier
Just keep doing what you're doing
b
awesome
it is building now
g
If you used secure boot, you would have to sign the kernel and the module too
b
sounds like a hassle, at least for my threat model
It failed:
Copy code
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65 After this operation, 140 KiB extra will be used (install 140 KiB, remove 0 B).
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65 Is this ok [y/N]: Package               Arch   Version            Repository        Size
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65 Installing:
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65  akmod-nct6687d       x86_64 1.0.155-git2f40c7e @commandline  29.5 KiB
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65  kmod-nct6687d        x86_64 1.0.155-git2f40c7e @commandline   0.0   B
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65  nct6687d             noarch 1.0.155-git2f40c7e @commandline   8.0   B
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65 Installing dependencies:
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65  akmods               noarch 0.6.2-3.fc42       updates       65.3 KiB
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65  grubby               x86_64 8.40-82.fc42       fedora        45.4 KiB
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65  kernel-devel-matched x86_64 6.17.13-200.fc42   updates        0.0   B
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65 
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65 Transaction Summary:
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65  Installing:         6 packages
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65 
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.65 Operation aborted by the user.
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.67 make: *** [Makefile:44: akmod/install] Error 1
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 40.67 ============================ Failed 'script' Module ============================
[15:55:14 g.i/o/ublue-sway-custom:latest] => #79 ERROR: process "/bin/sh -c /tmp/scripts/run_module.sh 'script'
there doesn't seem to be any useful logs
looks like it built but failed to install
g
Ah it's trying to run
sudo dnf install /tmp/files/scripts/nct6687d/.tmp/rpmbuild/RPMS/*/*.rpm
No
-y
You could try something like
Copy code
bash
cp /etc/dnf/dnf.conf /etc/dnf/dnf.conf.bak
echo 'assumeyes=True' | tee -a /etc/dnf/dnf.conf

# other code ...

# Reset config
rm -f /etc/dnf/dnf.conf 
mv /et/etc/dnf/dnf.conf.bak /etc/dnf/dnf.conf
b
I see
I will try that!
It worked with this script!
Copy code
bash
#!/usr/bin/env bash

set -oue pipefail

cp /etc/dnf/dnf.conf /etc/dnf/dnf.conf.bak
echo 'assumeyes=True' | tee -a /etc/dnf/dnf.conf

git clone https://github.com/Fred78290/nct6687d
cd nct6687d
make akmod
cd ..
rm -rf nct6687d

rm -f /etc/dnf/dnf.conf
mv /etc/dnf/dnf.conf.bak /etc/dnf/dnf.conf
but when I run sensors the system fans do not appear. do I need to load the kernel module? in the docs it says:
Copy code
markdown
## Load(prob) Sensors on boot

To make it loaded after system boots

Just add nct6687 into /etc/modules

`sudo sh -c 'echo "nct6687" >> /etc/modules'`

### Arch-Linux with systemd

`sudo sh -c 'echo "nct6687" >> /etc/modules-load.d/nct6687.conf'`
I run the arch systemd command and rebooted but it does not appear on
kmod list | grep nct6687
. I can see it installed correctly with:
Copy code
bash
$ dnf ls --installed | grep nct6687
akmod-nct6687d.x86_64                                1.0.155-git2f40c7e                   @commandline
kmod-nct6687d.x86_64                                 1.0.155-git2f40c7e                   @commandline
nct6687d.noarch                                      1.0.155-git2f40c7e                   @commandline
g
Adding
echo "nct6687" >> /etc/modules
to your script should work
b
ok, I'll try! thanks again for your patience
g
Yeah no prob
b
It's still not loading, and it's also not present on
/lib/modules/6.17.13-200.fc42.x86_64
. Any idea why? it shows as installed with dnf though
g
Oh, you'll probably need to run the [
initramfs
module](https://blue-build.org/reference/modules/initramfs/) afterwards
I suggest running this at the end of your recipe just in case
b
I have it at the end of my recipe
g
hmmm
b
I saw this non critical errors on the logs:
Copy code
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.44 >>> Created symlink '/etc/systemd/system/multi-user.target.wants/akmods.service'
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.44 >>>                                                                             
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.46 [6/8] Installing akmod-nct6687d-0:1.0.1 100% |   1.5 MiB/s |  30.0 KiB |  00m00s
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.46 >>> Running %post scriptlet: akmod-nct6687d-0:1.0.155-git2f40c7e.x86_64         
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.46 >>> Non-critical error in %post scriptlet: akmod-nct6687d-0:1.0.155-git2f40c7e.x
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.46 >>> Scriptlet output:                                                           
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.46 >>> Building /usr/src/akmods/nct6687d-kmod-1.0.155-git2f40c7e.src.rpm for kernel
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.46 >>> ERROR: Not to be used as root; start as user or 'akmodsbuild' instead.      
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.46 >>>                                                                             
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.46 >>> [RPM] %post(akmod-nct6687d-1.0.155-git2f40c7e.x86_64) scriptlet failed, exit
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.46 [7/8] Installing nct6687d-0:1.0.155-git 100% | 136.7 KiB/s | 280.0   B |  00m00s
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.83 [8/8] Installing kmod-nct6687d-0:1.0.15 100% | 339.0   B/s | 124.0   B |  00m00s
[18:42:35 g.i/o/ublue-sway-custom:latest] => #79 39.83 Warning: skipped OpenPGP checks for 3 packages from repository: @commandline
[18:42:36 g.i/o/ublue-sway-custom:latest] => #79 39.83 Complete!
g
@fiftydinar would you have any ideas?
f
no idea
b
https://github.com/obispobruno/ublue/blob/main/files/scripts/nct6687d.sh that worked
Copy code
bash
#!/usr/bin/env bash

set -euo pipefail

REPO_URL="https://github.com/Fred78290/nct6687d"
WORKDIR="$(mktemp -d)"

cleanup() {
  rm -rf "${WORKDIR}"
}
trap cleanup EXIT

# IMPORTANT:
# - This script runs during the image build, inside a container.
# - `uname -r` would report the GitHub runner kernel, not the kernel shipped in the image.
#   So we derive the target kernel version from the image's /usr/lib/modules instead.
if [[ -d /usr/lib/modules ]]; then
  KVER="$(ls -1 /usr/lib/modules | sort -V | tail -n1)"
else
  echo "ERROR: /usr/lib/modules not found; cannot determine target kernel version" >&2
  exit 1
fi

dnf -y install \
  gcc \
  git \
  kmod \
  make \
  elfutils-libelf-devel \
  "kernel-devel-${KVER}" \
  kernel-core

cd "${WORKDIR}"
git clone --depth=1 "${REPO_URL}" nct6687d
cd nct6687d

# Build against the kernel shipped in the image (KVER), not the build host kernel.
make -C "/usr/lib/modules/${KVER}/build" M="$PWD" modules

KO_SRC="$(find . -maxdepth 2 -type f -name '*.ko' | head -n1 || true)"
if [[ -z "${KO_SRC}" ]]; then
  echo "ERROR: build succeeded but no .ko file was produced" >&2
  exit 1
fi

KO_DEST="/usr/lib/modules/${KVER}/extra/$(basename "${KO_SRC}")"
install -D -m 0644 "${KO_SRC}" "${KO_DEST}"

depmod -a "${KVER}"

# Ensure the module is loaded on boot (Fedora uses systemd-modules-load, not /etc/modules).
MODNAME="$(modinfo -F name "${KO_DEST}" 2>/dev/null || true)"
if [[ -n "${MODNAME}" ]]; then
  install -D -m 0644 /dev/stdin "/usr/lib/modules-load.d/${MODNAME}.conf" <<<"${MODNAME}"
fi
6 Views