bootstrap CentOS from Gentoo (or any linux distribution)

To bootstrap CentOS in Gentoo, I did the following. It basically installs the essential CentOS components into the specified directory, and from there on, chroot into that directory and perform tests, etc. First off, you’ll need to unmask a few packages(replace ~amd64 with ~x86 if your on the x86 architecture), and enable the flag sqlite for rpm. Execute the following commands as root:

# echo sys-apps/yum ~amd64 >> /etc/portage/package.keywords
# echo dev-python/sqlitecachec ~amd64 >> /etc/portage/package.keywords
# echo app-arch/rpm sqlite >> /etc/portage/package.use

 
Now we’re ready to install the primary packages required to bootstrap CentOS. Merge the following atoms: sys-apps/yum app-arch/rpm dev-python/m2crypto as

# emerge -avuDN sys-apps/yum app-arch/rpm dev-python/m2crypto

 
In this example, we’ll bootstrap CentOS 5(x86_64). Download the stage2(sounds like gentoo now, huh?) from any CentOS mirror. The minimal stage2 does not work with this process.

# wget http://mirrors.seas.harvard.edu/centos/5.6/os/x86_64/images/stage2.img

 
You need to extract the contents of this squashfs image file, so make sure you have =sys-fs/squashfs-tools-3.1 installed. The latest one in portage is broken. Execute the following:

$ unsquashfs-3.1 -d /devel/centos5 stage2.img

 
Now we have a working CentOS 5.6 installation. Install bash and yum into it before you can finally chroot.

# yum --installroot /devel/centos5/ --nogpgcheck install bash
# yum --installroot /devel/centos5/ --nogpgcheck install yum

 
The –nogpgcheck is so that yum doesn’t check the gpg keys which are currently missing on your host gentoo system, or any other non-rpm distribution. chroot into /devel/centos5 and perform some cleaning:

# chroot /devel/centos5
# mkdir /old
# mv /var/lib/rpm /old
# yum install yum

 
What did you just do? Well the RPM DB generated by your host distribution’s RPM, will certainly not match CentOS’s yum, hence we remove the stale RPM database. Everything in the stage2 comprises only of the dependencies of yum and yum itself. Doing a yum install yum will fix everything.
 
Congratulations, you now have the base CentOS installation in /devel/centos5 These instructions are not limited to Gentoo alone, but to any distribution. Any questions may be posted as comments, and I’ll be glad to help you out.


Comments

7 responses to “bootstrap CentOS from Gentoo (or any linux distribution)”

  1. […] bootstrap CentOS from Gentoo (or any linux distribution) To bootstrap CentOS in Gentoo, I did the following. It basically installs the essential CentOS components into the specified directory, and from there on, chroot into that directory and perform tests, etc. First off, you’ll need to unmask a few packages(replace ~amd64 with ~x86 if your on the x86 architecture), and enable the flag sqlite for rpm. Execute the following commands as root: […]

  2. please help me….

    server # yum –installroot /var/centOS/ –nogpgcheck install bash
    Não há repositórios habilitados.
    Execute “yum repolist all” para ver os repositórios que você tem.
    Você pode habilitar repositórios com yum-config-manager –enable

    1. judepereira Avatar
      judepereira

      Hi Raphael,
      Your system does not have yum repositories in place.
      Download centos-release and epel release RPMs and install them locally, that is the directory /etc/yum.repos.d is created in your present system.

      1. server ~ # ls /etc/yum.repos.d/ -1
        CentOS-Base.repo
        mirrors-rpmforge
        mirrors-rpmforge-extras
        mirrors-rpmforge-testing
        rpmforge.repo
        server ~ # yum update
        YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
        Eg. $releasever is not a valid release or hasnt been released yet/
        removing mirrorlist with no valid mirrors: /var/cache/yum/addons/mirrorlist.txt
        Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again

      2. In which repository to find the bash and software for download using yum?

        1. judepereira Avatar
          judepereira

          The default repo has it all, you need to install centos-release on your host system, and then do a yum update.