Sunteți pe pagina 1din 2

21-04-2010 Content Preview

ACTIVATING USB AND SETTING UP PRINTING AND MOUNTING AN EXTERNAL USB STORAGE DEVICE
The Tutorial is made using a ASUS WL-500G Deluxe (or WL-500GX and WL-500GD as it is sometimes called).
It should however apply to all "OpenWRT Com patible" devices, even though some details like hardware addresses,
storage locations and so on could differ if you use other hardware. Check out the General OpenWRT Tutorial Inform ation
page for more information.

This tutorial will provide you information on mounting external USB Storage devices on startup, and will also provide
you a working print server.

Tutorial Index
1. Prerequisites - What is needed to get started.
2. Installing and activating USB drivers
3. Configuring Storage for use
4. Configuring Printer for use as Netw orked Printer

Prerequisites
All you need is :
An OpenWRT compatible router
OpenWRT 1.0 WhiteRussian RC2 or later
USB ports on your router

Installing and activating USB drivers


You should notice, that the modules and drives loaded are specifically chosen for the ASUS WL-500g Deluxe.
If you have a different router, you should consult The USB Storage How to on OpenWRT.org

ipkg install kmod-usb-core


ipkg install kmod-usb2
ipkg install kmod-usb-storage
ipkg install kmod-usb-printer
ipkg install kmod-usb-uhci

The above w ill install support for USB1.1 and USB2.0 devices. Both drivers for storage and printers are installed.

Next add the follow ing to the bottom of the file /etc/modules
usbcore
ehci-hcd
uhci
scsi_mod
sd_mod
sg
usb-storage
printer

Now reboot your router.


After the reboot you should open a ssh connection. Try to logread to follow w hat happens w hen you connect your USB device
logread -f

Now connect your USB Storage device (harddrive or usb memory stick or w hatever). When I connect my USB 2.0 harddrive that is split in 3 partitions to the USB 2.0
port that is closed to the LAN ports, I see this in the log :
jan 1 01:01:48 (none) kern.info kernel: hub.c: new USB device 01:02.2-1, assigned address 2
Jan 1 01:01:48 (none) kern.info kernel: scsi0 : SCSI emulation for USB Mass Storage devices
Jan 1 01:01:48 (none) kern.warn kernel: Vendor: USB 2.0 Model: Storage Device Rev: 0100
Jan 1 01:01:48 (none) kern.warn kernel: Type: Direct-Access ANSI SCSI revision: 02
Jan 1 01:01:48 (none) kern.warn kernel: Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
Jan 1 01:01:48 (none) kern.warn kernel: SCSI device sda: 39070080 512-byte hdwr sectors (20004 MB)
Jan 1 01:01:48 (none) kern.info kernel: Partition check:
Jan 1 01:01:48 (none) kern.info kernel: p1 p2 p3
Jan 1 01:01:48 (none) kern.debug kernel: WARNING: USB Mass Storage data integrity not assured
Jan 1 01:01:48 (none) kern.debug kernel: USB Mass Storage device found at 2

When connecting my USB printer to the other USB port this appears in the syslog:
Jan 1 00:03:42 (none) kern.info kernel: hub.c: new USB device 01:02.0-2, assigned address 2
Jan 1 00:03:42 (none) kern.info kernel: printer.c: usblp0: USB Bidirectional printer dev 2 if 0 alt 1 proto 2 vid 0x03F0 pid 0x1E11

If you see something simular, the kernel has found your hardw are, and are now ready to use it.
{mosgoogle bot}

Configuring Storage for use


In order to be able to actuately use the attached storage for something useful, you need to add support for filesystems to your router
The follow ing filesystem modules are available for OpenWRT:
kmod-ext2 - 2.4.30-brcm-2 - Kernel modules for EXT2 filesystem support
kmod-ext3 - 2.4.30-brcm-2 - Kernel modules for EXT3 filesystem support
kmod-hfsplus - 2.4.30-brcm-2 - Kernel modules for HFS+ filesystem support
kmod-vfat - 2.4.30-brcm-2 - Kernel modules for VFAT filesystem support
kmod-xfs - 2.4.30-brcm-2 - Kernel modules for XFS filesystem support
Most people w ill probably w ant to have support for a native linux filesystem like ext3 and also for USB Memory Sticks, w hich in general use VFAT (fat32 from

macsat.com/…/contentwindow.p… 1/2
21-04-2010 Content Preview
w indow s). To add support for theese filesystems you need to run
:
ipkg install kmod-ext2
ipkg install kmod-ext3
ipkg install kmod-vfat

Dont forget to add this to /etc/modules :


ext2
jbd
ext3
fat
vfat

Either reboot your router, or execute:


insmod ext2
insmod jbd
insmod ext3
insmod fat
insmod vfat

In order to activate the modules.

Now you can mount your drive, in my case I mount partition 2 to /opt (w hich I have created w ith mkdir /opt beforehand)
mount /dev/scsi/host0/bus0/target0/lun0/part2 /opt/

You can now access w hatever is on the device you added.


For now you w ill have to setup your filesystem on a real com puter, as program m es like fdisk and mke2fs are not yet available for OpenWRT

Enabeling at boot-tim e

For making the device mount to /opt at boot time, I have made the script /etc/init.d/S11mount :
#!/bin/sh
#
# macsat.com mount script
#

# Which device needs to be mounted?


MOUNT_DEVICE0=/dev/scsi/host0/bus0/target0/lun0/part1

i=0
# Wait 15 secs, mount when ready, and continue if it dosnt get ready within 15
secs.
while [ $i -le 15 ]
do

if [ -e $MOUNT_DEVICE0 ]
then
mount $MOUNT_DEVICE0 /opt/
echo "Success: $MOUNT_DEVICE0"
exit 0
fi

sleep 1
i=`expr $i + 1`
done

Be sure to change the MOUNT_DEVICE0 statement to w hatever your device might be (usb disk, usb flash memory, ide harddrive or w hatever!).

Configuring Printer for use as Networked Printer


I have chosen to install the simple p910n instead of Cups as "print server". While Cups is a full featured print server, it does depend on diskspace to spool print jobs to
w hile printing. Since not all OpenWRT devices or installations have access to disk space, I have decided to use p910n. The p910n deamon does not spool
locally,hence it w ill only w ork w hile the printer is actuately turned on!

Install the p910n deamon by:


ipkg install http://downloads.openwrt.org/people/nico/testing/mipsel/packages/p910nd_0.7-2_mipsel.ipk

The p910n deamon is started (and configured) using /etc/init.d/S51p910nd

Try to start it:


/etc/init.d/S51p910nd start
if this gives you an error like: p910nd: can't load library 'libgcc_s.so.1' you should install libgcc:
ipkg install libgcc
Now try to start the p910 server again.

if you see something like :


p9100d -b -f /dev/usb/lp0 0
When you do a "ps" you have the deamon running, and you should be able to print RAW printing to port 9100 from anyw here on your LAN

For help in setting up your computers for RAW printing, you could check out Olegs exellent printing guide

I hope you found this tutorial useful.


Comments and questions are w elcome at the Support Forum

Close Print

macsat.com/…/contentwindow.p… 2/2

S-ar putea să vă placă și