| Activating USB And setting up Printing and Mounting an external USB Storage Device |
|
|
|
| Written by macsat | |
| Thursday, 24 November 2005 | |
|
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 Compatible" 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 Information 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 Index1. Prerequisites - What is needed to get started.2. Installing and activating USB drivers 3. Configuring Storage for use 4. Configuring Printer for use as Networked Printer PrerequisitesAll you need is :Installing and activating USB driversYou 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 Howto 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 will install support for USB1.1 and USB2.0 devices. Both drivers for storage and printers are installed. Next add the following 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 what happens when you connect your USB device
logread -f
Now connect your USB Storage device (harddrive or usb memory stick or whatever). 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 hardware, and are now ready to use it. Configuring Storage for useIn order to be able to actuately use the attached storage for something useful, you need to add support for filesystems to your routerThe following filesystem modules are available for OpenWRT:
kmod-ext2 - 2.4.30-brcm-2 - Kernel modules for EXT2 filesystem support
Most people will probably want to have support for a native linux filesystem like ext3 and also for USB Memory Sticks, which in general use VFAT (fat32 from windows). To add support for theese filesystems you need to run 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 :
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 (which I have created with mkdir /opt beforehand)
mount /dev/scsi/host0/bus0/target0/lun0/part2 /opt/
You can now access whatever is on the device you added. For now you will have to setup your filesystem on a real computer, as programmes like fdisk and mke2fs are not yet available for OpenWRT Enabeling at boot-timeFor 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 whatever your device might be (usb disk, usb flash memory, ide harddrive or whatever!). Configuring Printer for use as Networked PrinterI 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 while 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 will only work while 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 anywhere 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. |
|
| Last Updated ( Monday, 29 January 2007 ) |
| < Prev | Next > |
|---|







