{"id":223,"date":"2009-12-24T00:26:54","date_gmt":"2009-12-23T21:26:54","guid":{"rendered":"http:\/\/www.held.org.il\/blog\/?p=223"},"modified":"2012-06-26T14:38:31","modified_gmt":"2012-06-26T11:38:31","slug":"udev-debugging-toolbox","status":"publish","type":"post","link":"http:\/\/www.held.org.il\/blog\/2009\/12\/udev-debugging-toolbox\/","title":{"rendered":"udev debugging toolbox"},"content":{"rendered":"<p><strong>Ever wondered why a certain rule doesn't get run? Ever got confused (or disgusted) by udev rules format?<\/strong><\/p>\n<p>Well, despite all the udev clutter, there are many useful tools in the udev package, which help to understand udev's behavior and decision making. I'm still far from knowing all the tricks, but here are some things that I've learned recently:<\/p>\n<p><strong>Note: the udev tools got changed several times during the last 5 years<\/strong>. I'll cover here the <span style=\"color: #ff9900;\">latest version (149)<strong>,<\/strong><\/span> and the older, <span style=\"color: #339966;\">RHEL\/CENTOS5<\/span> version.<\/p>\n<h2><strong>1. udevadm info: get all info available to udev about a certain device (or all devices):<\/strong><\/h2>\n<p># <span style=\"color: #ff9900;\">udevadm info -e <span style=\"color: #339966;\">(<\/span><\/span><span style=\"color: #339966;\">RHEL5: udevinfo -e)<\/span><\/p>\n<p>Try it.. amazing, eh? You can use each detail to write udev rules to match these devices.<\/p>\n<p><!--more--><\/p>\n<h2><strong>2. debug logging<\/strong>: <strong>see <span style=\"color: #ff0000;\">everything<\/span> that udev does<\/strong><\/h2>\n<p>a. <strong>On demand debugging: <\/strong>udev sends messages to syslog. Easiest way to see what udev does, is by increasing the log level. as easy as a pie:<\/p>\n<p># <span style=\"color: #ff9900;\">udevadm control --log_priority=debug <\/span><span style=\"color: #339966;\">(RHEL5: udevcontrol log_priority=debug)<\/span><\/p>\n<p>b. <strong>boot in debug mode: <\/strong>most of udev actions are running at boot time, so we need a way to tell udev to <strong>start<\/strong> in debug mode. This way \/var\/log\/messages would contain all udev actions messages starting with the very first one. Yes, syslog is down when udev starts.. Any idea how it works? \ud83d\ude42<\/p>\n<p>How to do it?<\/p>\n<p># <span style=\"color: #ff9900;\">edit<\/span><span style=\"color: #ff9900;\"><span style=\"color: #ff9900;\"> \/etc\/ud<\/span>ev\/udev.conf: set udev_log=\"debug\"<\/span><\/p>\n<p><span style=\"color: #339966;\">(RHEL5 has a nice trick: add <em>udevdebug <\/em>to the kernel boot parameters)<\/span><\/p>\n<h2><strong>3. udevadm trigger - causes something like a device rescan:<br \/>\n<\/strong><\/h2>\n<p>All 'add' events are re-sent from the kernel, thus triggering all udev rules.<\/p>\n<p># <span style=\"color: #ff9900;\">udevadm trigger<\/span> <span style=\"color: #339966;\">(RHEL5: udevtrigger)<\/span><\/p>\n<h2><strong>4. udevadm settle - blocks until udev has finished working on its queue<br \/>\n<\/strong><\/h2>\n<p>Due to the asynchronous nature of modern kernels, commands may return before the expected action has ended. E.g.: a command for loading a kernel module might finish running before the network interface was really created. Therefore, if the next command expects a network interface, it should really wait until the interface got created. Ok, to the business:<\/p>\n<p style=\"padding-left: 30px;\"># <span style=\"color: #ff9900;\">udevadm settle<\/span> <span style=\"color: #339966;\">(RHEL5: udevsettle)<\/span><\/p>\n<h2><strong>5. udevadm test, udevadm monitor<br \/>\n<\/strong><\/h2>\n<p><strong> <\/strong>Sounds very useful, although I found above methods good for most scenarios, so I didn't dig test\/monitor much.<\/p>\n<p>I hope this article will be helpful. Do you have a cool udev tip or trick? Be nice and post it as a comment!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever wondered why a certain rule doesn&#8217;t get run? Ever got confused (or disgusted) by udev rules format? Well, despite all the udev clutter, there are many useful tools in the udev package, which help to understand udev&#8217;s behavior and decision making. I&#8217;m still far from knowing all the tricks, but here are some things [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[75],"tags":[198,70,203,120],"_links":{"self":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/223"}],"collection":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/comments?post=223"}],"version-history":[{"count":0,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/223\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/media?parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/categories?post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/tags?post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}