BuildKernelWithChroot
Size: 2451
Comment:
|
← Revision 20 as of 2009-11-11 07:58:25 ⇥
Size: 4713
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
1. sudo apt-get install schroot # install necessary package on host<<BR>> 2. sudo mkdir /var/chroot # Where you put root of chroot<<BR>> 3. sudo vi /etc/schroot/schroot.conf # Add following content to the end of it |
<<Include(KernelTeamHeader)>> ||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<TableOfContents>>|| == Summary == 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 [[http://people.ubuntu.com/~acelan/scripts/create_chroot.sh|create_chroot.sh]] It should be run with root privilage. {{{ $ ./create_chroot.sh Usage: ./create_chroot.sh name corename arch location ex. ./create_chroot.sh hardy-lpia hardy lpia /var/chroot/hardy-lpia }}} {{{ $ sudo ./create_chroot.sh 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... ... postfix:*:14424:0:99999:7::: statd:*:14425:0:99999:7::: NOTE. there are three local files will be modified, they are /etc/schroot/schroot.conf /etc/fstab /etc/dchroot.conf please check the modification isn't mixed up the files and you can find the backup files in the /tmp. Done. You can try to use the new chroot by sudo chroot /var/chroot/jaunty-lpia or dchroot -c jaunty-lpia -d Enjoy. }}} == Modify the schroot config file == host# '''sudo vi /etc/schroot/schroot.conf'''<<BR>> ''Append the following context'' |
Line 9: | Line 56: |
users=<your_userid_on_your_machine> | users=<your_userid_on_your_host> |
Line 14: | Line 61: |
4. sudo debootstrap --variant=buildd --arch lpia hardy /var/chroot/hardy-lpia http://ports.ubuntu.com/ # install basic filesystem into chroot environment<<BR>> 5. sudo cp /etc/resolv.conf /var/chroot/hardy-lpia/etc/resolv.conf<<BR>> 6. sudo vi /var/chroot/hardy-lpia/etc/apt/sources.list # Remove everything and add following line |
== Install basic package into chroot environment == host# '''sudo debootstrap --variant=buildd --arch lpia hardy /var/chroot/hardy-lpia `http://ports.ubuntu.com/`'''<<BR>> host# '''sudo cp /etc/resolv.conf /var/chroot/hardy-lpia/etc/resolv.conf'''<<BR>> host# '''sudo vi /var/chroot/hardy-lpia/etc/apt/sources.list'''<<BR>> ''Remove everything and add following line'' |
Line 21: | Line 71: |
7. sudo chroot /var/chroot/hardy-lpia<<BR>> 8. apt-get install wget debconf devscripts gnupg nano vim debhelper locales dialog kernel-wedge<<BR>> 9. apt-get update<<BR>> 11. locale-gen en_US.UTF-8<<BR>> 12. tzselect<<BR>> 13. echo "export TZ='Asia/Taipei'" >> /root/.profile<<BR>> 14. exit # from chroot<<BR>> 15. sudo vi /etc/fstab and add following line |
== Now you can chroot in and install more package == host# '''sudo chroot /var/chroot/hardy-lpia'''<<BR>> root@chroot# '''apt-get install gnupg; apt-get update'''<<BR>> root@chroot# '''apt-get install wget debconf devscripts dialog nano vim debhelper locales sudo kernel-wedge fakeroot'''<<BR>> root@chroot# '''locale-gen en_US.UTF-8'''<<BR>> root@chroot# '''tzselect'''<<BR>> root@chroot# '''exit'''<<BR>> == Bind several directory with chroot and host == host# '''sudo vi /etc/fstab'''<<BR>> ''Append the following lines''<<BR>> ''Take care it will bind /home between your host and chroot environment''<<BR>> ''If you want to remove chroot environment, '''*umount them first*''''' |
Line 39: | Line 95: |
16. sudo mount -a<<BR>> 17. sudo cp /etc/passwd /var/chroot/hardy-lpia/etc/<<BR>> 18. sudo sed 's/\([^:]*\):[^:]*:/\1:*:/' /etc/shadow | sudo tee /var/chroot/hardy-lpia/etc/shadow<<BR>> 19. sudo cp /etc/group /var/chroot/hardy-lpia/etc/<<BR>> 20. sudo cp /etc/hosts /var/chroot/hardy-lpia/etc/<<BR>> 21. sudo cp /etc/sudoers /var/chroot/hardy-lpia/etc/<<BR>> 22. sudo chroot /var/chroot/hardy-lpia/<<BR>> 23. dpkg-reconfigure passwd<<BR>> 24. passwd <your-user-id><<BR>> 25. apt-get install sudo<<BR>> 26. exit # from chroot <<BR>> 27. echo hardy-lpia > etc/debian_chroot<<BR>> 28. sudo vi /etc/dchroot.conf and add following line |
host# '''sudo mount -a'''<<BR>> == Setup userid/password in chroot == host# '''sudo cp /etc/passwd /var/chroot/hardy-lpia/etc/'''<<BR>> host# '''`sudo sed 's/\([^:]*\):[^:]*:/\1:*:/' /etc/shadow | sudo tee /var/chroot/hardy-lpia/etc/shadow`'''<<BR>> host# '''sudo cp /etc/group /var/chroot/hardy-lpia/etc/'''<<BR>> host# '''sudo cp /etc/hosts /var/chroot/hardy-lpia/etc/'''<<BR>> host# '''sudo cp /etc/sudoers /var/chroot/hardy-lpia/etc/'''<<BR>> host# '''sudo chroot /var/chroot/hardy-lpia/'''<<BR>> chroot# '''dpkg-reconfigure passwd'''<<BR>> chroot# '''passwd <your_userid_on_your_host>'''<<BR>> chroot# '''echo hardy-lpia > /etc/debian_chroot'''<<BR>> chroot# '''exit''' == Setup final information for dchroot.conf == host# '''sudo vi /etc/dchroot.conf'''<<BR>> ''Append with the following content'' |
Line 55: | Line 115: |
29. dchroot -c hardy-lpia -d | == Congratulations, everything is done == host# '''dchroot -c hardy-lpia -d'''<<BR>> ''your shall prompt shall be something like this'' {{{ (hardy-lpia)ikepanhc@laptop:~$ }}} |
Summary
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 create_chroot.sh It should be run with root privilage.
$ ./create_chroot.sh Usage: ./create_chroot.sh name corename arch location ex. ./create_chroot.sh hardy-lpia hardy lpia /var/chroot/hardy-lpia
$ sudo ./create_chroot.sh 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... ... postfix:*:14424:0:99999:7::: statd:*:14425:0:99999:7::: NOTE. there are three local files will be modified, they are /etc/schroot/schroot.conf /etc/fstab /etc/dchroot.conf please check the modification isn't mixed up the files and you can find the backup files in the /tmp. Done. You can try to use the new chroot by sudo chroot /var/chroot/jaunty-lpia or dchroot -c jaunty-lpia -d Enjoy.
Modify the schroot config file
host# sudo vi /etc/schroot/schroot.conf
Append the following context
[hardy-lpia] description=Ubuntu hardy lpia 32 bit location=/var/chroot/hardy-lpia priority=3 users=<your_userid_on_your_host> groups=sbuild root-groups=root personality=linux32
Install basic package into chroot environment
host# sudo debootstrap --variant=buildd --arch lpia hardy /var/chroot/hardy-lpia http://ports.ubuntu.com/
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 http://ports.ubuntu.com hardy main restricted multiverse universe deb-src http://ports.ubuntu.com 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
(hardy-lpia)ikepanhc@laptop:~$
KernelTeam/BuildKernelWithChroot (last edited 2009-11-11 07:58:25 by 210)