Page 1 of 1

Q: How to include custom udev rule into initramfs ?

Posted: 2018/09/14 16:47:41
by macguru
Hi !

How to include custom udev rule into initramfs ?
I hacked "module-setup.sh", added "inst_rules 62-my.rules", yet it doesn't work, seems like this file should somewhere not in /usr/lib/dracut/modules.d/95udev-rules/.

Anyone can suggest right way to do this ?

Thanks in advance.

Re: Q: How to include custom udev rule into initramfs ?

Posted: 2018/09/14 18:37:54
by TrevorH
What are you really trying to do? This sounds like an XY question...

Re: Q: How to include custom udev rule into initramfs ?

Posted: 2018/09/14 18:50:17
by macguru
TrevorH wrote:
2018/09/14 18:37:54
What are you really trying to do? This sounds like an XY question...
Adjust some variables and permissions in sysfs, udev rules had to be added to initramfs otherwise they wouldn't work.

Re: Q: How to include custom udev rule into initramfs ?

Posted: 2018/09/14 21:04:58
by TrevorH
That doesn't really answer "what are you really trying to do" but... put your udev rules in /etc/udev/rules.d and rebuild the initramfs. They are included.

Re: Q: How to include custom udev rule into initramfs ?

Posted: 2018/09/15 11:44:23
by macguru
Dracut copies *some* udev rules from
/etc/udev/rules.d/
/usr/lib/udev/rules.d/
but not *all*, only selected by some config I'm not aware about.

PS. I'm need to adjust values in /sys/class/power_supply/BAT0/...
They are read-only after boot, not writeable by root even after chmod +w.

Re: Q: How to include custom udev rule into initramfs ?

Posted: 2018/09/15 12:28:34
by TrevorH
I would expect those "files" to always be readonly since they are a view onto the kernel itself.

Re: Q: How to include custom udev rule into initramfs ?

Posted: 2018/09/15 15:26:24
by macguru
TrevorH wrote:
2018/09/15 12:28:34
I would expect those "files" to always be readonly since they are a view onto the kernel itself.
So its not possible to alter their values even if custom udev rules included in initramfs ?

Code: Select all

ACTION=="add|change", KERNEL=="BAT*", SUBSYSTEM=="power_supply", ATTR{energy_full_design}="*", MODE="0664"
ACTION=="add|change", KERNEL=="BAT*", SUBSYSTEM=="power_supply", ATTR{energy_full_design}="68000000"

Re: Q: How to include custom udev rule into initramfs ?

Posted: 2018/09/15 16:10:30
by TrevorH
Everything under /sys is created by code in the kernel itself and just provides a view onto or a means of altering various "knobs" inside the system. I would expect that the code that creates those particular "files" there will have the mode hard coded.

I did some quick digging and found that there is some documentation (mostly aimed at kernel devs by the looks of it) in /usr/share/doc/kernel-doc-3.10.0/Documentation/power/power_supply_class.txt which is part of the kernel-doc package if it doesn't exist on your system now. I also found the code that is responsible for creating those /sys entries and that's in drivers/power/power_supply_sysfs.c in the kernel source. Most of that seems to assume that you already have a working knowledge of kernel development and my skills in that area are barely readonly but it would appear to me that the "file" you're looking at is meant to be for information only as the kernel sets the value in there based on what it thinks of your battery and its condition.