Q: How to include custom udev rule into initramfs ?

General support questions
Post Reply
macguru
Posts: 4
Joined: 2018/09/14 16:20:35

Q: How to include custom udev rule into initramfs ?

Post by macguru » 2018/09/14 16:47:41

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.

User avatar
TrevorH
Forum Moderator
Posts: 23870
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

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

Post by TrevorH » 2018/09/14 18:37:54

What are you really trying to do? This sounds like an XY question...
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

macguru
Posts: 4
Joined: 2018/09/14 16:20:35

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

Post by macguru » 2018/09/14 18:50:17

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.

User avatar
TrevorH
Forum Moderator
Posts: 23870
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

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

Post by TrevorH » 2018/09/14 21:04:58

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.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

macguru
Posts: 4
Joined: 2018/09/14 16:20:35

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

Post by macguru » 2018/09/15 11:44:23

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.

User avatar
TrevorH
Forum Moderator
Posts: 23870
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

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

Post by TrevorH » 2018/09/15 12:28:34

I would expect those "files" to always be readonly since they are a view onto the kernel itself.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

macguru
Posts: 4
Joined: 2018/09/14 16:20:35

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

Post by macguru » 2018/09/15 15:26:24

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"

User avatar
TrevorH
Forum Moderator
Posts: 23870
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

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

Post by TrevorH » 2018/09/15 16:10:30

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.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply