rev |
line source |
paul@41
|
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
paul@41
|
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>SliTaz Handbook (en) - Template</title>
|
paul@41
|
3
|
paul@41
|
4
|
paul@41
|
5
|
paul@41
|
6 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
|
paul@41
|
7 <meta name="description" content="slitaz English handbook" />
|
paul@41
|
8 <meta name="expires" content="never" />
|
paul@41
|
9 <meta name="modified" content="2008-02-26 18:30:00" />
|
paul@41
|
10 <meta name="publisher" content="www.slitaz.org" />
|
paul@41
|
11 <meta name="author" content="Christophe Lincoln" />
|
paul@41
|
12 <link rel="shortcut icon" href="favicon.ico" />
|
paul@41
|
13 <link rel="stylesheet" type="text/css" href="book.css" /></head><body bgcolor="#ffffff">
|
paul@41
|
14
|
paul@41
|
15 <!-- Header and quick navigation -->
|
paul@41
|
16 <div id="header">
|
paul@41
|
17 <div id="quicknav" align="right">
|
paul@41
|
18 <a name="top"></a>
|
paul@41
|
19 <a href="index.html">Table of contents</a>
|
paul@41
|
20 </div>
|
paul@41
|
21 <h1><font color="#3e1220">SliTaz Handbook (en)</font></h1>
|
paul@41
|
22 </div>
|
paul@41
|
23
|
paul@41
|
24 <!-- Content. -->
|
paul@41
|
25 <div id="content">
|
paul@41
|
26 <div class="content-right"></div>
|
paul@41
|
27
|
paul@41
|
28 <h2><font color="#df8f06">Chroot environment</font></h2>
|
paul@41
|
29
|
paul@41
|
30 <p>
|
paul@41
|
31 This document describes the necessary steps to create a chrooted environment, in order to change the root
|
paul@41
|
32 of the system so that you can work. This makes it possible to compile, test and develop SliTaz without any risk to
|
paul@41
|
33 the host system you're working on. The host system can be SliTaz installed to a hard drive or any other GNU/Linux system
|
paul@41
|
34 such as Debian, Fedora, PCLinuxOS and so on. You can also create a chrooted environment in LiveCD mode
|
paul@41
|
35 associated with USB media. The only prerequisite is to have a SliTaz ISO image available and a little
|
paul@41
|
36 time. Note that all commands are carried out as system administrator (<em>root</em>).
|
paul@41
|
37 </p>
|
paul@41
|
38 <h3>Prepare the environment</h3>
|
paul@41
|
39 <p>
|
paul@41
|
40 To begin, we must extract the contents of the ISO image into the directory that will serve as our chroot.
|
paul@41
|
41 The directory can be created any place you choose, we'll use a directory <code>/home/slitaz/chroot-env</code>.
|
paul@41
|
42 To extract the contents of an ISO image, we must mount it in a <em>loop</em> directory and then copy the compressed
|
paul@41
|
43 root filesystem (<code>rootfs.gz</code>) into the chroot directory. Assuming the ISO is in the current directory:
|
paul@41
|
44 </p>
|
paul@41
|
45 <pre> # mkdir /tmp/loop
|
paul@41
|
46 # mount -o loop slitaz-cooking.iso /tmp/loop
|
paul@41
|
47 # mkdir -p /home/slitaz/chroot-env
|
paul@41
|
48 # cp /tmp/loop/boot/rootfs.gz \
|
paul@41
|
49 /home/slitaz/chroot-env
|
paul@41
|
50 # umount /tmp/loop
|
paul@41
|
51 </pre>
|
paul@41
|
52 <p>
|
paul@41
|
53 Now we have a copy of the compressed filesystem, we must extract and unpack it (this is a <code>cpio</code>
|
paul@41
|
54 archive compressed with either gzip or lzma). To complete this stage, we can remove the
|
paul@41
|
55 <code>rootfs</code> which is no longer required:
|
paul@41
|
56 </p>
|
paul@41
|
57 <pre> # cd /home/slitaz/chroot-env
|
paul@41
|
58 # (zcat rootfs.gz 2>/dev/null || lzma d rootfs.gz -so) | cpio -id
|
paul@41
|
59 # rm rootfs rootfs.gz
|
paul@41
|
60 </pre>
|
paul@41
|
61 <p>
|
paul@41
|
62 If the unpacking of the rootfs compressed with lzma fails; you can use the following method:
|
paul@41
|
63 </p>
|
paul@41
|
64 <pre> # unlzma rootfs.gz -S .gz
|
paul@41
|
65 # cat rootfs | cpio -id
|
paul@41
|
66 </pre>
|
paul@41
|
67
|
paul@41
|
68 <h3>Using the environment</h3>
|
paul@41
|
69 <p>
|
paul@41
|
70 To begin using the chrooted environment, you just need to mount some virtual filesystems and use the <code>chroot</code>
|
paul@41
|
71 command. To simplify things, we can write a small script automating the process. Example using the
|
paul@41
|
72 chroot directory <code>/home/slitaz/chroot-env</code> and creating a script
|
paul@41
|
73 <code>chroot_in_env.sh</code> in <code>/home/slitaz</code>.
|
paul@41
|
74 On any systems other than SliTaz you can uncomment the lines about <code>/dev</code> and
|
paul@41
|
75 <code>/tmp</code> - <em>Note</em> to save typing you can copy and paste:
|
paul@41
|
76 </p>
|
paul@41
|
77 <pre> # cat > /home/slitaz/chroot_in_env.sh << "EOF"
|
paul@41
|
78 </pre>
|
paul@41
|
79 <pre class="script">#!/bin/sh
|
paul@41
|
80 # Chroot in SliTaz to hack.
|
paul@41
|
81 #
|
paul@41
|
82 ROOTFS="/home/slitaz/chroot-env"
|
paul@41
|
83
|
paul@41
|
84 # Mount virtual Kernel file systems and chroot.
|
paul@41
|
85 #
|
paul@41
|
86 #mount --bind /dev $ROOTFS/dev
|
paul@41
|
87 #mount --bind /tmp $ROOTFS/tmp
|
paul@41
|
88 mount -t proc proc $ROOTFS/proc
|
paul@41
|
89 mount -t sysfs sysfs $ROOTFS/sys
|
paul@41
|
90 mount -t devpts devpts $ROOTFS/dev/pts
|
paul@41
|
91 mount -t tmpfs shm $ROOTFS/dev/shm
|
paul@41
|
92
|
paul@41
|
93 echo "Chrooting in $ROOTFS... "
|
paul@41
|
94 chroot $ROOTFS /bin/sh --login
|
paul@41
|
95
|
paul@41
|
96 # Unmount virtual Kernel file systems on exit.
|
paul@41
|
97 #
|
paul@41
|
98 umount $ROOTFS/dev/shm
|
paul@41
|
99 umount $ROOTFS/dev/pts
|
paul@41
|
100 umount $ROOTFS/sys
|
paul@41
|
101 umount $ROOTFS/proc
|
paul@41
|
102 #umount $ROOTFS/tmp
|
paul@41
|
103 #umount $ROOTFS/dev
|
paul@41
|
104
|
paul@41
|
105 echo "Exiting of $ROOTFS chroot environment... "
|
paul@41
|
106
|
paul@41
|
107 EOF
|
paul@41
|
108 </pre>
|
paul@41
|
109 <p>
|
paul@41
|
110 To finish and test the environment, you just make the script executable and run:
|
paul@41
|
111 </p>
|
paul@41
|
112 <pre> # chmod +x /home/slitaz/chroot_in_env.sh
|
paul@41
|
113 # sh /home/slitaz/chroot_in_env.sh
|
paul@41
|
114 </pre>
|
paul@41
|
115 <h4>To activate the network</h4>
|
paul@41
|
116 <p>
|
paul@41
|
117 In order to have the network up to download and install some development packages, just start the
|
paul@41
|
118 DHCP client on the correct interface. Example using <code>eth1</code>:
|
paul@41
|
119 </p>
|
paul@41
|
120 <pre> /# udhcpc -i eth1
|
paul@41
|
121 </pre>
|
paul@41
|
122 <h4>Installing packages</h4>
|
paul@41
|
123 <p>
|
paul@41
|
124 If the network is functional, just reload the list of packages and use <code>tazpkg get-install</code> to
|
paul@41
|
125 install them. If a connection is not possible, you can download the packages from another system, copy them
|
paul@41
|
126 to the chrooted environment and install them with the <code>tazpkg install</code> command. To install the basic
|
paul@41
|
127 compilation tools:
|
paul@41
|
128 </p>
|
paul@41
|
129 <pre> /# tazpkg recharge
|
paul@41
|
130 /# tazpkg get-install slitaz-toolchain
|
paul@41
|
131 </pre>
|
paul@41
|
132 <p>
|
paul@41
|
133 Once the environment is configured, you can compile applications from source to create packages, test scripts etc.
|
paul@41
|
134 The <a href="../cookbook/">Cookbook</a> should help you out here:
|
paul@41
|
135 </p>
|
paul@41
|
136 <h4>Exit the environment</h4>
|
paul@41
|
137 <p>
|
paul@41
|
138 To exit the chrooted environment, just type <code>exit</code>, the <code>chroot_in_env.sh</code> script will then end
|
paul@41
|
139 by unmounting the virtual filesystems from the Linux Kernel:
|
paul@41
|
140 </p>
|
paul@41
|
141 <pre> /# exit
|
paul@41
|
142 #
|
paul@41
|
143 </pre>
|
paul@41
|
144
|
paul@41
|
145 <!-- End of content -->
|
paul@41
|
146 </div>
|
paul@41
|
147
|
paul@41
|
148 <!-- Footer. -->
|
paul@41
|
149 <div id="footer">
|
paul@41
|
150 <div class="footer-right"></div>
|
paul@41
|
151 <a href="#top">Top of the page</a> |
|
paul@41
|
152 <a href="http://www.slitaz.org/en/doc/handbook/index.html">Table of contents</a>
|
paul@41
|
153 </div>
|
paul@41
|
154
|
paul@41
|
155 <div id="copy">
|
paul@41
|
156 Copyright © 2008 <a href="http://www.slitaz.org/en/">SliTaz</a> -
|
paul@41
|
157 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br />
|
paul@41
|
158 Documentation is under
|
paul@41
|
159 <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>
|
paul@41
|
160 and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>.
|
paul@41
|
161 </div>
|
paul@41
|
162
|
paul@41
|
163 </body></html>
|
paul@41
|
164
|