slitaz-doc-wiki-data diff pages/en/guides/chroot.txt @ rev 7

Add pages/en folder.
author Christopher Rogers <slaxemulator@gmail.com>
date Sat Feb 26 12:17:18 2011 +0000 (2011-02-26)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/pages/en/guides/chroot.txt	Sat Feb 26 12:17:18 2011 +0000
     1.3 @@ -0,0 +1,96 @@
     1.4 +====== Chroot =======
     1.5 +
     1.6 +This guide explain how to setup a chroot to cook packages in a separate environment. The chroot can be built on a USB or HDD device to save RAM when using a live session. There is also a script which removes any packages installed during cooking on exit in order to keep the chroot light and also checks the build_depends.
     1.7 +
     1.8 +===== With Tazdev =====
     1.9 +
    1.10 +Over time the SliTaz developers created tools for the automation of various tasks. The slitaz-dev-tools package provides the tazdev utility and its configuration file /etc/slitaz/tazdev.conf; it can create a chroot to use:
    1.11 +
    1.12 +<code>
    1.13 +# tazpkg get-install slitaz-dev-tools
    1.14 +# tazdev gen-chroot
    1.15 +# tazdev chroot
    1.16 +</code>
    1.17 +
    1.18 +By default the chroot is created in ///home/slitaz/cooking/chroot// and is slitaz-based. For more info and available commands you can use 'tazdev usage' and/or take a look at the configuration file.
    1.19 +
    1.20 +===== Create the chroot =====
    1.21 +<file>
    1.22 +#!/bin/sh
    1.23 +mkdir /home/chroot
    1.24 +# You can mount a device to /home/chroot
    1.25 +# with mountbox or mount
    1.26 +tazpkg get-install busybox --root="/home/chroot"
    1.27 +echo "No" | tazpkg get-install bash --root="/home/chroot"
    1.28 +tazpkg get-install slitaz-toolchain --root="/home/chroot"
    1.29 +tazpkg get-install tazwok --root="/home/chroot"
    1.30 +tazpkg get-install tazpkg --root="/home/chroot"
    1.31 +tazpkg get-install lzma --root="/home/chroot"
    1.32 +mkdir /home/chroot/home/slitaz</file>
    1.33 +
    1.34 +Note, you can keep these lines in a script file if needed. Just add #!/bin/sh to the first line and make executable with:
    1.35 +<code># chmod +x script_file</code>
    1.36 +
    1.37 +===== Add a script file to automate some actions =====
    1.38 +
    1.39 +<code># cat > /home/chroot/chroot_script.sh << "EOF"</code>
    1.40 +<file>
    1.41 +#!/bin/sh
    1.42 +/bin/sh --login
    1.43 +for pkg in $(cat /var/log/tazpkg.log | grep -v Removed | sed 's/\(.*\)\(- Installed - \)\(.*\)\( (.*\)/\3/'); do
    1.44 +	echo "y" | tazpkg remove $pkg
    1.45 +done
    1.46 +rm /var/log/tazpkg.log
    1.47 +
    1.48 +EOF
    1.49 +</file>
    1.50 +<code># chmod +x "/home/chroot/chroot_script.sh"</code>
    1.51 +
    1.52 +Note, /bin/sh --login logs you into the chrooted environment. The commands after that auto-remove any packages added when cooking on exit. You can hack this file to execute various automated actions when entering and exiting the chroot.
    1.53 +
    1.54 +===== Add a script to mount and umount chroot =====
    1.55 +
    1.56 +<code># cat > /usr/bin/tazchroot << "EOF"</code>
    1.57 +<file>
    1.58 +#!/bin/sh
    1.59 +cat /etc/resolv.conf > /home/chroot/etc/resolv.conf
    1.60 +if [ ! -d "/home/chroot/proc/1" ]; then
    1.61 +	echo "Mounting virtual filesystems..."
    1.62 +	mount -t proc proc /home/chroot/proc
    1.63 +	mount -t sysfs sysfs /home/chroot/sys
    1.64 +	mount -t devpts devpts /home/chroot/dev/pts
    1.65 +	mount -t tmpfs shm /home/chroot/dev/shm
    1.66 +	mount /home/slitaz /home/chroot/home/slitaz
    1.67 +	chroot /home/chroot ./chroot_script.sh
    1.68 +	until [ "$ps" = "2" ]; do
    1.69 +		echo "Waiting for the end of all other chroot processes..."
    1.70 +		ps=$(ps | grep `basename $0` | grep -v grep | grep -v basename | wc -l)
    1.71 +		sleep 1
    1.72 +	done
    1.73 +	umount /home/chroot/home/slitaz
    1.74 +	umount /home/chroot/dev/shm
    1.75 +	umount /home/chroot/dev/pts
    1.76 +	umount /home/chroot/sys
    1.77 +	umount /home/chroot/proc
    1.78 +else
    1.79 +	echo "The chroot is already mounted"
    1.80 +fi
    1.81 +EOF
    1.82 +</file>
    1.83 +<code># chmod +x /usr/bin/tazchroot</code>
    1.84 +
    1.85 +Note, this script mounts ///home/slitaz// in your chroot, so you can use tazwok as if it was in your normal environment.
    1.86 +
    1.87 +---- 
    1.88 +\\
    1.89 +^  Page Review Section  ^^ 
    1.90 +|Quality| Good  |
    1.91 +|Review| Minor Updates  |
    1.92 +|Priority| Medium |
    1.93 +|Problems| add a [[http://forum.slitaz.org|forum post link]]|
    1.94 +|:::     | OR add a [[http://labs.slitaz.org/issues |lab issue tracker link ]]|
    1.95 +|How to Improve| Suggest briefly|
    1.96 +|::: |  |
    1.97 +
    1.98 +\\
    1.99 +----
   1.100 \ No newline at end of file