如何使用udev使用自定义目录填充/dev [英] How to populate /dev with a custom directory with udev
问题描述
要使用 gadgetfs ,我必须将gadgetfs文件系统挂载到挂载点/dev/gadget
.但是,由于/dev
由 udev 控制,因此每次重新启动时都会丢失手动创建的目录.当然,我可以在一些init.d-Skript中创建目录,但是更干净的解决方案是将udev配置为自动创建此目录.我很确定这一定可行,因为那里已经有很多其他目录了.
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.
那么如何配置udev以自动创建/dev/gadget
目录?
So how can I configure udev to create a /dev/gadget
directory automatically?
推荐答案
找到了解决方案:
使用以下内容创建/etc/udev/rules/99-gadgetfs.rules
:
ACTION=="add", DEVPATH=="/module/gadgetfs" SUBSYSTEM=="module" RUN+="/bin/mkdir /dev/gadget"
ACTION=="remove", DEVPATH=="/module/gadgetfs" SUBSYSTEM=="module" RUN+="/bin/rmdir /dev/gadget"
重新启动udev或运行以下命令:
Restart udev or run this command:
udevadm trigger
现在,当运行 modprobe gadgetfs
时,udev会自动创建/dev/gadget
目录,然后可以将其挂载. rmmod gadgetfs
自动删除目录.
Now when running modprobe gadgetfs
udev automatically creates the /dev/gadget
directory which can then be mounted. rmmod gadgetfs
automatically removes the directory.
这篇关于如何使用udev使用自定义目录填充/dev的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!