现在的位置: 首页 > 综合 > 正文

如何实现USB自动挂载?

2013年11月02日 ⁄ 综合 ⁄ 共 40421字 ⁄ 字号 评论关闭

我的问题:USB驱动都正常,USB插入和拔出也能正常识别.可是就是不能自动mount到/data/usb下,网上查了很多,贴出如下,可是都不适合我,我系统没有装udev,哪位大侠能帮帮我,如何实现USB自动挂载?

方法1:http://linux.chinaunix.net/bbs/archiver/?tid-1025201.html

 

方法2:http://blog.chinaunix.net/u/25969/showart_529230.html

方法3:

方法4: 编写usb_scanner _driver.如下:

 我的系统配置:

1.LINUX2.6.14.1 FOR S3C2410+DM9000+UDA1341+64M nandflash+64M sdram

2.u-boot1.1.3

3.cramfs+yaffs2

4.nfs+tftp

我把我的linuxrc/rcS/rc.local贴出来,大家帮忙分析分析.谢谢!

[root@zmf26 rootfs]# cat linuxrc

#!/bin/ash
echo "------next to run /linuxrc"
/bin/mount -f -t cramfs -o remount,ro /dev/mtdblock/3 /
/bin/mount -t tmpfs tmpfs /dev/shm
/bin/mount -f -t sysfs sysfs /sys
/bin/mount -t proc none /proc
/bin/mount -t devpts devpts /dev/pts

# mount devpts in order to use telnetd
/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
/sbin/mdev -s

echo "------next to mount /tmp,/tmp/app,cp /etc/tmp/boa /tmp/app"
/bin/mount -t tmpfs none /root
/bin/cp /etc/udev/usbmount.sh /root/

/bin/mount -t tmpfs none /var
/bin/mkdir -p /var/lib
/bin/mkdir -p /var/run
/bin/mkdir -p /var/log/boa
/bin/cp -rf /etc/tmp/www /var/
/bin/mkdir -p /var/www/cgi-bin

/bin/mount -t ramfs ramfs /tmp
/bin/mkdir /tmp/app
/bin/mount -f -t ramfs ramfs /tmp/app
/bin/cp -rf /etc/tmp/boa /tmp/app/

echo "------next to mount yaffs2 /user,/data"
/bin/mount -t yaffs2 /dev/mtdblock/4 /user
/bin/mount -t yaffs2 /dev/mtdblock/5 /data

exec /usr/etc/rc.local

echo "------next to run /sbin/init"
exec /sbin/init

 

[root@zmf26 rootfs]# cat etc/init.d/rcS
#!/bin/ash
echo "------next to run /etc/inid.d/rcS"
/bin/mount -a
exec /linuxrc
#exec /usr/etc/rc.local

[root@zmf26 rootfs]# cat usr/etc/rc.local
#!/bin/ash
echo "------next to run /usr/etc/rc.local "
#./usr/etc/profile
WEBPATH=/tmp/app
/sbin/inetd

#/sbin/ifconfig eth0 192.168.0.99
#/sbin/ifconfig eth0 down
#/sbin/ifconfig eth0 hw ether 00:00:f1:21:53:f5
#/sbin/pump -i eth0
/sbin/ifconfig eth0 192.168.0.99 netmask 255.255.255.0 up
/sbin/route add default gw 192.168.0.1
/sbin/inetd
echo "------ifconfig eth0 192.168.0.99 complete"

#cd /dev
#ln -s fb/0 fb0
#ln -s vc/0 tty0              
#ln -s vc/1 tty1              
#ln -s vc/2 tty2
#echo "------ ln -s vc/2 tty2 complete"

/sbin/inetd /etc/inetd.conf

if [ -f /tmp/app/boa/boa ];
then
/tmp/app/boa/boa -c /etc/boa/&
echo "------run /tmp/app/boa/boa&"
else
echo "------error:/tmp/app/boa file dose'n exist!"
fi

if [ -f $WEBPATH/powercontrolboard ];
then
$WEBPATH/powercontrolboard&
echo "------run $WEBPATH/powercontrolboard&"
else
echo "------error:$WEBPATH/powercontrolboard file dose'n exist!"
fi

if [ -f $WEBPATH/boa/http/cgi-bin/smart_arm.cgi ];
then
echo "------$WEBPATH/boa/http/cgi-bin/smart_arm.cgi file exist!"
else
echo "------error:$WEBPATH/boa/http/cgi-bin/smart_arm.cgi file dose'n exist!"
fi

启动信息如下:

