PDA

Bekijk de volledige versie : Followup to marcnesium's tutorial 1 - 3



r0kanon
03-09-2006, 03:26
1

It is very nice to be able to switch off your computer, hear the silence in your room and just see the rapidly blinking lights on the router. Thanks marcnesium, I did recently set up one router with the help of your tutorial and it works very well! I did encounter a few problems, but I was able to get around them.

I wrote some comments and additions hoping they might help somebody with no or little command line experience on unix like computers. So I intended my additions to be read together with your tutorial, perhaps in 2 windows - while setting up the router ;) In fact that's how I posted it on one of the PDA related forums - also linking marcnesium's tutorial so that the two might be read together.

So excuse me if I am explaining the obvious and I will be grateful for corrections and suggestions.

Summary of what you will need to do is:

01-> Choose router
02-> Choose external HDD
03-> Get telnet / ssh client to connect to your router
04-> Flash firmware into your router
05-> access your router via command line (telnet)
06-> Enable extra memory
07-> set up ssh access
08-> Set up your external hard disk drive

-> detect your HDD (if not done automatically)
-> partition your HDD
-> format your HDD
-> set up your HDD to be attached at boot time
09-> Set up ipkg installation mechanism
10-> install additional necessary and just nice packages

- nano (simple to use text editor - alternatvie to a bit cryptic vi)
- screen (necessary for you to be able to inconspicuously disconnect from router)
- cron (scheduler - to set up programs to run at some intervals)
- ntpclient (to keep router's clock precise)
- nload (to watch bytes going in and out on your terminal)
- ctorrent (well - for torrents download)
- enhanced-ctorrent (same but improved version - can download files > 2 GB)
11-> configure your SAMBA (Windows network) server for access from lacal network
12-> download torrent files to the SAMBA share
13-> downlad torrents

-> use screen so you can leave your router in peace, open 2 screens
-> start the command line enhanced-ctorrent in one screen
-> start nload in another screen to look at what you have done :)
-> stop nload by Ctrl-c
-> detach from screen by Ctrl-a + d
-> exit from putty
-> switch off your PC
14-> Watch your router, DSL modem and External HDD lights blink. It is your torrrent being downloaded. You feel proud of yourself, don't you? And by going a little deeper into all the commands you entered you might be able to do further configuration tweaks - allowing to download your new torrents automatically - as soon as you save them on your SAMBA share. This has been described on the net, but I have not got into it yet.

Some history : - I started by looking for routers that actually could use custom made open source firmware. Linksys, ASUS, Buffalo make very nice ones. I think all they are based on a Broadcom chip that is meant for running linux on it. So the manufacturers have to release the code with an open source license - which is picked up by the development community and usually something nice comes out. The best known projects are dd-wrt and openwrt. A bit less known but very relevant and respected is Oleg's firmware for ASUS routers. There are more.

I started off with dd-wrt and hoped to make it work with its nice web based interface. I got stuck at the point where one has to install and use USB HDD then make that available on Windows network (SAMBA). Packages for samba would not install in dd-wrt due to dependancy and version problems. Then I went to Oleg's firmware - and it works very well.

INITIAL SETUP NOTES (not covered by marcnesium):
-> 1) Choose router:
- ASUS wl-500 G Premium (aka wl-500Gp) - on eBay
- you can choose other but please verify
- that custom firmware exists
- it is still being developed
- good starting points are:
http://wl500g.info
http://www.dd-wrt.com
http://openwrt.org
http://www.wrt54g.net
Wikipedia

-> 2) Choose your external HDD. For example Seagate USB 2.0 model with 300 or 400 GB capacity. What you want to have is s simple external drive that would have good capacity and low noise. If the shop assistant tries to tell you this you need to install any drivers for it - be suspicious and go away.

-> 3) Have puTTY ready on your computer. It is a telnet and ssh client http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html It will be actually better for you perhaps not to type every command, but rather copy them from marcnesium's tutorial and mine and paste into puTTY. Pasting is performed by the left mouse button. A command will be executed after you press enter.

