Sean Hincheeinitial push75d07b48 years agoHistory
202 lines · 6.3 KB · HTML
RawDownload
<html><head><title>Linux emulation (Editing Sat Apr 21 18:32:50 EDT 2012 version)</title><META http-equiv="Content-Type" content="text/html; charset=utf-8"></head><!-- FFFFE9 is acme yellow; FFFFE9 is as close as you can get to it before charon decides to use  grey instead of map entry 254 --><body bgcolor="#FFFFE9" link="#0000AA" alink="#0000AA" vlink="#0000AA"><center><font size=+2><b>Linux emulation</b></font> (Editing Sat Apr 21 18:32:50 EDT 2012 version)</center><p> For information on editing, see thedescription of <a href="../0">Plan 9 wiki syntax</a>.<p><form action="/magic/wikipost" method="post"><table><tr><td valign=top><input type="submit" name="x" value="Put"></td><td><table><tr><td align=right>(optional) Comment:</td><td><input type="text" name="comment" value="" cols=40></td></tr><tr><td align=right>(optional) Email:</td><td><input type="text" name="author" value="" cols=40></td></tr></table><input type="hidden" name="title" value="Linux emulation"><input type="hidden" name="version" value="1335047570"><input type="hidden" name="service" value="plan9"><input type="hidden" name="base" value="/wiki/plan9"><p><textarea name="text" wrap="virtual" cols="80" rows="25">Linuxemu is a program that can execute Linux/i386 ELF binaries onPlan9. It was started by Russ Cox and development was continued bycinap_lenrek. Please contact cinap_lenrek AT gmx DOT de with bugreports or improvements. SOURCE [/n/sources/contrib/cinap_lenrek/linuxemu3.tgz |http://plan9.bell-labs.com/sources/contrib/cinap_lenrek/linuxemu3.tgz] [http://9hal.ath.cx/usr/cinap_lenrek/linuxemu3.tgz |http://9hal.ath.cx/usr/cinap_lenrek/linuxemu3.tgz] DOCUMENTATION Documentation is provided in the doc directory: ! 	doc/linuxemu.txt! 	doc/todo.txt INSTALLATION ! 	tar xzf linuxemu3.tgz! 	cd linuxemu3! 	mk! 	mk install BOOTSTRAP You need a Linux rootfilesystem packed in a tarball. Go! Get someLinux rootfs: [http://9hal.ath.cx/usr/cinap_lenrek/mroot-linuxemu.tbz |http://9hal.ath.cx/usr/cinap_lenrek/mroot-linuxemu.tbz] [http://plan9.stanleylieber.com/linuxemu/mroot.tgz |http://plan9.stanleylieber.com/linuxemu/mroot.tgz] The -linuxemu version contains no symlinks and can be extracted withplain plan9 tools bunzip/tar. The mroot.tgz version contains the same Debian Sarge base as-linuxemu, but with several additional packages pre-installed: ! 	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 and more. View its [setup |http://plan9.stanleylieber.com/linuxemu/setup] file for more details. You can create your own with debootstrap on Debian Linux, or helpwrite an installer that unpacks and installs Slackware on Plan 9...In any case, linuxemu is not hardwired to any Linux distribution! RUNNING Use the provided "linux" script to chroot into your Linux rootfs. The"linux" script is neccesary because for Linux programs to run, sharedlibraries from your rootfs have to appear at /lib and /usr/lib, whileconfiguration files are expected to be in /etc. The script will builda private namespace and bind the Linux rootfs over the Plan 9 root.the original Plan 9 namespace is mounted at /9. ! 	linux -r ./mroot /bin/bash -i 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 toyour $home/lib/profile. In the Linux rootfs, /etc/resolv.conf should be changed to match yournetwork nameserver. In addition, /etc/apt/sources.list should beupdated to a working Debian mirror. (Sarge packages can still beaccessed at deb http://archive.debian.org/debian-archive/debian sargemain) EXAMPLES Linux X11 programs may be used in conjunction with the Plan 9 [equis| http://www.plan9.bell-labs.com/wiki/plan9/X11_installation] X11contrib package. For example, to run the Opera web browser under yourLinux rootfs, start equis in a rio window, chroot into your LInuxrootfs and: ! 	dwm &! 	opera & Opera should (eventually) appear in the equis window. A windowmanager (this example uses dwm) is recommended so that X11 programswork properly. DEBUGGING If linuxemu crashes, use acid to figure out whats going on: ! 	mk acid! 	acid -l linuxemu.acid <pid> Then you can issue the following commands: ! 	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) Use xasm()/xcasm() for disassembly for Linux code. You can also enable full trace logging: ! 	linux -r ./mroot -dd /bin/bash -i >[2]/tmp/linuxemu.log This slows linuxemu down. In case of race conditions, it oftenhappens that the bug disapears when doing full trace logging! NPTL If you get one of these errors: ! 	cannot set up thread-local storage: cannot set up LDT for thread-local storage This is glibc/libpthread complaining! The problem is the following:glibc on i386 decided at some point to use the extra segmentregisters GS and FS as an indirection pointer for thread localstorage. The operating system kernel therfore must have a mechanismto let userspace change descriptor table entries and swap them in/outon context switch. To make it work here are several options: 1) Recompile and link the program with a pre NPTL version of glibc. 2) On some distributions, a non-tls version of libc/libpthread isavailable. in the -linuxemu fsroot, the NPTL version is in /lib/tls,the older version is in /lib. By renaming /lib/tls to/lib/_tls_disabled_ the loader will use the non-tls version. 3) Cinap made a kernel patch that adds support for per processdescriptors to Plan 9: [http://plan9.bell-labs.com/sources/contrib/cinap_lenrek/segdescpatch| /n/sources/contrib/cinap_lenrek/segdescpatch] [http://9hal.ath.cx/usr/cinap_lenrek/segdescpatch.tgz |http://9hal.ath.cx/usr/cinap_lenrek/segdescpatch.tgz] The above patch adds the files gdt and ldt to devarch (#P). </textarea><p></td></table></form> <hr><table width=100%><tr><td valign=center align=left></td><td valign=center align=right><a href="../about.html">About the server</a>| <a href="http://plan9.bell-labs.com/plan9"><img src="http://plan9.bell-labs.com/plan9/img/power36.gif"alt="Powered by Plan 9"></a></td></tr></table></html></body>