# [MDEV] Settings groups of /dev nodes right (not working)

## xaviermiller

Hello,

I am running mdev-based systems (USE="-udev"), and using mdev.conf and mdev scripts from "mdev like a boss", as cited in the Gentoo Wiki page

But some nodes are not with the right group, especially audio-related device nodes:

```
ls -la /dev/snd

total 0

drwxr-xr-x  2 root root      180  3 fév 18:12 .

drwxr-xr-x 13 root root     5620  3 fév 18:12 ..

crw-rw----  1 root root  116,  5  3 fév 18:12 controlC0

crw-rw----  1 root audio 226, 64  3 fév  2013 controlD64

crw-rw----  1 root root  116,  4  3 fév 18:12 hwC0D0

crw-rw----  1 root root  116,  3  3 fév 18:12 pcmC0D0c

crw-rw----  1 root root  116,  2  3 fév 18:12 pcmC0D0p

crw-rw----  1 root root  116,  1  3 fév 18:12 seq

crw-rw----  1 root root  116, 33  3 fév 18:12 timer
```

I would like all those /dev/snd devices be assigned to root:audio in place of root:root.

Some of those devices are loaded with modprobe, some other detected by mdev.

How can I tell the system to use the right group?

Thanks in advance!

----------

## xaviermiller

Hello,

I have found the problem : the script and configuration files from "mdev like a boss" are not as good as busybox.

So, please don't use those from "mdev like a boss" and keep the "vanilla" ones.

In that case, you need to coldplug the modules, and I do it in my "pre-init" script:

```
#!/bin/busybox ash

mount -t proc proc /proc

mount -t sysfs sysfs /sys

# Load kernel modules, run twice.

/usr/bin/find /sys -name 'modalias' -type f -exec /bin/cat '{}' + | /usr/bin/sort -u | /usr/bin/xargs /sbin/modprobe -b -a 2>/dev/null

/usr/bin/find /sys -name 'modalias' -type f -exec /bin/cat '{}' + | /usr/bin/sort -u | /usr/bin/xargs /sbin/modprobe -b -a 2>/dev/null

exec /sbin/init
```

The coldplug part is not mentionned in the Gentoo Wiki page, this could be nice if it was added.

----------

## xaviermiller

Hello,

Busybox's mdev cannot be use in a hot-plugged environment: the nodes are not created with the right groups, even if the entry is present in mdev.conf.

I tried with USB audio devices, and this is a nightmare. I had to launch "mdev -s" after a module is automatically loaded, in order to reset the rights. So hotplug don't work (and yes, /sbin/mdev is registered as the hotplug manager).

And no colplug.

So, don't use mdev as a (e)udev alternative for a dynamic desktop system.

----------

## cach0rr0

interesting that i stumbled onto this

I've been using mdev for the last ~9 months on one system, my old laptop

it creates device nodes with the appropriate permissions, precisely as we'd expect it to. I followed the mdev wiki for this way back when, and it worked (I've never heard of this "mdev like a boss" thing)

Fast forward to this past weekend, I get a new laptop (T420!), and begin running into this issue. 

Only difference I can see, new laptop is busybox 1.21.0, old one is an older busybox (i dont recall what version provides the binary I have in my initramfs)

I frankly don't see any other differences between the two systems. The init is damn near identical, only difference on the old one I use fbcondecor (new machine I use hardened-sources, old machine gentoo-sources)

Yeah, the kernel thing is somewhat of a significant difference, but I don't know how much it comes into play

```

#!/bin/busybox sh

rescue_shell() {

        echo "Something went wrong. Dropping you to a shell."

                busybox --install -s

        exec /bin/sh

}

mount -t proc none /proc

mount -t sysfs none /sys

mount -t devtmpfs devtmpfs /dev

cryptsetup -T5 luksOpen /dev/sda3 root

mount -t ext4 -o ro /dev/mapper/root /mnt/root || rescue_shell

umount /proc

umount /sys

umount /dev

exec switch_root /mnt/root /sbin/init

```

anyway, posting this as a reminder to check back on this myself. 

I've been having to chown device nodes by hand on this new build, to e.g. root:video and root:audio, that's the main annoyance. 

If I find out anything I'll post back. Long story short, mdev.conf thus far seems to be completely ignored.

DERP

editing instead of adding a new post, since it's fairly quickly after

so, apparently on this new box, i had 'udev-mount' added to sysinit runlevel. I didnt do this myself, I'm guessing portage did it for me (?)

I had to pull in udev because chromium will fail to build without it. So it just sits here as a build dependency doing nothing

ANYWAY

I can't pinpoint udev-mount as a cause, but i dont think ive changed anything else (and this is my zillionth reboot today working on this)

and

after a reboot things are *better*, but imperfect. 

Just to show the sequence of things I'm checking, and how I had to correct it:

