GentooQEMUBuildBox

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(New page: == Read first == Gentoo, http://www.gentoo.org/doc/en/handbook/handbook-arm.xml == Needed things == *unpatched QEMU from any normal distro *Gentoo stage: http://torindel.sezamkowa.n...)
 
(Advanced setup)
 
(6 intermediate revisions by 3 users not shown)
Line 21: Line 21:
 
mkfs.ext2 /dev/loop0
 
mkfs.ext2 /dev/loop0
 
mount /dev/loop0 /mnt
 
mount /dev/loop0 /mnt
tar -xjpf /media/card/stage3-armv4tl-*.tar.bz2 -C /media/card
+
tar -xjpf stage3-armv4tl-*.tar.bz2 -C /mnt
tar -xjpf /media/card/portage-*.tar.bz2 -C /media/card/usr
+
tar -xjpf portage-*.tar.bz2 -C /mnt/usr
 
umount /mnt
 
umount /mnt
 
mkswap qemuarm-0.swapfs
 
mkswap qemuarm-0.swapfs
Line 42: Line 42:
  
 
qemu-system-arm -kernel $KERNEL -net nic,vlan=0 -net tap,vlan=0,ifname=tap$NUMBER,script=$CURDIR/qemu-ifup-$NUMBER,downscript=$CURDIR/qemu-ifdown-$NUMBER \
 
qemu-system-arm -kernel $KERNEL -net nic,vlan=0 -net tap,vlan=0,ifname=tap$NUMBER,script=$CURDIR/qemu-ifup-$NUMBER,downscript=$CURDIR/qemu-ifdown-$NUMBER \
     -M versatilepb -hda $ROOTFS -hdb $SWAPFS -hdd $PORTAGEFS -no-reboot -m 256 -show-cursor -serial stdio -parallel none \
+
     -M versatilepb -hda $ROOTFS -hdb $SWAPFS -no-reboot -m 256 -show-cursor -serial stdio -parallel none \
 
     -monitor unix:"$QEMU_MONITOR",server,nowait -nographic \
 
     -monitor unix:"$QEMU_MONITOR",server,nowait -nographic \
 
     --append root=/dev/sda\ console=ttyAMA0\ ip=192.168.$NUMBER.10::192.168.$NUMBER.1:255.255.255.0\ mem=256M\ quiet
 
     --append root=/dev/sda\ console=ttyAMA0\ ip=192.168.$NUMBER.10::192.168.$NUMBER.1:255.255.255.0\ mem=256M\ quiet
Line 68: Line 68:
 
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.1.0/24
 
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.1.0/24
 
</pre>
 
</pre>
 +
 +
 +
== Alternative nfs rootfs ==
 +
 +
*Setup nfs server on localhost
 +
*Unpack stage/portage
 +
<pre>
 +
tar -xjpf stage3-armv4tl-*.tar.bz2 -C NFSPATH
 +
tar -xjpf portage-*.tar.bz2 -C NFSPATH/usr
 +
</pre>
 +
*Make swap patition
 +
*Replace "root=/dev/sda" with "root=/dev/nfs nfsroot=192.168.1.1:NFSPATH rw" and remove "-hda $ROOTFS" in run-qemu-1
  
  
Line 74: Line 86:
 
*Add "\ init=/bin/bash" to the end of run-qemu-1 just after quiet to get bash to do initial setup and run it
 
*Add "\ init=/bin/bash" to the end of run-qemu-1 just after quiet to get bash to do initial setup and run it
 
*<pre>mount -n -o remount,rw /</pre>
 
*<pre>mount -n -o remount,rw /</pre>
 +
*<pre>source /etc/profiles; env-update</pre>
 
*do setup things described in [[Gentoo]]
 
*do setup things described in [[Gentoo]]
 
*<pre>mknod /dev/ttyAMA0 c 204 64</pre>
 
*<pre>mknod /dev/ttyAMA0 c 204 64</pre>
Line 80: Line 93:
 
*emerge ntp (use binaries)
 
*emerge ntp (use binaries)
 
*setup /etc/resolv.conf and /etc/conf.d/net corectly (useing 192.168.1.10 as local ip and 192.168.1.1 as default route)
 
*setup /etc/resolv.conf and /etc/conf.d/net corectly (useing 192.168.1.10 as local ip and 192.168.1.1 as default route)
*add ntpdate ntp.task.gda.pl at the begining of start() in /etc/init,d/fsck
+
*add ntpdate ntp.task.gda.pl at the begining of start() in /etc/init,d/fsck to ensure correct date at boot (no rtc clock support in that kernel image)
 
*<pre>mkdir -p /lib/modules/2.6.23</pre>
 
*<pre>mkdir -p /lib/modules/2.6.23</pre>
 
*<pre>touch /lib/modules/2.6.23/modules.dep</pre>
 
*<pre>touch /lib/modules/2.6.23/modules.dep</pre>
Line 89: Line 102:
 
*Remove "\ init=/bin/bash" from run-qemu-1
 
*Remove "\ init=/bin/bash" from run-qemu-1
 
*Run run-qemu-1 / fix things if needed
 
*Run run-qemu-1 / fix things if needed
 +
 +
 +
== Advanced setup ==
 +
 +
* emerge distcc on qemu and localhost
 +
* install cross armv4tl-softfloat-linux-gnueabi toolchain on localhost (same versions as on gentoo image)
 +
* setup distcc specifying only localhost on emulated system
 +
* modify PATH in profile specifying /usr/lib/distcc/bin as first element so only preprocessing is done in qemu and all compilation on localhost
 +
 +
(instead of modifying the profile, just add a .sh file in /etc/profile.d that re-exports path. This will get sourced at the end of /etc/profile) --[[User:Trickie|Trickie]] 09:34, 23 October 2008 (UTC)
 +
 +
[[Category:Emulation]]

Latest revision as of 10:34, 23 October 2008

Contents

[edit] Read first

Gentoo, http://www.gentoo.org/doc/en/handbook/handbook-arm.xml


[edit] Needed things


[edit] Seting up with local hdd image

dd if=/dev/zero of=qemuarm-0.rootfs.ext2 count=16777216
dd if=/dev/zero of=qemuarm-0.swapfs count=524288
losetup -f qemuarm-0.rootfs.ext2
mkfs.ext2 /dev/loop0
mount /dev/loop0 /mnt
tar -xjpf stage3-armv4tl-*.tar.bz2 -C /mnt
tar -xjpf portage-*.tar.bz2 -C /mnt/usr
umount /mnt
mkswap qemuarm-0.swapfs


[edit] QEMU run scripts for local hdd image

run-qemu-1:

#!/bin/bash

CURDIR="/somedirwithqemuscriptsandrootfsimage"
NUMBER=1

KERNEL="$CURDIR/zImage-2.6.23-pinky-3.1-qemuarm.bin"
ROOTFS="$CURDIR/qemuarm-$NUMBER.gentoo.ext2"
SWAPFS="$CURDIR/qemuarm-$NUMBER.swapfs"

qemu-system-arm -kernel $KERNEL -net nic,vlan=0 -net tap,vlan=0,ifname=tap$NUMBER,script=$CURDIR/qemu-ifup-$NUMBER,downscript=$CURDIR/qemu-ifdown-$NUMBER \
    -M versatilepb -hda $ROOTFS -hdb $SWAPFS -no-reboot -m 256 -show-cursor -serial stdio -parallel none \
    -monitor unix:"$QEMU_MONITOR",server,nowait -nographic \
    --append root=/dev/sda\ console=ttyAMA0\ ip=192.168.$NUMBER.10::192.168.$NUMBER.1:255.255.255.0\ mem=256M\ quiet

qemu-ifup-1:

#!/bin/sh

/sbin/ifconfig tap1 192.168.1.1
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -I INPUT 1 -s 192.168.1.10 -j ACCEPT
/sbin/iptables -I OUTPUT 1 -s 192.168.1.1 -j ACCEPT
/sbin/iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.1.0/24

qemu-ifdown-1:

#!/bin/sh

/sbin/ifconfig tap1 down
echo 0 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -D INPUT -s 192.168.1.10 -j ACCEPT
/sbin/iptables -D OUTPUT -s 192.168.1.1 -j ACCEPT
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.1.0/24


[edit] Alternative nfs rootfs

  • Setup nfs server on localhost
  • Unpack stage/portage
tar -xjpf stage3-armv4tl-*.tar.bz2 -C NFSPATH
tar -xjpf portage-*.tar.bz2 -C NFSPATH/usr
  • Make swap patition
  • Replace "root=/dev/sda" with "root=/dev/nfs nfsroot=192.168.1.1:NFSPATH rw" and remove "-hda $ROOTFS" in run-qemu-1


[edit] First boot

  • Add "\ init=/bin/bash" to the end of run-qemu-1 just after quiet to get bash to do initial setup and run it
  • mount -n -o remount,rw /
  • source /etc/profiles; env-update
  • do setup things described in Gentoo
  • mknod /dev/ttyAMA0 c 204 64
  • edit /etc/inittab unhashing s0 and changeing it to ttyAMA0
  • add ttyAMA0 to /etc/securetty
  • emerge ntp (use binaries)
  • setup /etc/resolv.conf and /etc/conf.d/net corectly (useing 192.168.1.10 as local ip and 192.168.1.1 as default route)
  • add ntpdate ntp.task.gda.pl at the begining of start() in /etc/init,d/fsck to ensure correct date at boot (no rtc clock support in that kernel image)
  • mkdir -p /lib/modules/2.6.23
  • touch /lib/modules/2.6.23/modules.dep
  • sync
  • mount -n -o remount,ro /
  • init 0
  • Use ctrl+a ctrl+x to turn off qemu
  • Remove "\ init=/bin/bash" from run-qemu-1
  • Run run-qemu-1 / fix things if needed


[edit] Advanced setup

  • emerge distcc on qemu and localhost
  • install cross armv4tl-softfloat-linux-gnueabi toolchain on localhost (same versions as on gentoo image)
  • setup distcc specifying only localhost on emulated system
  • modify PATH in profile specifying /usr/lib/distcc/bin as first element so only preprocessing is done in qemu and all compilation on localhost

(instead of modifying the profile, just add a .sh file in /etc/profile.d that re-exports path. This will get sourced at the end of /etc/profile) --Trickie 09:34, 23 October 2008 (UTC)

Personal tools

Read first

Gentoo, http://www.gentoo.org/doc/en/handbook/handbook-arm.xml


Needed things


Seting up with local hdd image

dd if=/dev/zero of=qemuarm-0.rootfs.ext2 count=16777216
dd if=/dev/zero of=qemuarm-0.swapfs count=524288
losetup -f qemuarm-0.rootfs.ext2
mkfs.ext2 /dev/loop0
mount /dev/loop0 /mnt
tar -xjpf /media/card/stage3-armv4tl-*.tar.bz2 -C /media/card
tar -xjpf /media/card/portage-*.tar.bz2 -C /media/card/usr
umount /mnt
mkswap qemuarm-0.swapfs


QEMU run scripts for local hdd image

run-qemu-1:

#!/bin/bash

CURDIR="/somedirwithqemuscriptsandrootfsimage"
NUMBER=1

KERNEL="$CURDIR/zImage-2.6.23-pinky-3.1-qemuarm.bin"
ROOTFS="$CURDIR/qemuarm-$NUMBER.gentoo.ext2"
SWAPFS="$CURDIR/qemuarm-$NUMBER.swapfs"

qemu-system-arm -kernel $KERNEL -net nic,vlan=0 -net tap,vlan=0,ifname=tap$NUMBER,script=$CURDIR/qemu-ifup-$NUMBER,downscript=$CURDIR/qemu-ifdown-$NUMBER \
    -M versatilepb -hda $ROOTFS -hdb $SWAPFS -hdd $PORTAGEFS -no-reboot -m 256 -show-cursor -serial stdio -parallel none \
    -monitor unix:"$QEMU_MONITOR",server,nowait -nographic \
    --append root=/dev/sda\ console=ttyAMA0\ ip=192.168.$NUMBER.10::192.168.$NUMBER.1:255.255.255.0\ mem=256M\ quiet

qemu-ifup-1:

#!/bin/sh

/sbin/ifconfig tap1 192.168.1.1
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -I INPUT 1 -s 192.168.1.10 -j ACCEPT
/sbin/iptables -I OUTPUT 1 -s 192.168.1.1 -j ACCEPT
/sbin/iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.1.0/24

qemu-ifdown-1:

#!/bin/sh

/sbin/ifconfig tap1 down
echo 0 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -D INPUT -s 192.168.1.10 -j ACCEPT
/sbin/iptables -D OUTPUT -s 192.168.1.1 -j ACCEPT
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.1.0/24


First boot

  • Add "\ init=/bin/bash" to the end of run-qemu-1 just after quiet to get bash to do initial setup and run it
  • mount -n -o remount,rw /
  • do setup things described in Gentoo
  • mknod /dev/ttyAMA0 c 204 64
  • edit /etc/inittab unhashing s0 and changeing it to ttyAMA0
  • add ttyAMA0 to /etc/securetty
  • emerge ntp (use binaries)
  • setup /etc/resolv.conf and /etc/conf.d/net corectly (useing 192.168.1.10 as local ip and 192.168.1.1 as default route)
  • add ntpdate ntp.task.gda.pl at the begining of start() in /etc/init,d/fsck
  • mkdir -p /lib/modules/2.6.23
  • touch /lib/modules/2.6.23/modules.dep
  • sync
  • mount -n -o remount,ro /
  • init 0
  • Use ctrl+a ctrl+x to turn off qemu
  • Remove "\ init=/bin/bash" from run-qemu-1
  • Run run-qemu-1 / fix things if needed