Sunday, September 26, 2010

USB flash drive on OpenWRT 10.03 Backfire HOWTO


There's been a number of guides for using USB flash drives on OpenWRT, but they all seemed to be overly complicated, or for previous versions of OpenWRT before 10.03 Backfire, for which it's now pretty simple.

This guide is written with the assumption that your USB flash drive is already formatted in ext2 or ext3, but ends with pointers on what to do if not.

Starting with a clean install of OpenWRT, the following packages are already installed.


root@OpenWrt:/mnt# opkg list-installed | grep usb
kmod-usb-core - 2.6.32.16-1
kmod-usb-ohci - 2.6.32.16-1
kmod-usb2 - 2.6.32.16-1


1. Install USB mass storage support. 


root@OpenWrt:~# opkg install kmod-usb-storage
Installing kmod-usb-storage (2.6.32.16-1) to root...
Downloading http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/kmod-usb-storage_2.6.32.16-1_ar71xx.ipk.
Installing kmod-scsi-core (2.6.32.16-1) to root...
Downloading http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/kmod-scsi-core_2.6.32.16-1_ar71xx.ipk.
Configuring kmod-scsi-core.
Configuring kmod-usb-storage.


2. Install the necessary file system support, in this minimalist case, ext2. (Other common file systems include ext3, reiserfs, hfs, msdos, vfat and ntfs.)

root@OpenWrt:~# opkg install kmod-fs-ext2Installing kmod-fs-ext2 (2.6.32.16-1) to root...
Downloading http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/kmod-fs-ext2_2.6.32.16-1_ar71xx.ipk.
Installing kmod-fs-mbcache (2.6.32.16-1) to root...
Downloading http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/kmod-fs-mbcache_2.6.32.16-1_ar71xx.ipk.
Configuring kmod-fs-mbcache.
Configuring kmod-fs-ext2.


3. Create a mount point. I chose to use /mnt/usb for my USB flash drive.

root@OpenWrt:/mnt# mkdir /mnt/usb

4. Mount the USB flash drive. The "-o noatime" is used to reduce the number of disk writes (as USB flash drives have a limited number of write accesses) and to slightly improve performance.

root@OpenWrt:/sbin# mount -o noatime /dev/sda1 /mnt/usb

5. That's it, done.

root@OpenWrt:/mnt/usb# ls -l /mnt/usb
drwx------    2 root     root        12288 Sep 26 10:52 lost+found
root@OpenWrt:/mnt/usb# df -h | egrep "system|usb"
Filesystem                Size      Used Available Use% Mounted on
/dev/sda1               232.9M      6.0M    214.8M   3% /mnt/usb

What if the above steps doesn't work out?

A possible reason is that the USB flash drive isn't formatted in ext3. You can then either install other file system support (by replacing step 2 with kmod-fs-vfat, kmod-fs-ntfs, kmod-fs-msdos, kmod-fs-ext2, etc. as necessary) or format the USB flash drive to ext3 using fdisk followed by mkfs.ext3.

Another possibility may be that you need to install the appropriate character encoding (also known as code-pages) to suit your language/locality. Such modules are typically named kmod-nls-xxxx, eg. kmod-nls-cp437, kmod-nls-iso8859-1 or kmod-nls-utf8.

3 comments:

blog said...

Thanks for the great guide. I went with vfat over ext3. Also, I didn't need to install kmod-usb2. I only needed kmod-usb-core, kmod-usb-ohci, and kmod-usb-storage.

Ho Hock Jim said...

Glad it helped someone out. :)

openwrtuser said...

Thanks It helped a lot