Arm-linux supports and automatically mounts USB drives

Source: Internet
Author: User

Note the nature of the article.

In fact, I want to implement my FW150US-USB wireless card function on the arm Development Board, so test the USB interface.

1. Configuring the Kernel

Device Drivers--->        SCSI device Support--->                <*> SCSI Device Support                [*] Legacy/proc/scsi/suppo RT                <*> SCSI Disk support                <*> SCSI tap support                <*> SCSI CDROM Support        [*] USB support--- >                <*> support for host-side USB                [*] USB device filesystem                <*> OHCI HCD support                <*> USB Mass Storage supportfile Systems--->        dos/fat/nt  filesystems--->                <*>vfat (Windows-95) FS Support                (936), default codepage for Fat                (iso8859-1), default iocharater for fat

2. Burn and write the kernel and load

[Email protected]/]# ls/dev/
after inserting the USB flash drive will find that the directory is more sda1 (for some U disk, not the name, so in the automatic loading script should pay attention to the different treatment) node, this is what our system is assigned after it is recognized by the USB drive.


3. Manually mount the USB drive to the specified directory/udisk

[Email protected]/]# mount/dev/sda1/udisk/[[email protected]/]# [[email protected]/]# ls/udisk/images      images___ _ Finished, uninstall: [[email protected]/]# umount/udisk/

4, automatic hanging on the U disk implementation and script analysis

Add the following statement in the/etc/mdev.conf file:
SDA1            0:0     0600    =udisk */bin/hotplug_usb.sh
If you cannot confirm whether the [SDA1 (This is the default)], let the system automatically determine:
SD[A-Z]*[0-9]   0:0     0600    =udisk */bin/hotplug_usb.sh
As to why this is written, see the end of the configuration file Mdev.comn
hotplug_usb.sh script content and explanation:
#!/bin/sh# for convenience, the shell environment variable $MDEV will be set to the device name. For example the device ' HDC ' was matched, Mdev would is set to ' hdc ' case $MDEV in Udisk |    SDA1) devname=udisk Mountpoint=/udisk;; SDcard |    MMCBLK0P1) Devname=sdcard Mountpoint=/sdcard;; *) exit 0;; esac# If there is no/dev/null node, create the test! -c/dev/null && mknod-m 0666/dev/null C 1 3# hot swap implementation principle and process: # in the/etc/init.d/rcs file there is a sentence: Echo/sbin/mdev >/proc/sys/ kernel/hotplug# So when there is a hot plug event, the kernel calls the mdev# in the/sbin directory, and the action and Devpath in the environment variable (both of which are system-generated) are determined by Mdev to determine the actions of the hot-plug event and the impact/ The directory in SYS will then look at whether there is a "dev" property file in this directory, and if so, use this information to create a device node file for this device in/dev. Case $ACTION in Remove)/bin/umount $MOUNTPOINT | | True rmdir $MOUNTPOINT >/dev/null 2>&1 | |    true;; *)/bin/mkdir $MOUNTPOINT >/dev/null 2>&1 | | True/bin/mount-t vfat-o codepage=936-o iocharset=utf8-o sync-o noatime-o nodiratime/dev/$DEVNAME $MOUNTPOINT >/dev/null 2>&1 | | true;; Esacexit 0


PS: Aboutmdev.conf File/etc/mdev.conf is a mdev configuration file used to control the ownership/permissions of device nodes. If you do not use the file, the system defaultsRoot/root660 permissions. the format of the file is:[-]<device regex> <uid>:<gid> <permissions> or @<maj[,min1[-min2]]> <uid>:<gid> <permissions> or
$envvar =<regex> <uid>:<gid> <permissions> For example: hd[a-z][0-9]*    0:3    660
if we want to move the node to another directory or rename the node, configure the format:<device regex> <uid>:<gid> <permissions> [=path/new_name]
For example: HDA 0:3 660 =drives/This "HDA "was moved todrives/Sub-directory insideAnd: HDB 0:3 660 =cdrom
Just put"HDB " Rename to"CDROM"
If you want Mdev to execute a custom command when a matching row is found, the file format is as follows: <device regex> <uid>:<gid> <octal permissions> [<@|$| *> <command>]
Special characters have the following meanings: @ Run the command after the device node is created.    Run the command before removing the device node. * Commands are run after the device node is created and before the device node is deleted. Like what:
SD[A-Z]*[0-9] 0:0 0660 @ (mount/dev/$MDEV/udisk) sd[a-z]*[0-9] 0:0 0660 * (Umount/udisk)

pvs|Device or resource busy indicates that the equipment is busy, and that the device may already be in use, such as having completed the mount.

Arm-linux supports and automatically mounts USB drives

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.