-> 4) FLASH THE FIRMWARE: You need to obtain the correct firmware for your router. In our case you go to http://oleg.wl500g.info/ - at the bottom of the page you will find the latest Oleg's firmware - in January 2007 it is 1.9.2.7-7f. Your ASUS Premium image will be It is WL500gp-1.9.2.7-7f.zip
4.1 Flash it onto the router.

- put your router in recovery mode by disconnecting power, then keep reset button pressed (with a paper clip), conncet power, then wait about 5 seconds until router power light starts to blink slowly. This is recovery mode when router is awaiting an incoming tftp connection which will upload the new firmware,
- open the ASUS recovery utility - that is basically a tftp client and I suspect it has a few extras with it - maybe it clears nvram or des something similar. It is available on your CD and on the ASUS support site with driver downlads.
- choose your firmware file you downloaded to your PC e.g. WL500gx-1.9.2.7-7e.trx
- press upload button
- IMPORTANT: your PC must be connected to the router by a cable not by wireless cnnection. I don't think the wireless might work in recovery mode, but still this is an important point to observe when uploading any firmware to any router, therefore I mention it here.
- wait until it says "upload complete, router rebooting" or something like that.
4.2 CAVEAT - uploading some experimental firmwares may not reboot the router (it happened to me) :) - it will stay in recovery mode and do nothing. If that is so you can still use 2 firmware images to clean up, then you can upload the firmware of your choice again. Those images are: http://oleg.wl500g.info/wl500g-clear-nvram.trx and then after the power-off reboot-in-recovery mode use the other one: http://oleg.wl500g.info/wl500g-recover.trx This is almost 100% certain you will end up in a working router condition and then you can attempt a firmware upload again.
4.3 some people say it is best to upload firmware through the web interface. Well, I think is there is an easy to use tftp utility - why not use that.

r0kanon
03-09-2006, 03:30
2

-> 5-14) COMMENTS to marcnesium's tutorial:

# 1) mkdir -p /usr/local/sbin/ (writeability and swap)

as you can see from this command - /usr/local directory are writeable. What is important - the other ones are not (except /tmp). But what you can - and will do is - you can mount your hard disk partitions that are perfectly writeable into empty directories. You will need to mount one in /opt ; you could mount another partition in /mnt . So perhaps the number of partitions you will create with fdisk (later) could be three. Two big ones for data for mounting on /opt and /mnt then 64 MB one - for swap space. Swap is highly recommended as it is virtual memory. So your machine will have not 32 MB but 96 MB - the downside of course will be write operations that will use swap file and slow the machine down a bit.

This tutorial will refer to one big partition for data and a swap partition of 64 MB.

# 2) post-boot : Oleg's firmware is set up to automatically execute script files in /usr/local/sbin directory. So to set up things for you like hard disk and time synchronization you will write (or paste) corresponding commands in your mkdir -p /usr/local/sbin/post-boot file

# 3) dropbear : is ssh server. It is necessary to provide secure access to your router - either from outside, or from your local network - if you think it is insecure. Otherwise telnet will be ok as well.

# 4) RAM extension : due to some industrial strategy quirk ASUS wl-500Gp comes with 32 MB RAM of which only 16 MB are enabled. If you use this step, you will considerably extend the memory available. Beware that if you have any other model - this command sequence might damage it.

# 5) disks : it may happen that your ASUS does not pick up the disk at boot time or when you plug it in the USB port. Maybe not all the necessary kernel modules were loaded, maybe they just did not detect your disk and unloaded themselves. So you will insert them manually:

5.1 - verify if you have HDD recognized by:


ls -l /dev/d*

if you don't get response dics0
but get /dev/d*: No such file or directory

it means you don't have access to your HDD and probably some of the necessary modules have not loaded

5.2 - so insert modules manually:



insmod usbcore.o
insmod ehci-hcd.o
insmod scsi_mod.o
insmod usb-storage.o
# you will need the one line below if you use USB 1.1
# insmod uhci.o
# and finally
insmod sd_mod.o

In my case I identified which modules were not loaded and put this:


