问题
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