Hardware profiling for kernel module loading
EasyOS, when on a portable media such as a USB-stick, can be
booted on different computers. For this to work, Easy needs to remember
any settings for the particular hardware being booted on, especially for
video and audio. This is an ongoing project, see earlier blog posts:
- Pmcputemp now has hardware profiling — November 15, 2020
- Hardware profiling added to EasyOS features table — February 01, 2020
- Improved hardware profiling for audio — January 16, 2020
- Further improved video hardware profiling — January 15, 2020
- Hardware profiling for audio — January 13, 2020
- Improved hardware profiling for Xorg — January 13, 2020
One area that has missed out so far, is /etc/modprobe.d, in
particular for audio and video. For example, on one computer we might
want to blacklist the kernel 'nouveau' module, but might want it on
another computer.
To remedy, this, /etc/modprobe.d is now hardware-profiled, but only
for audio and video. This code has been added to the 'init' script in
the initrd:
###hardware profiling###
#20211015 want hardware-profiling for /etc/modprobe.d ...
ModprobeHardwareProfile=''
mkdir -p /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d
#class ids are: 0300 video controller, 0403 audio device, 0106 sata controller, 0c03 usb controller, 0600 host bridge
#note, must use busybox lspci...
newModprobeHardwareProfile="$(lspci | grep -E 'Class 0300:|Class 0403:' | cut -f 4 -d ' ' | tr '\n' '+')" #ex: 8086:3e91+8086:3e91+
if [ "$newModprobeHardwareProfile" ];then
if [ -f /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d/ModprobeHardwareProfile ];then
. /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d/ModprobeHardwareProfile
if [ ! -d /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d.${ModprobeHardwareProfile} ];then
cp -a /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d.${ModprobeHardwareProfile}
fi
fi
if [ "$ModprobeHardwareProfile" != "newModprobeHardwareProfile" ];then
if [ -d /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d.${newModprobeHardwareProfile} ];then
rm -rf /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d
cp -a /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d.${newModprobeHardwareProfile} /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d
fi
fi
#make sure they are synced...
echo "ModprobeHardwareProfile='${newModprobeHardwareProfile}'" > /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d/ModprobeHardwareProfile
rm -rf /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d.${newModprobeHardwareProfile}
cp -a /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d.${newModprobeHardwareProfile}
fi
What the above does, is keep a backup of /etc/modprobe.d for a
particular video+audio chip combination. If the hardware changes, the
backup will be restored to /etc/modprobe.d
###broken video###
#20211014 kernel boot "qfix=vid nomodeset"
# ...see refind.conf and syslinux.conf, generated by 3buildeasydistro
if [ $BROKENVID -eq 1 ];then
#prevent kernel drm gpu modules from loading...
#instead of modeprobe.blacklist=nouveau modeprobe.blacklist=i915 modeprobe.blacklist=radeon modeprobe.blacklist=amdgpu modeprobe.blacklist=gma500_gfx
echo 'blacklist amdgpu
blacklist gma500_gfx
blacklist i915
blacklist nouveau
blacklist radeon' > /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/modprobe.d/gpu.conf
# so whatever framebuffer currently active, run xorgwizard-cli...
# firstly, get rid of previous settings...
mkdir -p /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/X11
rm -f /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/X11/xorg.conf 2>/dev/null
rm -rf /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/xorg.conf.d 2>/dev/null
# now set a flag, /root/.profile will run xorgwizard-cli...
touch /mnt/${WKG_DEV}/${WKG_DIR}.session/.brokenvideo
fi
There is a new menu entry at bootup "Fix broken video". Still working on it, will post about it soon.
Note, I'm cutting down how long I sit in front of the computer, as
having trouble with eye strain. So, progress will be
slower.
Tags: easy