--- UserModeLinux-HOWTO.sgml.0.0.5 Sat Mar 4 00:51:53 2000 +++ UserModeLinux-HOWTO.sgml Sun Mar 12 20:41:01 2000 @@ -8,8 +8,8 @@ User Mode Linux HOWTO -<author>User Mode Linux Core Team -<date>v0.0.5, Sat Mar 4 00:44:00 EST 2000 +<author>User Mode Linux Core Team with the odd contribution from William Stearns +<date>v0.0.6, Sun Mar 12 19:47:00 EST 2000 <abstract> This document describes the use and abuse of Jeff Dike's User Mode Kernel: a port of the Linux kernel as a normal Intel Linux process. @@ -145,7 +145,7 @@ <p> Compiling the user mode kernel is just like compiling any other -kernel. Let's go through the steps, using 2.3.48 (current as of this +kernel. Let's go through the steps, using 2.3.51 (current as of this writing) as an example: <enum> @@ -155,19 +155,19 @@ <url url="http://sourceforge.net/project/filelist.php?group_id=429" name="http://sourceforge.net/project/filelist.php?group_id=429">. - In this example, the file is patch-2.3.48_devfs.bz2. + In this example, the file is patch-2.3.51.bz2. <item> Download the matching kernel from your favourite kernel mirror, such as: - <url url="ftp://ftp.ca.kernel.org/pub/kernel/v2.3/linux-2.3.48.tar.bz2" - name="ftp://ftp.ca.kernel.org/pub/kernel/v2.3/linux-2.3.48.tar.bz2">. + <url url="ftp://ftp.ca.kernel.org/pub/kernel/v2.3/linux-2.3.51.tar.bz2" + name="ftp://ftp.ca.kernel.org/pub/kernel/v2.3/linux-2.3.51.tar.bz2">. <item> Make a directory and unpack the kernel into it. <tscreen><verb> $ cd /usr/src/ - $ tar -xzvf linux-2.3.48.tar.bz2 + $ tar -xzvf linux-2.3.51.tar.bz2 $ mv linux linux-usermode </verb></tscreen> @@ -175,7 +175,7 @@ <tscreen><verb> $ cd /usr/src/linux-usermode - $ cat patch-2.3.48_devfs.bz2 | bunzip2 - | patch -p1 + $ cat patch-2.3.51.bz2 | bunzip2 - | patch -p1 </verb></tscreen> <item> Do a normal `make config'; you won't get asked any questions, @@ -274,13 +274,16 @@ <sect>Running User Mode Linux <p>Simply run `./linux' in the directory: it will try to mount the -file `root_fs' in the current directory. You do not need to run it as -root. +file `root_fs' in the current directory. `root_fs' should be +writable by you. You generally do not need to run it as +root. If your host kernel is 2.3.51, you do need to run it as root. <sect1>Logging In <p>If you use the `mkrootfs' script, you will have two accounts: -`root' and `user', neither of which will have passwords. +`root' and `user' (or `guest'). Either those accounts will have no password or +the root account will have password `root' and the guest account +will have password `guest'. <p>There are a number of ways of logging in: <itemize> @@ -322,13 +325,155 @@ telnetd can't allocate a pseudo-tty). </itemize> -<p>Once your kernel is operational, you should be able to set up slip -to the outside world by doing `ifconfig umn 192.168.0.253 hw ether -c0:a8:0:fd:0:0', but this gives me `SIOCSIFFLAGS: Device not configured'. +<sect1>Fun tricks +<p>Here are some things to try in your new UML. + +<itemize> +<item>To allocate more or less memory to a running UML +<p>The default is 16M. To use more or less, try: + +<tscreen><verb> +./linux-2.3.51 mem=24M +</verb></tscreen> +or +<tscreen><verb> +./linux-2.3.48 mem=12M +</verb></tscreen> + +<p>Make sure you have at least this much free hard drive space in the current directory. + +<item>To allocate a swap partition usable by UML +<p>For an 8M swap space, do the following in the host OS: + +<tscreen><verb> +dd if=/dev/zero of=./uml-swap1 bs=1M count=8 +mkswap -c ./uml-swap1 +</verb></tscreen> + +<p>Adjust count up or down for larger or smaller swap. + +<tscreen><verb> +./linux-2.3.51 fhd1=./uml-swap1 +</verb></tscreen> + +<p>Once booted, as root type: + +<tscreen><verb> +swapon /dev/disk/1 +</verb></tscreen> + +<p>If you're not using devfs, I believe the equivalent is: + +<tscreen><verb> +swapon /dev/fhd1 +</verb></tscreen> + +<item>If your kernel has devfs support but your root filesystem doesn't: + +<tscreen><verb> +./linux-2.3.51 devfs=nomount +</verb></tscreen> + +<item>- Basic networking: +<p>The following example assumes the IP address on your host OS' +Ethernet card is 172.20.0.253 and that you're using the default +UML IP address of 192.168.0.253. These steps will set up a +point-to-point link from UML to your host OS (the left set of +dashes, below), and will actually give you a full IP connection +to the outside world (via the Ethernet connection to the firewall +and masquerading there). Visually: + +<tscreen><verb> +.........Machine running Host OS and UML........... .....firewall.......... +....UML...... ...........Host Linux........... + umn sl0 eth0 eth0 ppp0 +192.168.0.253 ---- 192.168.0.254 172.20.0.253 ---- 172.20.0.1 12.13.14.15 -> Internet +</verb></tscreen> + +<p>Start up UML as normal. In UML: + +<tscreen><verb> +ifconfig lo 127.0.0.1 netmask 255.0.0.0 up +route add -net 127.0.0.0 netmask 255.0.0.0 dev lo +ifconfig umn 192.168.0.253 hw ether c0:a8:0:fd:0:0 +route add -host 192.168.0.254 dev umn +route add default gw 192.168.0.254 +</verb></tscreen> + +<p>At this point, you have a working network connection to your host OS. +You should be able to + +<tscreen><verb> +ping 192.168.0.254 +</verb></tscreen> + +from UML, and + +<tscreen><verb> +ping 192.168.0.253 +</verb></tscreen> + +from the host OS. + +<p>Now we give UML full access to the outside world. On the +Host OS: + +<tscreen><verb> +echo 1 >/proc/sys/net/ipv4/ip_forward +</verb></tscreen> + +to allow the Host OS to forward packets to and from UML. + +And finally, on the firewall: + +<tscreen><verb> +route add -host 192.168.0.253 gw 172.20.0.253 +</verb></tscreen> + +so the firewall can get packets back to uml, and either + +<tscreen><verb> +ipfwadm -F -a accept -m -S 192.168.0.0/24 -W ppp0 +</verb></tscreen> + +if your firewall uses ipfwadm (2.0 kernel), + +<tscreen><verb> +ipchains -A forward -s 192.168.0.0/24 -j MASQ -i ppp0 +</verb></tscreen> + +if your firewall uses ipchains (2.2 kernel), or + +<tscreen><verb> +ipnatctl -I -s 192.168.0.0/24 -b source -m masquerade -o ppp0 +</verb></tscreen> + +if your firewall uses netfilter (2.3 or 2.4 kernel). + +<p>At this point, any of the following should work: + +<tscreen><verb> +telnet some.machine.with.telnet +ftp ftp.somedomain.com +</verb></tscreen> + +<p>Note: If UML is unable to do DNS lookups, add the following +lines to /etc/resolv.conf inside UML: + +<tscreen><verb> +nameserver ip.address.of.my.isps.first.nameserver +nameserver ip.address.of.my.isps.second.nameserver +</verb></tscreen> + + +<item>Shutting down <p>You can run `halt' and `reboot' inside your user mode kernel as with a normal kernel. If the kernel hangs, you can do a `killall -9 linux' under your host kernel to get rid of it. + +</itemize> + <sect>Debugging the kernel