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

prepare disk for recieving data

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

Emulated hardware

buy hardware

sudo aptitude install qemu

When you now do

which qemu-system-mipsel

you should see

/usr/bin/qemu-system-mipsel

Debian kernel for test drive

cd ~
mkdir testdrive
cd testdrive
wget http://ftp.nl.debian.org/debian/pool/main/l/linux-2.6/linux-image-2.6.32-5-4kc-malta_2.6.32-29_mipsel.deb
dpkg -x linux-image*deb .
file boot/vmlinux*

that last line should show something like

boot/vmlinux-2.6.32-5-4kc-malta: ELF 32-bit LSB executable, \
 MIPS, MIPS32 version 1 (SYSV), statically linked, \
 with unknown capability 0xf41 = 0x756e6700, not stripped

The actual start

qemu-system-mipsel -M malta -nographic -kernel boot/vmlinux-2.6.32-5-4kc-malta

Should see lines like

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

Now you known:

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

To stop qemu-system-mipsel do in another terminal

kill -HUP $( ps -ef | awk '$8 ~ /qemu-.*-mipsel/ { print $2 }' )

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

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

sudo aptitude install  build-essential libncurses5-dev

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

Welcome back!

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.

Several minutes later ( expect a half hour)

A succesfull build finishes with

FIXME

Typing

make board

should report

Board    : malta
Sub-Board: le_Default

Find kernel

file build/openwrt-malta-le_Default-trunk-default/build_dir/linux-malta_le/vmlinux.elf

should report

build/openwrt-malta-le_Default-trunk-default/build_dir/linux-malta_le/vmlinux.elf: \
 ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), statically linked, \
 with unknown capability 0xf41 = 0x756e6700, stripped

Testdrive your new kernel

qemu-system-mipsel -M malta -nographic -kernel \
 build/openwrt-malta-le_Default-trunk-default/build_dir/linux-malta_le/vmlinux.elf

You should see these devices

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

To stop qemu-system-mipsel do in another terminal

kill -HUP $( ps -ef | awk '$8 ~ /qemu-.*-mipsel/ { print $2 }' )

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

Further preparation of our virtual disk. It uses loop device technique.

For the swap partition

sudo losetup --find --show --offset $[3750016*512] tile

may show

/dev/loop6

where the 6 is more likely to be 0

sudo mkswap /dev/loop6

gives

Setting up swapspace version 1, size = 227471 kB
no label, UUID=a31d5609-3a58-4c26-8078-4c7641e3d7df
sudo losetup --detach /dev/loop6

For the data partition

sudo losetup --find --show --offset $[32*512] tile

may show

/dev/loop6

where the 6 is more likely to be 0

LANG=C sudo mkfs -t ext3 /dev/loop6 1874992

gives

mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
117360 inodes, 468748 blocks
23437 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=482344960
15 block groups
32768 blocks per group, 32768 fragments per group
7824 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
sudo tune2fs -c 0 -i 0 /dev/loop6

gives

tune2fs 1.41.3 (12-Oct-2008)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds
sudo mkdir -p /mnt/target
sudo mount /dev/loop6 /mnt/target
df /mnt/target

gives

/dev/loop6             1845484     35564   1716172   3% /mnt/target

To be continued (by stappers)