[arch-general] Incorporate udev rules in initrd
Hey guys, I set the sensitivity of my Thinkpad X230i laptop trackpoint with an udev rule setting the values in sysfs fitting for me. One drawback of this solution is that this rule I wrote is not incorporated inside of the intird, so when I start up, the udev of initrd already recognized the trackpoint and my rule in the booted-up system is ignored. My workaround for this is to manually do "udevadm trigger", which bugs the hell out of me. How can I tell mkinitcpio to include a custom udev rule? Do I need to write a hook for that? How can a hook for this look like? Thanks in advance! Christoph
On Mon, Dec 31, 2012 at 8:37 AM, Christoph Vigano <mail@cvigano.de> wrote:
How can I tell mkinitcpio to include a custom udev rule? Do I need to write a hook for that? How can a hook for this look like?
AFAIK, using FILES="path-to-udev-rule-file" should be enough. The udev binaries and basic rules are already there, so adding the custom rule to the image should make it work automagically. HTH -- Rodrigo
On 31.12.2012 11:00, Rodrigo Rivas wrote:
On Mon, Dec 31, 2012 at 8:37 AM, Christoph Vigano <mail@cvigano.de> wrote:
How can I tell mkinitcpio to include a custom udev rule? Do I need to write a hook for that? How can a hook for this look like?
AFAIK, using FILES="path-to-udev-rule-file" should be enough. The udev binaries and basic rules are already there, so adding the custom rule to the image should make it work automagically.
HTH -- Rodrigo
Sadly, that did not work although the file containing the rule is inside the initrd (verified with lsinitcpio). Any other idea how to debug this? Greetings, Christoph
On Sat, Jan 12, 2013 at 10:55 PM, Christoph Vigano <mail@cvigano.de> wrote:
On 31.12.2012 11:00, Rodrigo Rivas wrote:
On Mon, Dec 31, 2012 at 8:37 AM, Christoph Vigano <mail@cvigano.de> wrote:
How can I tell mkinitcpio to include a custom udev rule? Do I need to write a hook for that? How can a hook for this look like?
AFAIK, using FILES="path-to-udev-rule-file" should be enough. The udev binaries and basic rules are already there, so adding the custom rule to the image should make it work automagically.
HTH -- Rodrigo
Sadly, that did not work although the file containing the rule is inside the initrd (verified with lsinitcpio).
Any other idea how to debug this?
Well... an ugly hack I did to debug the initrd is, if you use grub: 1. In the grub menu press 'e' to edit the boot commands. 2. Remove the 'root=whatever' or change it so something non-existant. 3. Run the boot commands with F10. This way the initramfs will not mount the root filesystem and will drop to a emergency shell. It will run with the initramfs mounted at '/', so you can use it to debug your problem. Note that you still can mount the real root into, for example, '/mnt' and copy or use any tool or file you need that is not available in initramfs (eg 'udevadm'). Yes, it is a hack, but I don't know a proper way to do it. Other distros, such as Ubuntu, have a 'debug=<breakpoint>' option to do this kind of things. But, hey, it works, I even used it once to convert the root filesystem from ext4 to btrfs without an additional boot device 8-). -- Rodrigo
On Sun, Jan 13, 2013 at 02:21:01PM +0000, Rodrigo Rivas wrote:
On Sat, Jan 12, 2013 at 10:55 PM, Christoph Vigano <mail@cvigano.de> wrote:
On 31.12.2012 11:00, Rodrigo Rivas wrote:
On Mon, Dec 31, 2012 at 8:37 AM, Christoph Vigano <mail@cvigano.de> wrote:
How can I tell mkinitcpio to include a custom udev rule? Do I need to write a hook for that? How can a hook for this look like?
AFAIK, using FILES="path-to-udev-rule-file" should be enough. The udev binaries and basic rules are already there, so adding the custom rule to the image should make it work automagically.
HTH -- Rodrigo
Sadly, that did not work although the file containing the rule is inside the initrd (verified with lsinitcpio).
Any other idea how to debug this?
Well... an ugly hack I did to debug the initrd is, if you use grub: 1. In the grub menu press 'e' to edit the boot commands. 2. Remove the 'root=whatever' or change it so something non-existant. 3. Run the boot commands with F10.
This way the initramfs will not mount the root filesystem and will drop to a emergency shell. It will run with the initramfs mounted at '/', so you can use it to debug your problem. Note that you still can mount the real root into, for example, '/mnt' and copy or use any tool or file you need that is not available in initramfs (eg 'udevadm').
Yes, it is a hack, but I don't know a proper way to do it. Other distros, such as Ubuntu, have a 'debug=<breakpoint>' option to do this kind of things. But, hey, it works, I even used it once to convert the root filesystem from ext4 to btrfs without an additional boot device 8-).
-- Rodrigo
mkinitcpio's manpage documents a 'break' variable which does this sanely.
On 31.12.2012 11:00, Rodrigo Rivas wrote:
On Mon, Dec 31, 2012 at 8:37 AM, Christoph Vigano <mail@cvigano.de> wrote:
How can I tell mkinitcpio to include a custom udev rule? Do I need to write a hook for that? How can a hook for this look like?
AFAIK, using FILES="path-to-udev-rule-file" should be enough. The udev binaries and basic rules are already there, so adding the custom rule to the image should make it work automagically.
HTH -- Rodrigo
Well, your solution was correct after all. The only thing missing was the psmouse module, which needed to be added to the initrd. Before adding that module, only a generic mouse device appeared in sysfs and my udev rule had no attribute sensitivity which it wanted to set. Thanks to Dave for pointing out the break-option which proved to be useful for examining sysfs as seen by the initrd. Now the struggle after rebooting has again lost some of its quirks ;) Greetings, Christoph
participants (3)
-
Christoph Vigano
-
Dave Reisner
-
Rodrigo Rivas