Skip to content

Instantly share code, notes, and snippets.

@lionelg3
Created May 11, 2018 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lionelg3/31c7f0723c0830024caa1ec11157d5c9 to your computer and use it in GitHub Desktop.
Save lionelg3/31c7f0723c0830024caa1ec11157d5c9 to your computer and use it in GitHub Desktop.
Simple chroot for centos7
#!/bin/sh
JAIL=$1
echo "Création du CHROOT $JAIL"
if [ -d $JAIL ]
then
echo "Le dossier existe deja"
exit 0
else
mkdir $JAIL
rpm --root=$JAIL --nodeps -i /root/centos-release-7-4.1708.el7.centos.x86_64.rpm
rpm --root=$JAIL --nodeps -i yum-3.4.3-154.el7.centos.noarch.rpm
yum -y --installroot=$JAIL update
yum -y --installroot=$JAIL install -y yum
yum --installroot=$JAIL install -y @core
cp /etc/resolv.conf $JAIL/etc/
fi
#!/bin/sh
JAIL=$1
echo "Lancement du CHROOT $JAIL"
if [ -d $JAIL/etc ]
then
echo "Chroot présent [OK]"
else
echo "Ce dossier n'est pas in chroot"
exit 0
fi
echo "proc $JAIL/proc proc defaults 0 0" > /etc/fstab
echo "sysfs $JAIL/sys sysfs defaults 0 0" >> /etc/fstab
mount proc $JAIL/proc -t proc
mount sysfs $JAIL/sys -t sysfs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment