Saturday, February 02, 2013

Silly geek things

I've purchased an ASUS RT-N66R wireless router for my house. At nearly $200, it's probably more than your average Net-using citizen requires, but I'm not a typical user. It runs a Linux kernel (handy!), it has three antennae and can easily light up any device in a standard house. E.g., my little phone can get a strong enough signal at the opposite end of the house to run Netflix. Of course watching movies on a tiny screen is straining for these old eyes, but if I need to watch Doctor Who while lying in bed, I have the bandwidth to pull it off.

Yay me.

Anyway, the stock OS load is decent and if you have no need to mess with computers and their parts, you'll be fine. I'm not fine, though. Tinkering is my game and this gadget is a tinkerer's jewel. I'm contemplating changing to an new version of Tomato or DD-WRT, but until then I needed a couple of network tools that weren't available on the stock ROM. To fix that, you'll need to do a couple of things, essentially, enable the download tools, add a drive and install the software packages you need.

To do that on an ASUS RT-N66U, you need to insert a USB thumb drive into the back of the router and then dismount it by using a browser to go to the router's address and logging in. On the left hand side, select the "Network Map" icon, then select the drive icon that shows up center bottom section (the USB icon). From there, click on the "Safely Remove disk: Remove" button. This will di/smount the newly inserted USB stick.


Now you'll need to telnet to the router and format the drive that you've just installed.

dmesg at the command prompt will tell you where the USB ended up (bottom slot is probably /dev/sdb and the top USB slot is /dev/sdc).  In my case it was /dev/sdc

Check the partitions by issuing

admin@RT-N66U:/# fdisk -l /dev/sdc

Disk /dev/sdc: 8004 MB, 8004304896 bytes
35 heads, 21 sectors/track, 21269 cylinders
Units = cylinders of 735 * 512 = 376320 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdc1               1       21270     7816688   b Win95 FAT32


 you'll probably see one partition, so let's delete it.  

admin@RT-N66U:/# fdisk /dev/sdc

The number of cylinders for this disk is set to 21269.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): d 1
Selected partition 1


 
Create a new disklabel:

Command (m for help): o
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.


The number of cylinders for this disk is set to 21269.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)


 
Now create new partition:

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


Now check your work:

Command (m for help): p

Disk /dev/sdc: 8004 MB, 8004304896 bytes
35 heads, 21 sectors/track, 21269 cylinders
Units = cylinders of 735 * 512 = 376320 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdc1               1       21269     7816347  83 Linux

Write your changes to the stick:

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table
admin@RT-N66U:/# 


Now format the stick:

admin@RT-N66U:/# mke2fs -b 1024 /dev/sdc1
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
977920 inodes, 7816344 blocks
390817 blocks (5.00%) reserved for the super user
First data block=1
955 block groups
8192 blocks per group, 8192 fragments per group
1024 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409, 663553,
        1024001, 1990657, 2809857, 5120001, 5971969

Writing inode tables: done                       
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


admin@RT-N66U:/#  

You're done.  Now you need to enable the Download Master software by going to the router's web page and clicking on USB applications and selecting the install option.  Optware has been installed.  You can now use the ipkg application like any other package manager and get useful tools for your router.  I installed openssh, openssh-sftp-server, nmap and tcpdump by using the following command:

ipkg install ckagename>

You can get a list of packages by using

ipkg list

and looking for what you need.