What is the correct way to restart udev?

1

I've changed the name of my eth1 interface to eth0. How to ask udev now to re-read the config?

service udev restart

and

udevadm control --reload-rules

don't help. So is there any valid way except of rebooting? (yes, reboot helps with this issue)

yes, I know I should prepend the commands with sudo, but either one I posted above changes nothing in ifconfig -a output: I still see eth1, not eth0.

I just changed the NAME property of udev-rule line. Don't know any reason for this to be ineffective.

There is no any error in executing of both commands I've posted above, but they just don't change actual interface name in ifconfig -a output. If I perform reboot - then interface name changes as expected.

For development purposes I write some script that clones virtual machines (VirtualBox-driven) and pre-sets them up in some way.

So I perform a command to clone VM, start it and as long as network interface MAC is changed - udev adds the...

0 0
2

Udev uses the inotify mechanism to watch for changes in the rules directory, in both the library and in the local configuration trees (typically located at /lib/udev/rules.d and /etc/udev/rules.d). So you don't need to do anything when you change a rules file.

You only need to notify the udev daemon explicitly if you're doing something unusual, for example if you have a rule that includes files in another directory. Then you can use the usual convention for asking daemons to reload their configuration: send a SIGHUP (pkill -HUP udevd). Or you can use the udevadm command: udevadm control --reload-rules.

The udev rules are only applied when a device is added. If you want to reapply the rules to a device that is already connected, you need to do this explicitly, by calling udevadm trigger with the right options to match the device(s) whose configuration has changed, e.g. udevadm trigger --attr-match=vendor='Yoyodyne' --attr-match=model='Frobnicator...

0 0
3

Hi there,

I used to use the following rule to start a service from an udev rule:

SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/systemctl start powersaving.service" SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/systemctl start powersaving.service"

This rule successfully runs the service. I changed this to the - what I believe - correct way:

SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", TAG+="systemd", ENV{SYSTEMD_WANTS}="powersaving.service" SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", TAG+="systemd", ENV{SYSTEMD_WANTS}="powersaving.service"

This rule no longer runs the service, nor is there any log output. Am I missing something?

The respective service file:

[Unit] Description=Run powersaving script depending on AC state [Service] Type=oneshot Environment=DISPLAY=:0 Environment=XAUTHORITY=/home/orschiro/.Xauthority ExecStart=/usr/bin/powersaving [Install]...
0 0
4

Sometimes when you messing around with network interfaces of Linux box, you end up with only one Ethernet adapter but instead of eth0 as you maybe expect it is still with eth1 or eth2 etc. Most often this is side result of cloning virtual machine or replacing a LAN card of physical machine.

Some people coming from the broken Windows world try to remedy this with restart but soon unpleasant surprise is discovered: the operating system still is in same state as before restart. Prime suspect in this endeavour is a udev. This is system which ensure that in no matter what order your computer load your interfaces, their names are consistent between reboots. That way your ISP interface always have correct configuration as well as all other lan cards. I had this problem in past with old (atm VERY old) Slackware distro and it wasn’t pretty, believe me.

Good news is that you can change it quick and easy.

Configuration of udev device can be found in plain text...

0 0
5
Re: What is the proper way to restart udev? [Date Prev][Date Next] [Thread Prev][Thread Next] [Thread Index] [Date Index] [Author Index] From: Tony Nelson To: Subject: Re: What is the proper way to restart udev? Date: Fri, 9 Jun 2006 21:11:04 -0400 At 4:18 PM -0400 6/9/06, Steven W. Orr wrote: >On Friday, Jun 9th 2006 at 13:04 -0400, quoth Dan: > >=>Steven W. Orr wrote: >=>> I found /sbin/udevstart but there is no udevstop. Can I kill -1 the >running >=>> udevd, or do I kill -9 the udevd followed by a udevstart, or do I have to >=>> reboot? >=>> >=>> TIA >=>> >=>Not certain on this but my gut tells me it'd be bad to kill udev on a >running >=>system. >=>-Dan > >Umm, thanks, but no. udevd is just another userspace process AFAICT. If it >weren't running then the worst that could happen is that some dynamic >device creation would not happen. > >Anyone else on how to restart? Run /sbin/start_udev? It seems to kill udevd before starting udevd. It's run by /etc/rc.d/rc.sysinit, which...
0 0
6

