In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to realize automatic mounting of U disk or SD card by mdev". In daily operation, I believe many people have doubts about how to realize automatic mounting of U disk or SD card by mdev. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to realize automatic mounting of U disk or SD card by mdev". Next, please follow the editor to study!
Mdev is a stripped-down version of the udev management program in busybox, which also creates device files by reading kernel information. Device nodes can be created and mounted automatically, but there is some difference in the implementation process. When hot-swappable occurs, mdev is directly called by hotplug. Then mdev determines the action of this hot-swappable event and which directory in / sys is affected by ACTION and DEVPATH in the environment variables. Then you will see if there is a property file for "dev" in this directory, and if so, use this information to create a device node file under / dev for the device.
Please refer to the busybox/doc/mdev.txt file for the use of mdev. There are two main uses of mdev:
Initialize / dev directory
Dynamically update the / dev directory to support hot swapping, that is, some actions that are performed when the device is connected or removed.
Enable mdev mechanism
Linux kernel support options
To use mdev, you need the kernel to support the sysfs file system, and to reduce read and write to flash, you also need to support the tmpfs file system. The options for configuring kernel support are as follows:
CONFIG_EMBEDDED=y
CONFIG_SYSFS=y
CONFIG_TMPFS=y
Root file system busybox support option
Linux System Utilities-- > [*] mdev [*] Support / etc/mdev.conf [*] Support command execution at device addition/removal
Configure file system support
Add the following to the startup script such as / etc/init.d/rcS:
Mount-t tmpfs mdev / dev mount-t sysfs sysfs / sys mkdir / dev/pts mount-t devpts devpts / dev/pts echo / sbin/mdev > / proc/sys/kernel/hotplug mdev-s
Mdev scans all device-like directories in / sys/class and / sys/block, and if there is a file named "dev" in the directory and the file contains the device number, mdev uses this information to create a device node file under / dev for that device. "mdev-s" is usually executed only once at startup.
Respond to hot-swappable equipment
Because the command: echo / sbin/mdev > / proc/sys/kernel/hotplug is run at startup, the kernel invokes mdev located in the / sbin directory when a hot plug event occurs. At this point, mdev uses the ACTION and DEVPATH in the environment variables (which are included with the system) to determine the action of this hot swap event and which directory in / sys is affected. Then you will see if there is a property file for "dev" in this directory, and if so, use this information to create a device node file under / dev for the device.
Realize the automatic mount of U disk and SD card, modify / etc/mdev.conf configuration file:
The last field is a script, the content of the script can be customized according to our needs, you can mount, uninstall or other functions. For example, / etc/sd_card_inserting is as follows:
#! / bin/sh mount-t vfat / dev/mmcblk0p1 / mnt/sd
The corresponding / etc/sd_card_removing content is as follows:
#! / bin/shsyncumount / mnt/sd at this point, the study on "how to realize automatic mounting of USB disk or SD card by mdev" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.