1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
<TITLE>User Mode Linux HOWTO : Compiling the kernel and modules</TITLE>
<LINK HREF="UserModeLinux-HOWTO-3.html" REL=next>
<LINK HREF="UserModeLinux-HOWTO-1.html" REL=previous>
<LINK HREF="UserModeLinux-HOWTO.html#toc2" REL=contents>
</HEAD>
<BODY>
<A HREF="UserModeLinux-HOWTO-3.html">Next</A>
<A HREF="UserModeLinux-HOWTO-1.html">Previous</A>
<A HREF="UserModeLinux-HOWTO.html#toc2">Contents</A>
<HR>
<H2><A NAME="compile"></A> <A NAME="s2">2.</A> <A HREF="UserModeLinux-HOWTO.html#toc2">Compiling the kernel and modules</A></H2>
<P> </P>
<H2><A NAME="ss2.1">2.1</A> <A HREF="UserModeLinux-HOWTO.html#toc2.1">Compiling the kernel</A>
</H2>
<P>Compiling the user mode kernel is just like compiling any other
kernel. Let's go through the steps, using 2.4.0-prerelease (current
as of this writing) as an example:</P>
<P>
<OL>
<LI> Download the latest UML patch from
the project's download page
In this example, the file is uml-patch-2.4.0-prerelease.bz2.
</LI>
<LI> Download the matching kernel from your favourite kernel mirror,
such as:
<A HREF="ftp://ftp.ca.kernel.org/pub/kernel/v2.4/linux-2.4.0-prerelease.tar.bz2"> ftp://ftp.ca.kernel.org/pub/kernel/v2.4/linux-2.4.0-prerelease.tar.bz2 </A> .
</LI>
<LI> Make a directory and unpack the kernel into it.
<BLOCKQUOTE><CODE>
<PRE>
$ cd /usr/src/uml
$ tar -xzvf linux-2.4.0-prerelease.tar.bz2
</PRE>
</CODE></BLOCKQUOTE>
</LI>
<LI> Apply the patch using
<BLOCKQUOTE><CODE>
<PRE>
$ cd /usr/src/uml/linux
$ cat uml-patch-2.4.0-prerelease.bz2 | bunzip2 - | patch -p1
</PRE>
</CODE></BLOCKQUOTE>
</LI>
<LI> Run your favorite config; `make xconfig ARCH=um' is the most
convenient. `make config ARCH=um' and 'make menuconfig ARCH=um' will
work as well. The defaults will give you a useful kernel. If you
want to change something, go ahead, it probably won't hurt anything.
<P>
Note: If the host is configured with a 2G/2G address space split
rather than the usual 3G/1G split, then the packaged UML binaries will
not run. They will immediately segfault. See
<A HREF="UserModeLinux-HOWTO-4.html#2G-2G">UML on 2G/2G hosts</A> for the scoop on
running UML on your system.</P>
</LI>
<LI> Finish with `make linux ARCH=um': the result is a file called `linux'
in the top directory of your source tree.
</LI>
</OL>
</P>
<P>Make sure that you don't build this
kernel in /usr/src/linux. On some distributions, /usr/include/asm
is a link into this pool. The user-mode build changes the other end
of that link, and things that include <asm/anything.h> stop compiling.</P>
<P> The sources are also available from cvs at
the project's cvs page, which has directions on getting
the sources. You
can also browse the CVS pool from there.</P>
<P> If you get the CVS sources, you will have to check them out into an
empty directory. You will then have to copy each file into the corresponding
directory in the appropriate kernel pool.</P>
<P> If you don't have the latest kernel pool, you can get the corresponding
user-mode sources with
<BLOCKQUOTE><CODE>
<PRE>
cvs co -r v_2_3_x linux
</PRE>
</CODE></BLOCKQUOTE>
where 'x' is the version in your pool. Note that you will not get the bug
fixes and enhancements that have gone into subsequent releases.</P>
<P>
If you build your own kernel, and want to boot it from one of the
filesystems distributed from this site, then, in nearly all cases,
devfs must be compiled into the kernel and mounted at boot time. The
exception is the SuSE filesystem. For this,
devfs must either not be in the kernel at all, or "devfs=nomount" must
be on the kernel command line. Any disagreement between the kernel
and the filesystem being booted about whether devfs is being used will
result in the boot getting no further than single-user mode.</P>
<P>
If you don't want to use devfs, you can remove the need for it from a
filesystem by copying /dev from someplace, making a bunch of
/dev/ubd devices:
<BLOCKQUOTE><CODE>
<PRE>
for i in 0 1 2 3 4 5 6 7; do mknod ubd$i b 98 $i; done
</PRE>
</CODE></BLOCKQUOTE>
and changing /etc/fstab and /etc/inittab to refer to the non-devfs devices.</P>
<H2><A NAME="ss2.2">2.2</A> <A HREF="UserModeLinux-HOWTO.html#toc2.2">Compiling and installing kernel modules</A>
</H2>
<P>UML modules are built in the same way as the native kernel (with the
exception of the 'ARCH=um' that you always need for UML):
<BLOCKQUOTE><CODE>
<PRE>
make modules ARCH=um
</PRE>
</CODE></BLOCKQUOTE>
Any modules that you want to load into this kernel need to
be built in the user-mode pool. Modules from the native kernel won't
work.</P>
<P>You can install them by using ftp or something to copy them into the
virtual machine and dropping them into /lib/modules/`uname -r`.</P>
<P>You can also get the kernel build process to install them as
follows:
<OL>
<LI>with the kernel not booted, mount the root filesystem in the top level
of the kernel pool:
<BLOCKQUOTE><CODE>
<PRE>
# mount root_fs mnt -o loop
</PRE>
</CODE></BLOCKQUOTE>
</LI>
<LI>run
<BLOCKQUOTE><CODE>
<PRE>
make modules_install INSTALL_MOD_PATH=`pwd`/mnt ARCH=um
</PRE>
</CODE></BLOCKQUOTE>
</LI>
<LI>unmount the filesystem
<BLOCKQUOTE><CODE>
<PRE>
# umount mnt
</PRE>
</CODE></BLOCKQUOTE>
</LI>
<LI>boot the kernel on it
</LI>
</OL>
</P>
<P>When the system is booted, you can use insmod as usual to get the modules
into the kernel. A number of things have been loaded into UML as
modules, especially filesystems and network protocols and filters, so
most symbols which need to be exported probably already are. However,
if you do find symbols that need exporting, let
<A HREF="http://user-mode-linux.sourceforge.net/contacts.html">us</A> know, and they'll be "taken care of".</P>
<HR>
<A HREF="UserModeLinux-HOWTO-3.html">Next</A>
<A HREF="UserModeLinux-HOWTO-1.html">Previous</A>
<A HREF="UserModeLinux-HOWTO.html#toc2">Contents</A>
</BODY>
</HTML>
|