/[gentoo]/xml/htdocs/doc/en/uml.xml
Gentoo

Diff of /xml/htdocs/doc/en/uml.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.32
1<?xml version='1.0'?> 1<?xml version='1.0' encoding="UTF-8"?>
2<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?> 2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/uml.xml,v 1.32 2013/07/23 14:10:11 swift Exp $ -->
3 3
4<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 4<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
5 5
6<guide link="/doc/uml.html"> 6<guide disclaimer="obsolete" redirect="https://wiki.gentoo.org/wiki/User-mode_Linux/System_testing_with_UML">
7<title>Gentoo Linux Developer's guide to system testing with User-Mode Linux</title> 7<title>Gentoo Linux Developer's guide to system testing with User-Mode Linux</title>
8
9<author title="Editor">
8<author title="Editor"><mail link="g2boojum@gentoo.org">Grant Goodyear</mail></author> 10 <mail link="g2boojum@gentoo.org">Grant Goodyear</mail>
11</author>
12<author title="Editor"><!-- zhen@gentoo.org -->
13 John Davis
14</author>
15<author title="Editor">
16 <mail link="swift@gentoo.org">Sven Vermeulen</mail>
17</author>
18<author title="Editor">
19 <mail link="bennyc@gentoo.org">Benny Chuang</mail>
20</author>
9 21
10<abstract> 22<abstract>
11 This guide shows Gentoo Linux developers how to set up and use 23This guide shows Gentoo Linux developers how to set up and use
12 user-mode linux for testing potentially system-breaking changes. 24user-mode linux for testing potentially system-breaking changes.
13</abstract> 25</abstract>
14 26
27<!-- The content of this document is licensed under the CC-BY-SA license -->
28<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
29<license/>
30
15<version>0.05</version> 31<version>1</version>
16<date>5 Mar 2002</date> 32<!-- Last content edit: 2008-03-01 -->
33<date>2013-07-23</date>
17 34
18<chapter> 35<chapter>
19<title>Obtaining User-Mode Linux</title> 36<title>Obtaining User-Mode Linux</title>
20<section> 37<section>
21<body> 38<body>
39
40<impo>
41Before you can use user-mode Linux, you <e>must</e> be using a non-NPTL
42profile, and you must be using &lt;<c>glibc</c>-2.4. Follow the instructions
43for <uri link="/doc/en/gentoo-upgrading.xml#instructions">changing
44profiles</uri>. You will need to run <c>emerge -e world</c> after switching to
45a non-NPTL profile.
46</impo>
47
48<p>
22<p>As the user-mode linux website 49As the user-mode Linux website
23(<uri>http://user-mode-linux.sourceforge.net</uri>) 50(<uri>http://user-mode-linux.sourceforge.net</uri>) states, user-modeL linux
24states, user-mode linux
25allows a user to "run Linux inside itself". Specifically, 51allows a user to "run Linux inside itself". Specifically,
26user-mode linux provides a virtual machine on which a user can "[r]un buggy 52user-mode linux provides a virtual machine on which a user can "[r]un buggy
27software, experiment with new Linux kernels or distributions, and poke around 53software, experiment with new Linux kernels or distributions, and poke around
28in the internals of Linux, all without risking your main Linux setup." Changes 54in the internals of Linux, all without risking your main Linux setup."
29to Gentoo core packages such as <e>sys-apps/baselayout</e> or <e>sys-libs/glibc</e> 55Experimental changes to Gentoo core packages such as <e>sys-apps/baselayout</e>
30have the potential to break the system and render it unbootable; with user-mode 56or <e>sys-libs/glibc</e> have the potential to break the system and render it
31linux we can test these changes without having to worry about breaking the live 57unbootable; with user-mode Linux we can test these changes without having to
32system. 58worry about breaking the live system.
33</p>
34<p> 59</p>
35Installing user-mode linux is essentially identical to a normal kernel 60
36install. First install the kernel sources (appropriately patched for
37user-mode linux), and then configure the user-mode linux kernel in the
38usual fashion:
39</p> 61<p>
62Most 2.6 kernels have UML support. Although you can use your current kernel
63sources, it might be wiser to keep the UML kernel tree(s) separate. After all,
64you'll be building a new kernel with a different configuration and you might
65want to have heterogenous systems on your main Linux system (several different
66UML kernels).
67</p>
68
40<pre> 69<p>
41# <i>emerge sys-kernel/usermode-sources</i> 70So download a nice kernel tree (like the vanilla one from <uri
71link="http://www.kernel.org">kernel.org</uri>) and extract it to some local
72development location.
73</p>
74
75<p>
76Next, configure this UML kernel as you would do for any other system, but append
77<e>ARCH=um</e> so that the kernel build software knows that the kernel
78is meant to run as a guest process on the main system.
79</p>
80
81<pre caption="Building the UML kernel">
42# <i>cd /usr/src/uml/linux</i> 82# <i>cd /srv/aegis/src/uml-linux</i>
43# <i>make menuconfig <comment>ARCH=um</comment></i> 83# <i>make menuconfig <comment>ARCH=um</comment></i>
44# <i>make linux <comment>ARCH=um</comment></i> 84# <i>make linux <comment>ARCH=um</comment></i>
45# <i>cp linux /usr/local/bin/linux</i> 85# <i>cp linux /usr/local/bin/linux</i>
46</pre> 86</pre>
87
88<warn>
47<warn>The <e>ARCH=um</e> fragment is <e>extremely</e> important!</warn> 89The <e>ARCH=um</e> fragment is <e>extremely</e> important!
48<impo> 90</warn>
91
92<p>
93On a default Gentoo system, <path>/usr/local/bin</path> is in your <c>$PATH</c>.
94If it isn't, you should find a definition of <c>PATH</c> in the
95<path>/etc/profile</path> and fix it:
96</p>
97
98<pre caption="Verifying $PATH">
99$ <i>echo $PATH | grep /usr/local/bin</i>
100</pre>
101
102<pre caption="Sample definition of $PATH in /etc/profile">
103PATH="/usr/local/bin:/usr/bin:/bin:${PATH}"
104</pre>
105
106<p>
107Don't forget to run <c>source /etc/profile</c> for the change to take effect.
108</p>
109
110<p>
49For the user-mode linux kernel to properly boot a Gentoo system the 111For the user-mode Linux kernel to properly boot a Gentoo system the
50kernel needs to be configured to <e>not</e> automatically mount 112kernel needs to be configured to <e>not</e> automatically mount
51<path>/dev</path> (devfs) by default. 113<path>/dev</path> (devfs) by default. Also, you will almost certainly
52Also, you will almost certainly
53want to make sure that you have <e>tmpfs</e> (the "Virtual Memory 114want to make sure that you have <e>tmpfs</e> (the "Virtual Memory
54Filesystem") compiled in, since by default the Gentoo linux bootscripts 115Filesystem") compiled in, since by default the Gentoo Linux bootscripts
55store their information in a small tmpfs partition. 116store their information in a small tmpfs partition.
56(The binary kernels available 117(The binary kernels available from the user-mode website do automatically
57from the user-mode website do automatically mount <path>/dev</path>, 118mount <path>/dev</path>, and they don't have tmpfs compiled in; don't bother
58and they don't have tmpfs compiled in; don't bother with them.) 119with them).
59</impo> 120</p>
121
122<p>
60<p>I highly recommend reading the user-mode linux documentation, but the 123I highly recommend reading the user-mode linux documentation, but the
61basic idea is that running the <path>/usr/local/bin/linux</path> program 124basic idea is that running the <path>/usr/local/bin/linux</path> program
62boots the user-mode kernel and tries to bring up the system stored in 125boots the user-mode kernel and tries to bring up the system stored in
63the file <path>root_fs</path> that should be located in the current working 126the file <path>root_fs</path> that should be located in the current working
64directory.</p> 127directory.
128</p>
129
130<p>
65<p>It won't hurt to also install the user-mode linux tools.</p> 131It won't hurt to also install the user-mode Linux tools.
66<pre> 132</p>
133
134<pre caption="Installing UML tools">
67# <i>emerge sys-apps/usermode-utilities</i> 135# <i>emerge sys-apps/usermode-utilities</i>
68</pre> 136</pre>
137
138<p>
69<p>These tools facilitate networking (among other things) 139These tools facilitate networking (among other things) between the user-mode
70between the user-mode linux virtual system 140Linux virtual system and the host Linux system.
71and the host Linux system.</p> 141</p>
142
72</body> 143</body>
73</section> 144</section>
74</chapter> 145</chapter>
75 146
76<chapter> 147<chapter>
77<title>Creating <path>root_fs</path></title> 148<title>Creating root_fs</title>
78
79<section> 149<section>
80<title>Making the Gentoo chroot</title> 150<title>Making the Gentoo chroot</title>
81<body> 151<body>
152
82<p> 153<p>
83The <path>root_fs</path> file needed for user-mode linux is 154The <path>root_fs</path> file needed for user-mode linux is
84a single file that contains an entire Gentoo Linux filesystem. 155a single file that contains an entire Gentoo Linux filesystem.
85To generate this file you will need to have Loopback device 156To generate this file you will need to have Loopback device
86support enabled in the host (non-user-mode) kernel. 157support enabled in the host (non-user-mode) kernel.
87</p> 158</p>
159
160<p>
88<p>Generating the <path>root_fs</path> file itself will be 161Generating the <path>root_fs</path> file itself will be
89our last step. First we will generate a Gentoo filesystem in 162our last step. First we will generate a Gentoo filesystem in
90an ordinary chroot. We need the build tarball available, which 163an ordinary chroot. We need the stage tarball available, which
91could be downloaded separately, extracted from a build cd, or 164could be downloaded separately, extracted from an Installation CD, or
92extracted from a build .iso. 165extracted from an Installation CD .iso.
93</p> 166</p>
167
94<pre caption="Mounting a build .iso"> 168<pre caption="Mounting an Installation CD .iso">
95# <i>mkdir /mnt/loop</i> 169# <i>mkdir /mnt/loop</i>
96# <i>mount -o loop /path/to/build-&lt;TAB&gt;.iso /mnt/loop</i> 170# <i>mount -o loop /path/to/install-&lt;TAB&gt;.iso /mnt/loop</i>
97</pre> 171</pre>
172
98<p> 173<p>
99Setting up the chroot is essentially identical to an ordinary Gentoo 174Setting up the chroot is essentially identical to an ordinary Gentoo
100Linux build. 175Linux build.
101</p> 176</p>
102<pre> 177
178<pre caption="Creating the Gentoo chroot mount">
103# <i>mkdir /mnt/gentoo</i> 179# <i>mkdir /mnt/gentoo</i>
104# <i>cd /mnt/gentoo</i> 180# <i>cd /mnt/gentoo</i>
105# <i>tar xvjpf /path/to/build-&lt;TAB&gt;.tar.bz2</i> 181# <i>tar xvjpf /path/to/stage&lt;TAB&gt;.tar.bz2</i>
106</pre> 182</pre>
183
107<p> 184<p>
108Go ahead and unmount the .iso. You don't need it anymore. 185Go ahead and unmount the .iso. You don't need it anymore.
109</p> 186</p>
110<pre> 187
111# <i>cp /etc/resolv.conf /mnt/gentoo/etc/</i>
112# <i>mount -o bind /proc /mnt/gentoo/proc</i>
113# <i>mkdir -p /mnt/gentoo/usr/portage/distfiles</i>
114# <i>mkdir -p /mnt/gentoo/usr/portage/packages</i>
115# <i>mount -o bind /usr/portage/distfiles /mnt/gentoo/usr/portage/distfiles</i>
116# <i>mount -o bind /usr/portage/packages /mnt/gentoo/usr/portage/packages</i>
117# <i>chroot /mnt/gentoo /bin/bash</i>
118# <i>env-update</i>
119# <i>source /etc/profile</i>
120</pre>
121<p>
122By bind-mounting <path>/usr/portage/distfiles</path> and
123<path>/usr/portage/packages</path> we avoid having to download
124or build packages that are already present on the Gentoo host.
125</p> 188<p>
189Build the system in the usual fashion: chroot into <path>/mnt/gentoo</path> and
190follow the Gentoo installation instructions.
126<p> 191</p>
127Bootstrap and build the system in the usual fashion: 192
128</p>
129<pre>
130# <i>emerge rsync</i>
131# <i>cd /usr/portage</i>
132# <i>nano -w /etc/make.conf</i>
133# <i>nano -w /etc/make.profile/packages</i>
134# <i>nano -w /usr/portage/profiles/package.mask</i>
135# <i>scripts/bootstrap.sh &amp;&amp; emerge --usepkg system</i>
136</pre>
137<warn>
138The <path>/etc/make.profile/packages</path> file needs to be
139edited to remove grub from the default system (just remove the "*"
140from the beginning of the "*sys-apps/grub" line). The grub ebuild
141tries to mount the /boot partition, which will fail in our chroot.
142</warn>
143<note>
144Make sure you examine <path>/etc/make.profile/packages</path>
145and <path>/usr/portage/profiles/package.mask</path> to be sure that
146any to-be-tested packages that you want to install aren't masked out.
147As currently written, <path>scripts/bootstrap.sh</path> will compile
148the bootstrap packages from source. To use already-existing packages,
149add <c>alias emerge="emerge --usepkg"</c> somewhere near the top of
150the bootstrap script.
151</note>
152<p> 193<p>
153Add any additional packages you desire. Feel free to give your virtual 194Add any additional packages you desire. Feel free to give your virtual
154Gentoo system a hostname, if you so desire. In <path>/etc/fstab</path> 195Gentoo system a hostname, if you so desire. In <path>/etc/fstab</path>
155you will want <path>/dev/ROOT</path> to be <path>/dev/ubd/0</path>, with 196you will want <path>/dev/ROOT</path> to be <path>/dev/ubda</path>, with
156a fs type of either ext2, ext3, or reiserfs. Set <path>/dev/SWAP</path> 197a fs type of either ext2, ext3, or reiserfs. Set <path>/dev/SWAP</path>
157to be <path>/dev/ubd/1</path>, and comment out <path>/dev/BOOT</path>. 198to be <path>/dev/ubdb</path>, and comment out <path>/dev/BOOT</path>.
199</p>
200
158</p> 201<p>
202At this point, remember to set your root password.
203</p>
204
205<pre caption="Setting root password">
206# <i>passwd</i>
207</pre>
208
209<p>
210Now we need to make some changes to the boot scripts. Remove consolefont and
211keymaps from the boot runlevel:
212</p>
213
214<pre caption="Removing unneeded initscripts">
215# <i>rc-update del consolefont boot</i>
216# <i>rc-update del keymaps boot</i>
217</pre>
218
159<p> 219<p>
160Exit the chroot, unmount all of the bind mounts, 220Exit the chroot, unmount all of the bind mounts,
161tar up the new Gentoo distro, and clean up: 221tar up the new Gentoo distro, and clean up.
162</p> 222</p>
163<pre> 223
164# <i>exit</i> 224<pre caption="Finalising the installation">
165# <i>umount /mnt/gentoo/usr/portage/distfiles</i>
166# <i>umount /mnt/gentoo/usr/portage/packages</i>
167# <i>umount /mnt/gentoo/proc</i>
168# <i>du -ks /mnt/gentoo</i> 225# <i>cd /mnt/gentoo</i>
169261744 /mnt/gentoo
170# <i>tar cvjpf ~/gentoo.tbz2 *</i> 226# <i>tar cvjpf ~/gentoo.tbz2 *</i>
171# <i>cd</i> 227# <i>cd</i>
172# <i>rm -rf /mnt/gentoo</i> 228# <i>rm -rf /mnt/gentoo</i>
173</pre> 229</pre>
174</body>
175</section>
176 230
231</body>
177<section> 232</section>
233<section>
178<title>Making <path>root_fs</path></title> 234<title>Making root_fs</title>
179<body> 235<body>
236
180<p> 237<p>
181Our Gentoo chroot is nearly 300 MB in size, so 238Our Gentoo chroot is nearly 300 MB in size, so
182<path>root_fs</path> needs to be at least that size. 239<path>root_fs</path> needs to be at least that size.
183We'll choose 0.5 GB as a reasonable size. 240We'll choose 0.5 GB as a reasonable size.
184</p> 241</p>
185<pre> 242
243<pre caption="Creating UML files">
186# <i>dd if=/dev/zero of=root_fs seek=500 count=1 bs=1M</i> 244# <i>dd if=/dev/zero of=root_fs seek=500 count=1 bs=1M</i>
187# <i>mke2fs -F root_fs</i> 245# <i>mke2fs -F root_fs</i>
188# <i>mount -o loop root_fs /mnt/loop</i> 246# <i>mount -o loop root_fs /mnt/loop</i>
189# <i>tar xvjpf gentoo.tbz2 -C /mnt/loop</i> 247# <i>tar xvjpf gentoo.tbz2 -C /mnt/loop</i>
190# <i>umount /mnt/loop</i> 248# <i>umount /mnt/loop</i>
191</pre> 249</pre>
250
192<p> 251<p>
193It would also be nice to have a 0.5 GB swap partition. 252It would also be nice to have a 0.5 GB swap partition.
194</p> 253</p>
195<pre> 254
255<pre caption="Create swap partition">
196# <i>dd if=/dev/zero of=swap_fs seek=500 count=1 bs=1M</i> 256# <i>dd if=/dev/zero of=swap_fs seek=500 count=1 bs=1M</i>
197# <i>mkswap -f swap_fs</i> 257# <i>mkswap -f swap_fs</i>
198</pre> 258</pre>
259
199<p> 260<p>
200Now see if it works! 261Now see if it works!
201</p> 262</p>
202<pre> 263
264<pre caption="Start UML kernel thread">
203# <i>linux ubd0=root_fs ubd1=swap_fs</i> 265# <i>linux ubd0=root_fs ubd1=swap_fs</i>
204</pre> 266</pre>
267
268<p>
269User-mode Linux uses xterms for the virtual consoles that
270are run at boot time, so you need to make sure that the
271terminal from which you run user-mode Linux has $DISPLAY
272properly set (along with proper xhost/xauth permissions).
273</p>
274
275<p>
276With any luck you should be able to log into your user-mode Linux
277Gentoo system. The only thing keeping this user-mode Linux version
278of Gentoo from being fully functional is networking from the virtual
279machine to the host.
280</p>
281
205<note> 282<note>
206User-mode linux uses xterms for the virtual consoles that 283If you receive "No space left on device" errors, you may need to allocate more
207are run at boot time, so you need to make sure that the 284memory to your user mode system by appending <c>mem=xxxMB</c> to the end of the
208terminal from which you run user-mode linux has $DISPLAY 285kernel thread line. For example: <c>linux ubd0=root_fs ubd1=swap_fs
209properly set (along with proper xhost/xauth permissions). 286mem=128MB</c>.
210</note> 287</note>
211<p> 288
212With any luck you should be able to log into your user-mode linux
213Gentoo system. The only thing keeping this user-mode linux version
214of Gentoo from being fully functional is networking from the virtual
215machine to the host. Such networking is supposed to be trivial,
216but I have yet to get it to work for me. Should you find a workable
217solution, please let me know!
218</p>
219</body> 289</body>
220</section> 290</section>
221</chapter> 291</chapter>
222 292
223<chapter> 293<chapter>
224<title>Networking</title> 294<title>Networking</title>
225
226<section> 295<section>
296<title>Using an Existing Network</title>
227<body> 297<body>
228<p> 298
229Thanks to Martin Schlemmer (Azarah), I now know how
230to get networking to function from within a user-mode
231system. The idea is that we set up a private network
232consisting of the user-mode system and the host system,
233and then the user-mode system routes all of its packets
234to the host, which then forwards packets to the net.
235Make sure that the host kernel has
236Networking --> IP: Netfilter Configuration --> IP tables support
237--> Full NAT --> MASQUERADE target support and
238Network Device Support --> Ethertap network tap
239compiled as modules; then do the following on the
240<e>host</e> machine:
241</p> 299<p>
300Make sure that the host kernel has the following settings compiled as modules:
301</p>
302
303<pre caption="Host kernel configuration">
304Networking --&gt;
305 IP: Netfilter Configuration --&gt;
306 IP tables support --&gt;
307 Full NAT --&gt;
308 &lt;M&gt; MASQUERADE target support
309
310 Network Device Support --&gt;
311 &lt;M&gt; TUN/TAP Support
242<pre> 312</pre>
313
314<p>
315Run the following commands on the <e>host</e> machine:
316</p>
317
318<pre caption="Setup networking">
243# <i>modprobe ethertap</i> 319# <i>modprobe tun</i>
320<comment>(If you receive a FATAL error here, try deleting /dev/net/tun and retry)</comment>
244# <i>modprobe iptable_nat</i> 321# <i>modprobe iptable_nat</i>
245# <i>iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE</i> 322# <i>iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE</i>
246# <i>echo 1 > /proc/sys/net/ipv4/ip_forward</i> 323# <i>echo 1 &gt; /proc/sys/net/ipv4/ip_forward</i>
247</pre> 324</pre>
325
248<p> 326<p>
249The iptables line sets up IP Masquerading between the private 327The iptables line sets up IP Masquerading between the private
250network that our user-mode system will be on and the internet 328network that our user-mode system will be on and the internet
251(reachable via <c>eth0</c> in our case). The echo line then 329(reachable via <c>eth0</c> in our case). The echo line then
252turns on packet forwarding between the private network and the 330turns on packet forwarding between the private network and the
253interface that the default gateway is on (eth0 for us). 331interface that the default gateway is on (eth0 for us).
254</p> 332</p>
333
255<p> 334<p>
256Now we bring up the user-mode system and see if networking 335Now we bring up the user-mode system and see if networking
257is functional. 336is functional.
258</p> 337</p>
259<pre> 338
339<pre caption="Get UML up and running">
260# <i>linux ubd0=root_fs ubd1=swap_fs eth0=ethertap,tap0,,192.168.0.254</i> 340# <i>linux ubd0=root_fs ubd1=swap_fs eth0=tuntap,,,192.168.0.254</i>
261<comment>(login to user-mode system)</comment> 341<comment>(login to user-mode system)</comment>
262# <i>ifconfig eth0 192.168.0.1 up</i> 342# <i>ifconfig eth0 192.168.0.1 up</i>
263# <i>ping -c 2 192.168.0.254</i> 343# <i>ping -c 2 192.168.0.254</i>
264PING 192.168.0.254 (192.168.0.254): 56 octets data 344PING 192.168.0.254 (192.168.0.254): 56 octets data
26564 octets from 192.168.0.254: icmp_seq=0 ttl=255 time=0.8 ms 34564 octets from 192.168.0.254: icmp_seq=0 ttl=255 time=0.8 ms
26664 octets from 192.168.0.254: icmp_seq=1 ttl=255 time=0.6 ms 34664 octets from 192.168.0.254: icmp_seq=1 ttl=255 time=0.6 ms
267 347
268--- 192.168.0.254 ping statistics --- 348--- 192.168.0.254 ping statistics ---
2692 packets transmitted, 2 packets received, 0% packet loss 3492 packets transmitted, 2 packets received, 0% packet loss
270round-trip min/avg/max = 0.6/0.7/0.8 ms 350round-trip min/avg/max = 0.6/0.7/0.8 ms
271<i>route add default gw 192.168.0.254</i> 351# <i>route add default gw 192.168.0.254</i>
272<i>netstat -rn</i> 352# <i>netstat -rn</i>
273Kernel IP routing table 353Kernel IP routing table
274Destination Gateway Genmask Flags MSS Window irtt Iface 354Destination Gateway Genmask Flags MSS Window irtt Iface
275192.168.0.0 0.0.0.0 255.255.255.0 U 40 0 0 eth0 355192.168.0.0 0.0.0.0 255.255.255.0 U 40 0 0 eth0
2760.0.0.0 192.168.0.254 0.0.0.0 UG 40 0 0 eth0 3560.0.0.0 192.168.0.254 0.0.0.0 UG 40 0 0 eth0
277<i>scp user@192.168.0.254:/etc/resolv.conf /etc/resolv.conf</i> <comment>(if needed)</comment> 357# <i>scp user@192.168.0.254:/etc/resolv.conf /etc/resolv.conf</i> <comment>(if needed)</comment>
278<i>ping -c 2 www.gentoo.org</i> 358# <i>ping -c 2 www.gentoo.org</i>
279PING www.gentoo.org (207.170.82.202): 56 octets data 359PING www.gentoo.org (207.170.82.202): 56 octets data
28064 octets from 207.170.82.202: icmp_seq=0 ttl=240 time=119.6 ms 36064 octets from 207.170.82.202: icmp_seq=0 ttl=240 time=119.6 ms
28164 octets from 207.170.82.202: icmp_seq=1 ttl=240 time=92.0 ms 36164 octets from 207.170.82.202: icmp_seq=1 ttl=240 time=92.0 ms
282 362
283--- www.gentoo.org ping statistics --- 363--- www.gentoo.org ping statistics ---
2842 packets transmitted, 2 packets received, 0% packet loss 3642 packets transmitted, 2 packets received, 0% packet loss
285round-trip min/avg/max = 92.0/105.8/119.6 ms 365round-trip min/avg/max = 92.0/105.8/119.6 ms
286</pre> 366</pre>
367
287<p> 368<p>
288On the user-mode system we assign the user-mode eth0 interface 369On the user-mode system we assign the user-mode eth0 interface
289the private IP address 192.168.0.1 and bring up the interface. The 370the private IP address 192.168.0.1 and bring up the interface. The
290host has private IP address 192.168.0.254, and we ping it to make sure 371host has private IP address 192.168.0.254, and we ping it to make sure
291that our networking is, indeed, up. The route line adds a default 372that our networking is, indeed, up. The route line adds a default
293<path>/etc/resolv.conf</path> (if necessary), and we ping www.gentoo.org 374<path>/etc/resolv.conf</path> (if necessary), and we ping www.gentoo.org
294to make sure that name resolution (and general access to the internet) 375to make sure that name resolution (and general access to the internet)
295is working from our user-mode system. Now the user-mode system can 376is working from our user-mode system. Now the user-mode system can
296<c>emerge</c> at will! 377<c>emerge</c> at will!
297</p> 378</p>
379
380</body>
381</section>
382<section>
383<title>Using a Virtual Network</title>
384<body>
385
386<p>
387Before you get all too excited, this is not a virtual private network. It is a
388network that is only accessible by the UML instances. The
389<c>usermode-utilities</c> package provides a tool called <c>uml_switch</c> which
390defines the end points of the switch.
391</p>
392
393<pre caption="Activating end points of a UML switch">
394<comment>(If the switch information should stay in the foreground:)</comment>
395$ <i>uml_switch -unix ~/tmp/switch.sock</i>
396
397<comment>(If it should be backgrounded:)</comment>
398$ <i>uml_switch -unix ~/tmp/switch.sock &amp;&gt; ~/tmp/switch.log &amp;</i>
399</pre>
400
401<p>
402To start the UML instances on the switch, run the next command. Your
403(virtual) network interface will be connected to the <c>uml_switch</c> process
404and will be using the given MAC address.
405</p>
406
407<pre caption="Running first UML instance">
408$ <i>linux ubd0=first_rootfs ubd1=first_swapfs eth0=daemon,10:00:01:02:00:00,,~/tmp/switch.sock</i>
409</pre>
410
411<p>
412You can still connect the system to the existing network, or have a second
413process attached to both the virtual one and the existing one:
414</p>
415
416<pre caption="Running second UML instance">
417$ <i>linux ubd0=second_rootfs ubd1=second_swapfs eth0=daemon,10:00:01:02:00:01,,~/tmp/switch.sock \
418 eth1=tuntap,,,192.168.1.43</i>
419</pre>
420
421<p>
422More information about the tuntap setting can be found in the previous section.
423</p>
424
298</body> 425</body>
299</section> 426</section>
300</chapter> 427</chapter>
301
302<chapter> 428<chapter>
303<title>Testing the .iso</title> 429<title>Testing the .iso</title>
304
305<section> 430<section>
306<body> 431<body>
432
307<p> 433<p>
308Perhaps the true ideal of Gentoo Linux testing would be 434Perhaps the true ideal of Gentoo Linux testing would be
309to boot the .iso with user-mode linux and do the complete 435to boot the .iso with user-mode Linux and do the complete
310Gentoo install from within the user-mode linux virtual system. 436Gentoo install from within the user-mode Linux virtual system.
311</p> 437</p>
438
312<p> 439<p>
313Booting the .iso, or actually the initrd from the .iso, is pretty 440Booting the .iso, or actually the initrd from the .iso, is pretty
314straightforward. 441straightforward.
315</p> 442</p>
316<pre> 443
444<pre caption="Booting the ISO">
317# <i>mount -o loop /path/to/build-&lt;TAB&gt;.iso /mnt/loop</i> 445# <i>mount -o loop /path/to/install-&lt;TAB&gt;.iso /mnt/loop</i>
318# <i>cp /mnt/loop/isolinux/rescue.gz .</i> 446# <i>cp /mnt/loop/isolinux/gentoo.igz .</i>
319# <i>linux load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=22000 \</i> 447# <i>linux load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=22000 \</i>
320&gt; <i>initrd=rescue.gz root=/dev/ram0 ubd0=root_fs ubd1=swap_fs \</i> 448&gt; <i>initrd=rescue.gz root=/dev/ram0 ubd0=root_fs ubd1=swap_fs \</i>
321&gt; <i>ubd2=/dev/cdroms/cdrom0 eth0=ethertap,tap0,,192.168.0.254</i> 449&gt; <i>ubd2=/dev/cdroms/cdrom0 eth0=tuntap,,,192.168.0.254</i>
322</pre> 450</pre>
451
452<p>
323<p>Now you can follow the Gentoo install doc essentially verbatim, 453Now you can follow the Gentoo install doc essentially verbatim,
324although you'll need to know that the root filesystem will be 454although you'll need to know that the root filesystem will be
325<path>/dev/ubd/0</path>, the swap "partition" 455<path>/dev/ubd/0</path>, the swap "partition"
326will be <path>/dev/ubd/1</path>, and the CD rom 456will be <path>/dev/ubd/1</path>, and the CD rom
327will be <path>/dev/ubd/2</path>.</p> 457will be <path>/dev/ubd/2</path>.
458</p>
459
328</body> 460</body>
329</section> 461</section>
330</chapter> 462</chapter>
331 463
464<chapter>
465<title>Resources</title>
466<section>
467<body>
468
469<ul>
470 <li>
471 <uri link="http://edeca.net/articles/bridging/index.html">Bridging with
472 UML</uri>
473 </li>
474 <li>
475 <uri link="http://user-mode-linux.sourceforge.net/">UML Homepage</uri>
476 </li>
477 <li>
478 <uri link="http://www.theshore.net/~caker/uml/">Caker's UML Notes</uri>
479 </li>
480 <li>
481 <uri link="http://sourceforge.net/mailarchive/forum.php?forum_id=3647">UML
482 Mailinglist archives</uri>
483 </li>
484</ul>
485
486</body>
487</section>
488</chapter>
332 489
333</guide> 490</guide>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.32

  ViewVC Help
Powered by ViewVC 1.1.20