Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
en:handbook:chroot [2010/02/26 22:34] linea |
en:handbook:chroot [2011/05/03 22:46] domcox update |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Chroot environment ====== | + | ====== Environnement chrooté ====== |
- | This document describes the necessary steps to create a chrooted environment, in order to change the root of the system so that you can work. This makes it possible to compile, test and develop SliTaz without any risk to the host system you're working on. The host system can be SliTaz installed to a hard drive or any other GNU/Linux system such as Debian, Fedora, PCLinuxOS and so on. You can also create a chrooted environment in LiveCD mode associated with USB media. The only prerequisite is to have a SliTaz ISO image available and a little time. Note that all commands are carried out as system administrator (root). | + | Ce document décrit les étapes à réaliser pour créer un environnement chrooté afin de changer la racine du système pour travailler. Cela permet de compiler, tester et développer SliTaz sans risques pour le système hôte depuis lequel on travaille. Ce système hôte peut être SliTaz installée en dur ou tout autre système GNU/Linux tel que Debian, Fedora, PCLinuxOS, etc. On peut aussi créer un environnement chrooté en mode LiveCD associé à un média USB. Les seuls prérequis sont d'avoir une image ISO de SliTaz à disposition et un peu de temps. À noter que toutes les opérations sont réalisées en tant qu'administrateur (//root//). |
- | ===== Prepare the environment ===== | + | ===== Préparer l'environnement ===== |
- | To begin, we must extract the contents of the ISO image into the directory that will serve as our chroot. The directory can be created any place you choose, we'll use a directory ///home/slitaz/chroot-env//. To extract the contents of an ISO image, we must mount it in a loop directory and then copy the compressed root filesystem (rootfs.gz) into the chroot directory. Assuming the ISO is in the current directory: | + | Pour commencer, il faut extraire le contenu de l'image ISO dans le répertoire qui va servir au chroot. Le répertoire de chroot peut se créer à l'endroit que l'on veut, nous utilisons un répertoire ///home/slitaz/chroot-env//. Pour extraire le contenu d'une image ISO, il faut la monter en //loop// sur un répertoire, pour ensuite copier le système de fichiers racine compressé (//rootfs.gz//) dans le répertoire de chroot. En supposant que l'ISO est dans le répertoire courant : |
<code> | <code> | ||
# mkdir /tmp/loop | # mkdir /tmp/loop | ||
- | # mount -o loop slitaz-cooking.iso /tmp/loop | + | # mount -o loop slitaz-3.0.iso /tmp/loop |
# mkdir -p /home/slitaz/chroot-env | # mkdir -p /home/slitaz/chroot-env | ||
# cp /tmp/loop/boot/rootfs.gz \ | # cp /tmp/loop/boot/rootfs.gz \ | ||
Line 16: | Line 16: | ||
</code> | </code> | ||
- | Now we have a copy of the compressed filesystem, we must extract and unpack it (this is a cpio archive compressed with either gzip or lzma). To complete this stage, we can remove the rootfs which is no longer required: | + | Maintenant qu'on a une copie du système de fichiers compressé, il faut le décompresser et le dés-archiver (c'est une archive //cpio// compressée avec lzma ou gzip). Pour finir cette étape de préparation et continuer, on peut retirer le //rootfs// qui n'est plus utilisé : |
<code> | <code> | ||
Line 24: | Line 24: | ||
</code> | </code> | ||
- | If the unpacking of the rootfs compressed with lzma fails; you can use the following method: | + | Si le dés-archivage du rootfs compressé avec LZMA échoue en utilisant la première méthode vous pouvez utiliser: |
<code> | <code> | ||
Line 31: | Line 31: | ||
</code> | </code> | ||
- | ===== Using the environment ===== | + | ===== Utiliser l'environnement ===== |
- | + | ||
- | To begin using the chrooted environment, you just need to mount some virtual filesystems and use the chroot command. To simplify things, we can write a small script automating the process. Example using the chroot directory ///home/slitaz/chroot-env// and creating a script chroot_in_env.sh in ///home/slitaz//. On any systems other than SliTaz you can uncomment the lines about ///dev// and ///tmp// - Note to save typing you can copy and paste: | + | |
+ | Pour utiliser l'environnement chrooté, il suffit de monter quelques systèmes de fichier virtuels et d'utiliser la commande //chroot//. Pour se simplifier la vie on peut rapidement créer un petit script automatisant le chroot. Exemple en utilisant le répertoire de chroot ///home/slitaz/chroot-env// et en créant un script nommé //chroot_in_env.sh// dans ///home/slitaz//. À noter que le contenu du script n'a pas besoin d'être tapé mais simplement copié/coller dans le terminal et que sur un autre système que SliTaz vous pouvez dé-commenter les lignes montant/démontant ///dev// et ///tmp// : | ||
<code> # cat > /home/slitaz/chroot_in_env.sh << "EOF" | <code> # cat > /home/slitaz/chroot_in_env.sh << "EOF" | ||
Line 69: | Line 68: | ||
</code> | </code> | ||
- | To finish and test the environment, you just make the script executable and run: | + | Pour finir et tester l'environnement, il suffit de rendre le script exécutable et le lancer : |
<code> | <code> | ||
Line 76: | Line 75: | ||
</code> | </code> | ||
- | === To activate the network === | + | === Activer le réseau === |
- | In order to have the network up to download and install some development packages, just start the DHCP client on the correct interface. Example using eth1: | + | Pour avoir le réseau afin de télécharger, naviguer en mode texte et installer des paquets de développement, il suffit de lancer le client DHCP sur la bonne interface, exemple avec //eth1// : |
<code> # udhcpc -i eth1 </code> | <code> # udhcpc -i eth1 </code> | ||
- | === Installing packages === | + | === Installer des paquets === |
- | If the network is functional, just reload the list of packages and use tazpkg get-install to install them. If a connection is not possible, you can download the packages from another system, copy them to the chrooted environment and install them with the tazpkg install command. To install the basic compilation tools: | + | Si le réseau est fonctionnel, il suffit de recharger la liste des paquets et utiliser //tazpkg get-install// pour installer de nouveaux paquets. Si la connexion n'est pas possible, on peut télécharger les paquets du miroir depuis un autre système, les copier dans l'environnement chrooté et les installer via la commande //tazpkg install//. Pour installer la base des outils de compilation : |
<code> # tazpkg recharge | <code> # tazpkg recharge | ||
# tazpkg get-install slitaz-toolchain </code> | # tazpkg get-install slitaz-toolchain </code> | ||
- | Once the environment is configured, you can compile applications from source to create packages, test scripts, etc. The Cookbook should help you out here: | + | Une fois l'environnement configuré, on peut compiler des applications depuis les sources pour en créer des paquets, tester des scripts et autre. Le chapitre [[en:handbook:development|développement]] du Handbook et le [[fr:cookbook:start|Cookbook] devraient aider à aller plus loin. |
- | === Exit the environment === | + | === Sortir de l'environnement === |
- | To exit the chrooted environment, just type exit, the //chroot_in_env.sh// script will then end by unmounting the virtual filesystems from the Linux Kernel: | + | Pour sortir de l'environnement chrooté il suffit de taper //exit//, le script //chroot_in_env.sh// va finir son rôle en démontant le systèmes de fichiers virtuels propre au noyau Linux : |
<code> | <code> | ||
Line 99: | Line 98: | ||
# | # | ||
</code> | </code> | ||
- |