```

vunnable ~ # ls -alh /dev/dri/

total 0

drwxr-xr-x  2 root root      60 Feb 18 17:55 .

drwxr-xr-x 10 root root    5.8K Feb 18 17:55 ..

crw-rw----  1 root video 226, 0 Feb 18 17:55 card0

vunnable ~ # ls -alh /dev/snd/

total 0

drwxr-xr-x  2 root root      220 Feb 18 17:55 .

drwxr-xr-x 10 root root     5.8K Feb 18 17:55 ..

crw-rw----  1 root root  116,  8 Feb 18 17:55 controlC0

crw-rw----  1 root root  116,  2 Feb 18 17:55 controlC29

crw-rw----  1 root audio 226, 64 Feb 18 17:55 controlD64

crw-rw----  1 root root  116,  7 Feb 18 17:55 pcmC0D0c

crw-rw----  1 root root  116,  6 Feb 18 17:55 pcmC0D0p

crw-rw----  1 root root  116,  5 Feb 18 17:55 pcmC0D3p

crw-rw----  1 root root  116,  4 Feb 18 17:55 pcmC0D7p

crw-rw----  1 root root  116,  3 Feb 18 17:55 pcmC0D8p

crw-rw----  1 root root  116, 33 Feb 18 17:55 timer

vunnable ~ # vi /etc/mdev.conf 

vunnable ~ # mdev -s

vunnable ~ # ls -alh /dev/snd/

total 0

drwxr-xr-x  2 root root      220 Feb 18 17:55 .

drwxr-xr-x 10 root root     5.8K Feb 18 17:56 ..

crw-rw----  1 root audio 116,  8 Feb 18 17:55 controlC0

crw-rw----  1 root audio 116,  2 Feb 18 17:55 controlC29

crw-rw----  1 root audio 226, 64 Feb 18 17:55 controlD64

crw-rw----  1 root audio 116,  7 Feb 18 17:55 pcmC0D0c

crw-rw----  1 root audio 116,  6 Feb 18 17:55 pcmC0D0p

crw-rw----  1 root audio 116,  5 Feb 18 17:55 pcmC0D3p

crw-rw----  1 root audio 116,  4 Feb 18 17:55 pcmC0D7p

crw-rw----  1 root audio 116,  3 Feb 18 17:55 pcmC0D8p

crw-rw----  1 root audio 116, 33 Feb 18 17:55 timer

```

Notice the screwiness with /dev/snd/*

I may just add a call to "mdev -s" to a script in /etc/local.d/

I'm also wondering if my automounting of a devtmpfs (kernel setting) is partially responsible. I may be able to live without it given how I have things set up. Will post back after another reboot, but if udev-mount was in any way related, I'm seriously scratching my head.

----------

## xaviermiller

Hello,

Running mdev -s after coldpluggging is a solution, but not for real use : I plug and unplug audio devices (sound card, synthesizers), and this is a nightmare.

mdev is not suitable for hot-plugging for now.

----------

## cach0rr0

not a solution for you, a solution for me  :Smile: 

My issue was module-created device nodes having buggered permissions on boot

dev/{snd,dri,videoX} were all root:root, which was a significant problem. 

And it's a new issue, because my system that's had mdev for the better part of a year doesn't have the issue

but

for me hotplug is not part of the picture

either way, for my particular issue this works. I'm still not sure why it only affects my new laptop, and not my old, that's a headscratcher. But the mdev -s after module load does work as a workaround

----------

## xaviermiller

So, for now

- coldplugging is buggy

- hot-plugging is buggy

And since udev has a good Gentoo developer / kernel developer in the team, I will still stay on udev, even if the process is called "systemd-blah-blah"  :Wink: 

----------

## SlashBeast

@XavierMiller your issue with permissions is a bug in latest busybox. Downgrade to older version of busybox or install busybox without mdev and emerge mdev-bb from foo-overlay. I've reported this very bug along with other issues with mdev to busybox mailinglist and as far as I know Denys Vlasenko work on it.

fwiw the gentoo wiki's mdev page is a bit off, you don't really need a linuxrc or any custom init wrapper to use mdev, its pretty much drop-in replacement as dev manager.

----------

## xaviermiller

Hello SlashBeast,

I will wait this issue will be fixed upstream. Meanwhile, I wll use udev  :Wink: 

----------

## SlashBeast

This issue aside, new mdev have removed -net/ rules support and there is no alternative at this very moment so don't expeect it anytime soon.

----------

## miroR

 *XavierMiller wrote:*   

> Hello SlashBeast,
> 
> I will wait this issue will be fixed upstream. Meanwhile, I wll use udev 

 

I couldn't give advice to you certainly,, XavierMiller, so pls. do not take this in the wrong way.

This is, namely, not just FYI, but for the information to other users who might wish  to install something really simpler, nicer, user-oriented, without all the bloat and control that evades the user...

I would like to point out that, with some help from khayyam and others, I have managed to install and am faultlessly running:

mdev-like-a-boss

Unfortunately, I have problems (or perceived problems), or imperfection in the presentation, but actually more something akin to wondering int the wood, the wood being those Gentoo cogs and wheels that one needs to understand to install mdev-like-a-boss, so...

So there was really a lot of wondering to figure out what I needed to do, and only after having been helped did I manage.

So, be warned that my successful install is somewhat difficult to read:

Uninstalling dbus and *kits (to Unfacilitate Remote Seats)

https://forums.gentoo.org/viewtopic-t-992146.html the beginning

for more strictly mdev the reader could try and pick from here onward:

https://forums.gentoo.org/viewtopic-t-992146.html#7559822

Miroslav Rovis

www.CroatiaFidelis.hr

----------

