Howto uClibc chroot

If you want to create an embedded Gentoo image using uClibc, you will need a Gentoo uClibc environment. To do this you could do a full Gentoo uClibc install and boot into that, or create a 'fake' install in a folder and just chroot into that when you need it. As getting Gtk+2 and other such things on uClibc can be a bit of a pain, as well as all the hassel of an other working Gentoo install, the chroot way is a lot faster and easier to setup and to use. The chroot can also be setup in nearly any Linux distribution.

Instead of this Howto, you could follow the official Gentoo handbook, but instead of installing onto disk install into a folder, and skip the bootloader, kernel and syslog steps.


We will need to create folder that is used as the chroot. The exact location or the folder name doesn't really matter.

# mkdir /root/uclibc
# cd /root/uclibc

You could mount an empty partition onto /root/uclibc now if you wanted to, though it isn't necessary.

Next you will need to download and extract an uClibc stage into the chroot folder. Select a mirror near you, and navigate to experimental/x86/embedded/stages/. If this folder does not exist, try an other mirror.
Download the latest stage3 (currently stage3-x86-uclibc-2006.1.tar.bz2) to /root/uclibc/, and extract it.
We will also create a folder that we can bind our portage tree to.

# wget http://mirror_name/experimental/x86/embedded/stages/stage3-x86-uclibc-2006.1.tar.bz2
# tar xjpf stage3-x86-uclibc-2006.1.tar.bz2
# mkdir usr/portage

To check that you have extracted it correctly

# ls
bin boot dev etc home lib mnt opt proc root sbin stage3-x86-uclibc-2006.1.tar.bz2 sys tmp usr var

Before our chroot will be a fully functional we will need to have the portage tree in /root/uclibc/usr/portage. If you are doing this in a Gentoo system, you can bind your portage tree into the chroot.

# mount --bind /usr/portage /root/uclibc/usr/portage

Users of other systems will need to follow the Installing Portage section of the Gentoo handbook, with the minor change that you will be using /root/uclibc instead of /mnt/gentoo.

Now you are ready to enter the chroot.

# cp /etc/resolv.conf etc/
# chroot .


Packages on the stage are usually slightly out of date, so it is a good idea to update the chroot system.

We will start by setting the profile to the latest one

# ln -snf ../usr/portage/profiles/uclibc/x86 /etc/make.profile

You will also probably want to edit /etc/make.conf to suit your needs

CFLAGS="-Os -pipe"
CXXFLAGS="-Os -pipe"

FEATURES="buildpkg ccache"

If you want ccache

# emerge -av ccache

And to update the system

# emerge -uDNav world

If the emerge fails on a package, you can try skipping it

# emerge --resume --skipfirst

There will probably be a lot of config files that have changed. As this isn't a bootable system, you don't usually have to worry about them, so you can just use -5 as the option to etc-update.

# etc-update


That's pretty much it.
Now you can easily access a Gentoo uClibc system for things like TinyGentoo

Images by Mrs A. Linnapuomi