QEMU evaluation

Hans Bezemer thebeez at xs4all.nl
Thu Sep 13 13:43:07 EDT 2012


Hi!

As you've seen, I came pretty far with my hack. Now I've rolled back several 
changes in order to achieve the minimal amount of work one needs to do on a 
vanilla rootfs in order to make it run in QEMU.

One can put the changes into three categories:
- Changes to rc.d and inittab;
- Changes to uci-defaults;
- Missing devices, directories and files.

NOTE THAT THE FILE BELOW HAS NOT BEEN PROPERLY TESTED YET!
*** USE AT YOUR OWN RISK ***

Most issues are resolved, although a few remain:
- the kernel boots in console, which pretty much hinders every program that 
requires a true tty (including busybox, seems to be kernel related);
- no sound and no networking
- not all programs work (e.g. nupdf) or garble the shell (stty sane)

I will repeat the procedure with the next release of Ben/OpenWRT to iron out 
any bugs.

Hans Bezemer

---8<---
#!/bin/sh
set -x

PROGNAME=`basename $0`
ROOTDIR=$1

if [ -z $ROOTDIR ]; then
   echo "Cannot apply changes to your root directory!"
   exit 1
fi

# Make devices.

mknod -m 0600 "$ROOTDIR/dev/console"  c 5 1
mknod -m 0660 "$ROOTDIR/dev/full"     c 1 7
mknod -m 0640 "$ROOTDIR/dev/kmem"     c 1 2
mknod -m 0660 "$ROOTDIR/dev/loop0"    b 7 0
mknod -m 0640 "$ROOTDIR/dev/mem"      c 1 1
mknod -m 0666 "$ROOTDIR/dev/null"     c 1 3
mknod -m 0640 "$ROOTDIR/dev/port"     c 1 4
mknod -m 0666 "$ROOTDIR/dev/random"   c 1 8
mknod -m 0660 "$ROOTDIR/dev/tty"      c 5 0
mknod -m 0666 "$ROOTDIR/dev/urandom"  c 1 9
mknod -m 0666 "$ROOTDIR/dev/zero"     c 1 5
mknod -m 0666 "$ROOTDIR/dev/fb0"      c 29 0
mknod -m 0666 "$ROOTDIR/dev/sda"      b 8 0
mknod -m 0666 "$ROOTDIR/dev/sda1"     b 8 1

# This may fail, depending on your system
ln -s /proc/kcore "$ROOTDIR/dev/core"
ln -s /dev/ram1 "$ROOTDIR/dev/ram"
ln -s /dev/sda1 "$ROOTDIR/dev/root"

for N in `seq 0 5` ; do
    mknod -m 0660 "$ROOTDIR/dev/tty$N" c 4 $N
done

for N in `seq 0 15` ; do
    mknod -m 0660 "$ROOTDIR/dev/ram$N" b 1 $N
done

mkdir "$ROOTDIR/sys/kernel"
mkdir "$ROOTDIR/sys/kernel/debug"

mv "$ROOTDIR/etc/inittab" mv "$ROOTDIR/etc/inittab.org"

cat << 'EOF' > "$ROOTDIR/etc/inittab"
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K stop
::askfirst:/bin/sh
EOF

cat << 'EOF' > "$ROOTDIR/etc/init.d/qemu"
#!/bin/sh
mount -t proc none /proc

if [ -f /var/run/dbus.pid ]; then
   rm /var/run/dbus.pid
fi

setfont /usr/share/kbd/consolefonts/kernel-6x11-font
EOF

cd "$ROOTDIR/etc/rc.d"
ln -s ../init.d/qemu S09qemu
rm K01ben-nanonote
rm S01ben-nanonote
rm S93triggerhappy
cd -

cat << 'EOF' > "$ROOTDIR/etc/uci-defaults/01-optimization-for-ben-nanonote"
#!/bin/sh

# no need in NanoNote
/etc/init.d/atd disable
/etc/init.d/led disable
/etc/init.d/telnet disable

# generate fontconfig cache
/usr/bin/fc-cache

exit 0
EOF

cat << 'EOF' > "$ROOTDIR/etc/uci-defaults/99-set-time"
#!/bin/sh 
date --set 201207072133
EOF
---8<---

Hans Bezemer

-- 
Absolutely no trees were killed to produce this sig. Well, OK, we had to tie 
one up and torture it. That's it.

Visit our website! http://thebeez.home.xs4all.nl/4tH/

*** Home of the 4tH compiler! ***




More information about the discussion mailing list


interactive