At Websolr, we use a combination of a custom init.d script plus Monit to start Solr and ensure that it stays running.

That said, for a simpler self-hosted setup, I would recommend using Upstart to start and stop Solr, if your system has Upstart available. Upstart scripts have the benefit of being fairly simple, and Upstart does a good job restarting processes in the event they crash. Plus the start and stop commands (start and stop, respectively) are pretty easy to remember for the next time you need to make Solr aware of new configs.

Here is a good blog post covering starting Solr with Upstart. I've copied their upstart script below; be sure to update the relevant paths to match your system:

description "Solr Search Server" # Make sure the file system and network devices have started before # we begin the daemon start on (filesystem and net-device-up IFACE!=lo) # Stop the event daemon on system shutdown stop on shutdown # Respawn the process on unexpected...
0 0
7

I'm running Arch Linux, and I have a udev rule which starts a service when a device is inserted. In this case, it dials a connection when a 3G modem is plugged in.

KERNEL=="ttyUSB*", SYMLINK=="gsmmodem", TAG+="systemd", ENV{SYSTEMD_WANTS}="[email protected]"

However, if the device is removed, systemd won't stop the service, and hence when it is plugged in again, it won't start the service, since it's already running.

What I need is a matching udev rule which runs when the device is removed to stop the service.

Using the answer below, what I now have is the following udev rule

KERNEL=="ttyUSB*", SYMLINK=="gsmmodem", TAG+="systemd", ENV{SYSTEMD_WANTS}="vodafone.service"

