OpenWRT-UML-Netkit

Notes on OpenWRT UML + Netkit

The goal of this guide is to use Netkit with OpenWRT hosts in the emulated environment.

http://wiki.netkit.org/index.php/Main_Page

UML binaries are built with the host toolchain and are meant to run on the host they were built on.

We used a Gentoo machine amd64 profile (64bit processor)

Create OpenWRT UML images

Download and compile OpenWRT for the UML target (tested at 9/12/2009 revision 18717)

svn co svn://svn.openwrt.org/openwrt/trunk/
cd trunk
make menuconfig

select the UML target and compile

we are using the following CHOST x86_64-pc-linux-gnu-4.3.4

we had a problem with some script looking for a lib64 dir that was not existing, solved like this:

cd $trunk_dir$/staging_dir/toolchain-x86_64_gcc-4.1.2_uClibc-0.9.30.1/
ln -s lib lib64

if the firmware compiles you have the binaries in $trunk_dir$/bin/uml

Test the UML binary

To test if your UML binary boots just use the guide from zoobab http://www.zoobab.com/openwrt-and-user-mode-linux

Integrate in Netkit

Launch in Netkit like this:

cd bin/uml
vstart openwrt --eth0=0 --con0=xterm --con1=xterm --verbose -m openwrt-uml-ext2.img -k ./openwrt-uml-vmlinux

also you may need extra Kernel command line options:

--append=root=98:0 --append=init=/etc/preinit

You will have a OpenWRT machine launched within Netkit, but only the second terminal is properly working for now, adjust inittab (see later)

Remount Read Write

To remount the filesystem readwrite

mount --remount -o rw /dev/root /

Adjust inittab

Original /etc/inittab in OpenWRT looks like this:

root@OpenWrt:/# cat /etc/init
/etc/init.d/  /etc/inittab
root@OpenWrt:/# cat /etc/inittab 
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K stop
tts/0::askfirst:/bin/ash --login
tty1::askfirst:/bin/ash --login
root@OpenWrt:/# 

modify like this:

root@OpenWrt:/# cat /etc/inittab 
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K stop
tty0::askfirst:/bin/ash --login
tty1::askfirst:/bin/ash --login
root@OpenWrt:/#

Everything in a patch

saverio@nordkapp ~/SORGENTI/openwrt-trunk-UML $ svn diff
Index: package/base-files/files/etc/inittab
===================================================================
--- package/base-files/files/etc/inittab        (revisione 18727)
+++ package/base-files/files/etc/inittab        (copia locale)
@@ -1,5 +1,4 @@
 ::sysinit:/etc/init.d/rcS S boot
 ::shutdown:/etc/init.d/rcS K stop
-tts/0::askfirst:/bin/ash --login
-ttyS0::askfirst:/bin/ash --login
+tty0::askfirst:/bin/ash --login
 tty1::askfirst:/bin/ash --login
Index: package/base-files/files/etc/config/network
===================================================================
--- package/base-files/files/etc/config/network (revisione 18727)
+++ package/base-files/files/etc/config/network (copia locale)
@@ -8,7 +8,7 @@
 
 config interface lan
        option ifname   eth0
-       option type     bridge
+       #option type    bridge
        option proto    static
        option ipaddr   192.168.1.1
        option netmask  255.255.255.0
saverio@nordkapp ~/SORGENTI/openwrt-trunk-UML $

Notes on netkit labs

lstart --verbose -o --append=root=98:0 -o --append=init=/etc/preinit
l'ultima modifica รจ del 2013-04-12 14:24:02, fatta da 151