CentOS 6 in a chroot

When fiddling with CentOS 6.x in a chroot:

  • If your host architecture is x86_64 but your chroot architecture is i686 then you’ll find that yum update will try to install lots of x86_64 packages, and then fail. That’s because the arch command still returns “x86_64”. You’ll want to use setarch:
    # arch
    # setarch i386 /bin/bash
    # arch
  • You’ll need to make sure you have a useful /proc as otherwise yum won’t be able to work out how much free disk space there is and will refuse to proceed. Bind mounting is probably easiest:
    $ sudo mount --bind /proc /srv/your/chroot/proc
  • You might find that things you install aren’t labelled correctly for SELinux. If this is a virtual machine then you can force it to relabel on boot:
    $ sudo touch /srv/your/chroot/.autorelabel

    fixfiles may also work, but I haven’t tried that.

Thanks to Alex for the setarch tip which I had not come across before.

One thought on “CentOS 6 in a chroot

  1. Hi,
    thanks for this solution.

    It’s strange. Centos5(32bit) and rhel6(32bit) did work with arch=x86_64 within a chrooted enviroment.

Leave a Reply

Your email address will not be published. Required fields are marked *