PDA

View Full Version : HOWTO install debian on 128 mb usb stick


iiivx
23-04-2005, 21:36
install debian on a usb stick

Setup good firmware

I used phedny's custom firmware (1.9.2.7-3b) with ipv6 support, you can download it here (http://masteen2.iiivx.net/wl500g/WL500g-1.9.2.7-3b+ipv6.trx). Howto install new firmware is described in other howto's on the wl500g forums.

If you don't want ipv6, you can skip setting it up. But hey, why not use ipv6 when I included all kinds of neat ipv6 things like radvd, iproute2, ping6 and traceroute6! Well, read howto setup your wl500g as a ipv6 router (http://wl500g.info/showthread.php?t=1685&highlight=ipv6)

I disabled the stupid-ftp server, because it's .. to simple. Why not use a cool ftpd server when you have a working debian installation? :-) If you have disabled the ftp server on the admin webpages, the usb-storage modules won't be loaded into the kernel. Make sure you have loaded the required modules into the kernel:

insmod /lib/modules/2.4.20/kernel/drivers/scsi/scsi_mod.o
insmod /lib/modules/2.4.20/kernel/drivers/scsi/sd_mod.o
insmod /lib/modules/2.4.20/kernel/drivers/usb/storage/usb-storage.o

Download the image and store it on the usb memory stick:

wget -O /dev/scsi/host0/bus0/target0/lun0/disc http://masteen2.iiivx.net/wl500g/debian/debian-sarge-128mb-mipsel.image

this image includes a partition table and stuff, because the ipv6 firmware doesn't have e2fsprogs out of the box. Mount the crazy thing so you can start messing around.

mount /dev/scsi/host0/bus0/target0/lun0/part1 /tmp/harddisk

Get into your debian installation.

chroot /tmp/harddisk/debian-distro /bin/bash
mount -t proc none /proc
mount -t devfs devfs /dev
swapon /dev/scsi/host0/bus0/target0/lun0/part2

Generate your own key's and start dropbear
rm /etc/dropbear/dropbear_rsa_host_key && rm /etc/dropbear/dropbear_dss_host_key
dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
/etc/init.d/dropbear start

Use your fresh debian installation

Now the second part, using your debian installation!

Ssh to your router using the account 'normaluser' and the default password 'userpasswd'. Change your password and type 'su', the default root password is 'rootpasswd'.

Do something kinky like
apt-get update; apt-get dist-upgrade

And enjoy! Don't forget to regulary clean up the useless stuff I mentioned before.

Additional information

Example of how things can look when everything goes okay
Feanor:~ iiivx$ ssh normaluser@192.168.1.1
normaluser@192.168.1.1's password:
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
normaluser@wl500g-router:~$ su
Password:
wl500g-router:/home/normaluser# uptime
21:08:10 up 2 days, 8:38, 1 user, load average: 0.29, 0.36, 0.69
wl500g-router:/home/normaluser# uname -a
Linux wl500g-router 2.4.20 #57 Thu Feb 10 14:29:29 CET 2005 mips GNU/Linux
wl500g-router:/home/normaluser# cat /etc/debian_version
3.1
wl500g-router:/home/normaluser#


How did I make this? How can this work?

Indeed, "cdebootstrap -amipsel sarge debian-distro http://ftp.de.debian.org/debian" creates a 100 megabyte filetree, and if you unpack the stuff it gets even worse. So I decided to delete all the 'useless' crap.

The first reduction technique is to remove the documentation from the root filesystem. They include the Perl .pod files and everything under the following directories:
/usr/doc
/usr/info
/usr/man
/usr/share/doc
/usr/share/info
/usr/share/man
Two others that should either be trimmed or eliminated are . . .
/usr/share/locale
/usr/share/zoneinfo
/usr/share/locale provides locale information, so that users can see the system in their own languages, currency formats, etc. /usr/share/zoneinfo provides timezone definitions, so that users can see local time and perform timezone conversions. Both of these could certainly be trimmed down -- a server which is going to be administered by a single person does not need locale information for languages that person does not speak; and a server which will be used in one place, and does not do complex time-related applications (e.g. calendaring) will never use more than one timezone definitions.

However, removing all of the documentation, the locale, and timezone information only reduces the size of the Debian root filesystem that much, so I also deleted a bunch of not-required libraries and packages. If you miss them, you can install them using apt-get(8).

I ended up using this packages list: debian-sarge-128mb-mipsel-packages.txt (http://masteen2.iiivx.net/wl500g/debian/debian-sarge-128mb-mipsel-packages.txt)

output of my df -h & free -m

root@wl500g-router:/# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/scsi/host0/bus0/target0/lun0/part1
112M 78M 29M 74% /
root@wl500g-router:/# free -m
total used free shared buffers cached
Mem: 13 12 1 0 0 5
-/+ buffers/cache: 6 7
Swap: 10 1 9
root@wl500g-router:/#

Oleg
25-04-2005, 17:45
Just to let you know: 1.9.2.7-4 includes ipv6 and has fdisk and e2fsprogs.
So, it's better to pack your image as tar.gz and include an info on partitioning disks to the how-to, as even 128MB flash drives could be different.

iiivx
25-04-2005, 17:59
Just to let you know: 1.9.2.7-4 includes ipv6 and has fdisk and e2fsprogs.
So, it's better to pack your image as tar.gz and include an info on partitioning disks to the how-to, as even 128MB flash drives could be different.

I am aware of the fact that this howto isn't capable of handling slightly different setups. As soon as I have time to test 1.9.2.7-4, I will update the howto and include information on partitioning the stick and tarball's.

rinco
07-06-2005, 13:41
Great stuff... but I have a conundrum.

I can see usbdevfs:

[admin@mouser root]$ ls /proc/bus/usb/
001 devices drivers

But usbdevfs doesn't seem to appear in the chrooted environment:

[admin@mouser admin]$ ls /tmp/harddisk/debian-distro/proc/bus/
pci usb
[admin@mouser admin]$ ls /tmp/harddisk/debian-distro/proc/bus/usb/
[admin@mouser admin]$

Do you have any suggestions as to how I can execute the Debian software
and access usbdevfs?

edit: someone on #wrt54g suggested -obind with mount, which seems to have done the trick.

iiivx
20-06-2005, 04:11
edit: someone on #wrt54g suggested -obind with mount, which seems to have done the trick.

Indeed, either way you can mount /proc and /dev from within the chrooted enviroment, or perform a binded mount. I'm glad you liked this :-)

Darkstar
20-06-2005, 13:58
Hi iiivx,
I am a bit lazy with cleaning, so I would like to take a 1024MB USB stick, but the cdebootstrap command failes with "E: Couldn't install root!" after extracting the last package. What is going wrong?

Darkstar.

iiivx
22-06-2005, 11:46
Hi iiivx,
I am a bit lazy with cleaning, so I would like to take a 1024MB USB stick, but the cdebootstrap command failes with "E: Couldn't install root!" after extracting the last package. What is going wrong?

Darkstar.

The cdebootstrap command is expected to fail, since you aren't bootstrapping on a mipsel machine. Thus it cannot execute the binaries it want's to execute. Read the tutorial on the wiki, it should help you enough to get something up and running.

Darkstar
23-06-2005, 13:24
Ok, got this. But I have another question: Is it possible to boot into the Debian distribution in order to start the desired services via the /etc/rcX.d/... framework?

Darkstar.

rdk
07-07-2005, 22:03
Unfortunately the wiki is not acessible right now?! I really would like to try the debian on the wl500g...
Do you still plan to post an image of debian without the partition table ? :o

What can you do exactly with it? Can in the chrooted environment thttpd and mysql be run? mysql seems to be avaible in debian mipsel package....

Thanks for your help.

Rainer

therealhunter
01-09-2005, 17:12
i have done everything the wy you explaind
but after i add this command
mount /dev/scsi/host0/bus0/target0/lun0/part1 /tmp/harddisk

i get this error

mount: mount point /tmp/harddisk does not exist


i don't know what i'm doin wrong,

i'm using olegs latest firmware version

thx hunter

Styno
02-09-2005, 09:34
Unfortunately the wiki is not acessible right now?! I really would like to try the debian on the wl500g...
Wiki is running fine here: http://wiki.wl500g.info/

Kleinertuerke
29-09-2005, 14:18
Hello
Thanks for the great tutorial. It worked fine for me.
But now i have a little problem:
after "apt-get update; apt-get dist-upgrade" i have very little space left for other packages. So is there a way to resize the image???
I use a 6GB Harddisk and Olegs Firmware 1.9.2.7-6b.

Styno
29-09-2005, 14:29
If you attach your USB device to a PC, you can use Partition Magic for that or otherwise Ranish Partition Manager.

Kleinertuerke
29-09-2005, 14:54
Hello
Thanks for your answer Styno. Partition Magic is telling me that the harddisk is defectiv :confused: and i cant do anything except creating a new partition.
iiivx wrote that the image includes a partiton table. Is there no easy way to change that?? I guess i should ask google ;)

molski
29-09-2005, 20:41
I installed Debian onto a 256MB USB disk, everything is working great.
The output of 'df -h' is as follows:

root@Asus:/# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/scsi/host0/bus0/target0/lun0/part1
112M 78M 29M 74% /
root@Asus:/#

What I understand from this is that only half of the size of my USB disk is used.
Is it possible to extend the size of this partition to use every available space that is still on the USB disk? If so, how can I do this?


Regards,

Molski

Styno
29-09-2005, 21:10
Molski, see my post 2 above yours.

Kleinentuerke, I have no idea....sorry.

nerodark
03-10-2005, 00:50
styno, i tried, partition magic and ranish partition manager, and both wouldn't detect my usb key (if they do it is really hard to find the option to show the partitions on my usb key)

i had the same problem than most of you: i have a 512MB usb key and when i tried to install debian on it, it created something like a 120MB partition (linux ext3) and a 15MB partition (linux swap2)

i recommend you use Paragon Partition Manager to do the following steps to resize the partition (you have to get the FULL VERSION ONLY to unlock limited features)

using paragon you will see something like (i will use this example during this little tutorial), it must look like this because the debian installation created this special partition table designed for a 128MB usb key:
[--------120MB(ext3)--------][---15MB(swap2)---][----------unallocated space(369MB)----------] = ~512MB

1- you will see there is a lot of free space after the swap partition, the first thing you would probably do, instinctively, is delete the swap partition (because you think it doesnt contain any data and wont hurt the debian installation), then resize the ext3 and recreate a swap space. well no, you must not do that.

2- first you have to play with the current swap space: set the free space after to 0MB and the free space before to 389MB (according to the example, still do it based on the size of your usb memory key). then resize the ext3 partition to the maximum allowed based on your unallocated free space.

[--------120MB(ext3)--------][----------unallocated space(369MB)----------][---15MB(swap2)---] = ~512MB

[------------------470MB(ext3)------------------][---15MB(swap2)---] = ~512MB

3- apply the changes, reboot your computer (if necessary), now you are safe to remove the usb key, plug it in your asus router, reboot your router to load, mount, and then you are good

NOTE: if Paragon Partition Manager tells you that it cannot proceed to apply the changes because the usb memory key is used by another program (in other words, it is already in used by Windows itself because it loaded the driver for it to be browsable), simply reboot your computer, do not unplug the usb key leave it in the slot, paragon will lauch the task to apply the changes before windows start loading his drivers

David
03-10-2005, 16:49
Did anybody tried QTParted ?

Available on Knoppix and SysRescueCd.

cadderly
15-10-2005, 16:55
Hi!
I had the same problem.
Solved it this way under RH:

1) Install the image on the USB-stick as described.
2) Open a terminal and make the following steps:

#Dump the image onto your harddisk
dd if=/dev/sda1 of=/path_where_to_store_dumpfile/file bs=512

#Run fdisk, delete all existing partitions, create resized partitions
#In my case 196Mb Linux and 32Mb Linux swap
#sda=usbdevice

fdisk /dev/sda

#copy back image

dd if=/path_where_to_store_dumpfile/file of=/dev/sda1 bs=512

# run e2fsck t check the partition

e2fsck -f /dev/sda1

#resize filesystem

resize2fs -p /dev/sda1

This worked fine for me.

Hope that helps
Cad

acidbao
30-12-2005, 15:04
Hello,

I tried the method in the wiki to install Debian.

But after i have the skeleton in /tmp/harddisk/debian-distro (i made it on a Debian PC with cdebootstrap).

When i do chroot /tmp/harddisk/debian-distro /bin/sh everything is ok
but after that any mount command give me the message "Illegal instruction"


[admin@routeur debian-distro]$ chroot . /bin/sh
[root@routeur /]$ mount -t proc none /proc
Illegal instruction
[root@routeur /]$

acidbao
01-01-2006, 19:09
Ok, i found all of my problems, my USB key was a data corruptor, so i changed it. And know everything works fine :cool:

I installed debian with cdebootstrap, and inside it i have only dropbear and samba installed so when i telnet the router i get in Oleg's Linux and when i ssh it i get in the debian realm.

The USB key is mounted in /opt in that example.

Here is my /usr/local/sbin/post-boot if it can help


#!/bin/sh
insmod scsi_mod && insmod sd_mod && insmod usb-storage
mount -t ext3 -o rw,noatime /dev/discs/disc0/part1 /opt
swapon /dev/discs/disc0/part2

if [ -d /opt/debian-distro ]; then
chroot /opt/debian-distro /etc/rc.asus
fi


And the /opt/debian-distro/etc/rc.asus that i made and chmodded a+x


#!/bin/sh

mount -t proc none /proc
mount -t devfs devfs /dev

invoke-rc.d rc 5


First it mounts the proc & dev and then it launch the installed services by switching to runlevel 5. That way everything is launched in a neat manner (even if it launches cron and inetd that i don't need).

If you run the script manually you would see somthing like this

Starting Dropbear SSH server: Starting internet superserver: inetd.
Starting Samba daemons: nmbd smbd.
Starting periodic command scheduler: cron.


And after 4 nights of searching i finally have samba 3.0.14 running on my WL500G Deluxe. :)

herskegut
21-04-2006, 14:02
Thanks to everyone inhere :) i finally got i working!!

Created my own cdebootstrap, and took it from there.. now the router is running web/php/mysql/samba server, and all is working perfectly! :D


:edit
Forgot to tell that it is running on a 512 mb usbkey, Not the fastest thing in the world.. but it get's the job done ;)