with the following service file (which was basically copied and pasted from the netcfg service file:

[Unit] Description=Netcfg networking service for Vodafone Dongle Before=network.target Wants=network.target BindsTo=dev-gsmmodem.device After=dev-gsmmodem.device [Service] Type=oneshot...
0 0
8

One day I stumbled upon Attiny85 Breakout Keychain Game, I immediately browsed through parts list to find out what it was comprised of. What brougth my attention is the fact that this keychain game was based on Attiny85 microcontroller. It is the one being suggested in case if you want to shrinkify your arduino projects i.e. make simple Arduino based projects where you don’t need all capabilities of Arduino platform which is based on ATmega328P microcontroller. In case if you are not familiar - Arduino is an open-source electronics platform based on easy-to-use hardware and software. You can read more about it here - What is Arduino?

At once I got captivated by idea of making my own keychain game and decided to go with Tiny AVR Programmer from SparkFun

at that moment it seemed acceptable choice and I ordered batch of Attiny85s, they arrived in this anti-static tube that was put in antistatic bag.

Even before ordering anything I checked Tiny AVR Programmer...

0 0
9
I've tried:

sudo /etc/init.d/networking restart

but get a deprecation error

I googled this and it seems to have changed to:

sudo ifdown eth0
sudo ifup eth0

but when I do that I get "interface eth0 not configured"

I look in:

/etc/network/interfaces

and all it has is:

auto lo
iface lo inet loopback

no eth0?

where can I study up on networking on 11.04?

The indicator in the Gnome menu bar can disconnect/reconnect
connections or turn networking off or on - is it using scripts to do
this work?

Thanks,

-wes

Wes

There seems to be some discrepancy in the way this has been automated in various releases. network-manager is supposed to work, but doesn't always. It sounds from the description of your interfaces file that network-manager is what you have been using. If you drop into a terminal and run (as sudo):

killall nm-applet and then nm-applet...

0 0
10

For Oracle Automatic Storage Manager (ASM) to use disks, it needs to be able to identify the devices consistently and for them to have the correct ownership and permissions. In Linux you can use ASMLib to manage these tasks, but it is seen as an additional layer of complexity and has never really gained any popularity. Instead, many people use the Linux device manager "udev" to perform these tasks. This article presents a brief overview of setting up udev rules with respect to disks for use with ASM in Oracle 11g. The examples are all done using Oracle Linux 5, 6 and 7, so they will be consistent with RHEL and CentOS 5, 6 and 7.

Background

Essentially, what udev does is apply rules defined in files in the "/etc/udev/rules.d" directory to the device nodes listed in the "/dev" directory. The rules can be defined in a variety of ways, but what we need to do is identify the device and say what we want udev to do with it.

In this case I know all my disk devices...

0 0
11
Home » Articles » Linux » Here

For Oracle Automatic Storage Manager (ASM) to use disks, it needs to be able to identify the devices consistently and for them to have the correct ownership and permissions. In Linux you can use ASMLib to manage these tasks, but it is seen as an additional layer of complexity and has never really gained any popularity. Instead, many people use the Linux device manager "udev" to perform these tasks. This article presents a brief overview of setting up udev rules with respect to disks for use with ASM in Oracle 11g. The examples are all done using Oracle Linux 5, 6 and 7, so they will be consistent with RHEL and CentOS 5, 6 and 7.

Background

Essentially, what udev does is apply rules defined in files in the "/etc/udev/rules.d" directory to the device nodes listed in the "/dev" directory. The rules can be defined in a variety of ways, but what we need to do is identify the device and say what we want udev to do with it.

In this...

0 0
12

I have a bash script which fails. After inspection, it appears that the failure is due to the fact that MongoDB is accessed immediately after being restarted.

For example, running:

mongo --eval "db.version()"

gives the expected output:


MongoDB shell version: 2.4.9

connecting to: test

2.4.9

while running:

service mongodb restart; mongo --eval "db.version()"

produces the following output, emphasis mine:


mongodb stop/waiting

mongodb start/running, process 1466

MongoDB shell version: 2.4.9

connecting to: test

Sat Oct 25 02:52:29.736 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145

exception: connect failed

because the server is not ready yet.

What is the correct way to wait during the execution of the bash script until MongoDB is actually ready?


service mongodb status

is not a solution, because it...
0 0
13

I've noticed several topics regarding how to correctly set the device access permissions so that software such as Weather Display can access the device without needing 'root' superuser privilege escalation.

There is some confusion about the correct way to do it with many suggestions to manually change permissions of device nodes rather than set a system-wide automatically applied rule. I've responded to a couple but suspect the location of the information is not perfect for anyone finding my postings later. I've also had some requests to explain how to do it for a variety of devices. Instead of replying individually it would be better to share the information here for everyone to learn from and ask questions of.

For those that don't want to understand what they're doing here's a summary of the sections so you can skip ahead - be warned though, without the background you may make mistakes and suffer frustration.

Udev OverviewIdentifying Devices a. Removable...
0 0
14


I would try:

Moving the rules file to 90-local.rules (so it is processed last and its intended effect is not removed by later rules) Simplify the rules to only set the name (that is the thing least likely to cause breakage). Test. If the mount works OK, add the USER= and retest, if that works add the GROUP= and retest. Update this thread Last edited by catkin; 03-29-2010 at .

At least the experiments are having some effect! Keep poking it in different ways and study the outcome in the hope of gaining understanding -- same as CERN but a lot cheaper!

Might be worth examining the rules in /lib/udev/rules.d for possible inter-action. Might be worth changing your rule to set only USER and see what happens.

What little knowledge I have about udev comes from tinkering with Slackware 13.0 so details may vary.

...
0 0
15

I want to run script when I plug-in/-out power cable into my laptop.
I created these files:

cat /etc/udev/rules.d/91-power.rules

SUBSYSTEM=="power_supply", TAG+="systemd", ENV{SYSTEMD_WANTS}="mypower@$attr{online}.service"

cat /etc/systemd/system/mypower@.service

[Unit] Description=Power supply handling task [Service] ExecStart=/usr/local/bin/mypower.sh %I

cat /usr/local/bin/mypower.sh

#!/bin/bash case $1 in 0) echo 'off' > /home/data/test ;; 1) echo 'on' > /home/data/test ;; *) echo 'wtf' > /home/data/test ;; esac

Then I ran sudo udevadm control --reload, then devadm monitor, then unplug and plug in cable.
Here is the output of devadm monitor:

KERNEL[2672.773310] change /devices/platform/ACPI0003:00/power_supply/AC0 (power_supply) UDEV [2672.803313] change /devices/platform/ACPI0003:00/power_supply/AC0 (power_supply) KERNEL[2673.347460] change ...
0 0
16

Starting a blog the right way requires 6 simple steps.

These are the main steps to start a blog. Don’t worry, I’ll walk you through each of the steps.

Decide what you will blog aboutChoose a blogging platformFind a hostPick a domain name you like.Install WordPress (1-Click Installation)Design and start posting to your blog.

Step 1: Decide what you blog will be about

What do you want to write about?

Write down all the topics you truly want to write about. Writing blog posts will be difficult if you don’t enjoy the topic.

So write down everything that you would enjoy blogging about and sharing with your readers.

TIP: What type of books do you tend to buy? Draw inspiration from your book collection to remember topics that interest you. Also consider your favorite YouTube channels or podcasts you listen to regularly. This should help you comprise your list of favorite topics to write about.

Step 2: Choose your blogging...

0 0
17

I have a bash script which fails. After inspection, it appears that the failure is due to the fact that MongoDB is accessed immediately after being restarted.

For example, running:

wget js redirectionget output from shell_exec command as command runsHow do I pass a literal forward slash into Node.js in Git Bash for Windows?How do I JS-Beautify recursively?How to get system statistics with node.jsHow to make javascript support shebang(#!)?mongo --eval "db.version()"

gives the expected output:

MongoDB shell version: 2.4.9
connecting to: test
2.4.9

while running:

service mongodb restart; mongo --eval "db.version()"

produces the following output, emphasis mine:

mongodb stop/waiting
mongodb start/running, process 1466
MongoDB shell version: 2.4.9
connecting to: test
Sat Oct 25 02:52:29.736 Error: couldn’t connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed

...
0 0
18

I found out and got more information:

On my SLES11 system "man udev" reads:

udev provides a dynamic device directory containing only the files for actually present devices. It creates or removes device node files in the /dev directory

In contrast on my openSUSE Leap 42.1 system
(which is basically the same as a SLES12 system)
"man udev" reads:

udev supplies the system software with device events, manages permissions of device nodes and may create additional symlinks in the /dev directory, or renames network interfaces. The kernel usually just assigns unpredictable device names based on the order of discovery.

Accordingly udev changed from creating
device node files in the /dev directory under SLE11
to nowadays where it seems the kernel itself creates
device node files in the /dev directory.

I asked one of the SUSE systemd/udev maintainers
and he confirmed it:

"Since SLE12, devtmpfs pseudo filesystem is used.
...

0 0
19

One of the most satisfying aspects of running free and open source software is the ability to be able to continually tinker with your setup, limited only by your imagination and ability. The more you do tinker, the smaller the gap between the former and the latter, as each small project inevitably leads you into a deeper understanding of various aspects of your system1 and how you can customize that system to suit your exact requirements.

Over the last couple of days, I have been playing with udev, the kernel device manager, as I was attempting to run a script once a specific USB drive was plugged in. It turns out, as is so often the case, that udev is only part of the picture…

As both my work and personal laptops have relatively small SSDs, I carry around my music on a 1TB external drive. As the drive only contains .flac files, I wanted to automate the process of rsync’ing music from my desktop to the drive and, for the laptops, repopulating the symlinks to ~/Music/...

0 0
20

I'm sure many people who use removable devices have noticed that sometimes they don't appear where they were before.

You plug your USB drive in, and use fdisk to find the device node and then mount it. Sometimes the USB appears as /dev/sda1, sometimes /dev/sdb1. It can depend on what order you plug in your USB devices, and where you plug them in. This is a real pain if you mount devices manually or if you are trying to customise your /etc/fstab.

udev (http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html) allows the assignment of a persistant device node, /dev/..., based on a rule match defined by your specific hardware. In other words, if a device is attached that matches certain criteria it is given it's own device node, rather than being assigned a dynamic one.

It's actually really easy to setup.

______

To start with you need to know the dynamic device node that is given to a device when attached for the first time. The way that I...

0 0
21
...
0 0
22
the proper way to restart udev to pick up a new group? [Date Prev][Date Next] [Thread Prev][Thread Next] [Thread Index] [Date Index] [Author Index] From: "Robert P. J. Day" To: Fedora List Subject: the proper way to restart udev to pick up a new group? Date: Wed, 15 Apr 2009 16:08:56 -0400 (EDT) in order to have a udev-created device file belong to a newly-created group, i added a trivial rules file to /etc/udev/rules.d/, but i'm assuming i have to restart udevd to have the new group recognized, since i can see from the man page for udevd that there is a --resolve-names option which defaults to "early", and i'm assuming that that means that only the groups that exist when udevd *starts* are valid for rules files, is that correct? i kind of surmised that when i saw, in /var/log/messages, a udevd diagnostic claiming that the group was "unknown". so, other than just flat out killing udevd and starting it again manually, what's the proper way to restart it so that it sees the new...
0 0