<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="keywords" content="9p, 9p2000, research, Plan 9, Inferno, Unix, Open Source, Bell Labs" /> <meta name="description" content="Open source distributed operating system Plan 9 from Bell Labs." /> <link rel="stylesheet" href="/wiki-style.css" media="all" type="text/css" /> <title>Linux emulation (Diff)</title></head><body><h1><a name="top"></a>Linux emulation <i>-Diff-</i></h1> <div class='body'> <!-- ***************************** --> <hr /><div class='diff_head'><a href="index.html">Sat Apr 21 18:32:50 EDT 2012</a>, sl</div><hr />LinuxemuisaprogramthatcanexecuteLinux/i386ELFbinariesonPlan9.ItwasstartedbyRussCoxanddevelopmentwascontinuedbycinap_lenrek.Pleasecontactcinap_lenrekATgmxDOTdewithbugreportsorimprovements.<a name="SOURCE" /><h3>SOURCE</h3> <p class='para'><a href="http://plan9.bell-labs.com/sources/contrib/cinap_lenrek/linuxemu3.tgz">/n/sources/contrib/cinap_lenrek/linuxemu3.tgz</a></p> <p class='para'><a href="http://9hal.ath.cx/usr/cinap_lenrek/linuxemu3.tgz">http://9hal.ath.cx/usr/cinap_lenrek/linuxemu3.tgz</a></p> <a name="DOCUMENTATION" /><h3>DOCUMENTATION</h3> <p class='para'>Documentationisprovidedinthedocdirectory:</p> <pre> doc/linuxemu.txt doc/todo.txt</pre> <a name="INSTALLATION" /><h3>INSTALLATION</h3> <pre> tar xzf linuxemu3.tgz cd linuxemu3 mk mk install</pre> <a name="BOOTSTRAP" /><h3>BOOTSTRAP</h3> <p class='para'>YouneedaLinuxrootfilesystempackedinatarball.Go!GetsomeLinuxrootfs:</p> <p class='para'><a href="http://9hal.ath.cx/usr/cinap_lenrek/mroot-linuxemu.tbz">http://9hal.ath.cx/usr/cinap_lenrek/mroot-linuxemu.tbz</a></p> <p class='para'><a href="http://plan9.stanleylieber.com/linuxemu/mroot.tgz">http://plan9.stanleylieber.com/linuxemu/mroot.tgz</a></p> <p class='para'>The-linuxemuversioncontainsnosymlinksandcanbeextractedwithplainplan9toolsbunzip/tar.</p> <p class='para'>Themroot.tgzversioncontainsthesameDebianSargebaseas-linuxemu,butwithseveraladditionalpackagespre-installed:</p> <pre> 9base dmenu-4.1.1 dwm-5.8.2 gcc 3.3.5 linux-kernel-headers mercurial 0.9.4 opera 10.11 python 2.3.5 xlib-dev</pre> <p class='para'>andmore.Viewits<a href="http://plan9.stanleylieber.com/linuxemu/setup">setup</a>fileformoredetails.</p> <p class='para'>YoucancreateyourownwithdebootstraponDebianLinux,orhelpwriteaninstallerthatunpacksandinstallsSlackwareonPlan9...Inanycase,linuxemuisnothardwiredtoanyLinuxdistribution!</p> <a name="RUNNING" /><h3>RUNNING</h3> <p class='para'>Usetheprovided"linux"scripttochrootintoyourLinuxrootfs.The"linux"scriptisneccesarybecauseforLinuxprogramstorun,sharedlibrariesfromyourrootfshavetoappearat/liband/usr/lib,whileconfigurationfilesareexpectedtobein/etc.ThescriptwillbuildaprivatenamespaceandbindtheLinuxrootfsoverthePlan9root.theoriginalPlan9namespaceismountedat/9.</p> <pre> linux -r ./mroot /bin/bash -i</pre> <p class='para'>Ifthe-roptionisomitted,theLinuxrootfsdefaultsto/sys/lib/linux.youmayputyourLinuxrootfsthereoraddabindtoyour$home/lib/profile.</p> <p class='para'>IntheLinuxrootfs,/etc/resolv.confshouldbechangedtomatchyournetworknameserver.Inaddition,/etc/apt/sources.listshouldbeupdatedtoaworkingDebianmirror.(Sargepackagescanstillbeaccessedatdebhttp://archive.debian.org/debian-archive/debiansargemain)</p> <a name="EXAMPLES" /><h3>EXAMPLES</h3> <p class='para'>LinuxX11programsmaybeusedinconjunctionwiththePlan9<a href="http://www.plan9.bell-labs.com/wiki/plan9/X11_installation">equis</a>X11contribpackage.Forexample,toruntheOperawebbrowserunderyourLinuxrootfs,startequisinariowindow,chrootintoyourLInuxrootfsand:</p> <pre> dwm & opera &</pre> <p class='para'>Operashould(eventually)appearintheequiswindow.Awindowmanager(thisexampleusesdwm)isrecommendedsothatX11programsworkproperly.</p> <a name="DEBUGGING" /><h3>DEBUGGING</h3> <p class='para'>Iflinuxemucrashes,useacidtofigureoutwhatsgoingon:</p> <pre> mk acid acid -l linuxemu.acid <pid></pre> <p class='para'>Thenyoucanissuethefollowingcommands:</p> <pre> ustk() dump a (userspace) stacktrace for the current thread umem(Current()) dump the memory mappings ufds(Current()) dump the filedescriptor table utrace(Current()) dump the internal tracebuffer (enabled by -d option)</pre> <p class='para'>Usexasm()/xcasm()fordisassemblyforLinuxcode.</p> <p class='para'>Youcanalsoenablefulltracelogging:</p> <pre> linux -r ./mroot -dd /bin/bash -i >[2]/tmp/linuxemu.log</pre> <p class='para'>ThisLines 1–500 of 741. Load more
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="keywords" content="9p, 9p2000, research, Plan 9, Inferno, Unix, Open Source, Bell Labs" /> <meta name="description" content="Open source distributed operating system Plan 9 from Bell Labs." /> <link rel="stylesheet" href="/wiki-style.css" media="all" type="text/css" /> <title>Linux emulation (Diff)</title> </head> <body> <h1><a name="top"></a> Linux emulation <i>-Diff-</i></h1> <div class='body'> <!-- ***************************** --> <hr /><div class='diff_head'> <a href="index.html">Sat Apr 21 18:32:50 EDT 2012</a>, sl </div><hr />Linuxemu is a program that can execute Linux/i386 ELF binaries on Plan9. It was started by Russ Cox and development was continued by cinap_lenrek. Please contact cinap_lenrek AT gmx DOT de with bug reports or improvements. <a name="SOURCE" /><h3>SOURCE</h3> <p class='para'> <a href="http://plan9.bell-labs.com/sources/contrib/cinap_lenrek/linuxemu3.tgz">/n/sources/contrib/cinap_lenrek/linuxemu3.tgz</a> </p> <p class='para'> <a href="http://9hal.ath.cx/usr/cinap_lenrek/linuxemu3.tgz">http://9hal.ath.cx/usr/cinap_lenrek/linuxemu3.tgz</a> </p> <a name="DOCUMENTATION" /><h3>DOCUMENTATION</h3> <p class='para'> Documentation is provided in the doc directory: </p> <pre> doc/linuxemu.txt doc/todo.txt </pre> <a name="INSTALLATION" /><h3>INSTALLATION</h3> <pre> tar xzf linuxemu3.tgz cd linuxemu3 mk mk install </pre> <a name="BOOTSTRAP" /><h3>BOOTSTRAP</h3> <p class='para'> You need a Linux rootfilesystem packed in a tarball. Go! Get some Linux rootfs: </p> <p class='para'> <a href="http://9hal.ath.cx/usr/cinap_lenrek/mroot-linuxemu.tbz">http://9hal.ath.cx/usr/cinap_lenrek/mroot-linuxemu.tbz</a> </p> <p class='para'> <a href="http://plan9.stanleylieber.com/linuxemu/mroot.tgz">http://plan9.stanleylieber.com/linuxemu/mroot.tgz</a> </p> <p class='para'> The -linuxemu version contains no symlinks and can be extracted with plain plan9 tools bunzip/tar. </p> <p class='para'> The mroot.tgz version contains the same Debian Sarge base as -linuxemu, but with several additional packages pre-installed: </p> <pre> 9base dmenu-4.1.1 dwm-5.8.2 gcc 3.3.5 linux-kernel-headers mercurial 0.9.4 opera 10.11 python 2.3.5 xlib-dev </pre> <p class='para'> and more. View its <a href="http://plan9.stanleylieber.com/linuxemu/setup">setup</a> file for more details. </p> <p class='para'> You can create your own with debootstrap on Debian Linux, or help write an installer that unpacks and installs Slackware on Plan 9... In any case, linuxemu is not hardwired to any Linux distribution! </p> <a name="RUNNING" /><h3>RUNNING</h3> <p class='para'> Use the provided "linux" script to chroot into your Linux rootfs. The "linux" script is neccesary because for Linux programs to run, shared libraries from your rootfs have to appear at /lib and /usr/lib, while configuration files are expected to be in /etc. The script will build a private namespace and bind the Linux rootfs over the Plan 9 root. the original Plan 9 namespace is mounted at /9. </p> <pre> linux -r ./mroot /bin/bash -i </pre> <p class='para'> If the -r option is omitted, the Linux rootfs defaults to /sys/lib/linux. you may put your Linux rootfs there or add a bind to your $home/lib/profile. </p> <p class='para'> In the Linux rootfs, /etc/resolv.conf should be changed to match your network nameserver. In addition, /etc/apt/sources.list should be updated to a working Debian mirror. (Sarge packages can still be accessed at deb http://archive.debian.org/debian-archive/debian sarge main) </p> <a name="EXAMPLES" /><h3>EXAMPLES</h3> <p class='para'> Linux X11 programs may be used in conjunction with the Plan 9 <a href="http://www.plan9.bell-labs.com/wiki/plan9/X11_installation">equis</a> X11 contrib package. For example, to run the Opera web browser under your Linux rootfs, start equis in a rio window, chroot into your LInux rootfs and: </p> <pre> dwm & opera & </pre> <p class='para'> Opera should (eventually) appear in the equis window. A window manager (this example uses dwm) is recommended so that X11 programs work properly. </p> <a name="DEBUGGING" /><h3>DEBUGGING</h3> <p class='para'> If linuxemu crashes, use acid to figure out whats going on: </p> <pre> mk acid acid -l linuxemu.acid <pid> </pre> <p class='para'> Then you can issue the following commands: </p> <pre> ustk() dump a (userspace) stacktrace for the current thread umem(Current()) dump the memory mappings ufds(Current()) dump the filedescriptor table utrace(Current()) dump the internal tracebuffer (enabled by -d option) </pre> <p class='para'> Use xasm()/xcasm() for disassembly for Linux code. </p> <p class='para'> You can also enable full trace logging: </p> <pre> linux -r ./mroot -dd /bin/bash -i >[2]/tmp/linuxemu.log </pre> <p class='para'> This