How to populate /dev with a custom directory with udev

左心房为你撑大大i 提交于 2021-02-08 10:14:51

问题


For using gadgetfs I have to mount the gadgetfs filesystem to the mount point /dev/gadget. But because /dev is controlled by udev a manually created directory gets lost on each reboot. Sure, I could create the directory in some init.d-Skript but a more clean solution would be to configure udev to automatically create this directory. I'm pretty sure this must be possible somehow because there are lots of other directories in there already.

So how can I configure udev to create a /dev/gadget directory automatically?


回答1:


Found the solution:

Create /etc/udev/rules/99-gadgetfs.rules with the following content:

ACTION=="add", DEVPATH=="/module/gadgetfs" SUBSYSTEM=="module" RUN+="/bin/mkdir /dev/gadget"
ACTION=="remove", DEVPATH=="/module/gadgetfs" SUBSYSTEM=="module" RUN+="/bin/rmdir /dev/gadget"

Restart udev or run this command:

udevadm trigger

Now when running modprobe gadgetfs udev automatically creates the /dev/gadget directory which can then be mounted. rmmod gadgetfs automatically removes the directory.



来源:https://stackoverflow.com/questions/30547290/how-to-populate-dev-with-a-custom-directory-with-udev

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!