Uncompressing Linux............................................................................................. done, booting the kernel.
Linux version 2.6.14 (root@zmf26.WORKGROUP) (gcc version 3.4.1) #108 Wed Aug 5 03:02:40 CST 2009
CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)
Machine: SMDK2410
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 200.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
S3C2410 Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists
Kernel command line: mem=64M console=ttySAC0,115200 root=/dev/nfs nfsroot=192.168.0.57:/home/arm/dev_home/rootfs ip=192.168.0.99:192.168.0.57:192.168.0.1:255.255.255.0::eth0:off
irq: clearing subpending status 00000002
PID hash table entries: 512 (order: 9, 8192 bytes)
timer tcon=00500000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 64MB = 64MB total
Memory: 61824KB available (2330K code, 559K data, 96K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
softlockup thread 0 started up.
NET: Registered protocol family 16
S3C2410: Initialising architecture
SCSI subsystem initialized
usbcore: registered new driver usbfs
usbcore: registered new driver hub
S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics
DMA channel 0 at c4800000, irq 33
DMA channel 1 at c4800040, irq 34
DMA channel 2 at c4800080, irq 35
DMA channel 3 at c48000c0, irq 36
NetWinder Floating Point Emulator V0.97 (double precision)
devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x1
NTFS driver 2.1.24 [Flags: R/W DEBUG].
yaffs Aug  2 2009 17:07:52 Installing.
Initializing Cryptographic API
Console: switching to colour frame buffer device 80x25
fb0: Virtual frame buffer device, using 1024K of video memory
S3C2410 RTC, (c) 2004 Simtec Electronics
/dev/keybutton inited: newkoom company:zhengmeifu@sina.com
/dev/ledrpm inited: newkoom company:zhengmeifu@sina.com
s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 8 RAM disks of 4096K size 1024 blocksize
nbd: registered device at major 43
usbcore: registered new driver ub
dm9000 Ethernet Driver
dm9000 io_base is : c4910300
eth0: dm9000 at c4910300,c4912304 IRQ 19 MAC: 02:e1:3d:a4:d7:f7
netconsole: not configured, aborting
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2410-nand: mapped registers at c4980000
s3c2410-nand: timing: Tacls 10ns, Twrph0 40ns, Twrph1 10ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 3777 at 0x03b04000
Bad eraseblock 3778 at 0x03b08000
Bad eraseblock 3779 at 0x03b0c000
Bad eraseblock 3780 at 0x03b10000
Bad eraseblock 3781 at 0x03b14000
Bad eraseblock 3782 at 0x03b18000
Bad eraseblock 3783 at 0x03b1c000
Bad eraseblock 3784 at 0x03b20000
Bad eraseblock 3785 at 0x03b24000
Bad eraseblock 3786 at 0x03b28000
Bad eraseblock 3787 at 0x03b2c000
Bad eraseblock 3789 at 0x03b34000
Bad eraseblock 3791 at 0x03b3c000
Bad eraseblock 3794 at 0x03b48000
Bad eraseblock 3827 at 0x03bcc000
Bad eraseblock 3828 at 0x03bd0000
Bad eraseblock 3830 at 0x03bd8000
Bad eraseblock 3895 at 0x03cdc000
Bad eraseblock 4094 at 0x03ff8000
Creating 6 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x00000000-0x000e0000 : "bootloader"
0x000e0000-0x00100000 : "param"
0x00100000-0x00400000 : "kernel"
0x00400000-0x02200000 : "root"
0x02200000-0x02c00000 : "user"
0x02c00000-0x04000000 : "data"
usbmon: debugfs is not available
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 2.6.14 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usb 1-1: new full speed USB device using s3c2410-ohci and address 2
usb 1-1: Product: DataTraveler 2.0
usb 1-1: Manufacturer: Kingston
usb 1-1: SerialNumber: 5B82190008A7
ub(1.2): GetMaxLUN returned 0, using 1 LUNs
 /dev/ub/a: unknown partition table
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
UDA1341 audio driver initialized
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
TCP bic registered
eth0: link down
IP-Config: Complete:
      device=eth0, addr=192.168.0.99, mask=255.255.255.0, gw=192.168.0.1,
     host=192.168.0.99, domain=, nis-domain=(none),
     bootserver=192.168.0.57, rootserver=192.168.0.57, rootpath=
Looking up port of RPC 100003/2 on 192.168.0.57
eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
Looking up port of RPC 100005/1 on 192.168.0.57
VFS: Mounted root (nfs filesystem).
Mounted devfs on /dev
Freeing init memory: 96K
init started:  BusyBox v1.1.3 (2009.07.28-04:02+0000) multi-call binary
init started:  BusyBox v1.1.3 (2009.07.28-04:02+0000) multi-call binary
Starting pid 205, console /dev/tts/0: '/etc/init.d/rcS'
------next to run /etc/inid.d/rcS
mount: Mounting none on /dev/pts failed: No such file or directory
------next to run /linuxrc
mount: Mounting none on /proc failed: Device or resource busy
mount: Mounting devpts on /dev/pts failed: Device or resource busy
------next to mount /tmp,/tmp/app,cp /etc/tmp/boa /tmp/app
------next to mount yaffs2 /user,/data
yaffs: dev is 32505860 name is "mtdblock4"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.4, "mtdblock4"
yaffs: auto selecting yaffs1
yaffs: dev is 32505861 name is "mtdblock5"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.5, "mtdblock5"
yaffs: auto selecting yaffs1
block 962 is bad
block 963 is bad
block 964 is bad
block 965 is bad
block 966 is bad
block 967 is bad
block 968 is bad
block 969 is bad
block 970 is bad
block 971 is bad
block 972 is bad
block 974 is bad
block 976 is bad
block 979 is bad
block 1012 is bad
block 1013 is bad
block 1015 is bad
block 1080 is bad
block 1279 is bad
------next to run /usr/etc/rc.local
route: SIOC[ADD|DEL]RT: File exists
------ifconfig eth0 192.168.0.99 complete
------run /tmp/app/boa/boa&
------error:/tmp/app/powercontrolboard file dose'n exist!
------error:/tmp/app/boa/http/cgi-bin/smart_arm.cgi file dose'n exist!

Please press Enter to activate this console.

【上篇】
【下篇】

抱歉!评论已关闭.