USB storage
From DD-WRT Wiki
Revision as of 03:59, 28 October 2007 (edit) Carlb (Talk | contribs) m (USB moved to USB storage: This article covers just flashdrive and hard disc; there are other USB apps such as printers, serial/parallel ports and audio that should be on the main USB page) ← Previous diff |
Revision as of 04:23, 28 October 2007 (edit) (undo) Carlb (Talk | contribs) (→Installation) Next diff → |
||
Line 1: | Line 1: | ||
+ | = USB storage = | ||
+ | == Applications == | ||
+ | * The use of a USB-compatible router makes the [[SD/MMC mod]]ification unnecessary. Just drop any old digital camera card into a USB flash card reader and easily expand the tiny 4Mb or so of flash memory in a typical Linux-based router to as much as eight gigabytes. Any of the various card types, including CompactFlash and SD, are suitable. USB flash devices are also available as one self-contained unit: a small "tag" which can store up to several gigabytes of data. | ||
+ | * A USB hard drive can be used as network-attached storage, shared by all computers on a LAN using [[Samba]] or [[NFS]]. Most standard internal hard drives (notebook or desktop) can be converted simply by installing them in an inexpensive USB enclosure. | ||
+ | * A USB hard drive can also be used as virtual memory by creating swap space. Instead of abruptly running out of memory when the 32Mb of physical RAM in these units is full, a portion is swapped to disc and the applications continue to run normally, but with a speed penalty. | ||
+ | * Mounting a USB storage device as /opt provides nearly-unlimited space to install many applications from the large collection of [[Optware]] packages, ported to embedded Linux originally for use with the Linksys "slug" (NSLU2) USB network-attached storage servers. A USB-compatible router can provide pretty much all of the NSLU2's capabilities (at a comparable price) plus offer all of the capabilites of a standard router and a wireless access point. | ||
+ | |||
+ | The use of standard USB hubs allows other USB devices (such as printers, serial ports, CD/DVD drives and audio) to remain connected even while the USB interface is used for flash cards or hard drive interfaces. | ||
+ | |||
+ | == Compatible units == | ||
+ | This is not a comprehensive list, please add more: | ||
+ | * [[Asus WT500W]] | ||
+ | * [[Linksys WRTSL54GS]] | ||
+ | |||
= Installation = | = Installation = | ||
Revision as of 04:23, 28 October 2007
Contents |
USB storage
Applications
- The use of a USB-compatible router makes the SD/MMC modification unnecessary. Just drop any old digital camera card into a USB flash card reader and easily expand the tiny 4Mb or so of flash memory in a typical Linux-based router to as much as eight gigabytes. Any of the various card types, including CompactFlash and SD, are suitable. USB flash devices are also available as one self-contained unit: a small "tag" which can store up to several gigabytes of data.
- A USB hard drive can be used as network-attached storage, shared by all computers on a LAN using Samba or NFS. Most standard internal hard drives (notebook or desktop) can be converted simply by installing them in an inexpensive USB enclosure.
- A USB hard drive can also be used as virtual memory by creating swap space. Instead of abruptly running out of memory when the 32Mb of physical RAM in these units is full, a portion is swapped to disc and the applications continue to run normally, but with a speed penalty.
- Mounting a USB storage device as /opt provides nearly-unlimited space to install many applications from the large collection of Optware packages, ported to embedded Linux originally for use with the Linksys "slug" (NSLU2) USB network-attached storage servers. A USB-compatible router can provide pretty much all of the NSLU2's capabilities (at a comparable price) plus offer all of the capabilites of a standard router and a wireless access point.
The use of standard USB hubs allows other USB devices (such as printers, serial ports, CD/DVD drives and audio) to remain connected even while the USB interface is used for flash cards or hard drive interfaces.
Compatible units
This is not a comprehensive list, please add more:
Installation
Install USB Kernel modules
If your kernel is still 2.4.30 (older versions of dd-wrt -> see output of uname -a):
ipkg install kmod-usb-uhci // this is for USB 1.1 (only required if your router does not support USB 2) ipkg install kmod-usb-core ipkg install kmod-usb2 ipkg install kmod-usb-storage
If your kernel is newer than 2.4.30:
ipkg -force-depends install kmod-usb-core kmod-usb2 kmod-usb-storage
This has been tested with kernel 2.4.35 and it did work .....
Manual installation and check
- insert the modules one by one by following commands in a telnet session.
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 insmod /jffs/lib/modules/2.4.30/sd_mod.o
Check
- See the enabling from dmesg output of a Linksys WRTSL54GS. A SanDisk Cruzer Micro 4G flash drive as recognized.
/ # dmesg <snip> <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
/mnt # ipkg install kmod-vfat ipkg_depends: Warning: kernel mentioned in dependency but no package found in //jffs/usr/lib/ipkg/lists Downloading http://downloads.openwrt.org/whiterussian/packages/kmod-vfat_2.4.30-brcm-5_mipsel.ipk ... Connecting to downloads.openwrt.org[195.56.146.238]:80 kmod-vfat_2.4.30-brc 100% |********************************************| 32018 --:--:-- ETA Done. ipkg_depends: Warning: kernel mentioned in dependency but no package found in //jffs/usr/lib/ipkg/lists Unpacking kmod-vfat...Done. Configuring kmod-vfat...Done. /mnt #
Check what got installed.
/mnt # ipkg files kmod-vfat /jffs /jffs/lib /jffs/lib/modules /jffs/lib/modules/2.4.30 /jffs/lib/modules/2.4.30/vfat.o /jffs/lib/modules/2.4.30/fat.o /jffs/etc /jffs/etc/modules.d /jffs/etc/modules.d/30-vfat /mnt #
ipkg install kmod-ext2 ipkg install kmod-ext3 ipkg install kmod-xfs
autoload filesystem modules
This part is very confusing. So I should add the filesystem modules to usb.startup? Where should I add them? Can somebody clear this up?
Add to /jffs/etc/config/usb.startup (comment out lines you don't need to save memory)
/mnt # cat /jffs/etc/config/usb.startup #!/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 /mnt #
the following lines:
# Filesystems # Ext2 insmod /jffs/lib/modules/2.4.30/ext2.o # Ext3 insmod /jffs/lib/modules/2.4.30/jbd.o insmod /jffs/lib/modules/2.4.30/ext3.o # 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
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
You can also add the above line to /jffs/etc/config/usb.startup to mount the partition on reboot
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.
On a WRTSL54G with 4G flash disk
/ # hdparm -tT /dev/scsi/host0/bus0/target0/lun0/part2 /dev/scsi/host0/bus0/target0/lun0/part2: Timing cached reads: 148 MB in 2.03 seconds = 72.91 MB/sec Timing buffered disk reads: 24 MB in 3.22 seconds = 7.45 MB/sec / #
On a WRT350N with 2GB SanDisk Cruzer Titanium flash disk
/ # hdparm -tT /dev/scsi/host0/bus0/target0/lun0/part1 /dev/scsi/host0/bus0/target0/lun0/part1: Timing cached reads: 196 MB in 2.01 seconds = 97.51 MB/sec Timing buffered disk reads: 28 MB in 3.04 seconds = 9.21 MB/sec / #
Listing Contents
ls -l /mnt
# 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
If you're having trouble
If you still cannot get your USB drive to mount after following these instructions to the letter, you can try resetting the NVRAM. Do this by using the recovery utility to upload the bin/trx file meant for that purpose.
NOTE: This has miraculously solved problems on an ASUS WL-500G Premium. Your mileage may vary, especially if you have a different router.