| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente |
| schroot [Le 11/09/2022, 11:57] – Suppression des espaces en fin de ligne (détecté et corrigé via le bot wiki-corrector (https://forum.ubuntu-fr.org/viewtopic.php?id=2067892) moths-art | schroot [Le 12/02/2026, 18:46] (Version actuelle) – andykimpe |
|---|
| |
| ===== Mise en place d'un environnement chroot ===== | ===== Mise en place d'un environnement chroot ===== |
| * Création du répertoire :<code>mkdir chroot</code>N'importe quel répertoire peut faire l'affaire. L'exemple est donné avec le dossier **/chroot**, à changer à loisir. | * Création du répertoire :<code>sudo mkdir /chroot</code>N'importe quel répertoire peut faire l'affaire. L'exemple est donné avec le dossier **/chroot**, à changer à loisir. |
| |
| * Installation d'une distribution (Ubuntu). Pour cela, on récupérera l'ensemble des paquets. Pour du 64 bits :<code>sudo debootstrap --arch amd64 quantal /chroot/quantal http://us.archive.ubuntu.com/ubuntu/</code>Ou bien, pour installer l'environnement en 32 bits :<code>sudo debootstrap --arch i386 quantal /chroot/quantal http://us.archive.ubuntu.com/ubuntu/</code>Après cela, le dossier **/chroot/quantal/** contient l'arborescence habituelle de la racine de la distribution Ubuntu Quantal Lynx 10.04. | * Installation d'une distribution (Ubuntu). Pour cela, on récupérera l'ensemble des paquets. Pour du 64 bits :<code>sudo debootstrap --arch amd64 noble /chroot/noble http://fr.archive.ubuntu.com/ubuntu/</code>Ou bien, pour installer l'environnement en 32 bits Debian 12 dernier OS 32 bits :<code>sudo debootstrap --arch i386 bookworm /chroot/bookworm http://ftp.fr.debian.org/debian</code>Après cela, le dossier **/chroot/noble/** contient l'arborescence habituelle de la racine de la distribution Ubuntu Noble 24.04 LTS ou dossier /chroot/bookworm debian 12 stable 32 bits. |
| |
| * Pour conserver les logins utilisateurs, mots de passe, groupes etc du système hôte, ajouter ces lignes au fichier /etc/schroot/default/copyfiles :<code> | * Pour conserver les logins utilisateurs, mots de passe, groupes etc du système hôte, ajouter ces lignes au fichier /etc/schroot/default/copyfiles :<code> |
| |
| * [[:tutoriel:comment_modifier_un_fichier|Configuration du fichier]] **/etc/schroot/schroot.conf**<file> | * [[:tutoriel:comment_modifier_un_fichier|Configuration du fichier]] **/etc/schroot/schroot.conf**<file> |
| [quantal] | [noble] |
| description=quantal | description=noble |
| directory=/chroot/quantal | directory=/chroot/noble |
| users=user1,user2,... | users=user1,user2,... |
| root-groups=root | root-groups=root |
| SCHROOT_ID=$(schroot -b -c lenny) | SCHROOT_ID=$(schroot -b -c lenny) |
| |
| schroot -r -c $SCHROOT_ID /etc/init.d/mtab.sh | schroot -r -c "$SCHROOT_ID" /etc/init.d/mtab.sh |
| schroot -r -c $SCHROOT_ID /etc/init.d/mysql start | schroot -r -c "$SCHROOT_ID" /etc/init.d/mysql start |
| schroot -r -c $SCHROOT_ID /etc/init.d/apache2 start | schroot -r -c "$SCHROOT_ID" /etc/init.d/apache2 start |
| schroot -r -c $SCHROOT_ID /etc/init.d/exim4 start | schroot -r -c "$SCHROOT_ID" /etc/init.d/exim4 start |
| |
| mkdir /tmp/schroot/ | mkdir /tmp/schroot/ |
| echo $SCHROOT_ID > /tmp/schroot/$NAMESCRIPT | echo "$SCHROOT_ID" > /tmp/schroot/$NAMESCRIPT |
| |
| elif [ -e "/tmp/schroot/$NAMESCRIPT" ]; then | elif [ -e "/tmp/schroot/$NAMESCRIPT" ]; then |
| if [ -e "/tmp/schroot/$NAMESCRIPT" ]; then | if [ -e "/tmp/schroot/$NAMESCRIPT" ]; then |
| SCHROOT_ID=$(cat /tmp/schroot/$NAMESCRIPT) | SCHROOT_ID=$(cat /tmp/schroot/$NAMESCRIPT) |
| schroot -r -c $SCHROOT_ID /etc/init.d/mysql stop | schroot -r -c "$SCHROOT_ID" /etc/init.d/mysql stop |
| schroot -r -c $SCHROOT_ID /etc/init.d/apache2 stop | schroot -r -c "$SCHROOT_ID" /etc/init.d/apache2 stop |
| schroot -r -c $SCHROOT_ID /etc/init.d/exim4 stop | schroot -r -c "$SCHROOT_ID" /etc/init.d/exim4 stop |
| schroot -e -c $SCHROOT_ID | schroot -e -c "$SCHROOT_ID" |
| |
| rm -R /tmp/schroot/ | rm -R /tmp/schroot/ |