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.21 2004/10/22 09:34:38 bennyc 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 link="/doc/en/uml.xml"> |
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 | <author title="Editor"> |
8 | <author title="Editor"><mail link="g2boojum@gentoo.org">Grant Goodyear</mail></author> |
9 | <mail link="g2boojum@gentoo.org">Grant Goodyear</mail> |
|
|
10 | </author> |
|
|
11 | <author title="Editor"><!-- zhen@gentoo.org --> |
|
|
12 | John Davis |
|
|
13 | </author> |
|
|
14 | <author title="Editor"> |
|
|
15 | <mail link="swift@gentoo.org">Sven Vermeulen</mail> |
|
|
16 | </author> |
|
|
17 | <author title="Editor"> |
|
|
18 | <mail link="bennyc@gentoo.org">Benny Chuang</mail> |
|
|
19 | </author> |
9 | |
20 | |
10 | <abstract> |
21 | <abstract> |
11 | This guide shows Gentoo Linux developers how to set up and use |
22 | This guide shows Gentoo Linux developers how to set up and use |
12 | user-mode linux for testing potentially system-breaking changes. |
23 | user-mode linux for testing potentially system-breaking changes. |
13 | </abstract> |
24 | </abstract> |
14 | |
25 | |
|
|
26 | <license/> |
|
|
27 | |
15 | <version>0.05</version> |
28 | <version>0.9</version> |
16 | <date>5 Mar 2002</date> |
29 | <date>October 22, 2004</date> |
17 | |
30 | |
18 | <chapter> |
31 | <chapter> |
19 | <title>Obtaining User-Mode Linux</title> |
32 | <title>Obtaining User-Mode Linux</title> |
20 | <section> |
33 | <section> |
21 | <body> |
34 | <body> |
|
|
35 | |
|
|
36 | <p> |
22 | <p>As the user-mode linux website |
37 | As the user-mode linux website |
23 | (<uri>http://user-mode-linux.sourceforge.net</uri>) |
38 | (<uri>http://user-mode-linux.sourceforge.net</uri>) states, user-mode linux |
24 | states, user-mode linux |
|
|
25 | allows a user to "run Linux inside itself". Specifically, |
39 | allows a user to "run Linux inside itself". Specifically, |
26 | user-mode linux provides a virtual machine on which a user can "[r]un buggy |
40 | user-mode linux provides a virtual machine on which a user can "[r]un buggy |
27 | software, experiment with new Linux kernels or distributions, and poke around |
41 | software, experiment with new Linux kernels or distributions, and poke around |
28 | in the internals of Linux, all without risking your main Linux setup." Changes |
42 | in the internals of Linux, all without risking your main Linux setup." Changes |
29 | to Gentoo core packages such as <e>sys-apps/baselayout</e> or <e>sys-libs/glibc</e> |
43 | to Gentoo core packages such as <e>sys-apps/baselayout</e> or |
30 | have the potential to break the system and render it unbootable; with user-mode |
44 | <e>sys-libs/glibc</e> have the potential to break the system and render it |
31 | linux we can test these changes without having to worry about breaking the live |
45 | unbootable; with user-mode linux we can test these changes without having to |
32 | system. |
46 | worry about breaking the live system. |
33 | </p> |
47 | </p> |
|
|
48 | |
34 | <p> |
49 | <p> |
35 | Installing user-mode linux is essentially identical to a normal kernel |
50 | Installing user-mode linux is essentially identical to a normal kernel |
36 | install. First install the kernel sources (appropriately patched for |
51 | install. First install the kernel sources (appropriately patched for |
37 | user-mode linux), and then configure the user-mode linux kernel in the |
52 | user-mode linux), and then configure the user-mode linux kernel in the |
38 | usual fashion: |
53 | usual fashion: |
39 | </p> |
54 | </p> |
40 | <pre> |
55 | |
|
|
56 | <pre caption="Installing UML kernel sources"> |
41 | # <i>emerge sys-kernel/usermode-sources</i> |
57 | # <i>emerge sys-kernel/usermode-sources</i> |
42 | # <i>cd /usr/src/uml/linux</i> |
58 | # <i>cd /usr/src/uml/linux</i> |
43 | # <i>make menuconfig <comment>ARCH=um</comment></i> |
59 | # <i>make menuconfig <comment>ARCH=um</comment></i> |
44 | # <i>make linux <comment>ARCH=um</comment></i> |
60 | # <i>make linux <comment>ARCH=um</comment></i> |
45 | # <i>cp linux /usr/local/bin/linux</i> |
61 | # <i>cp linux /usr/local/bin/linux</i> |
46 | </pre> |
62 | </pre> |
|
|
63 | |
|
|
64 | <warn> |
47 | <warn>The <e>ARCH=um</e> fragment is <e>extremely</e> important!</warn> |
65 | The <e>ARCH=um</e> fragment is <e>extremely</e> important! |
48 | <impo> |
66 | </warn> |
|
|
67 | |
|
|
68 | <p> |
|
|
69 | Make sure that <path>/usr/local/bin</path> is in your path. Edit |
|
|
70 | <path>/etc/env.d/00basic</path> to that the PATH variable contains |
|
|
71 | <path>/usr/local/bin</path> and rerun <c>env-update</c>: |
|
|
72 | </p> |
|
|
73 | |
|
|
74 | <pre caption="Editing 00basic"> |
|
|
75 | # <i>nano -w /etc/env.d/00basic</i> |
|
|
76 | # <i>env-update</i> |
|
|
77 | # <i>source /etc/profile</i> |
|
|
78 | </pre> |
|
|
79 | |
|
|
80 | <p> |
49 | For the user-mode linux kernel to properly boot a Gentoo system the |
81 | For the user-mode linux kernel to properly boot a Gentoo system the |
50 | kernel needs to be configured to <e>not</e> automatically mount |
82 | kernel needs to be configured to <e>not</e> automatically mount |
51 | <path>/dev</path> (devfs) by default. |
83 | <path>/dev</path> (devfs) by default. Also, you will almost certainly |
52 | Also, you will almost certainly |
|
|
53 | want to make sure that you have <e>tmpfs</e> (the "Virtual Memory |
84 | want to make sure that you have <e>tmpfs</e> (the "Virtual Memory |
54 | Filesystem") compiled in, since by default the Gentoo linux bootscripts |
85 | Filesystem") compiled in, since by default the Gentoo linux bootscripts |
55 | store their information in a small tmpfs partition. |
86 | store their information in a small tmpfs partition. |
56 | (The binary kernels available |
87 | (The binary kernels available from the user-mode website do automatically |
57 | from the user-mode website do automatically mount <path>/dev</path>, |
88 | mount <path>/dev</path>, and they don't have tmpfs compiled in; don't bother |
58 | and they don't have tmpfs compiled in; don't bother with them.) |
89 | with them). |
59 | </impo> |
90 | </p> |
|
|
91 | |
|
|
92 | <p> |
60 | <p>I highly recommend reading the user-mode linux documentation, but the |
93 | I highly recommend reading the user-mode linux documentation, but the |
61 | basic idea is that running the <path>/usr/local/bin/linux</path> program |
94 | basic idea is that running the <path>/usr/local/bin/linux</path> program |
62 | boots the user-mode kernel and tries to bring up the system stored in |
95 | boots the user-mode kernel and tries to bring up the system stored in |
63 | the file <path>root_fs</path> that should be located in the current working |
96 | the file <path>root_fs</path> that should be located in the current working |
64 | directory.</p> |
97 | directory. |
|
|
98 | </p> |
|
|
99 | |
|
|
100 | <p> |
65 | <p>It won't hurt to also install the user-mode linux tools.</p> |
101 | It won't hurt to also install the user-mode linux tools. |
66 | <pre> |
102 | </p> |
|
|
103 | |
|
|
104 | <pre caption="Installing UML tools"> |
67 | # <i>emerge sys-apps/usermode-utilities</i> |
105 | # <i>emerge sys-apps/usermode-utilities</i> |
68 | </pre> |
106 | </pre> |
|
|
107 | |
|
|
108 | <p> |
69 | <p>These tools facilitate networking (among other things) |
109 | These tools facilitate networking (among other things) between the user-mode |
70 | between the user-mode linux virtual system |
110 | linux virtual system and the host Linux system. |
71 | and the host Linux system.</p> |
111 | </p> |
|
|
112 | |
72 | </body> |
113 | </body> |
73 | </section> |
114 | </section> |
74 | </chapter> |
115 | </chapter> |
75 | |
116 | |
76 | <chapter> |
117 | <chapter> |
77 | <title>Creating <path>root_fs</path></title> |
118 | <title>Creating root_fs</title> |
78 | |
|
|
79 | <section> |
119 | <section> |
80 | <title>Making the Gentoo chroot</title> |
120 | <title>Making the Gentoo chroot</title> |
81 | <body> |
121 | <body> |
|
|
122 | |
82 | <p> |
123 | <p> |
83 | The <path>root_fs</path> file needed for user-mode linux is |
124 | The <path>root_fs</path> file needed for user-mode linux is |
84 | a single file that contains an entire Gentoo Linux filesystem. |
125 | a single file that contains an entire Gentoo Linux filesystem. |
85 | To generate this file you will need to have Loopback device |
126 | To generate this file you will need to have Loopback device |
86 | support enabled in the host (non-user-mode) kernel. |
127 | support enabled in the host (non-user-mode) kernel. |
87 | </p> |
128 | </p> |
|
|
129 | |
|
|
130 | <p> |
88 | <p>Generating the <path>root_fs</path> file itself will be |
131 | Generating the <path>root_fs</path> file itself will be |
89 | our last step. First we will generate a Gentoo filesystem in |
132 | our last step. First we will generate a Gentoo filesystem in |
90 | an ordinary chroot. We need the build tarball available, which |
133 | an ordinary chroot. We need the stage tarball available, which |
91 | could be downloaded separately, extracted from a build cd, or |
134 | could be downloaded separately, extracted from a liveCD, or |
92 | extracted from a build .iso. |
135 | extracted from a liveCD .iso. |
93 | </p> |
136 | </p> |
|
|
137 | |
94 | <pre caption="Mounting a build .iso"> |
138 | <pre caption="Mounting a liveCD .iso"> |
95 | # <i>mkdir /mnt/loop</i> |
139 | # <i>mkdir /mnt/loop</i> |
96 | # <i>mount -o loop /path/to/build-<TAB>.iso /mnt/loop</i> |
140 | # <i>mount -o loop /path/to/install-<TAB>.iso /mnt/loop</i> |
97 | </pre> |
141 | </pre> |
|
|
142 | |
98 | <p> |
143 | <p> |
99 | Setting up the chroot is essentially identical to an ordinary Gentoo |
144 | Setting up the chroot is essentially identical to an ordinary Gentoo |
100 | Linux build. |
145 | Linux build. |
101 | </p> |
146 | </p> |
102 | <pre> |
147 | |
|
|
148 | <pre caption="Creating the Gentoo chroot mount"> |
103 | # <i>mkdir /mnt/gentoo</i> |
149 | # <i>mkdir /mnt/gentoo</i> |
104 | # <i>cd /mnt/gentoo</i> |
150 | # <i>cd /mnt/gentoo</i> |
105 | # <i>tar xvjpf /path/to/build-<TAB>.tar.bz2</i> |
151 | # <i>tar xvjpf /path/to/stage<TAB>.tar.bz2</i> |
106 | </pre> |
152 | </pre> |
|
|
153 | |
107 | <p> |
154 | <p> |
108 | Go ahead and unmount the .iso. You don't need it anymore. |
155 | Go ahead and unmount the .iso. You don't need it anymore. |
109 | </p> |
156 | </p> |
110 | <pre> |
157 | |
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> |
|
|
122 | By bind-mounting <path>/usr/portage/distfiles</path> and |
|
|
123 | <path>/usr/portage/packages</path> we avoid having to download |
|
|
124 | or build packages that are already present on the Gentoo host. |
|
|
125 | </p> |
158 | <p> |
|
|
159 | Bootstrap and build the system in the usual fashion. Just follow the |
|
|
160 | installation instructions :) |
126 | <p> |
161 | </p> |
127 | Bootstrap and build the system in the usual fashion: |
162 | |
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 && emerge --usepkg system</i> |
|
|
136 | </pre> |
|
|
137 | <warn> |
|
|
138 | The <path>/etc/make.profile/packages</path> file needs to be |
|
|
139 | edited to remove grub from the default system (just remove the "*" |
|
|
140 | from the beginning of the "*sys-apps/grub" line). The grub ebuild |
|
|
141 | tries to mount the /boot partition, which will fail in our chroot. |
|
|
142 | </warn> |
|
|
143 | <note> |
|
|
144 | Make sure you examine <path>/etc/make.profile/packages</path> |
|
|
145 | and <path>/usr/portage/profiles/package.mask</path> to be sure that |
|
|
146 | any to-be-tested packages that you want to install aren't masked out. |
|
|
147 | As currently written, <path>scripts/bootstrap.sh</path> will compile |
|
|
148 | the bootstrap packages from source. To use already-existing packages, |
|
|
149 | add <c>alias emerge="emerge --usepkg"</c> somewhere near the top of |
|
|
150 | the bootstrap script. |
|
|
151 | </note> |
|
|
152 | <p> |
163 | <p> |
153 | Add any additional packages you desire. Feel free to give your virtual |
164 | Add any additional packages you desire. Feel free to give your virtual |
154 | Gentoo system a hostname, if you so desire. In <path>/etc/fstab</path> |
165 | Gentoo system a hostname, if you so desire. In <path>/etc/fstab</path> |
155 | you will want <path>/dev/ROOT</path> to be <path>/dev/ubd/0</path>, with |
166 | you will want <path>/dev/ROOT</path> to be <path>/dev/ubd/0</path>, with |
156 | a fs type of either ext2, ext3, or reiserfs. Set <path>/dev/SWAP</path> |
167 | a fs type of either ext2, ext3, or reiserfs. Set <path>/dev/SWAP</path> |
157 | to be <path>/dev/ubd/1</path>, and comment out <path>/dev/BOOT</path>. |
168 | to be <path>/dev/ubd/1</path>, and comment out <path>/dev/BOOT</path>. |
158 | </p> |
169 | </p> |
|
|
170 | |
|
|
171 | <p> |
|
|
172 | At this point, remember to set your root password. |
|
|
173 | </p> |
|
|
174 | |
|
|
175 | <pre caption="Setting root password"> |
|
|
176 | # <i>passwd</i> |
|
|
177 | </pre> |
|
|
178 | |
|
|
179 | <p> |
|
|
180 | Now we need to make some changes to the boot scripts. Remove consolefont and |
|
|
181 | keymaps from the boot runlevel: |
|
|
182 | </p> |
|
|
183 | |
|
|
184 | <pre caption="Removing unneeded initscripts"> |
|
|
185 | # <i>rc-update del consolefont boot</i> |
|
|
186 | # <i>rc-update del keymaps boot</i> |
|
|
187 | </pre> |
|
|
188 | |
159 | <p> |
189 | <p> |
160 | Exit the chroot, unmount all of the bind mounts, |
190 | Exit the chroot, unmount all of the bind mounts, |
161 | tar up the new Gentoo distro, and clean up: |
191 | tar up the new Gentoo distro, and clean up. |
162 | </p> |
192 | </p> |
163 | <pre> |
193 | |
164 | # <i>exit</i> |
194 | <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> |
195 | # <i>cd /mnt/gentoo</i> |
169 | 261744 /mnt/gentoo |
|
|
170 | # <i>tar cvjpf ~/gentoo.tbz2 *</i> |
196 | # <i>tar cvjpf ~/gentoo.tbz2 *</i> |
171 | # <i>cd</i> |
197 | # <i>cd</i> |
172 | # <i>rm -rf /mnt/gentoo</i> |
198 | # <i>rm -rf /mnt/gentoo</i> |
173 | </pre> |
199 | </pre> |
174 | </body> |
|
|
175 | </section> |
|
|
176 | |
200 | |
|
|
201 | </body> |
177 | <section> |
202 | </section> |
|
|
203 | <section> |
178 | <title>Making <path>root_fs</path></title> |
204 | <title>Making root_fs</title> |
179 | <body> |
205 | <body> |
|
|
206 | |
180 | <p> |
207 | <p> |
181 | Our Gentoo chroot is nearly 300 MB in size, so |
208 | Our Gentoo chroot is nearly 300 MB in size, so |
182 | <path>root_fs</path> needs to be at least that size. |
209 | <path>root_fs</path> needs to be at least that size. |
183 | We'll choose 0.5 GB as a reasonable size. |
210 | We'll choose 0.5 GB as a reasonable size. |
184 | </p> |
211 | </p> |
185 | <pre> |
212 | |
|
|
213 | <pre caption="Creating UML files"> |
186 | # <i>dd if=/dev/zero of=root_fs seek=500 count=1 bs=1M</i> |
214 | # <i>dd if=/dev/zero of=root_fs seek=500 count=1 bs=1M</i> |
187 | # <i>mke2fs -F root_fs</i> |
215 | # <i>mke2fs -F root_fs</i> |
188 | # <i>mount -o loop root_fs /mnt/loop</i> |
216 | # <i>mount -o loop root_fs /mnt/loop</i> |
189 | # <i>tar xvjpf gentoo.tbz2 -C /mnt/loop</i> |
217 | # <i>tar xvjpf gentoo.tbz2 -C /mnt/loop</i> |
190 | # <i>umount /mnt/loop</i> |
218 | # <i>umount /mnt/loop</i> |
191 | </pre> |
219 | </pre> |
|
|
220 | |
192 | <p> |
221 | <p> |
193 | It would also be nice to have a 0.5 GB swap partition. |
222 | It would also be nice to have a 0.5 GB swap partition. |
194 | </p> |
223 | </p> |
195 | <pre> |
224 | |
|
|
225 | <pre caption="Create swap partition"> |
196 | # <i>dd if=/dev/zero of=swap_fs seek=500 count=1 bs=1M</i> |
226 | # <i>dd if=/dev/zero of=swap_fs seek=500 count=1 bs=1M</i> |
197 | # <i>mkswap -f swap_fs</i> |
227 | # <i>mkswap -f swap_fs</i> |
198 | </pre> |
228 | </pre> |
|
|
229 | |
199 | <p> |
230 | <p> |
200 | Now see if it works! |
231 | Now see if it works! |
201 | </p> |
232 | </p> |
202 | <pre> |
233 | |
|
|
234 | <pre caption="Start UML kernel thread"> |
203 | # <i>linux ubd0=root_fs ubd1=swap_fs</i> |
235 | # <i>linux ubd0=root_fs ubd1=swap_fs</i> |
204 | </pre> |
236 | </pre> |
205 | <note> |
237 | |
|
|
238 | <p> |
206 | User-mode linux uses xterms for the virtual consoles that |
239 | User-mode linux uses xterms for the virtual consoles that |
207 | are run at boot time, so you need to make sure that the |
240 | are run at boot time, so you need to make sure that the |
208 | terminal from which you run user-mode linux has $DISPLAY |
241 | terminal from which you run user-mode linux has $DISPLAY |
209 | properly set (along with proper xhost/xauth permissions). |
242 | properly set (along with proper xhost/xauth permissions). |
210 | </note> |
243 | </p> |
|
|
244 | |
211 | <p> |
245 | <p> |
212 | With any luck you should be able to log into your user-mode linux |
246 | With any luck you should be able to log into your user-mode linux |
213 | Gentoo system. The only thing keeping this user-mode linux version |
247 | Gentoo system. The only thing keeping this user-mode linux version |
214 | of Gentoo from being fully functional is networking from the virtual |
248 | of Gentoo from being fully functional is networking from the virtual |
215 | machine to the host. Such networking is supposed to be trivial, |
249 | machine to the host. |
216 | but I have yet to get it to work for me. Should you find a workable |
|
|
217 | solution, please let me know! |
|
|
218 | </p> |
250 | </p> |
|
|
251 | |
219 | </body> |
252 | </body> |
220 | </section> |
253 | </section> |
221 | </chapter> |
254 | </chapter> |
222 | |
255 | |
223 | <chapter> |
256 | <chapter> |
224 | <title>Networking</title> |
257 | <title>Networking</title> |
225 | |
|
|
226 | <section> |
258 | <section> |
227 | <body> |
259 | <body> |
228 | <p> |
260 | |
229 | Thanks to Martin Schlemmer (Azarah), I now know how |
|
|
230 | to get networking to function from within a user-mode |
|
|
231 | system. The idea is that we set up a private network |
|
|
232 | consisting of the user-mode system and the host system, |
|
|
233 | and then the user-mode system routes all of its packets |
|
|
234 | to the host, which then forwards packets to the net. |
|
|
235 | Make sure that the host kernel has |
|
|
236 | Networking --> IP: Netfilter Configuration --> IP tables support |
|
|
237 | --> Full NAT --> MASQUERADE target support and |
|
|
238 | Network Device Support --> Ethertap network tap |
|
|
239 | compiled as modules; then do the following on the |
|
|
240 | <e>host</e> machine: |
|
|
241 | </p> |
261 | <p> |
|
|
262 | Make sure that the host kernel has the following settings compiled as modules: |
|
|
263 | </p> |
|
|
264 | |
|
|
265 | <pre caption="Host kernel configuration"> |
|
|
266 | Networking --> |
|
|
267 | IP: Netfilter Configuration --> |
|
|
268 | IP tables support --> |
|
|
269 | Full NAT --> |
|
|
270 | <M> MASQUERADE target support |
|
|
271 | |
|
|
272 | Network Device Support --> |
|
|
273 | <M> TUN/TAP Support |
242 | <pre> |
274 | </pre> |
|
|
275 | |
|
|
276 | <p> |
|
|
277 | Run the following commands on the <e>host</e> machine: |
|
|
278 | </p> |
|
|
279 | |
|
|
280 | <pre caption="Setup networking"> |
243 | # <i>modprobe ethertap</i> |
281 | # <i>modprobe tun</i> |
|
|
282 | <comment>(If you receive a FATAL error here, try deleting /dev/net/tun and retry)</comment> |
244 | # <i>modprobe iptable_nat</i> |
283 | # <i>modprobe iptable_nat</i> |
245 | # <i>iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE</i> |
284 | # <i>iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE</i> |
246 | # <i>echo 1 > /proc/sys/net/ipv4/ip_forward</i> |
285 | # <i>echo 1 > /proc/sys/net/ipv4/ip_forward</i> |
247 | </pre> |
286 | </pre> |
|
|
287 | |
248 | <p> |
288 | <p> |
249 | The iptables line sets up IP Masquerading between the private |
289 | The iptables line sets up IP Masquerading between the private |
250 | network that our user-mode system will be on and the internet |
290 | network that our user-mode system will be on and the internet |
251 | (reachable via <c>eth0</c> in our case). The echo line then |
291 | (reachable via <c>eth0</c> in our case). The echo line then |
252 | turns on packet forwarding between the private network and the |
292 | turns on packet forwarding between the private network and the |
253 | interface that the default gateway is on (eth0 for us). |
293 | interface that the default gateway is on (eth0 for us). |
254 | </p> |
294 | </p> |
|
|
295 | |
255 | <p> |
296 | <p> |
256 | Now we bring up the user-mode system and see if networking |
297 | Now we bring up the user-mode system and see if networking |
257 | is functional. |
298 | is functional. |
258 | </p> |
299 | </p> |
259 | <pre> |
300 | |
|
|
301 | <pre caption="Get UML up and running"> |
260 | # <i>linux ubd0=root_fs ubd1=swap_fs eth0=ethertap,tap0,,192.168.0.254</i> |
302 | # <i>linux ubd0=root_fs ubd1=swap_fs eth0=tuntap,,,192.168.0.254</i> |
261 | <comment>(login to user-mode system)</comment> |
303 | <comment>(login to user-mode system)</comment> |
262 | # <i>ifconfig eth0 192.168.0.1 up</i> |
304 | # <i>ifconfig eth0 192.168.0.1 up</i> |
263 | # <i>ping -c 2 192.168.0.254</i> |
305 | # <i>ping -c 2 192.168.0.254</i> |
264 | PING 192.168.0.254 (192.168.0.254): 56 octets data |
306 | PING 192.168.0.254 (192.168.0.254): 56 octets data |
265 | 64 octets from 192.168.0.254: icmp_seq=0 ttl=255 time=0.8 ms |
307 | 64 octets from 192.168.0.254: icmp_seq=0 ttl=255 time=0.8 ms |
266 | 64 octets from 192.168.0.254: icmp_seq=1 ttl=255 time=0.6 ms |
308 | 64 octets from 192.168.0.254: icmp_seq=1 ttl=255 time=0.6 ms |
267 | |
309 | |
268 | --- 192.168.0.254 ping statistics --- |
310 | --- 192.168.0.254 ping statistics --- |
269 | 2 packets transmitted, 2 packets received, 0% packet loss |
311 | 2 packets transmitted, 2 packets received, 0% packet loss |
270 | round-trip min/avg/max = 0.6/0.7/0.8 ms |
312 | round-trip min/avg/max = 0.6/0.7/0.8 ms |
271 | <i>route add default gw 192.168.0.254</i> |
313 | # <i>route add default gw 192.168.0.254</i> |
272 | <i>netstat -rn</i> |
314 | # <i>netstat -rn</i> |
273 | Kernel IP routing table |
315 | Kernel IP routing table |
274 | Destination Gateway Genmask Flags MSS Window irtt Iface |
316 | Destination Gateway Genmask Flags MSS Window irtt Iface |
275 | 192.168.0.0 0.0.0.0 255.255.255.0 U 40 0 0 eth0 |
317 | 192.168.0.0 0.0.0.0 255.255.255.0 U 40 0 0 eth0 |
276 | 0.0.0.0 192.168.0.254 0.0.0.0 UG 40 0 0 eth0 |
318 | 0.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> |
319 | # <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> |
320 | # <i>ping -c 2 www.gentoo.org</i> |
279 | PING www.gentoo.org (207.170.82.202): 56 octets data |
321 | PING www.gentoo.org (207.170.82.202): 56 octets data |
280 | 64 octets from 207.170.82.202: icmp_seq=0 ttl=240 time=119.6 ms |
322 | 64 octets from 207.170.82.202: icmp_seq=0 ttl=240 time=119.6 ms |
281 | 64 octets from 207.170.82.202: icmp_seq=1 ttl=240 time=92.0 ms |
323 | 64 octets from 207.170.82.202: icmp_seq=1 ttl=240 time=92.0 ms |
282 | |
324 | |
283 | --- www.gentoo.org ping statistics --- |
325 | --- www.gentoo.org ping statistics --- |
284 | 2 packets transmitted, 2 packets received, 0% packet loss |
326 | 2 packets transmitted, 2 packets received, 0% packet loss |
285 | round-trip min/avg/max = 92.0/105.8/119.6 ms |
327 | round-trip min/avg/max = 92.0/105.8/119.6 ms |
286 | </pre> |
328 | </pre> |
|
|
329 | |
287 | <p> |
330 | <p> |
288 | On the user-mode system we assign the user-mode eth0 interface |
331 | On the user-mode system we assign the user-mode eth0 interface |
289 | the private IP address 192.168.0.1 and bring up the interface. The |
332 | the private IP address 192.168.0.1 and bring up the interface. The |
290 | host has private IP address 192.168.0.254, and we ping it to make sure |
333 | host has private IP address 192.168.0.254, and we ping it to make sure |
291 | that our networking is, indeed, up. The route line adds a default |
334 | that 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 |
336 | <path>/etc/resolv.conf</path> (if necessary), and we ping www.gentoo.org |
294 | to make sure that name resolution (and general access to the internet) |
337 | to make sure that name resolution (and general access to the internet) |
295 | is working from our user-mode system. Now the user-mode system can |
338 | is working from our user-mode system. Now the user-mode system can |
296 | <c>emerge</c> at will! |
339 | <c>emerge</c> at will! |
297 | </p> |
340 | </p> |
|
|
341 | |
298 | </body> |
342 | </body> |
299 | </section> |
343 | </section> |
300 | </chapter> |
344 | </chapter> |
301 | |
|
|
302 | <chapter> |
345 | <chapter> |
303 | <title>Testing the .iso</title> |
346 | <title>Testing the .iso</title> |
304 | |
|
|
305 | <section> |
347 | <section> |
306 | <body> |
348 | <body> |
|
|
349 | |
307 | <p> |
350 | <p> |
308 | Perhaps the true ideal of Gentoo Linux testing would be |
351 | Perhaps the true ideal of Gentoo Linux testing would be |
309 | to boot the .iso with user-mode linux and do the complete |
352 | to boot the .iso with user-mode linux and do the complete |
310 | Gentoo install from within the user-mode linux virtual system. |
353 | Gentoo install from within the user-mode linux virtual system. |
311 | </p> |
354 | </p> |
|
|
355 | |
312 | <p> |
356 | <p> |
313 | Booting the .iso, or actually the initrd from the .iso, is pretty |
357 | Booting the .iso, or actually the initrd from the .iso, is pretty |
314 | straightforward. |
358 | straightforward. |
315 | </p> |
359 | </p> |
316 | <pre> |
360 | |
|
|
361 | <pre caption="Booting the ISO"> |
317 | # <i>mount -o loop /path/to/build-<TAB>.iso /mnt/loop</i> |
362 | # <i>mount -o loop /path/to/install-<TAB>.iso /mnt/loop</i> |
318 | # <i>cp /mnt/loop/isolinux/rescue.gz .</i> |
363 | # <i>cp /mnt/loop/isolinux/gentoo.igz .</i> |
319 | # <i>linux load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=22000 \</i> |
364 | # <i>linux load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=22000 \</i> |
320 | > <i>initrd=rescue.gz root=/dev/ram0 ubd0=root_fs ubd1=swap_fs \</i> |
365 | > <i>initrd=rescue.gz root=/dev/ram0 ubd0=root_fs ubd1=swap_fs \</i> |
321 | > <i>ubd2=/dev/cdroms/cdrom0 eth0=ethertap,tap0,,192.168.0.254</i> |
366 | > <i>ubd2=/dev/cdroms/cdrom0 eth0=tuntap,,,192.168.0.254</i> |
322 | </pre> |
367 | </pre> |
|
|
368 | |
|
|
369 | <p> |
323 | <p>Now you can follow the Gentoo install doc essentially verbatim, |
370 | Now you can follow the Gentoo install doc essentially verbatim, |
324 | although you'll need to know that the root filesystem will be |
371 | although you'll need to know that the root filesystem will be |
325 | <path>/dev/ubd/0</path>, the swap "partition" |
372 | <path>/dev/ubd/0</path>, the swap "partition" |
326 | will be <path>/dev/ubd/1</path>, and the CD rom |
373 | will be <path>/dev/ubd/1</path>, and the CD rom |
327 | will be <path>/dev/ubd/2</path>.</p> |
374 | will be <path>/dev/ubd/2</path>. |
|
|
375 | </p> |
|
|
376 | |
328 | </body> |
377 | </body> |
329 | </section> |
378 | </section> |
330 | </chapter> |
379 | </chapter> |
331 | |
380 | |
|
|
381 | <chapter> |
|
|
382 | <title>Resources</title> |
|
|
383 | <section> |
|
|
384 | <body> |
|
|
385 | |
|
|
386 | <ul> |
|
|
387 | <li> |
|
|
388 | <uri link="http://edeca.net/articles/bridging/index.html">Bridging with |
|
|
389 | UML</uri> |
|
|
390 | </li> |
|
|
391 | <li> |
|
|
392 | <uri link="http://user-mode-linux.sourceforge.net/">UML Homepage</uri> |
|
|
393 | </li> |
|
|
394 | <li> |
|
|
395 | <uri link="http://www.theshore.net/~caker/uml/">Caker's UML Notes</uri> |
|
|
396 | </li> |
|
|
397 | <li> |
|
|
398 | <uri link="http://sourceforge.net/mailarchive/forum.php?forum_id=3647">UML |
|
|
399 | Mailinglist archives</uri> |
|
|
400 | </li> |
|
|
401 | </ul> |
|
|
402 | |
|
|
403 | </body> |
|
|
404 | </section> |
|
|
405 | </chapter> |
332 | |
406 | |
333 | </guide> |
407 | </guide> |