website rev 41

Add Chroot to Handbook (en) and fix typos
author Paul Issott <paul@slitaz.org>
date Sat May 07 21:03:21 2011 +0000 (2011-05-07)
parents 8c689138f7fd
children d0b00447604c
files en/doc/handbook/chroot-env.html en/doc/handbook/index.html en/doc/handbook/web-server.html
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/en/doc/handbook/chroot-env.html	Sat May 07 21:03:21 2011 +0000
     1.3 @@ -0,0 +1,164 @@
     1.4 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     1.5 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>SliTaz Handbook (en) - Template</title>
     1.6 +
     1.7 +
     1.8 +    
     1.9 +    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
    1.10 +    <meta name="description" content="slitaz English handbook" />
    1.11 +    <meta name="expires" content="never" />
    1.12 +    <meta name="modified" content="2008-02-26 18:30:00" />
    1.13 +    <meta name="publisher" content="www.slitaz.org" />
    1.14 +    <meta name="author" content="Christophe Lincoln" />
    1.15 +    <link rel="shortcut icon" href="favicon.ico" />
    1.16 +    <link rel="stylesheet" type="text/css" href="book.css" /></head><body bgcolor="#ffffff">
    1.17 +
    1.18 +<!-- Header and quick navigation -->
    1.19 +<div id="header">
    1.20 +<div id="quicknav" align="right">
    1.21 +    <a name="top"></a>
    1.22 +    <a href="index.html">Table of contents</a>
    1.23 +</div>
    1.24 +<h1><font color="#3e1220">SliTaz Handbook (en)</font></h1>
    1.25 +</div>
    1.26 +
    1.27 +<!-- Content. -->
    1.28 +<div id="content">
    1.29 +<div class="content-right"></div>
    1.30 +
    1.31 +<h2><font color="#df8f06">Chroot environment</font></h2>
    1.32 +
    1.33 +<p>
    1.34 +This document describes the necessary steps to create a chrooted environment, in order to change the root 
    1.35 +of the system so that you can work. This makes it possible to compile, test and develop SliTaz without any risk to
    1.36 +the host system you're working on. The host system can be SliTaz installed to a hard drive or any other GNU/Linux system
    1.37 +such as Debian, Fedora, PCLinuxOS and so on. You can also create a chrooted environment in LiveCD mode
    1.38 +associated with USB media. The only prerequisite is to have a SliTaz ISO image available and a little
    1.39 +time. Note that all commands are carried out as system administrator (<em>root</em>).
    1.40 +</p>
    1.41 +<h3>Prepare the environment</h3>
    1.42 +<p>
    1.43 +To begin, we must extract the contents of the ISO image into the directory that will serve as our chroot.
    1.44 +The directory can be created any place you choose, we'll use a directory <code>/home/slitaz/chroot-env</code>.
    1.45 +To extract the contents of an ISO image, we must mount it in a <em>loop</em> directory and then copy the compressed
    1.46 +root filesystem (<code>rootfs.gz</code>) into the chroot directory. Assuming the ISO is in the current directory:
    1.47 +</p>
    1.48 +<pre> # mkdir /tmp/loop
    1.49 + # mount -o loop slitaz-cooking.iso /tmp/loop
    1.50 + # mkdir -p /home/slitaz/chroot-env
    1.51 + # cp /tmp/loop/boot/rootfs.gz \
    1.52 +   /home/slitaz/chroot-env
    1.53 + # umount /tmp/loop
    1.54 +</pre>
    1.55 +<p>
    1.56 +Now we have a copy of the compressed filesystem, we must extract and unpack it (this is a <code>cpio</code>
    1.57 +archive compressed with either gzip or lzma). To complete this stage, we can remove the
    1.58 +<code>rootfs</code> which is no longer required:
    1.59 +</p>
    1.60 +<pre> # cd /home/slitaz/chroot-env
    1.61 + # (zcat rootfs.gz 2&gt;/dev/null || lzma d rootfs.gz -so) | cpio -id
    1.62 + # rm rootfs rootfs.gz
    1.63 +</pre>
    1.64 +<p>
    1.65 +If the unpacking of the rootfs compressed with lzma fails; you can use the following method:
    1.66 +</p>
    1.67 +<pre> # unlzma rootfs.gz -S .gz 
    1.68 + # cat rootfs | cpio -id
    1.69 +</pre>
    1.70 +
    1.71 +<h3>Using the environment</h3>
    1.72 +<p>
    1.73 +To begin using the chrooted environment, you just need to mount some virtual filesystems and use the <code>chroot</code>
    1.74 +command. To simplify things, we can write a small script automating the process. Example using the 
    1.75 +chroot directory <code>/home/slitaz/chroot-env</code> and creating a script
    1.76 +<code>chroot_in_env.sh</code> in <code>/home/slitaz</code>.
    1.77 +On any systems other than SliTaz you can uncomment the lines about <code>/dev</code> and
    1.78 +<code>/tmp</code> - <em>Note</em> to save typing you can copy and paste:
    1.79 +</p>
    1.80 +<pre> # cat &gt; /home/slitaz/chroot_in_env.sh &lt;&lt; "EOF"
    1.81 +</pre>
    1.82 +<pre class="script">#!/bin/sh
    1.83 +# Chroot in SliTaz to hack.
    1.84 +#
    1.85 +ROOTFS="/home/slitaz/chroot-env"
    1.86 +
    1.87 +# Mount virtual Kernel file systems and chroot.
    1.88 +#
    1.89 +#mount --bind /dev $ROOTFS/dev
    1.90 +#mount --bind /tmp $ROOTFS/tmp
    1.91 +mount -t proc proc $ROOTFS/proc
    1.92 +mount -t sysfs sysfs $ROOTFS/sys
    1.93 +mount -t devpts devpts $ROOTFS/dev/pts
    1.94 +mount -t tmpfs shm $ROOTFS/dev/shm
    1.95 +
    1.96 +echo "Chrooting in $ROOTFS... "
    1.97 +chroot $ROOTFS /bin/sh --login
    1.98 +
    1.99 +# Unmount virtual Kernel file systems on exit.
   1.100 +#
   1.101 +umount $ROOTFS/dev/shm
   1.102 +umount $ROOTFS/dev/pts
   1.103 +umount $ROOTFS/sys
   1.104 +umount $ROOTFS/proc
   1.105 +#umount $ROOTFS/tmp
   1.106 +#umount $ROOTFS/dev
   1.107 +
   1.108 +echo "Exiting of $ROOTFS chroot environment... "
   1.109 +
   1.110 +EOF
   1.111 +</pre>
   1.112 +<p>
   1.113 +To finish and test the environment, you just make the script executable and run:
   1.114 +</p>
   1.115 +<pre> # chmod +x /home/slitaz/chroot_in_env.sh
   1.116 + # sh /home/slitaz/chroot_in_env.sh
   1.117 +</pre>
   1.118 +<h4>To activate the network</h4>
   1.119 +<p>
   1.120 +In order to have the network up to download and install some development packages, just start the
   1.121 +DHCP client on the correct interface. Example using <code>eth1</code>:
   1.122 +</p>
   1.123 +<pre> /# udhcpc -i eth1
   1.124 +</pre>
   1.125 +<h4>Installing packages</h4>
   1.126 +<p>
   1.127 +If the network is functional, just reload the list of packages and use <code>tazpkg get-install</code> to
   1.128 +install them. If a connection is not possible, you can download the packages from another system, copy them 
   1.129 +to the chrooted environment and install them with the <code>tazpkg install</code> command. To install the basic
   1.130 +compilation tools:
   1.131 +</p>
   1.132 +<pre> /# tazpkg recharge
   1.133 + /# tazpkg get-install slitaz-toolchain
   1.134 +</pre>
   1.135 +<p>
   1.136 +Once the environment is configured, you can compile applications from source to create packages, test scripts etc.
   1.137 +The <a href="../cookbook/">Cookbook</a> should help you out here:
   1.138 +</p>
   1.139 +<h4>Exit the environment</h4>
   1.140 +<p>
   1.141 +To exit the chrooted environment, just type <code>exit</code>, the <code>chroot_in_env.sh</code> script will then end
   1.142 +by unmounting the virtual filesystems from the Linux Kernel:
   1.143 +</p>
   1.144 +<pre> /# exit
   1.145 + #
   1.146 +</pre>
   1.147 +
   1.148 +<!-- End of content -->
   1.149 +</div>
   1.150 +
   1.151 +<!-- Footer. -->
   1.152 +<div id="footer">
   1.153 +	<div class="footer-right"></div>
   1.154 +	<a href="#top">Top of the page</a> | 
   1.155 +	<a href="http://www.slitaz.org/en/doc/handbook/index.html">Table of contents</a>
   1.156 +</div>
   1.157 +
   1.158 +<div id="copy">
   1.159 +    Copyright © 2008 <a href="http://www.slitaz.org/en/">SliTaz</a> -
   1.160 +    <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br />
   1.161 +    Documentation is under
   1.162 +    <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>
   1.163 +    and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>.
   1.164 +</div>
   1.165 +
   1.166 +</body></html>
   1.167 +
     2.1 --- a/en/doc/handbook/index.html	Thu May 05 12:59:13 2011 +0000
     2.2 +++ b/en/doc/handbook/index.html	Sat May 07 21:03:21 2011 +0000
     2.3 @@ -50,6 +50,7 @@
     2.4  	<li><a href="hacking-livecd.html">Hacking LiveCD</a> - Manipulate and play with the ISO
     2.5  	image of LiveCD.</li>
     2.6  	<li><a href="web-server.html">Web server</a> - Configure and use the LightTPD web server.</li>
     2.7 +	<li><a href="chroot-env.html">Chroot Environment</a> - Build a chroot to protect the host system.</li>
     2.8  </ul>
     2.9  
    2.10  <h3>About this Handbook</h3>
     3.1 --- a/en/doc/handbook/web-server.html	Thu May 05 12:59:13 2011 +0000
     3.2 +++ b/en/doc/handbook/web-server.html	Sat May 07 21:03:21 2011 +0000
     3.3 @@ -16,6 +16,7 @@
     3.4  <div id="header">
     3.5  <div id="quicknav" align="right">
     3.6      <a name="top"></a>
     3.7 +    <a href="chroot-env.html">Chroot Environment</a> |
     3.8      <a href="index.html">Table of contents</a>
     3.9  </div>
    3.10  <h1><font color="#3e1220">SliTaz Handbook (en)</font></h1>
    3.11 @@ -48,14 +49,14 @@
    3.12  </p>
    3.13  <p>
    3.14  On SliTaz the server is automatically launched at system startup and is preconfigured with PHP. The root
    3.15 -of the documents served by default are in <code>/var/www</code> and contain a default page <code>index.html</code>,
    3.16 +of the documents served by default are in <code>/var/www</code>, this contains the default page <code>index.html</code>,
    3.17  images are stored in the <code>images/</code> directory.
    3.18  LightTPD website: <a href="http://www.lighttpd.net/">http://www.lighttpd.net/</a>
    3.19  </p>
    3.20  <a name="var-www"></a>
    3.21  <h3>/var/www - Root directory of documents</h3>
    3.22  <p>
    3.23 -The directory /var/www is the root directory of documents - you can access this via the URL
    3.24 +The /var/www folder is the <em>root</em> directory of documents - you can access this via the URL
    3.25  <a href="http://localhost/">http://localhost/</a>. If you want to host a site, you can save all your documents
    3.26  in here. If you want to host multiple sites, you'll need to create virtual hosts. Note you can also check the 
    3.27  <a href="http://localhost/server-status">http://localhost/server-status</a>. 
    3.28 @@ -88,7 +89,7 @@
    3.29  <p>
    3.30  By default, SliTaz starts the server automatically at boot, to prevent this you need to remove
    3.31  <code>lighttpd</code> from the variable RUN_DAEMONS located in the system file
    3.32 -<code>/etc/rcS.conf</code>. To start, stop, restart the server; you can use the commands:
    3.33 +<code>/etc/rcS.conf</code>. To start, stop or restart the server; you can use the commands:
    3.34  <code>/etc/init.d/lighttpd [start|stop|restart]</code>. Example to restart the server after
    3.35  changing the configuration file:
    3.36  </p>
    3.37 @@ -188,7 +189,7 @@
    3.38   # nano /etc/lighttpd/plain.passwd
    3.39  </pre>
    3.40  <p>
    3.41 -To test the address: http://localhost/admin/, just restart the server:
    3.42 +To test the address: <strong>http://localhost/admin/</strong>, just restart the server:
    3.43  </p>
    3.44  <pre> # /etc/init.d/lighttpd restart
    3.45  </pre>