Skip to content

Instantly share code, notes, and snippets.

@ldx
Created February 20, 2014 15:23
Show Gist options
  • Save ldx/9116170 to your computer and use it in GitHub Desktop.
Save ldx/9116170 to your computer and use it in GitHub Desktop.
Build a chroot with a CentOS 6.5 base install.
#!/bin/sh
#
# Build a chroot with a CentOS 6.5 base install.
#
CHROOT=/tmp/chroot
mkdir -p $CHROOT
mkdir -p $CHROOT/var/lib/rpm
rpm --rebuilddb --root=$CHROOT
wget http://fr2.rpmfind.net/linux/centos/6.5/updates/x86_64/Packages/centos-release-6-5.el6.centos.11.2.x86_64.rpm
rpm -i --root=$CHROOT --nodeps centos-release-6-5.*.rpm
yum --installroot=$CHROOT install -y rpm-build yum
mkdir -p $CHROOT/proc
mount --bind /proc $CHROOT/proc
mkdir -p $CHROOT/dev
mount --bind /dev $CHROOT/dev
mkdir -p $CHROOT/etc
cp /etc/resolv.conf $CHROOT/etc/resolv.conf
mkdir -p $CHROOT/root
cp $CHROOT/etc/skel/.??* $CHROOT/root