The aim this time is to setup a base rootfs for Ubuntu/Debian distro which can be used for setting up a chroot jail or to create a docker container base image. This blog is based on a earlier blog which I have written but forgot to publish around June, 2012.The below mentioned steps are validated on Fedora 25 Workstation installation.
For setting up a
debian based rootfs we need a tool called
debootstrap. It’s available as part of EPEL repository for Fedora and other Redhat based distros. Make sure to always install the latest version of
To setup a base rootfs you need to decide on the version of debian distro (wheezy, jessie, buster), the target architecture (i386 or amd64) and what kind of variant you want to setup. Do read the man page of
debootstrap to know about more advanced options.
For this post, we are looking to setup a
debian wheezy based rootfs to be used as amd64 build environment.
In the above command
components argument is used to specify which components to enable the distri repository. For
debian, there are three components -
non-free. We have enabled all three for our base rootfs.
But if you notice, the second line is slightly different because this points to the
ubuntu repository and creates a rootfs for
precise release of
ubuntu repository are named differently than the
We are going to install
sudo package inside the chroot.
Once the customization is done we need to properly unmount all the chroot mount points.
In case you simply want to invoke a command inside the chroot skipping all the complex mount point setup you do so by running the command in the below mentioned format.
As final step we can package the chroot as a tarball. It is recommended to clean the cache folder of the rootfs before creating the tarball.
This will create a tarball named
wheezy-chroot.tar.xz in the current directory. The newly created tarball can be used as base to create a new docker container or as a chroot jail.