特殊:Badtitle/NS100:DebootstrapChroot:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
(未显示同一用户的4个中间版本) | |||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/DebootstrapChroot}} | {{From|https://help.ubuntu.com/community/DebootstrapChroot}} | ||
{{Languages|UbuntuHelp:DebootstrapChroot}} | {{Languages|UbuntuHelp:DebootstrapChroot}} | ||
This article demonstrates a quick and easy way to create a ''chroot'' environment on an Ubuntu computer, which is like having a virtual system without the overhead of actual virtualization. | |||
This article | A ''chroot'' can be used for things like: | ||
* Running a 32-bit Firefox browser or a 32-bit Wine bottle on a 64-bit system. | |||
=== | * Trying an older or newer Ubuntu release without reinstalling the operating system. | ||
* Trying a [http://www.debian.org Debian] release or other distribution derived from Debian. | |||
* Cross compiling and building packages for a different platform like [http://www.launchpad.net/ Launchpad] or [https://launchpad.net/soyuz/ Soyuz] does it. | |||
=== Example Configuration === | |||
In this example, we use a current Ubuntu 9.04 Jaunty system (the "host") to create a ''chroot'' for the older Ubuntu 8.04 Hardy release (the "target"). We are arbitrarily naming the new ''chroot'' environment '''hardy_i386''' and putting it in the /srv/chroot directory on the host system. | |||
=== Step 1: Install packages on the host computer. === | |||
First, install `debootstrap`, which is a utility that downloads and unpacks a basic Ubuntu system: | |||
<pre><nowiki> | <pre><nowiki> | ||
$ sudo apt-get install debootstrap | |||
</nowiki></pre> | </nowiki></pre> | ||
Second, install `schroot`, which is a utility that wraps the regular `chroot` program and automatically manages ''chroot'' environments: | |||
<pre><nowiki> | <pre><nowiki> | ||
sudo apt-get install | $ sudo apt-get install schroot | ||
</nowiki></pre> | </nowiki></pre> | ||
Note: The `debootstrap` utility is usually backwards compatible with older releases, but it may be incompatible with newer releases. For example, the `debootstrap` that is bundled with Jaunty can prepare a Hardy ''chroot'' like we are doing here, but the `debootstrap` that is bundled with Hardy cannot prepare a Jaunty ''chroot''. | |||
If you have any difficultly with a `debootstrap` version mismatch, then visit http://packages.ubuntu.com/ to manually download and install the [http://packages.ubuntu.com/search?keywords=debootstrap debootstrap package] on the host system from the repository for the target release. | |||
=== Step 2: Create a configuration file for schroot. === | |||
Choose a short name for the ''chroot'', we use '''hardy_i386''' in this example, and create a configuration file for it like this: | |||
<pre><nowiki> | <pre><nowiki> | ||
sudo editor /etc/schroot/chroot.d/hardy_i386.conf | |||
</nowiki></pre> | </nowiki></pre> | ||
Put this in the new file: | |||
<pre><nowiki> | <pre><nowiki> | ||
[hardy_i386] | |||
description=Ubuntu 8.04 Hardy for i386 | |||
location=/srv/chroot/hardy_i386 | |||
#personality=linux32 | |||
root-users=bob | |||
run-setup-scripts=true | |||
run-exec-scripts=true | |||
type=directory | |||
users=alice,bob,charlie | |||
</nowiki></pre> | </nowiki></pre> | ||
Note: if you copy this example to your clipboard, be careful to start each line in column 1 before you save the new file! If you forget, the command '''schroot -l''' will fail with an error, e.g. `E: /etc/schroot/chroot.d/hardy_i386.conf: line 0: Invalid line: “ [hardy_i386]”`. | |||
Change these things in the example configuration file to fit your system: | |||
. '''location''': This should be a directory that is outside of the /home tree. The latest `schroot` documentation recommends /srv/chroot. | |||
. '''personality''': Enable this line if the host system is 64-bit running on an amd64/x64 computer and the chroot is 32-bit for i386. Otherwise, leave it disabled. | |||
. '''users''': These are users on the host system that can invoke the `schroot` program and get access to the ''chroot'' system. Your username on the host system should be here. | |||
. '''root-users''': These are users on the host system that can invoke the `schroot` program and get direct access to the chroot system as the root user. | |||
Note: Do not put whitespace around the '=' character, and do not quote strings after the '=' character. | |||
=== Step 3: Run debootstrap. === | |||
This will download and unpack a basic Ubuntu system to the chroot directory, similar to what the host system already has at the real root directory ("/"). | |||
<pre><nowiki> | <pre><nowiki> | ||
sudo | $ sudo mkdir -p /srv/chroot/hardy_i386 | ||
sudo | $ sudo debootstrap --variant=buildd --arch i386 hardy /srv/chroot/hardy_i386 http://archive.ubuntu.com/ubuntu/ | ||
</nowiki></pre> | </nowiki></pre> | ||
This command should work for any distribution that is derived from Debian. Substitute the architecture "i386", the release name "hardy", and the repository address "http://archive.ubuntu.com/ubuntu/" appropriately. For example, do this to get the 64-bit build of Hardy instead of the 32-bit build: | |||
<pre><nowiki> | <pre><nowiki> | ||
$ sudo debootstrap --arch amd64 hardy /srv/chroot/hardy_amd64/ http://archive.ubuntu.com/ubuntu/ | |||
</nowiki></pre> | </nowiki></pre> | ||
Note: Remember to change all instances of '''hardy_i386''' to '''hardy_amd64''' in the configuration file and on the command line if you actually do this. | |||
Do something like this to get an upstream Debian release: | |||
<pre><nowiki> | <pre><nowiki> | ||
$ sudo debootstrap --arch amd64 sid /srv/chroot/sid_amd64/ http://ftp.debian.org/debian/ | |||
</nowiki></pre> | </nowiki></pre> | ||
=== Step 4: Check the chroot === | |||
This command lists configured ''chroot''s: | |||
<pre><nowiki> | <pre><nowiki> | ||
$ schroot -l | |||
</nowiki></pre> | </nowiki></pre> | ||
If '''hardy_i386''' appears in the list, then run: | |||
<pre><nowiki> | <pre><nowiki> | ||
$ schroot -c hardy_i386 -u root | |||
</nowiki></pre> | </nowiki></pre> | ||
Note: This should work without using `sudo` to invoke the `schroot` program, and it should result in a root prompt in the ''chroot'' environment. | |||
Check that the root prompt is in a different system: | |||
<pre><nowiki> | <pre><nowiki> | ||
# lsb_release -a | |||
</nowiki></pre> | </nowiki></pre> | ||
For the Hardy system that we just built, the `lsb_release` command should print: | |||
<pre><nowiki> | <pre><nowiki> | ||
No LSB modules are available. | |||
Distributor ID: Ubuntu | |||
Description: Ubuntu 8.04 | |||
Release: 8.04 | |||
Codename: hardy | |||
</nowiki></pre> | </nowiki></pre> | ||
We're done! | |||
== WARNING == | |||
For convenience, the default `schroot` configuration rebinds the /home directory on the host system so that it appears in the ''chroot'' system. This could be unexpected if you are familiar with the older `dchroot` program or the regular `chroot` program because it means that you can accidentally delete or otherwise damage things in /home on the host system. | |||
To change this behavior run: | |||
<pre><nowiki> | <pre><nowiki> | ||
sudo mount - | $ sudo editor /etc/schroot/mount-defaults | ||
</nowiki></pre> | </nowiki></pre> | ||
And disable the /home line so that the file reads: | |||
<pre><nowiki> | <pre><nowiki> | ||
# mount.defaults: static file system information for chroots. | |||
# Note that the mount point will be prefixed by the chroot path | |||
# (CHROOT_PATH) | |||
# | |||
# <file system> <mount point> <type> <options> <dump> <pass> | |||
proc /proc proc defaults 0 0 | |||
/dev/pts /dev/pts none rw,bind 0 0 | |||
tmpfs /dev/shm tmpfs defaults 0 0 | |||
#/home /home none rw,bind 0 0 | |||
/tmp /tmp none rw,bind 0 0 | |||
</nowiki></pre> | </nowiki></pre> | ||
The mount.defaults file is the /etc/fstab for ''chroot'' environments. | |||
== Hints == | |||
Install the ubuntu-minimal package in a new ''chroot'' after you create it: | |||
<pre><nowiki> | <pre><nowiki> | ||
$ schroot -c hardy_i386 -u root | |||
</nowiki></pre> | # apt-get install ubuntu-minimal | ||
</nowiki></pre> | |||
If you get locale warnings in the ''chroot'' like "'''Locale not supported by C library.'''" or '''"perl: warning: Setting locale failed."''' , then try one or more of these commands: | |||
you | |||
'' | |||
<pre><nowiki> | <pre><nowiki> | ||
$ sudo dpkg-reconfigure locales | |||
</nowiki></pre> | </nowiki></pre> | ||
<pre><nowiki> | <pre><nowiki> | ||
$ sudo apt-get install language-pack-en | |||
</nowiki></pre> | </nowiki></pre> | ||
<pre><nowiki> | <pre><nowiki> | ||
$ locale-gen en_US.UTF-8 | |||
</nowiki></pre> | </nowiki></pre> | ||
If your preferred language is not English, then change "-en" and "en_US" appropriately. | |||
If | ---- | ||
[[category:CategoryDevelopment]] | |||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2010年5月19日 (三) 21:59的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/DebootstrapChroot }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/af | • {{#if: UbuntuHelp:DebootstrapChroot|Afrikaans| [[::DebootstrapChroot/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/ar | • {{#if: UbuntuHelp:DebootstrapChroot|العربية| [[::DebootstrapChroot/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/az | • {{#if: UbuntuHelp:DebootstrapChroot|azərbaycanca| [[::DebootstrapChroot/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/bcc | • {{#if: UbuntuHelp:DebootstrapChroot|جهلسری بلوچی| [[::DebootstrapChroot/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/bg | • {{#if: UbuntuHelp:DebootstrapChroot|български| [[::DebootstrapChroot/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/br | • {{#if: UbuntuHelp:DebootstrapChroot|brezhoneg| [[::DebootstrapChroot/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/ca | • {{#if: UbuntuHelp:DebootstrapChroot|català| [[::DebootstrapChroot/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/cs | • {{#if: UbuntuHelp:DebootstrapChroot|čeština| [[::DebootstrapChroot/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/de | • {{#if: UbuntuHelp:DebootstrapChroot|Deutsch| [[::DebootstrapChroot/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/el | • {{#if: UbuntuHelp:DebootstrapChroot|Ελληνικά| [[::DebootstrapChroot/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/es | • {{#if: UbuntuHelp:DebootstrapChroot|español| [[::DebootstrapChroot/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/fa | • {{#if: UbuntuHelp:DebootstrapChroot|فارسی| [[::DebootstrapChroot/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/fi | • {{#if: UbuntuHelp:DebootstrapChroot|suomi| [[::DebootstrapChroot/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/fr | • {{#if: UbuntuHelp:DebootstrapChroot|français| [[::DebootstrapChroot/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/gu | • {{#if: UbuntuHelp:DebootstrapChroot|ગુજરાતી| [[::DebootstrapChroot/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/he | • {{#if: UbuntuHelp:DebootstrapChroot|עברית| [[::DebootstrapChroot/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/hu | • {{#if: UbuntuHelp:DebootstrapChroot|magyar| [[::DebootstrapChroot/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/id | • {{#if: UbuntuHelp:DebootstrapChroot|Bahasa Indonesia| [[::DebootstrapChroot/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/it | • {{#if: UbuntuHelp:DebootstrapChroot|italiano| [[::DebootstrapChroot/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/ja | • {{#if: UbuntuHelp:DebootstrapChroot|日本語| [[::DebootstrapChroot/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/ko | • {{#if: UbuntuHelp:DebootstrapChroot|한국어| [[::DebootstrapChroot/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/ksh | • {{#if: UbuntuHelp:DebootstrapChroot|Ripoarisch| [[::DebootstrapChroot/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/mr | • {{#if: UbuntuHelp:DebootstrapChroot|मराठी| [[::DebootstrapChroot/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/ms | • {{#if: UbuntuHelp:DebootstrapChroot|Bahasa Melayu| [[::DebootstrapChroot/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/nl | • {{#if: UbuntuHelp:DebootstrapChroot|Nederlands| [[::DebootstrapChroot/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/no | • {{#if: UbuntuHelp:DebootstrapChroot|norsk| [[::DebootstrapChroot/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/oc | • {{#if: UbuntuHelp:DebootstrapChroot|occitan| [[::DebootstrapChroot/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/pl | • {{#if: UbuntuHelp:DebootstrapChroot|polski| [[::DebootstrapChroot/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/pt | • {{#if: UbuntuHelp:DebootstrapChroot|português| [[::DebootstrapChroot/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/ro | • {{#if: UbuntuHelp:DebootstrapChroot|română| [[::DebootstrapChroot/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/ru | • {{#if: UbuntuHelp:DebootstrapChroot|русский| [[::DebootstrapChroot/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/si | • {{#if: UbuntuHelp:DebootstrapChroot|සිංහල| [[::DebootstrapChroot/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/sq | • {{#if: UbuntuHelp:DebootstrapChroot|shqip| [[::DebootstrapChroot/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/sr | • {{#if: UbuntuHelp:DebootstrapChroot|српски / srpski| [[::DebootstrapChroot/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/sv | • {{#if: UbuntuHelp:DebootstrapChroot|svenska| [[::DebootstrapChroot/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/th | • {{#if: UbuntuHelp:DebootstrapChroot|ไทย| [[::DebootstrapChroot/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/tr | • {{#if: UbuntuHelp:DebootstrapChroot|Türkçe| [[::DebootstrapChroot/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/vi | • {{#if: UbuntuHelp:DebootstrapChroot|Tiếng Việt| [[::DebootstrapChroot/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/yue | • {{#if: UbuntuHelp:DebootstrapChroot|粵語| [[::DebootstrapChroot/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/zh | • {{#if: UbuntuHelp:DebootstrapChroot|中文| [[::DebootstrapChroot/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/zh-hans | • {{#if: UbuntuHelp:DebootstrapChroot|中文(简体)| [[::DebootstrapChroot/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DebootstrapChroot | UbuntuHelp:DebootstrapChroot | {{#if: | :}}DebootstrapChroot}}/zh-hant | • {{#if: UbuntuHelp:DebootstrapChroot|中文(繁體)| [[::DebootstrapChroot/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:DebootstrapChroot|:DebootstrapChroot|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :DebootstrapChroot/zh | | {{#ifexist: DebootstrapChroot/zh | | {{#ifeq: {{#titleparts:DebootstrapChroot|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:DebootstrapChroot|1|-1|}} | zh | | }}
This article demonstrates a quick and easy way to create a chroot environment on an Ubuntu computer, which is like having a virtual system without the overhead of actual virtualization. A chroot can be used for things like:
- Running a 32-bit Firefox browser or a 32-bit Wine bottle on a 64-bit system.
- Trying an older or newer Ubuntu release without reinstalling the operating system.
- Trying a Debian release or other distribution derived from Debian.
- Cross compiling and building packages for a different platform like Launchpad or Soyuz does it.
Example Configuration
In this example, we use a current Ubuntu 9.04 Jaunty system (the "host") to create a chroot for the older Ubuntu 8.04 Hardy release (the "target"). We are arbitrarily naming the new chroot environment hardy_i386 and putting it in the /srv/chroot directory on the host system.
Step 1: Install packages on the host computer.
First, install `debootstrap`, which is a utility that downloads and unpacks a basic Ubuntu system:
$ sudo apt-get install debootstrap
Second, install `schroot`, which is a utility that wraps the regular `chroot` program and automatically manages chroot environments:
$ sudo apt-get install schroot
Note: The `debootstrap` utility is usually backwards compatible with older releases, but it may be incompatible with newer releases. For example, the `debootstrap` that is bundled with Jaunty can prepare a Hardy chroot like we are doing here, but the `debootstrap` that is bundled with Hardy cannot prepare a Jaunty chroot. If you have any difficultly with a `debootstrap` version mismatch, then visit http://packages.ubuntu.com/ to manually download and install the debootstrap package on the host system from the repository for the target release.
Step 2: Create a configuration file for schroot.
Choose a short name for the chroot, we use hardy_i386 in this example, and create a configuration file for it like this:
sudo editor /etc/schroot/chroot.d/hardy_i386.conf
Put this in the new file:
[hardy_i386] description=Ubuntu 8.04 Hardy for i386 location=/srv/chroot/hardy_i386 #personality=linux32 root-users=bob run-setup-scripts=true run-exec-scripts=true type=directory users=alice,bob,charlie
Note: if you copy this example to your clipboard, be careful to start each line in column 1 before you save the new file! If you forget, the command schroot -l will fail with an error, e.g. `E: /etc/schroot/chroot.d/hardy_i386.conf: line 0: Invalid line: “ [hardy_i386]”`. Change these things in the example configuration file to fit your system: . location: This should be a directory that is outside of the /home tree. The latest `schroot` documentation recommends /srv/chroot. . personality: Enable this line if the host system is 64-bit running on an amd64/x64 computer and the chroot is 32-bit for i386. Otherwise, leave it disabled. . users: These are users on the host system that can invoke the `schroot` program and get access to the chroot system. Your username on the host system should be here. . root-users: These are users on the host system that can invoke the `schroot` program and get direct access to the chroot system as the root user. Note: Do not put whitespace around the '=' character, and do not quote strings after the '=' character.
Step 3: Run debootstrap.
This will download and unpack a basic Ubuntu system to the chroot directory, similar to what the host system already has at the real root directory ("/").
$ sudo mkdir -p /srv/chroot/hardy_i386 $ sudo debootstrap --variant=buildd --arch i386 hardy /srv/chroot/hardy_i386 http://archive.ubuntu.com/ubuntu/
This command should work for any distribution that is derived from Debian. Substitute the architecture "i386", the release name "hardy", and the repository address "http://archive.ubuntu.com/ubuntu/" appropriately. For example, do this to get the 64-bit build of Hardy instead of the 32-bit build:
$ sudo debootstrap --arch amd64 hardy /srv/chroot/hardy_amd64/ http://archive.ubuntu.com/ubuntu/
Note: Remember to change all instances of hardy_i386 to hardy_amd64 in the configuration file and on the command line if you actually do this. Do something like this to get an upstream Debian release:
$ sudo debootstrap --arch amd64 sid /srv/chroot/sid_amd64/ http://ftp.debian.org/debian/
Step 4: Check the chroot
This command lists configured chroots:
$ schroot -l
If hardy_i386 appears in the list, then run:
$ schroot -c hardy_i386 -u root
Note: This should work without using `sudo` to invoke the `schroot` program, and it should result in a root prompt in the chroot environment. Check that the root prompt is in a different system:
# lsb_release -a
For the Hardy system that we just built, the `lsb_release` command should print:
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 8.04 Release: 8.04 Codename: hardy
We're done!
WARNING
For convenience, the default `schroot` configuration rebinds the /home directory on the host system so that it appears in the chroot system. This could be unexpected if you are familiar with the older `dchroot` program or the regular `chroot` program because it means that you can accidentally delete or otherwise damage things in /home on the host system. To change this behavior run:
$ sudo editor /etc/schroot/mount-defaults
And disable the /home line so that the file reads:
# mount.defaults: static file system information for chroots. # Note that the mount point will be prefixed by the chroot path # (CHROOT_PATH) # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/pts /dev/pts none rw,bind 0 0 tmpfs /dev/shm tmpfs defaults 0 0 #/home /home none rw,bind 0 0 /tmp /tmp none rw,bind 0 0
The mount.defaults file is the /etc/fstab for chroot environments.
Hints
Install the ubuntu-minimal package in a new chroot after you create it:
$ schroot -c hardy_i386 -u root # apt-get install ubuntu-minimal
If you get locale warnings in the chroot like "Locale not supported by C library." or "perl: warning: Setting locale failed." , then try one or more of these commands:
$ sudo dpkg-reconfigure locales
$ sudo apt-get install language-pack-en
$ locale-gen en_US.UTF-8
If your preferred language is not English, then change "-en" and "en_US" appropriately.