How to make a small Gentoo distro

First off, Gentoo is awesome for making small or custom linux distributions. It allows you (with emerge) to build little package tarballs and make your own image.

Now. to get started add this to your gentoo make.conf


That will tell portage to create the tarball packages every time you emerge anything.

This next part is up for debate. The bare minimal packages in my opinion are bash, baselayout, busybox, openrc. So lets emerge them

emerge bash baselayout busybox openrc

After this is done. And it can take a while. You should have a nice directory struct in /usr/portage/packages. Look for the 4 that you just built. After you got them. create a directory to load build your minimal gentoo distro in.

mkdir -p /build/minimal

The -p just tells it to make all the parent directories too. so it will make /build and then make /build/minimal

now copy those tarballs into this path like so

cp sys-apps/baselayout-1.12.13.tbz2 /build/minimal/
cp sys-apps/busybox-1.16.0.tbz2 /build/minimal/
cp sys-apps/openrc-0.6.1-r1.tbz2 /build/minimal/
cp app-shells/bash-4.0_p37.tbz2 /build/minimal/

Untar them.

cd /build/minimal
tar -xjvf *

The next step you need to figure out what libraries bash needs to run. do this.

ldd bin/bash

Should give you something like this. =>  (0xb78b8000) => /lib/ (0xb786a000) => /lib/ (0xb7866000) => /lib/ (0xb771e000)
        /lib/ (0xb78b9000)

Those are the libs you will need. Go ahead and copy them over.

cp /lib/ /build/minimal/lib/
cp /lib/ /build/minimal/lib/
cp /lib/ /build/minimal/lib/
cp /lib/ /build/minimal/lib/

And now you can chroot inside your minimal enviroment.

chroot /build/minimal/ /bin/bash --login

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s