insmod scsi_mod && insmod sd_mod && insmod usb-storage && sleep 5s

in my /usr/local/sbin/post-boot file

5.3 Verify again if you have disks as in 5.1

5.4 If you have disks then proceed to partitioning:


fdisk /dev/discs/disc0/disc

you will have help available by pressing m
p will print your current partitions
d will delete partition you specify
l will show you what types of partitions you may create
you will need only 82 83
w will write changes to the partition table and exit
q exits without changing anything

set up swap partition (type 82) twice the size of your real RAM - the is 64 MB. I think you will do so by pressing n then when you need to enter size do +64M ; The next partition can occupy the rest of your HDD. Changes you are making to the partition table will be available after reboot - so do:


flashfs save && flashfs commit && flashfs enable && reboot

After reboot you will be able to identify (list) partitions by


ls -l /dev/discs/disc0/

If you can't identify disc (as in 5.1) you will need to insert modules again as in 5.2.
(You will want to add the insmod commands to your post-boot, but wait until you install nano - it is much easier text editor than vi)
You will see partitions named as part1 and part2 - unless you have done something very unusal.
Name disc in the same directory refers to your whole hard disc and is usable with fdisk - as you have done already. You can try again and you will be able to use p to look at your partitions.

Once you see the partitions - you are one step away to be able to use them. First you will need to format your data partition. if you set up swap partition first it will be the small one named part1 - so part2 will be your data partition. It is other way in marcnesium's tutorial so just pay attention to what commands you are typing. In my case mke2fs -j /dev/discs/disc0/part2 is correct, in his mke2fs -j /dev/discs/disc0/part1


mke2fs -j /dev/discs/disc0/partx (where x is correct partition number)

This will take time as the disk is large. Notice that -j switch is important - if you omit it format will proceed but you won't be able to mount your partitions.

Then create swap space on your other partition


mkswap /dev/discs/disc0/partx (where x is correct partition number)

5.5 marcnesium proceeds to use vi to set up partitions for reboot. I would say - install an easier text editor - nano and then do edits and reboot. To do that you will first need to mount your data partition.


mount /dev/discs/disc0/partx /opt (where x is correct partition number)

Now your data partition is available in /opt - which means you can create directories, files in it.

Go on to marcnesium's steps on initializing ipkg


mkdir /opt/tmp
mkdir /opt/tmp/ipkg
ipkg.sh update
ipkg.sh install ipkg
ipkg update

ipkg is the package manager that has been partially pre-setup in Oleg's firmware. It is very handy as it allows you to install software compatible with your router by a very simple mechanism. So commands starting with ipkg.sh are the initial script for setting up the ipkg. After those commands you will be using ipkg itself. your first command will be ipkg update which will update the list of available packages from http://wl500g.dyndns.org/ipkg and http://ipkg.nslu2-linux.org/feeds/unslung/wl500g - as set up in your /opt/etc/ipkg.conf file.

install nano text editor.


ipkg install nano

