/[gentoo]/xml/htdocs/proj/en/base/amd64/howtos/chroot.xml
Gentoo

Diff of /xml/htdocs/proj/en/base/amd64/howtos/chroot.xml

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

Revision 1.2 Revision 1.15
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE sections SYSTEM "/dtd/book.dtd"> 2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3<!-- $HEADER$ --> 3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/base/amd64/howtos/chroot.xml,v 1.15 2012/11/16 18:39:44 ago Exp $ -->
4 4
5<!-- The content of this document is licensed under the CC-BY-SA license --> 5<!-- The content of this document is licensed under the CC-BY-SA license -->
6<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> 6<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
7<guide lang="en" >
8<title>How to set up a 32bit chroot</title>
7 9
8<sections> 10<author title="Author">
11 <mail link="metalgod@gentoo.org">Luis Medinas</mail>
12</author>
9 13
14<abstract>
15This HOWTO shows you how to create a 32bit chroot.
16</abstract>
17
18<license/>
19
10<version>1.0</version> 20<version>2</version>
11<date>2005-07-15</date> 21<date>2012-11-16</date>
12 22
13<section> 23<chapter>
14<title>Introduction</title> 24<title>Introduction</title>
15<subsection> 25<section>
16<title>Introduction to 64bit system</title> 26<title>Introduction to 64bit system</title>
17<body> 27<body>
28
18<p> 29<p>
19The Gentoo Linux 32bits chroot guide will help you setting up a true 32bit chroot for your Gentoo/AMD64 system. 30The Gentoo Linux 32bit chroot guide will help you setting up a true 32bit chroot for your Gentoo/AMD64 system.
20</p>
21<p> 31</p>
32
33<p>
22As you know 64bit systems don't run 32bits applications natively yet (at least not with portage) so you need to use emulation libraries to make them working or create a true 32bit system inside a chroot to install and run native 32bit applications. For the most common uses you do not need do build a 32bits chroot system. However, if you want to run applications that don't have a binary available to run with 32bits libraries, you should use a 32bit chroot. This guide will teach you how to set up a 32bit chroot and how to install and run applications inside the chroot. 34As you know 64bit systems don't run 32bit applications natively yet (at least not with portage) so you need to use emulation libraries to make them working or create a true 32bit system inside a chroot to install and run native 32bit applications. For the most common uses you do not need do build a 32bit chroot system. However, if you want to run applications that don't have a binary available to run with 32bit libraries, you should use a 32bit chroot. This guide will teach you how to set up a 32bit chroot and how to install and run applications inside the chroot.
23</p> 35</p>
24</body>
25</subsection>
26</section>
27 36
37</body>
28<section> 38</section>
39</chapter>
40
41<chapter>
29<title>Installation</title> 42<title>Installation</title>
30<subsection> 43<section>
31<title>Installation of your 32bit chroot</title> 44<title>Installation of your 32bit chroot</title>
32<body> 45<body>
46
33<p> 47<p>
34To install a 32bit chroot you need to follow many footsteps that you use to install Gentoo Linux on a x86 computer. For now you need the latest stage3 available on our <uri link="http://www.gentoo.org/main/en/mirrors.xml">mirrors</uri>. 48To install a 32bit chroot you need to follow many footsteps that you use to install Gentoo Linux on a x86 computer. For now you need the latest stage3 available on our <uri link="http://www.gentoo.org/main/en/mirrors.xml">mirrors</uri>.
35</p> 49</p>
50
36<pre caption="downloading stage3 from a gentoo mirror"> 51<pre caption="downloading stage3 from a gentoo mirror">
37$ cd /home/user/downloads 52$ cd /home/user/downloads
38$ wget -c http://distfiles.gentoo.org/releases/x86/2005.0/stages/athlon-xp/stage3-athlon-xp-2005.0.tar.bz2 53$ wget -c ftp://distfiles.gentoo.org/releases/x86/2006.1/stages/stage3-i686-2006.1.tar.bz2
39</pre> 54</pre>
55
40<note>Note that we dowload a stage for x86, <c>not</c> for AMD64.</note> 56<note>Note that we download a stage for x86, <c>not</c> for AMD64.</note>
57
41<p> 58<p>
42After downloading the stage3 you need to create a new directory to build your new chroot. 59After downloading the stage3 you need to create a new directory to build your new chroot.
43</p> 60</p>
61
44<pre caption="creating directory for 32bits chroot"> 62<pre caption="creating directory for 32bit chroot">
45$ su root <i>insert your root password</i> 63$ su root <i>insert your root password</i>
46# cd /mnt 64# cd /mnt
47# mkdir gentoo32 65# mkdir gentoo32
48</pre> 66</pre>
67
49<p> 68<p>
50Then move the stage you have already downloaded, unpack it and setup it like this example. 69Then move the stage you have already downloaded, unpack it and set it up it like this example.
51</p> 70</p>
71
52<pre caption="installing from stage3"> 72<pre caption="installing from stage3">
53# cd /mnt/gentoo32 73# cd /mnt/gentoo32
54# tar -xvjpf /home/user/downloads/stage3-athlon-xp-2005.0.tar.bz2 74# tar -xvjpf /home/user/downloads/stage3-i686-2006.1.tar.bz2
55# cp -L /etc/resolv.conf /mnt/gentoo32/etc/ 75# cp -L /etc/resolv.conf /mnt/gentoo32/etc/
56# cp -L /etc/passwd /mnt/gentoo32/etc/ 76# cp -L /etc/passwd /mnt/gentoo32/etc/
57</pre> 77</pre>
78
58<p> 79<p>
59Now you have the chroot ready for setup. Read the next chapter to learn how to set it up. 80Now you have the chroot ready for setup. Read the next chapter to learn how to set it up.
60</p> 81</p>
61</body>
62</subsection>
63</section>
64 82
83</body>
65<section> 84</section>
85</chapter>
86
87<chapter>
66<title>Setup</title> 88<title>Setup</title>
67<subsection> 89<section>
68<title>Doing a setup for your new 32bit chroot</title> 90<title>Doing a setup for your new 32bit chroot</title>
69<body> 91<body>
92
70<p> 93<p>
71If everything went well until here now you will be able to set up your new 32bit chroot and finishing installation of this chroot. 94If everything went well until here now you will be able to set up your new 32bit chroot and finish the installation of this chroot.
72</p>
73<p> 95</p>
96
97<p>
74The next step is setup your new <c>/mnt/gentoo32/etc/make.conf</c>. 98The next step is to setup your new <c>/mnt/gentoo32/etc/make.conf</c>.
75</p> 99</p>
100
76<pre caption="Configuring your new make.conf"> 101<pre caption="Configuring your new make.conf">
77CFLAGS="-O2 -march=athlon-xp -msse2 -pipe -fomit-frame-pointer" 102CFLAGS="-O2 -march=athlon-xp -msse2 -pipe -fomit-frame-pointer"
78CHOST="i686-pc-linux-gnu" 103CHOST="i686-pc-linux-gnu"
79CXXFLAGS="${CFLAGS}" 104CXXFLAGS="${CFLAGS}"
80MAKEOPTS="-j2" 105MAKEOPTS="-j2"
81</pre> 106</pre>
107
82<p> 108<p>
83Now mount the various bogus file systems: 109Now mount the various bogus file systems:
84</p> 110</p>
111
85<pre caption="Mount virtual file systems"> 112<pre caption="Mount virtual file systems">
86# mount -o bind /dev /mnt/gentoo32/dev 113# mount -o bind /dev /mnt/gentoo32/dev
87# mount -o bind /dev/pts /mnt/gentoo32/dev/pts 114# mount -o bind /dev/pts /mnt/gentoo32/dev/pts
88# mount -o bind /dev/shm /mnt/gentoo32/dev/shm 115# mount -o bind /dev/shm /mnt/gentoo32/dev/shm
89# mount -o bind /proc /mnt/gentoo32/proc 116# mount -o bind /proc /mnt/gentoo32/proc
90# mount -o bind /proc/bus/usb /mnt/gentoo32/proc/bus/usb 117# mount -o bind /proc/bus/usb /mnt/gentoo32/proc/bus/usb
91# mount -o bind /sys /mnt/gentoo32/sys 118# mount -o bind /sys /mnt/gentoo32/sys
92</pre> 119</pre>
120
93<p> 121<p>
94Now you have a true 32bit chroot installed in your 64bits system which is almost ready for use. Next, you need to create a link from your portage available in your 64bit system to your chroot. This way, you only need to update it in one installation instead of duplicating a lot of data. 122Now you have a true 32bit chroot installed in your 64bits system which is almost ready for use. Next, you need to create a link from your portage available in your 64bit system to your chroot. This way, you only need to update it in one installation instead of duplicating a lot of data.
95</p> 123</p>
124
96<pre caption="Link portage to /usr/portage inside the 32bits chroot"> 125<pre caption="Link portage to /usr/portage inside the 32bit chroot">
97# mkdir -p /mnt/gentoo32/usr/portage/ 126# mkdir -p /mnt/gentoo32/usr/portage/
98# mount -o bind /usr/portage /mnt/gentoo32/usr/portage/ 127# mount -o bind /usr/portage /mnt/gentoo32/usr/portage/
99</pre> 128</pre>
129
100<note>Everytime you update your portage by doing a emerge sync, you update your 32bit chroot's portage as well.</note> 130<note>Everytime you update your portage by doing a emerge sync, you update your 32bit chroot's portage as well.</note>
131
101<p> 132<p>
102If you want to run 32bit applications which use X, you also need to mount /tmp. 133If you want to run 32bit applications which use X, you also need to mount /tmp.
103</p> 134</p>
135
104<pre caption="Mount /tmp for applications with a GUI"> 136<pre caption="Mount /tmp for applications with a GUI">
105# mount -o bind /tmp /mnt/gentoo32/tmp 137# mount -o bind /tmp /mnt/gentoo32/tmp
106</pre> 138</pre>
139
107<p> 140<p>
108Now we're ready to switch inside the chroot. 141Now we're ready to switch inside the chroot.
109</p> 142</p>
143
110<pre caption="Changing inside the chroot"> 144<pre caption="Changing inside the chroot">
111<i>(Only perform this step if you don't have linux32 already installed)</i> 145<i>(Only perform this step if you don't have util-linux already installed)</i>
112# emerge linux32 146# emerge util-linux
113# linux32 chroot /mnt/gentoo32 /bin/bash 147# linux32 chroot /mnt/gentoo32 /bin/bash
114<i>(Make sure we have a i686 setup)</i> 148<i>(Make sure we have a i686 setup)</i>
115# uname -m 149# uname -m
116Linux mysystem 2.6.12-gentoo-r1 #1 Mon Jun 27 02:41:55 GMT 2005 i686 AMD Athlon(tm) 64 Processor 3500+ AuthenticAMD GNU/Linux 150i686
117</pre> 151</pre>
152
118<warn>The <c>linux32</c> util is needed to change the CHOST value. If you forget it, you're likely to be unable to compile anything inside the chroot environment.</warn> 153<warn>The <c>linux32</c> util is needed to change the CHOST value. If you forget it, you're likely to be unable to compile anything inside the chroot environment.</warn>
154
119<p> 155<p>
120Now you have a new 32bits chroot system ready to be updated. Follow the next steps to update it. 156Now you have a new 32bit chroot system ready to be updated. Follow the next steps to update it.
121</p> 157</p>
158
122<pre caption="Updating your new 32bits chroot"> 159<pre caption="Updating your new 32bit chroot">
123# source /etc/profile 160# source /etc/profile
124# env-update 161# env-update
162# emerge --sync
125# emerge -au world 163# emerge -auDN world
126</pre> 164</pre>
165
127<p> 166<p>
128After this you basically have finished the setup of your 32bits chroot. To make things more suitable, we are going to set up a new file in your 64bit system to enable the 32bits chroot when booting. 167After this you basically have finished the setup of your 32bit chroot. To make things more suitable, we are going to set up a new file in your 64bit system to enable the 32bit chroot when booting.
129</p> 168</p>
169
130<pre caption="creating a new file in /etc/init.d"> 170<pre caption="creating a new file in /etc/init.d">
131# nano -w /etc/init.d/gentoo32 171# nano -w /etc/init.d/gentoo32
132#!/sbin/runscript 172#!/sbin/runscript
133 173
134depend() { 174depend() {
135 need localmount 175 need localmount
136 need bootmisc 176 need bootmisc
137} 177}
138 178
139start() { 179start() {
140 ebegin "Mounting 32bits chroot dirs" 180 ebegin "Mounting 32bit chroot dirs"
141 mount -o bind /dev /mnt/gentoo32/dev >/dev/null &amp; 181 mount -o bind /dev /mnt/gentoo32/dev >/dev/null
142 mount -o bind /dev/pts /mnt/gentoo32/dev/pts >/dev/null &amp; 182 mount -o bind /dev/pts /mnt/gentoo32/dev/pts >/dev/null &amp;
143 mount -o bind /dev/shm /mnt/gentoo32/dev/shm >/dev/null &amp; 183 mount -o bind /dev/shm /mnt/gentoo32/dev/shm >/dev/null &amp;
144 mount -o bind /proc /mnt/gentoo32/proc >/dev/null &amp; 184 mount -o bind /proc /mnt/gentoo32/proc >/dev/null
145 mount -o bind /proc/bus/usb /mnt/gentoo32/proc/bus/usb >/dev/null &amp; 185 mount -o bind /proc/bus/usb /mnt/gentoo32/proc/bus/usb >/dev/null &amp;
186 mount -o bind /sys /mnt/gentoo32/sys >/dev/null &amp;
146 mount -o bind /tmp /mnt/gentoo32/tmp >/dev/null &amp; 187 mount -o bind /tmp /mnt/gentoo32/tmp >/dev/null &amp;
147 mount -o bind /usr/portage /mnt/gentoo32/usr/portage/ >/dev/null &amp; 188 mount -o bind /usr/portage /mnt/gentoo32/usr/portage/ >/dev/null &amp;
148 eend $? "An error occured while attempting to mount 32bit chroot directories" 189 eend $? "An error occured while attempting to mount 32bit chroot directories"
149 ebegin "Copying 32bits chroot files" 190 ebegin "Copying 32bit chroot files"
150 cp -pf /etc/resolv.conf /mnt/gentoo32/etc >/dev/null &amp; 191 cp -pf /etc/resolv.conf /mnt/gentoo32/etc >/dev/null &amp;
151 cp -pf /etc/passwd /mnt/gentoo32/etc >/dev/null &amp; 192 cp -pf /etc/passwd /mnt/gentoo32/etc >/dev/null &amp;
152 cp -pf /etc/shadow /mnt/gentoo32/etc >/dev/null &amp; 193 cp -pf /etc/shadow /mnt/gentoo32/etc >/dev/null &amp;
194 cp -pf /etc/group /mnt/gentoo32/etc >/dev/null &amp;
195 cp -pf /etc/gshadow /mnt/gentoo32/etc >/dev/null &amp;
153 cp -pf /etc/hosts /mnt/gentoo32/etc > /dev/null &amp; 196 cp -pf /etc/hosts /mnt/gentoo32/etc > /dev/null &amp;
154 cp -Ppf /etc/localtime /mnt/gentoo32/etc >/dev/null &amp; 197 cp -Ppf /etc/localtime /mnt/gentoo32/etc >/dev/null &amp;
155 eend $? "An error occured while attempting to copy 32 bits chroot files." 198 eend $? "An error occured while attempting to copy 32 bits chroot files."
156} 199}
157 200
158stop() { 201stop() {
159 ebegin "Unmounting 32bits chroot dirs" 202 ebegin "Unmounting 32bit chroot dirs"
160 umount -f /mnt/gentoo32/dev/pts >/dev/null &amp; 203 umount -f /mnt/gentoo32/dev/pts >/dev/null
161 umount -f /mnt/gentoo32/dev/shm >/dev/null &amp; 204 umount -f /mnt/gentoo32/dev/shm >/dev/null
162 umount -f /mnt/gentoo32/dev >/dev/null &amp; 205 umount -f /mnt/gentoo32/dev >/dev/null &amp;
163 umount -f /mnt/gentoo32/proc/bus/usb >/dev/null &amp; 206 umount -f /mnt/gentoo32/proc/bus/usb >/dev/null
164 umount -f /mnt/gentoo32/proc >/dev/null &amp; 207 umount -f /mnt/gentoo32/proc >/dev/null &amp;
208 umount -f /mnt/gentoo32/sys >/dev/null &amp;
165 umount -f /mnt/gentoo32/tmp >/dev/null &amp; 209 umount -f /mnt/gentoo32/tmp >/dev/null &amp;
166 umount -f /mnt/gentoo32/usr/portage/ >/dev/null &amp; 210 umount -f /mnt/gentoo32/usr/portage/ >/dev/null &amp;
167 eend $? "An error occured while attempting to unmount 32bits chroot directories" 211 eend $? "An error occured while attempting to unmount 32bit chroot directories"
168} 212}
169</pre> 213</pre>
214
170<p> 215<p>
171Now you only need to run <c>rc-update add gentoo32 default</c> to run it at boot time. 216Now you only need to run <c>rc-update add gentoo32 default</c> to run it at boot time.
172</p> 217</p>
218
173<p> 219<p>
174Whenever you want to switch to your chroot environment, you only need to run the following command: <c>linux32 chroot /mnt/gentoo32 /bin/bash</c>. 220Whenever you want to switch to your chroot environment, you only need to run the following command: <c>linux32 chroot /mnt/gentoo32 /bin/bash</c>.
175</p> 221</p>
222
176<p> 223<p>
177Now you have your 32bit chroot ready to install new applications. 224Now you have your 32bit chroot ready to install new applications.
178</p> 225</p>
179</body>
180</subsection>
181</section>
182 226
227</body>
183<section> 228</section>
229</chapter>
230
231<chapter>
184<title>Applications</title> 232<title>Applications</title>
185<subsection> 233<section>
186<title>Installing new applications in your chroot</title> 234<title>Installing new applications in your chroot</title>
187<body> 235<body>
236
188<p> 237<p>
189Now that you have a fully functional 32bits chroot you can install every application in 32bits mode. Let's see how you can install new packages on your 32bits chroot. 238Now that you have a fully functional 32bit chroot you can install every application in 32bit mode. Let's see how you can install new packages on your 32bit chroot.
190</p> 239</p>
240
191<pre caption="Install foo inside the chroot"> 241<pre caption="Install foo inside the chroot">
192# linux32 chroot /mnt/gentoo32 /bin/bash 242# linux32 chroot /mnt/gentoo32 /bin/bash
193# source /etc/profile 243# source /etc/profile
194# env-update 244# env-update
195# emerge foo 245# emerge foo
196</pre> 246</pre>
247
197<note>Always remember to do <c>source /etc/profile</c> and <c>env-update</c> after switching inside the chroot.</note> 248<note>Always remember to do <c>source /etc/profile</c> and <c>env-update</c> after switching inside the chroot.</note>
249
198<p> 250<p>
199You now have installed a new package in your 32bit chroot. If you want to run your new package you need to run it inside of your chroot. If you want to run 251You now have installed a new package in your 32bit chroot. If you want to run your new package you need to run it inside of your chroot. If you want to run
200X applications the best solution to run it is doing the <c>xhost</c> trick. Everytime you need to run a X application run the this command in your 64bit environment: 252X applications the best solution to run it is doing the <c>xhost</c> trick. Everytime you need to run a X application run the this command in your 64bit environment:
201</p> 253</p>
254
202<pre caption="Xhost trick"> 255<pre caption="Xhost trick">
203# xhost local:localhost 256# xhost local:localhost
204</pre> 257</pre>
258
205<p> 259<p>
206After this get inside your chroot again and you should be able to run every X application you build inside your 32bits chroot. 260After this get inside your chroot again and you should be able to run every X application you build inside your 32bit chroot.
207</p> 261</p>
208</body>
209</subsection>
210</section>
211 262
263</body>
212<section> 264</section>
265</chapter>
266
267<chapter>
213<title>Conclusion</title> 268<title>Conclusion</title>
214<subsection> 269<section>
215<title>Conclusion of this guide</title> 270<title>Conclusion of this guide</title>
216<body> 271<body>
272
217<p> 273<p>
218With this chroot you can install many packages available only for x86 arch. Some packages like <c>OpenOffice</c> can be installed by using the binary available for Gentoo/AMD64. Some of the codecs available for <c>MPlayer</c> need this 32bit chroot to so you can install <c>win32codecs</c> with this chroot. 274With this chroot you can install many packages available only for x86 arch. Some packages like <c>OpenOffice</c> can be installed by using the binary available for Gentoo/AMD64. Some of the codecs available for <c>MPlayer</c> need this 32bit chroot so you can install <c>win32codecs</c> with this chroot.
219</p> 275</p>
220</body>
221</subsection>
222</section>
223 276
277</body>
224</sections> 278</section>
279</chapter>
280</guide>

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.13