Debian Chroot Installation


Table of Contents

D.3. Installing Debian GNU/Linux from a Unix/Linux System 
D.3.1. Getting Started 
D.3.2. Install debootstrap 
D.3.3. Run debootstrap 
D.3.4. Configure The Base System 
D.3.5. Install a Kernel 
D.3.6. Set up the Boot Loader 
Debian Chroot Install 
Summary 
Why Do It This Way? 
Method 
Further Configuration and Package Installs 

D.3. Installing Debian GNU/Linux from a Unix/Linux System 

http://d-i.alioth.debian.org/manual/en.i386/apds03.html

Excerpted on 2006.06.20.

D.3.1. Getting Started 

create file systems on your partitions.

Initialize and activate swap 

# mkswap /dev/hda5
# sync; sync; sync
# swapon /dev/hda5

Mount one partition as /mnt/debinst 

The mount point name is strictly arbitrary, it is referenced later below.

# mkdir /mnt/debinst
# mount /dev/hda6 /mnt/debinst

D.3.2. Install debootstrap 

The tool that the Debian installer uses, which is recognized as the official way to install a Debian base system, is debootstrap. It uses wget and ar, but otherwise depends only on /bin/sh and basic Unix/Linux tools[11]. Install wget and ar if they aren't already on your current system, then download and install debootstrap.

The debootstrap binary is located in the Debian archive (be sure to select the proper file for your architecture). Download the debootstrap .deb from the pool http://ftp.debian.org/debian/pool/main/d/debootstrap/, copy the package to the work folder, and extract the binary files from it. You will need to have root privileges to install the binaries.

# ar -x debootstrap_0.X.X_arch.deb
# cd /
# zcat /full-path-to-work/work/data.tar.gz | tar xv

D.3.3. Run debootstrap 

debootstrap can download the needed files directly from the archive when you run it. You can substitute any Debian archive mirror for http.us.debian.org/debian in the command example below, preferably a mirror close to you network-wise. Mirrors are listed at http://www.debian.org/misc/README.mirrors.

Substitute one of the following for ARCH in the debootstrap command: alpha, arm, hppa, i386, ia64, m68k, mips, mipsel, powerpc, s390, or sparc.

# /usr/sbin/debootstrap --arch ARCH etch \
   /mnt/debinst http://http.us.debian.org/debian

D.3.4. Configure The Base System 

Now you've got a real Debian system, though rather lean, on disk. Chroot into it:

# LANG= chroot /mnt/debinst /bin/bash

D.3.4.1. Mount Partitions 

You need to create /etc/fstab.

# editor /etc/fstab

Here is a sample you can modify to suit:

# /etc/fstab: static file system information.
#
# file system    mount point   type    options                  dump pass
/dev/XXX         /             ext3    defaults                 0    1
/dev/XXX         /boot         ext3    ro,nosuid,nodev          0    2

/dev/XXX         none          swap    sw                       0    0
proc             /proc         proc    defaults                 0    0

/dev/fd0         /mnt/floppy   auto    noauto,rw,sync,user,exec 0    0
/dev/cdrom       /mnt/cdrom    iso9660 noauto,ro,user,exec      0    0

/dev/XXX         /tmp          ext3    rw,nosuid,nodev          0    2
/dev/XXX         /var          ext3    rw,nosuid,nodev          0    2
/dev/XXX         /usr          ext3    rw,nodev                 0    2
/dev/XXX         /home         ext3    rw,nosuid,nodev          0    2

Use mount -a to mount all the file systems you have specified in your /etc/fstab. You can mount the proc file system multiple times and to arbitrary locations, though /proc is customary. If you didn't use mount -a, be sure to mount proc before continuing:

# mount -t proc proc /proc

The command ls /proc should now show a non-empty directory. Should this fail, you may be able to mount proc from outside the chroot:

# mount -t proc proc /mnt/debinst/proc

D.3.4.2. Configure Keyboard 

To configure your keyboard:

# dpkg-reconfigure console-data

Note that the keyboard cannot be set while in the chroot, but will be configured for the next reboot.

D.3.4.3. Configure Networking 

To configure networking, edit /etc/network/interfaces, /etc/resolv.conf, /etc/hostname and /etc/hosts.

# editor /etc/network/interfaces

Here are some simple examples from /usr/share/doc/ifupdown/examples:

######################################################################
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# See the interfaces(5) manpage for information on what options are
# available.
######################################################################

# We always want the loopback interface.
#
auto lo
iface lo inet loopback

# To use dhcp:
#
# auto eth0
# iface eth0 inet dhcp

# An example static IP setup: (broadcast and gateway are optional)
#
# auto eth0
# iface eth0 inet static
#     address 192.168.0.42
#     network 192.168.0.0
#     netmask 255.255.255.0
#     broadcast 192.168.0.255
#     gateway 192.168.0.1

Enter your nameserver(s) and search directives in /etc/resolv.conf:

# editor /etc/resolv.conf

A simple /etc/resolv.conf:

search hqdom.local
nameserver 10.1.1.36
nameserver 192.168.9.100

Enter your system's host name (2 to 63 characters):

# echo DebianHostName > /etc/hostname

If you have multiple network cards, you should arrange the names of driver modules in the /etc/modules file into the desired order. Then during boot, each card will be associated with the interface name (eth0, eth1, etc.) that you expect.

D.3.4.4. Configure Locales 

To configure your locale settings to use a language other than English, install the locales support package and configure it:

# apt-get install locales
# dpkg-reconfigure locales
[Note]

Apt must be configured beforehand by creating a sources.list and running apt-get update.

D.3.5. Install a Kernel 

If you intend to boot this system, you probably want a Linux kernel and a boot loader. Identify available pre-packaged kernels with

# apt-cache search linux-image

Then install your choice using its package name.

# apt-get install linux-image-2.6.15-arch-etc

D.3.6. Set up the Boot Loader 

To make your Debian GNU/Linux system bootable, set up your boot loader to load the installed kernel with your new root partition. Note that debootstrap does not install a boot loader, though you can use apt-get inside your Debian chroot to do so.

Check info grub or man lilo.conf for instructions on setting up the bootloader. If you are keeping the system you used to install Debian, just add an entry for the Debian install to your existing grub menu.lst or lilo.conf. For lilo.conf, you could also copy it to the new system and edit it there. After you are done editing, call lilo (remember it will use lilo.conf relative to the system you call it from).

Here is a basic /etc/lilo.conf as an example:

boot=/dev/hda6
root=/dev/hda6
install=menu
delay=20
lba32
image=/vmlinuz
label=Debian

documented on: 2006.06.20