All commands you need will be available on your terminal screen for example:
Ctrl-g will show help screen
Ctrl-o will save file
Ctrl-x will exit (asking if you want to save - if you haven't)

To try that out start nano and edit the file post-boot


nano /usr/local/sbin/post-boot

5.6 add then these lines into that file:


#!/bin/sh
# Start ssh server
dropbear

# test if USB disc has been attached
# if not - then insert needed modules
if [ ! -d /dev/discs ]
then
insmod scsi_mod && insmod sd_mod && insmod usb-storage && sleep 5s
fi

# Wait for /opt to mount
mount /dev/discs/disc0/part1 /opt
i=0
while [ $i -le 30 ]
do
if [ -d /opt/etc ]
then
break
fi
sleep 1
i=`expr $i + 1`
done

# Activate swap
swapon /dev/discs/disc0/part2

Of course - for mount and mkswap commands see that your partitons are identified correctly! That should be easy if you paid attention in comment 5.4 just a bit earlier :read: Save and exit nano. Now your ASUS system is ready to reboot and hopefully - to survive it well.


flashfs save && flashfs commit && flashfs enable && reboot

5.7 After reboot check if your filesystems have mounted by


mount

The response should be something like:

/dev/root on / type squashfs (ro)
none on /dev type devfs (rw)
proc on /proc type proc (rw)
ramfs on /tmp type ramfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/discs/disc0/part2 on /opt type ext3 (rw)

And the essential thing is that you can see - your HDD has been mounted in /opt
This concludes the disc setup and the rest should be quite easy - as in marcnesium's tutorial

r0kanon
03-09-2006, 03:37
3

# 6) mc cannot be installed from default ipkg locations - so don't stress about that for now. Later on you may be able to find suitable package and install it from that location.

# 7) as regards setting up SAMBA shares I went with slightly different smb.conf
It is located in /opt/etc/samba/smb.conf - edit with nano as usual


[global]
workgroup = WORKGROUOP_AS_ON_YOUR_WINDOWS_PCS
server string = ASUS
# hosts allow = 192.168.1.0/24 127.0.0.1
# hosts deny = ALL
# lanman auth = no
# lm announce = no
# min protocol = NT1
interfaces = 192.168.1.0/24 127.0.0.1
bind interfaces only = yes
guest account = nobody
security = share
# writeable = yes
browseable = yes
guest ok = yes
guest only = yes
log level = 1
max log size = 100
local master = no
dns proxy = no

[ASUS_Share]
path=/opt/smbshare
writeable=yes
browseable=yes

I have requested SAMBA server to bind only to the internal network interfaces. I did not think it was very necessary to set up user level security but it can be done according to some articles on the net. Some other options not supported by the ipkg samba daemon edition have been commented out.

Add the following lines to your /usr/local/sbin/post-boot file :


# Set hostname
hostname your.host.name.change.as.needed

# Synchoronize time
# For GMT time zone you would want to:
echo "GMT+0BST-1,M3.5.0/01:00:00,M10.5.0/02:00:00" > /etc/TZ && sleep 2s
# Then ntpclient can update the time correctly
ntpclient -l -h 0.uk.pool.ntp.org -c 1 -s

# Run all active services - active means starts with S
# SAMBA will be started from there if you have follow marcnesium's instructions
/opt/etc/init.d/rc.unslung

Save that file!

Also you need to change the permissions for your /opt/smbshare directory - currently it is writeable by the root only. You are providing access through nobody account (see in smb.conf). So you need to enable write for others. Do:


chmod ugoa+w /opt/smbshare

and check it with


ls -l /opt/s*

result will be like this:

drwxr-xr-x 2 admin root 4096 Sep 2 18:51 sbin
drwxr-xr-x 5 admin root 4096 Aug 28 16:40 share
drwxrwxrwx 2 admin root 4096 Aug 28 16:36 smbshare

As you notice the smbshare line is different - everybody can write in it.

Now you should be able to do everything after reboot.


flashfs save && flashfs commit && flashfs enable && reboot

Test it by browsing to your router from your PC.

!!! One thing to note with the very lightweight SAMBA implementation though!!!!

Somehow the deletion of files is not supported from PC. You can read (copy files from your router) and write (copy files to router). So you should note this and do deletion from command line using rm command. Of course the more experienced may point out if perhaps this has something to do with share mode authentication and unix permissions?



cd /opt/smbshare/your_directory
rm ./file_you_want_to_remove.avi


If you have not discovered it yet - the command auto-completion with tab works very well here. Just try to write part of command or file name and press tab key. You may be surprised and start liking -nix more.

# 8) TORRENTS:

Well you went through all this to be able to do some torrents as well.


ipkg install enhanced-ctorrent

Very good and simple documentation is available at http://www.rahul.net/dholmes/ctorrent/

Use it in conjunction with screen. Start screen (you have it installed, haven't you :-?)


screen

Play with these commands

Ctrl+a c create new window with shell and switch to it
Ctrl+a 0 - 9 switch to screen N
Ctrl+a n / p switch to next / previous screen
Ctrl+a " list all screens
Ctrl+a d detach screens
Ctrl+a A name this screen (useful when you list them)
Ctrl+a r re-attach to screens after you have logged back into your router

Ctrl+a means press those keys together. Then let go and press the next key needed ;)
You can exit current screen by


exit

If you exit from all screens you exit screen application as such. Most of the time you will want simply to detach - so that you can leave your enhanced-ctorrent doing what it needs.

Torrenting:


enhanced-ctorrent -s file.extn -i your.ip.add.ress -e 12 -p 6881 eg.torrent

Which means that file will be saved to your file with name file.extn torrent will listen to your.ip.add.ress (this has to be numeric of course and you can learn it by browsing to http://whatismyip.com) it will seed for 12 hours, the incoming port will be 6881 (did you open it as marcnesium said - in his tutorial the /usr/local/sbin/post-firewall file) and the local torrent file is eg.torrent

# 9) What a job, isn't it? You can look at it by opening nload in one of your screens.


nload -t 300 -s 9 -i 1024 -o 1024 -u H vlan1

vlan1 is the internet side network interface for your router. You can verify it by


ifconfig

(the interface which will have your external ip address will be the external one)

Now if you use nano to create /usr/local/sbin/nld file with the lines:


#!/bin/sh
nload -t 300 -s 9 -i 1024 -o 1024 -u H vlan1

in it and then make this script executable


chmod +x /usr/local/sbin/nld

you will be able to start nload with the above configuration just by typing nld and pressing Enter
The short manual is here: http://www.penguin-soft.com/penguin/man/1/nload.html
And I advise to play with the short section called OPTION WINDOW

nload will show you in real-time bits flowing in and out of your machine. You will see the results of your hard work for yourself, and probably it will make you a bit happy you have suceeded to do this thing with the small white ASUS box.

# 10) WHAT THEN ABOUT WIRELESS AND STUFF ???!!!

Well - the ASUS web interface is still perfectly usable. Even better with some bits than the original one. I did all wireless config through the web interface. It is not quite as cool as dd-wrt web interface or does not seem as techie as doing it all via command line but it does the job perfectly.

questions and improvements to this article are highly welcome

:D

LinusW
07-09-2006, 11:36
Hi

Great guide, but when i get to the usb-disc part i can't get it to work. The line

ls -l /dev/d*
returns

ls: /dev/d*: No such file or directory
and in the following section, 5.2, all modules already exists.

I've tried to open fdisk, but I get

Unable to open /dev/discs/disc0/disc

Need help with this one, thank you.

Egres
07-09-2006, 18:51
i`ve been folowing both howtos from marcnesium and r0kanon but Samba still not working

on

ps |grep "smb"

156 admin 380 R grep smb

thttpd Web Server and vsftp works fine by www.mascat.com

and post-mout doesn't start only works manully

any suggestions ?

r0kanon
13-09-2006, 10:08
usb-disc part i can't get it to work. The line

ls -l /dev/d*
returns

ls: /dev/d*: No such file or directory
and in the following section, 5.2, all modules already exists.

I've tried to open fdisk, but I get

Unable to open [/CODE]

Need help with this one, thank you.

This line ls -l /dev/d* simply checks whether the usb/scsi modules have loaded and detected the disk. If there is no /dev/disc/and/the/rest it means modules for some reason did not load on startup (usually did not have time to recognize the disc) and need to be added by hand. I suggest - gather a list of modules (from tutorial) and try inserting one by one in the suggested order - like in
insmod your_module.oIf module already loaded nothing terrible will happen, it will simply say so. The aim of the exercise is to get positive answer to ls -l /dev/d* - meaning that your disk device has been recognised by the system.

I hope this makes things clearer :rolleyes:

ser_zh
06-10-2006, 22:02
-> 4) FLASH THE FIRMWARE: You need to obtain the correct firmware for your router. In our case you go to http://oleg.wl500g.info/ - at the bottom of the page you will find the latest Oleg's firmware. Even though it says beta - it works fine. It is WL500gx-1.9.2.7-7e.zip (x stands for any letter, I guess)

Correct FIRMWARE is here:
http://oleg.wl500g.info/gp/WL500gp-1.9.2.7-7f-pre6.trx

kvi
22-10-2006, 14:38
I can't get my hd to work.

I have 80Gb Western Digital hd and it has a single fat32 drive on it by default. I have used it with the original firmware and there are files on that partition. So, here with the problem:

The box just keeps mounting the old fat32 partition to /tmp/harddisk no matter how much I try to follow the instructions given here. I have even tried to delete all partitions from the hd with fdisk and used the o command (create a new empty DOS partition table)

I do like this:

delete all partitions and all from hd and then:

flashfs save && flashfs commit && flashfs enable && reboot

when it comes back up, it does NOT mount the old fat32 drive.

then I do the /dev/discs/disc0/part1 as swap and part2 as the huge drive. I write the new partition table and do the

flashfs save && flashfs commit && flashfs enable && reboot

it come up and quess what? part1 mounted as /tmp/harddisk and ALL files from the old partition are there!!! dmesg gives fat panic & problems and it says that it is mounted as read only. BUT WHY THE HELL DOES IT MOUNT IT!!!! I CAN'T HAVE SWAP BECAUSE OF THIS!!! HELP!! please!!

Banane
28-10-2006, 23:32
Hi r0kanon!

Nice work, though I didn't try it yet. But there is one mistake, as ser_zh already said.


1
-> 4) FLASH THE FIRMWARE: You need to obtain the correct firmware for your router. In our case you go to http://oleg.wl500g.info/ - at the bottom of the page you will find the latest Oleg's firmware. Even though it says beta - it works fine. It is WL500gx-1.9.2.7-7e.zip (x stands for any letter, I guess)


The URL for the firmware is wrong. The wrong link points to the firmware for:
Asus WL 500g Deluxe (x=Deluxe)
I don't know what will happen if someone flashes this wrong firmware onto his
Asus WL 500 g Premium (P=Premium)
Please, edit and correct your post. (for people that won't read that far till this/mine/our post). The correct link is:
http://oleg.wl500g.info/gp
There you find several files for several models and even several version for some models. Only the files with gp are for Premium-Device. And "pre" apparently means "beta".

best regards

Thorsten

velcrow
01-11-2006, 14:31
Thanks for this great tutorial

Nearly all up and working - could you give me some more info on:


did you open it as marcnesium said - in his tutorial the /usr/local/sbin/post-firewall file

How is this done?

r0kanon
13-01-2007, 18:45
Dear All,

I was very busy with my direct work and was unable to visit this forum for a while. Thanks for your corrections. I have updated the beginning so that it points to correct firmware.

As to welcrow's question - post-firewall file runs after the basic firewall is set up. So it is the place where you enter firewall modifications. I can't find at the moment an example of such a rule as my ASUS is down, but I should be able to post it in a week if necessary. But these examples of iptables command are very widely available on the net and also in these forums.

nico
06-05-2007, 22:59
:confused: i get also the same result like usser KVI ,after rebooting ?
please help us ?

velcrow
24-05-2007, 18:03
As to welcrow's question - post-firewall file runs after the basic firewall is set up. So it is the place where you enter firewall modifications...

Thanks for the reply - Your tutorial got me additicted

All good now - have been enjoying the world of BusyBox Linux... Who needs Vista ;)

hypernetics
15-08-2007, 10:21
Hi r0kanon, GREAT GUIDE!!!! I am following your guide, (also working of marcnesium's and moody blue's)

Your seems to be giving me the most success so far. :)

I have got this far:

The response should be something like:

/dev/root on / type squashfs (ro)
none on /dev type devfs (rw)
proc on /proc type proc (rw)
ramfs on /tmp type ramfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/discs/disc0/part2 on /opt type ext3 (rw)

And the essential thing is that you can see - your HDD has been mounted in /opt


... I get the exact same respone... BUT I do not get the last line "/dev/discs/disc0/part2 on /opt type ext3 (rw)",
Can I continue or is this the 'essential thing'??:eek:

If so what have I missed, any help appreciated?:rolleyes: