Version 4 (modified by stappers, 2 years ago) (diff)

CLI and sudo power check

This page walks through the DebWrt project in small steps. It is written with hands on in mind. What you need is a Debian GNU/Linux computer. Other hardware will be emulated.

Status: Work in Progress

Have a Command Line Interface. When you type

ls -ld /usr/src

you should see

drwxrwsr-x 27 root src 4096 dec  5 11:26 /usr/src

Check bash

echo $[4*6]

should print 24

Check if you are allowed to do sudo

sudo echo $[6*7]

should print 42

Using the sudo power

stappers@inertia:~
$ echo ${LOGNAME} # print user name
stappers
stappers@inertia:~
$ LANG=C sudo delgroup ${LOGNAME} src
Removing user `stappers' from group `src' ...
Done.
stappers@inertia:~
$ LANG=C sudo delgroup ${LOGNAME} src
/usr/sbin/delgroup: The user `stappers' is not a member of group `src'.
stappers@inertia:~
$ LANG=C sudo addgroup ${LOGNAME} src
Adding user `stappers' to group `src' ...
Adding user stappers to group src
Done.
stappers@inertia:~
$ LANG=C sudo addgroup ${LOGNAME} src
The user `stappers' is already a member of `src'.
stappers@inertia:~
$ 

Now is is user ${LOGNAME} allowed to write in the directory /usr/src

which qemu-system-mipsel buy hardware

sudo aptitude install qemu

which qemu-system-mipsel

Debian kernel for test drive

cd ~
mkdir testdrive
cd testdrive
wget http linux-image_version-mipsel.deb
dpkg -x linux-image*deb .
qemu-system-mipsel -M malta -nographic -kernet boot/vmlinux-TAB

Should see lines like

PCI: Enabling device 0000:00:0a.1 (0000 -> 0001)
scsi0 : ata_piix
scsi1 : ata_piix
ata1: PATA max UDMA/33 cmd 0x1f0 ctl 0x3f6 bmdma 0x1040 irq 14
ata2: PATA max UDMA/33 cmd 0x170 ctl 0x376 bmdma 0x1048 irq 15
physmap platform flash device: 00400000 at 1e000000
physmap-flash physmap-flash.0: map_probe failed
pcnet32: pcnet32.c:v1.35 21.Apr.2008 tsbogend@alpha.franken.de
PCI: Enabling device 0000:00:0b.0 (0000 -> 0003)
pcnet32: PCnet/PCI II 79C970A at 0x1020, 52:54:00:12:34:56 assigned IRQ 10
pcnet32: eth0: registered as PCnet/PCI II 79C970A
pcnet32: 1 cards_found

Now you known:

  • Serial port works
  • IDE Controller is seen as a SCSI device
  • Network Interface Card is detected

That kernel did serve it's purpose.

cd ~ ; rm -rf testdrive/  # to cleanup
which svn

Should report /usr/bin/svn, otherwise sudo aptitude install subversion.

Go to the directory where the DebWrt source should go

cd /usr/src

That place is the linux kernel source. Another good reason for not under /home, it that there will be pathnames without username in further bugreports.

Now download debwrt by

svn checkout http://www.debwrt.net/repos/debwrt/trunk debwrt

You might see output like

A    debwrt/openwrt/openwrt-deliver.mk
 U   debwrt
Checked out revision 140.

You have a new directoy, please enter it by

cd debwrt

A ls will show

config  Config.in  debian  LICENSE  Makefile  openwrt  README  rules

The next step is a quatum leap, visit and read WORKinPROGRESS

Welcome back!

You are about to build debwrt, and you need build dependencies.

sudo aptitude install  build-essential libncurses5-dev

The next step is starting the build process. The command is

make

Give your build host time to do much work, including several source downloads.

A succesfull build finishes with

show board FIXME

Find kernel

file build_dir/asdfaddf/FIXME/vmlinux

should report

mipsel kernel FIXME

Testdrive your new kernel

You should see these devices

DISK

Now we gonna create a disk

dd if=/dev/zero of=/usr/src/debwrt/tile bs=1M count=2048

you get output like

2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 26.1691 s, 82.1 MB/s

and now have a file that has the size of two gigabyte

Swap space 128Megabyte

echo $[2048-128]

shows 1920

Next you need fdisk that uses libparted

sudo fdisk -v

should show something like

GNU Fdisk 1.2.4

We will run fdisk to partition our disk. These commands / keystrokes where used:

sudo fdisk /usr/src/debwrt/tile
u
n
p

+1920MB
p
n
p


t
2
82
w

to see this:

GNU Fdisk 1.2.4
Copyright (C) 1998 - 2006 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.
  
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
  
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Using /usr/src/debwrt/tile
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): n
Partition type
   e   extended
   p   primary partition (1-4)
p
First sector  (default 32s):
Last sector or +size or +sizeMB or +sizeKB  (default 4194303s): +1920MB
Command (m for help): n
Partition type
   e   extended
   p   primary partition (1-4)
p
First sector  (default 3750016s):
Last sector or +size or +sizeMB or +sizeKB  (default 4194303s):
Command (m for help): t
Partition number (1-2): 2
Hex code (type L to list codes): 82
Changed type of partition 2 to 82 (Linux swap)
Command (m for help): w

Writing all changes to /usr/src/debwrt/tile

Listing the partition table with fdisk -l /usr/src/debwrt/tile will show

Disk /usr/src/debwrt/tile: 2 GB, 2147483648 bytes
4 heads, 32 sectors/track, 32768 cylinders
Units = cylinders of 128 * 512 = 65536 bytes

               Device Boot      Start         End      Blocks   Id  System 
/usr/src/debwrt/tile1               1       29297     1874992   83  Linux
/usr/src/debwrt/tile2           29298       32768      222080   82  Linux swap

Listing the partition table in sectors with fdisk -lu /usr/src/debwrt/tile will show

Disk /usr/src/debwrt/tile: 2 GB, 2147483648 bytes
4 heads, 32 sectors/track, 32768 cylinders, total 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes

               Device Boot      Start         End      Blocks   Id  System 
/usr/src/debwrt/tile1              32     3750015     1874992   83  Linux
/usr/src/debwrt/tile2         3750016     4194303      222080   82  Linux swap

To be continued (by stappers)