USB storage
From DD-WRT Wiki
Revision as of 19:18, 18 February 2007 (edit) Tjyang (Talk | contribs) (→Installation) ← Previous diff |
Revision as of 19:18, 18 February 2007 (edit) (undo) Tjyang (Talk | contribs) (→Check) Next diff → |
||
Line 13: | Line 13: | ||
</pre> | </pre> | ||
=== Check === | === Check === | ||
- | * See the enabling from dmesg output. | + | * See the enabling from dmesg output. A SanDisk Model: U3 Cruzer Micro 4G flash drive as recognized. |
- | + | ||
<pre> | <pre> | ||
/ # dmesg | / # dmesg | ||
Line 125: | Line 124: | ||
</pre> | </pre> | ||
+ | |||
== Create a startup script that loads the modules == | == Create a startup script that loads the modules == | ||
Revision as of 19:18, 18 February 2007
Contents |
Installation
Install USB Kernel modules
ipkg install kmod-usb-uhci // this is for USB 1.1 ipkg install kmod-usb-core ipkg install kmod-usb2 ipkg install kmod-usb-storage
Manual installation and check
- insert the modules one by one.
Check
- See the enabling from dmesg output. A SanDisk Model: U3 Cruzer Micro 4G flash drive as recognized.
/ # dmesg <0>CPU revision is: 00029006 <0>Linux version 2.4.34-pre2 (root@linux) (gcc version 3.4.6 (OpenWrt-2.0)) #170 Fri Sep 15 20:10:21 CEST 2006 <0>Setting the PFC value as 0x15 <0>Determined physical RAM map: <0> memory: 02000000 @ 00000000 (usable) <0>On node 0 totalpages: 8192 <0>zone(0): 8192 pages. <0>zone(1): 0 pages. <0>zone(2): 0 pages. <0>Kernel command line: root=/dev/mtdblock2 rootfstype=squashfs,jffs2 noinitrd console=ttyS0,115200 <0>CPU: BCM4704 rev 8 at 264 MHz <0>Using 132.000 MHz high precision timer. <0>Calibrating delay loop... 263.78 BogoMIPS <6>Dentry cache hash table entries: 4096 (order: 3, 32768 bytes) <6>Inode cache hash table entries: 2048 (order: 2, 16384 bytes) <6>Mount cache hash table entries: 512 (order: 0, 4096 bytes) <6>Buffer cache hash table entries: 1024 (order: 0, 4096 bytes) <0>Page-cache hash table entries: 8192 (order: 3, 32768 bytes) <0>Checking for 'wait' instruction... unavailable. <0>POSIX conformance testing by UNIFIX <0>PCI: Fixing up bus 0 <0>PCI: Fixing up bridge <7>PCI: Setting latency timer of device 01:00.0 to 64 <0>PCI: Fixing up bus 1 <0>Initializing RT netlink socket <0>Starting kswapd <6>devfs: v1.12c (20020818) Richard Gooch (rgooch@atnf.csiro.au) <6>devfs: boot_options: 0x1 <6>squashfs: version 3.0 (2006/03/15) Phillip Lougher <0>pty: 256 Unix98 ptys configured <6>Serial driver version 5.05c (2001-07-08) with MANY_PORTS SHARE_IRQ SERIAL_PCI enabled <6>ttyS00 at 0xb8000300 (irq = 3) is a 16550A <6>ttyS01 at 0xb8000400 (irq = 3) is a 16550A <6>Software Watchdog Timer: 0.05, timer margin: 60 sec <7>PCI: Setting latency timer of device 00:01.0 to 64 <7>PCI: Setting latency timer of device 00:02.0 to 64 <6>imq driver loaded. <6>Universal TUN/TAP device driver 1.5 (C)1999-2002 Maxim Krasnyansky <7>Physically mapped flash: Found an alias at 0x800000 for the chip at 0x0 <7>Physically mapped flash: Found an alias at 0x1000000 for the chip at 0x0 <7>Physically mapped flash: Found an alias at 0x1800000 for the chip at 0x0 <5>cfi_cmdset_0001: Erase suspend on write enabled <7>0: offset=0x0,size=0x20000,blocks=64 <0>Using buffer write method <5>Flash device: 0x800000 at 0x1c000000 <5>Physically mapped flash: squashfs filesystem found at block 823 <5>Creating 5 MTD partitions on "Physically mapped flash": <5>0x00000000-0x00040000 : "pmon" <5>0x00040000-0x007e0000 : "linux" <5>0x000cde5c-0x0039682a : "rootfs" <0>mtd: partition "rootfs" doesn't start on an erase block boundary -- force read-only <5>0x007e0000-0x00800000 : "nvram" <5>0x003a0000-0x007e0000 : "ddwrt" <6>Initializing Cryptographic API <6>IP Protocols: ICMP, UDP, TCP, IGMP <6>IP: routing cache hash table of 512 buckets, 4Kbytes <6>TCP: Hash tables configured (established 2048 bind 4096) <0>ip_conntrack version 2.1 (512 buckets, 4096 max) - 336 bytes per conntrack <0>ip_tables: (C) 2000-2002 Netfilter core team <6>IPP2P v0.8.1_rc1 loading <0>ipt_random match loaded <0>netfilter PSD loaded - (c) astaro AG <6>ipt_osf: Startng OS fingerprint matching module. <0>ipt_IPV4OPTSSTRIP loaded <0>ip_conntrack_rtsp v0.01 loading <0>ip_nat_rtsp v0.01 loading <6>NET4: Unix domain sockets 1.0/SMP for Linux NET4.0. <6>802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com> <6>All bugs added by David S. Miller <davem@redhat.com> <0>VFS: Mounted root (squashfs filesystem) readonly. <6>Mounted devfs on /dev <6>diag boardtype: 0000042f <7>PCI: Setting latency timer of device 01:01.0 to 64 <0>PCI: Enabling device 01:01.0 (0004 -> 0006) <0>eth2: Broadcom BCM4318 802.11 Wireless Controller 3.90.39.0 <5>JFFS2 version 2.1. (C) 2001 Red Hat, Inc., designed by Axis Communications AB. <6>device eth0 entered promiscuous mode <6>device eth2 entered promiscuous mode <6>usb.c: registered new driver usbdevfs <6>usb.c: registered new driver hub <0>PCI: Enabling device 01:02.2 (0000 -> 0002) <6>ehci_hcd 01:02.2: PCI device 1033:00e0 <6>ehci_hcd 01:02.2: irq 2, pci mem c0181000 <6>usb.c: new USB bus registered, assigned bus number 1 <6>ehci_hcd 01:02.2: USB 2.0 enabled, EHCI 1.00, driver 2003-Dec-29/2.4 <6>hub.c: USB hub found <6>hub.c: 5 ports detected <6>hub.c: new USB device 01:02.2-1, assigned address 2 <4>usb.c: USB device 2 (vend/prod 0x781/0x5406) is not claimed by any active driver. <6>SCSI subsystem driver Revision: 1.00 <6>Initializing USB Mass Storage driver... <6>usb.c: registered new driver usb-storage <6>scsi0 : SCSI emulation for USB Mass Storage devices <0> Vendor: SanDisk Model: U3 Cruzer Micro Rev: 2.18 <0> Type: Direct-Access ANSI SCSI revision: 02 <0> Vendor: SanDisk Model: U3 Cruzer Micro Rev: 2.18 <0> Type: CD-ROM ANSI SCSI revision: 02 <7>WARNING: USB Mass Storage data integrity not assured <7>USB Mass Storage device found at 2 <6>USB Mass Storage support registered. <0>Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0 <0>SCSI device sda: 8015505 512-byte hdwr sectors (4104 MB) <0>sda: Write Protect is off <6>Partition check: <6> /dev/scsi/host0/bus0/target0/lun0: p1 p2 p3 / #
Create a startup script that loads the modules
Create a file, usb.startup in /jffs/etc/config/ directory
~ # mkdir /jffs/etc/config ~ # vi /jffs/etc/config/usb.startup
that contains this (press i once for insert mode):
#!/bin/sh insmod /jffs/lib/modules/2.4.30/usbcore.o insmod /jffs/lib/modules/2.4.30/ehci-hcd.o insmod /jffs/lib/modules/2.4.30/scsi_mod.o insmod /jffs/lib/modules/2.4.30/usb-storage.o # remove the dash (#) from the line below if you use USB 1.1 #insmod /jffs/lib/modules/2.4.30/uhci.o insmod /jffs/lib/modules/2.4.30/sd_mod.o
vi is ended using "ESC" and then :wq
make the script executable:
chmod +x /jffs/etc/config/usb.startup
For DD-WRT v23 SP1 or below
add the follwing script to startup. It executes on every reboot all *.startup scripts located in /jffs/etc/config/
console mode > ~ # nvram set rc_startup=" > for I in `/bin/ls /jffs/etc/config/*.startup` > do > sh $I & > done > " > ~ # nvram commit > web interface mode for I in `/bin/ls /jffs/etc/config/*.startup` do sh $I & done
This is it. Here's my dmesg from Asus WL-500gP
dmesg SCSI subsystem driver Revision: 1.00 Initializing USB Mass Storage driver... usb.c: registered new driver usb-storage USB Mass Storage support registered. uhci.c: USB Universal Host Controller Interface driver v1.1 PCI: Enabling device 01:03.0 (0000 -> 0001) uhci.c: USB UHCI at I/O 0x100, IRQ 2 usb.c: new USB bus registered, assigned bus number 2 hub.c: USB hub found hub.c: 2 ports detected PCI: Enabling device 01:03.1 (0000 -> 0001) uhci.c: USB UHCI at I/O 0x120, IRQ 2 usb.c: new USB bus registered, assigned bus number 3 hub.c: USB hub found hub.c: 2 ports detected
kernel modules for filesystems
Now to access FAT/EXT/XFS partitions you must install
ipkg install kmod-vfat ipkg install kmod-ext2 ipkg install kmod-ext3 ipkg install kmod-xfs
autoload filesystem modules
Add to /jffs/etc/config/usb.startup (comment out lines you don't need to save memory)
# FAT insmod /jffs/lib/modules/2.4.30/fat.o insmod /jffs/lib/modules/2.4.30/vfat.o #XFS #insmod /jffs/lib/modules/2.4.30/xfs.o #EXT2 #insmod /jffs/lib/modules/2.4.30/ext2.o #EXT2 #insmod /jffs/lib/modules/2.4.30/ext3.o
Now dmesg should show (The example below is from a 80 GB HD)
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0 SCSI device sda: 156301488 512-byte hdwr sectors (80026 MB) Partition check: /dev/scsi/host0/bus0/target0/lun0
Multislot card reader
In order to use a multislot card reader, you must add the following parameter to the scsi_mod in the file /jffs/etc/modules.d/60-usb-storage:
scsi_mod max_scsi_luns=8
Usage
Mounting
mount /dev/scsi/host0/bus0/target0/lun0/part1 /mnt
Performance Testing
With help of the hdparm package you could test your performance. On an Asus WL-500gP(remium) without overclocking you will get
hdparm -tT /dev/scsi/host0/bus0/target0/lun0/part2
Timing cached reads: 188 MB in 2.04 seconds = 92.16 MB/sec Timing buffered disk reads: 24 MB in 3.19 seconds = 7.52 MB/sec
Please note overclocking wouldn´t get you significant more performance on Asus WL-500gP(remium) Router.
Listing Contents
ls -l /mnt
You can also add the above line to /jffs/etc/config/usb.startup to mount the partition on reboot
# multiple partitions mkdir /tmp/usb mkdir /tmp/usb/1 # wait to recognize devices properly sleep 2 # mount first partition /bin/mount /dev/scsi/host0/bus0/target0/lun0/part1 /tmp/usb/1 # list its contents ls -l /tmp/usb/1 # second partition mkdir /tmp/usb/2 mount /dev/scsi/host0/bus0/target0/lun0/part2 /tmp/usb/2 # list its contents ls -l /tmp/usb/2