This wiki page is the step-by-step document for build the environment of chroot for build kernel image

Install necessary package on host

host# sudo apt-get install schroot debootstrap dchroot

Where the root of chroot is

host# sudo mkdir /var/chroot

Before you start

There is an easy script that can do whole things that have to be done at host side that describe as below section. You can download this script and give it a try It should be run with root privilage.

$ ./
Usage: ./ name corename arch location
 ex. ./ hardy-lpia hardy lpia /var/chroot/hardy-lpia

$ sudo ./ jaunty-lpia jaunty lpia /var/chroot/jaunty-lpia
I: Retrieving Release
I: Retrieving Packages
I: Validating Packages
I: Resolving dependencies of required packages...
I: Resolving dependencies of base packages...

NOTE. there are three local files will be modified, they are
please check the modification isn't mixed up the files and you can find the backup files in the /tmp.


You can try to use the new chroot by
        sudo chroot /var/chroot/jaunty-lpia
        dchroot -c jaunty-lpia -d

Modify the schroot config file

host# sudo vi /etc/schroot/schroot.conf
Append the following context

description=Ubuntu hardy lpia 32 bit

Install basic package into chroot environment

host# sudo debootstrap --variant=buildd --arch lpia hardy /var/chroot/hardy-lpia
host# sudo cp /etc/resolv.conf /var/chroot/hardy-lpia/etc/resolv.conf
host# sudo vi /var/chroot/hardy-lpia/etc/apt/sources.list
Remove everything and add following line

deb hardy main restricted multiverse universe
deb-src hardy main restricted multiverse universe

Now you can chroot in and install more package

host# sudo chroot /var/chroot/hardy-lpia
root@chroot# apt-get install gnupg; apt-get update
root@chroot# apt-get install wget debconf devscripts dialog nano vim debhelper locales sudo kernel-wedge fakeroot
root@chroot# locale-gen en_US.UTF-8
root@chroot# tzselect
root@chroot# exit

Bind several directory with chroot and host

host# sudo vi /etc/fstab
Append the following lines
Take care it will bind /home between your host and chroot environment
If you want to remove chroot environment, *umount them first*

# Hardy-lpia
/home           /var/chroot/hardy-lpia/home        none    bind            0       0
/tmp            /var/chroot/hardy-lpia/tmp         none    bind            0       0
/dev            /var/chroot/hardy-lpia/dev         none    bind            0       0
proc-chroot     /var/chroot/hardy-lpia/proc        proc    defaults        0       0
devpts-chroot   /var/chroot/hardy-lpia/dev/pts     devpts  defaults        0       0

host# sudo mount -a

Setup userid/password in chroot

host# sudo cp /etc/passwd /var/chroot/hardy-lpia/etc/
host# sudo sed 's/\([^:]*\):[^:]*:/\1:*:/' /etc/shadow | sudo tee /var/chroot/hardy-lpia/etc/shadow
host# sudo cp /etc/group /var/chroot/hardy-lpia/etc/
host# sudo cp /etc/hosts /var/chroot/hardy-lpia/etc/
host# sudo cp /etc/sudoers /var/chroot/hardy-lpia/etc/
host# sudo chroot /var/chroot/hardy-lpia/
chroot# dpkg-reconfigure passwd
chroot# passwd <your_userid_on_your_host>
chroot# echo hardy-lpia > /etc/debian_chroot
chroot# exit

Setup final information for dchroot.conf

host# sudo vi /etc/dchroot.conf
Append with the following content

hardy-lpia /var/chroot/hardy-lpia/

Congratulations, everything is done

host# dchroot -c hardy-lpia -d
your shall prompt shall be something like this


KernelTeam/BuildKernelWithChroot (last edited 2009-11-11 07:58:25 by acelankao)