* Networking now works in the UML machine. Masquerading for the tun

device should be enabled on the host in order for the UML machine to
  be able to talk to the Internet.

svn path=/nixu/trunk/; revision=806
This commit is contained in:
Eelco Dolstra 2004-02-19 12:49:00 +00:00
parent 3514c5658b
commit 91a5fe9eb0
9 changed files with 43 additions and 13 deletions

View file

@ -1,6 +1,6 @@
#! @bash@/bin/sh -e
export PATH=@nix@/bin:@bash@/bin:@coreutils@/bin:@findutils@/bin:@utillinux@/bin:@utillinux@/sbin:@sysvinit@/bin:@sysvinit@/sbin:@e2fsprogs@/bin:@e2fsprogs@/sbin
. @out@/bin/env.sh
echo "--- Nix ---"
@ -16,4 +16,16 @@ mount -n -o remount,rw /dev/root /
echo "mounting /mnt/host..."
mount -n -t hostfs none /mnt/host
echo "setting up hostname..."
hostname uml
echo "enabling loopback interface..."
ifconfig lo 127.0.0.1
echo "enabling ethernet interface..."
ifconfig eth0 $(cat /etc/networking/local-ip) up
echo "setting up routing table..."
route add default gw $(cat /etc/networking/gateway-ip)
echo "boot done."

View file

@ -5,7 +5,7 @@
mkdir $out
mkdir $out/bin
for i in $boot $halt $login; do
for i in $boot $halt $login $env; do
dst=$out/bin/$(basename $i | cut -c34-)
sed \
-e "s^@bash\@^$bash^g" \
@ -14,7 +14,9 @@ for i in $boot $halt $login; do
-e "s^@utillinux\@^$utillinux^g" \
-e "s^@sysvinit\@^$sysvinit^g" \
-e "s^@e2fsprogs\@^$e2fsprogs^g" \
-e "s^@nettools\@^$nettools^g" \
-e "s^@nix\@^$nix^g" \
-e "s^@out\@^$out^g" \
< $i > $dst
chmod +x $dst
done
done

View file

@ -1,4 +1,5 @@
{stdenv, bash, coreutils, findutils, utillinux, sysvinit, e2fsprogs, nix}:
{ stdenv, bash, coreutils, findutils, utillinux, sysvinit, e2fsprogs
, nettools, nix}:
derivation {
name = "boot";
@ -7,5 +8,7 @@ derivation {
boot = ./boot.sh;
halt = ./halt.sh;
login = ./login.sh;
inherit stdenv bash coreutils findutils utillinux sysvinit e2fsprogs nix;
env = ./env.sh;
inherit stdenv bash coreutils findutils utillinux sysvinit
e2fsprogs nettools nix;
}

1
boot/env.sh Normal file
View file

@ -0,0 +1 @@
export PATH=@nix@/bin:@bash@/bin:@coreutils@/bin:@findutils@/bin:@utillinux@/bin:@utillinux@/sbin:@sysvinit@/bin:@sysvinit@/sbin:@e2fsprogs@/bin:@e2fsprogs@/sbin:@nettools@/bin:@nettools@/sbin:

View file

@ -1,6 +1,6 @@
#! @bash@/bin/sh -e
export PATH=@nix@/bin:@bash@/bin:@coreutils@/bin:@findutils@/bin:@utillinux@/bin:@utillinux@/sbin:@sysvinit@/bin:@sysvinit@/sbin:@e2fsprogs@/bin:@e2fsprogs@/sbin
. @out@/bin/env.sh
echo "remounting / read-only..."
mount -n -o remount,rw /dev/root / || echo "(failed)" # ignore errors

View file

@ -1,11 +1,11 @@
#! @bash@/bin/sh -e
. @out@/bin/env.sh
tty=$1
exec < $tty > $tty 2>&1
export PATH=@nix@/bin:@bash@/bin:@coreutils@/bin:@findutils@/bin:@utillinux@/bin:@utillinux@/sbin:@sysvinit@/bin:@sysvinit@/sbin:@e2fsprogs@/bin:@e2fsprogs@/sbin
echo
echo "=== Welcome to Nix! ==="

View file

@ -69,7 +69,16 @@ echo "id:2:initdefault:" >> $root/etc/inittab
echo "si::bootwait:$bootPath/bin/boot.sh" >> $root/etc/inittab
echo "ht:06:wait:$bootPath/bin/halt.sh" >> $root/etc/inittab
echo "1:2345:respawn:$bootPath/bin/login.sh /dev/ttys/0" >> $root/etc/inittab
echo "2:2345:respawn:$bootPath/bin/login.sh /dev/ttys/1" >> $root/etc/inittab
#echo "2:2345:respawn:$bootPath/bin/login.sh /dev/ttys/1" >> $root/etc/inittab
echo setting up networking information...
make_dir 00755 /etc/networking
echo 192.168.150.1 > $root/etc/networking/local-ip
echo 192.168.150.3 > $root/etc/networking/gateway-ip
cp /etc/resolv.conf $root/etc
rm -f $root/etc/hosts
echo "127.0.0.1 localhost" >> $root/etc/hosts
echo "192.168.150.1 uml" >> $root/etc/hosts
echo unmounting...
umount $root

View file

@ -1,9 +1,10 @@
rec {
inherit (import pkgs/system/i686-linux.nix)
stdenv bash coreutils findutils utillinux sysvinit e2fsprogs nix;
stdenv bash coreutils findutils utillinux sysvinit e2fsprogs
nettools nix;
boot = (import ./boot)
{inherit stdenv bash coreutils findutils utillinux sysvinit e2fsprogs nix;};
boot = (import ./boot) {inherit stdenv bash coreutils findutils
utillinux sysvinit e2fsprogs nettools nix;};
everything = [boot sysvinit];
}

4
run.sh
View file

@ -2,4 +2,6 @@
image=/tmp/disk.img
linux ubd0="$image" mem=256M init="/init"
linux ubd0="$image" mem=256M \
eth0=tuntap,tap4,,192.168.150.1 \
init="/init"