USB stick in OpenWrt

After connecting of the usb-hub you can use its capabilities.

Connect the USB stick and copy the file system to it in order not to be dependent on the size of flash memory in the router.

At the stage of configuration OpenWrt you need to install the following modules:
Kernel modules:
USB Support:
<*> Kmod-usb-storage
Filesystems:
<*> Kmod-fs-ext3
Base system:
<*> Block-extroot
Utilities:
Filesystem:
<*> E2fsprogs
Disc:
<*> Fdisk

Prepare the USB stick:

Connect the USB stick to the router. Go to the router using telnet:

$ telnet 192.168.1.1

Check the name of the USB stick in the system:

# fdisk -l (my USB stick had been identified as /dev/sda)

Format the USB stick:

# fdisk /dev/sda
Command (m for help): d
Partition number (1-4): 1

Command (m for help): d
Partition number (1-4): 2

Command (m for help): d
Partition number (1-4): 3

Command (m for help): d
No partition is defined yet!

Split the USB stick into the following parts - Swap (64Mb), Root File System (128Mb), Home (the remaining space on the USB stick):

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p

Partition number (1-4): 1
First cylinder (1-122, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-122, default 122): +64M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p

Partition number (1-4): 2
First cylinder (10-122, default 10):
Using default value 10
Last cylinder or +size or +sizeM or +sizeK (10-122, default 122): +128M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p

Partition number (1-4): 3
First cylinder (27-122, default 27):
Using default value 27
Last cylinder or +size or +sizeM or +sizeK (27-122, default 122):
Using default value 122

Check the result of operations:

Command (m for help): p
Disk /dev/sda: 1010 MB, 1010826752 bytes
255 heads, 63 sectors/track, 122 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x91f72d24
Device Boot Start End Blocks Id System
/dev/sda1 1 9 72261 83 Linux
/dev/sda2 10 26 136552+ 83 Linux
/dev/sda3 27 122 771120 83 Linux

The first section has to have the type Swap, let’s change the type for it:

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to 82 (Linux swap / Solaris)
Command (m for help): p
Disk /dev/sda: 1010 MB, 1010826752 bytes
255 heads, 63 sectors/track, 122 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x91f72d24
Device Boot Start End Blocks Id System
/dev/sda1 1 9 72261 82 Linux swap / Solaris
/dev/sda2 10 26 136552+ 83 Linux
/dev/sda3 27 122 771120 83 Linux

Apply and exit:

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

Format the partitions:

# mkswap /dev/sda1
# mkfs.ext3 -L RootFS /dev/sda2
# mkfs.ext3 -L MyData /dev/sda3

The disk is ready. Copy the root file system to it:

For this you should connect it to your computer and copy the contents of the openwrt/build_dir/target-mipsel_uClibc-0.9.31/root-brcm47xx / to the second
section (RootFS) of the USB stick

For downloading from the USB stick you should change the file /etc/config/fstab
as follows:

config global automount
option from_fstab 1
option anon_mount 1
config global autoswap
option from_fstab 1
option anon_swap 0
config mount
option target /
option device /dev/sda2
option fstype ext3
option options rw,sync
option enabled 1
option is_rootfs 1
config mount
option target /home
option device /dev/sda3
option fstype ext3
option options rw,sync
option enabled 1
config swap
option device /dev/sda1
option enabled 1

Reboot with the connected USB stick and check the result:

root@OpenWrt:/# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 1.9M 1.9M 0 100% /rom
tmpfs 14.5M 40.0K 14.5M 0% /tmp
tmpfs 512.0K 0 512.0K 0% /dev
/dev/sda2 129.1M 11.8M 110.7M 10% /overlay
mini_fo:/overlay 1.9M 1.9M 0 100% /
/dev/sda3 741.2M 16.8M 686.8M 2% /home
root@OpenWrt:/# free
total used free shared buffers
Mem: 29732 15476 14256 0 1540
Swap: 72256 0 72256
Total: 101988 15476 86512

Now you are not limited by the size of the internal flash memory on the router and you can put any application on it.

       Buy a USB stick from us:
       USB stick 4Gb - $ 10
       USB stick 8Gb - $ 20
       USB stick 16Gbt - $ 25
       USB stick 32Gb - $ 45
       USB stick 64Gb - $ 80
       USB stick 128Gb - $ 100

       Let’s make it possible to install the modules from a local repository. The following commands are used for this:

$ opkg update — update the list of available packages
$ opkg install — install package

      How to do this:

1) You need to open the access via ftp to the directory -
bin/brcm47xx/packages. You can do this by using of any ftp-server (for example - gadmin-proftpd).

2) In the file / etc / opkg.conf you need to comment out the main repository and
to add its own:

src/gz localpackages ftp://(server address)

3) Update the access list of packages:

root@OpenWrt:/# opkg update
Downloading ftp://ftp:ftp@192.168.1.9/Packages.gz.
Inflating ftp://ftp:ftp@192.168.1.9/Packages.gz.
Updated list of available packages in /var/opkg-lists/localpackages

4) Now you can install packages using the following command:

root@OpenWrt:/# opkg install package name

5) You can also remove:

root@OpenWrt:/#opkg remove --force-removal-of-dependent-packages package name


flash-stick 1Gb