Centos Chroot

12 Dec 2017 19:49

Let's say you want a chroot with CentOS with an older version of the system to test something.

Get the minimal root fs

  1. Check out Docker images for CentOS: https://hub.docker.com/_/centos/
  2. Follow the Dockerfile link for the version you're interested in, say 6.6: https://github.com/CentOS/sig-cloud-instance-images/blob/8911843d9a6cc71aadd81e491f94618aded94f30/docker/Dockerfile
  3. Go one level up in GitHub and locate the centos-*.tar.xz file, it's the archive with the mininal rootfs for CentOS: https://github.com/CentOS/sig-cloud-instance-images/blob/8911843d9a6cc71aadd81e491f94618aded94f30/docker/centos-6.6-20150304_1234-docker.tar.xz
  4. Click the download link

Prepare a directory, unpack the root fs

sudo mkdir -p /mnt/centos-chroot/
# You may need to uncompress the XZ file, but my tar could deal with it, so try yourself:
sudo tar -xf /path/to/centos-6.6-20150304_1234-docker.tar.xz
# Mount some pseudo filesystems:
cd /mnt/centos-chroot/
sudo mount --bind /sys sys
sudo mount --bind /dev dev
sudo mount -t proc proc proc

Enter your precious chroot:

sudo chroot /mnt/centos-chroot/ /bin/bash
. /etc/environment

Done!


More posts on this topic

Comments

Add a New Comment
or Sign in as Wikidot user
(will not be published)
- +
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License