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

Debian Chroot Install 

Revision r1.12 - 17 May 2004 - DrewKime

http://twiki.iwethey.org/twiki/bin/view/Main/DebianChrootInstall

Summary 

Debian GNU/Linux offers a number of installation options. These are well documented in the Debian Installation Instructions. Instructions for a remote Debian chroot install are available in HOWTO - Install Debian Onto a Remote Linux System. http://www.underhanded.org/papers/debian-conversion/remotedeb.html

The instructions here have been largely incorporated into Installing Debian GNU/Linux 3.0 For Intel x86 http://www.debian.org/releases/stable/i386/install also covers this as Installing Debian GNU/Linux from a Unix/Linux System, describing a "zero downtime" Debian install. The primary difference is use of debootstrap rather than the Potato base filesystem image to bootstrap the process. I've tried both, both work well.

The goal is to end up with an unpacked tarball of the base system on a partition, with a working, bootable, kernel, and networking, from which additional configuration may be performed. The means:

  1. Booting some other OS on the system.

  2. Partitioning the system as desired.

  3. Transferring the base image.

  4. Unpacking the base image.

  5. Chrooting into the base system.

  6. Completing installation tasks normally handled by the Debian installer.

  7. Further OS configuration and package installs.

Note that this really is an exercise in flexibility. That is: there's more than one way to do it. Adapting methods to your circumstances is encouraged, though we're going to try providing instructions which, if followed, result in a working Debian GNU/Linux install.

Also note that there's more than one way to do it. A method for installing Debian under an existing GNU/Linux or other Unix system, remotely, is described at http://trilldev.sourceforge.net/files/remotedeb.html, as well as the official Debian installation documentation mentioned earlier.

Why Do It This Way? 

The advantage to this method is that you're working in a chrooted environment. Outside this "chroot jail", you've got a fully capable GNU/Linux system — more so if you're using KNOPIX, the LNX-BBC, other bootable "desktop" GNU/Linux systems, or an existing install. If you're booting from removable media, you can modify any fixed storage (aka hard drives) on the installation system without affecting the system that's running.

Once you've got the new Debian system configured to your preference, you can migrate your existing user data (if any) to it, and keep on rolling. Thus this is also a "zero downtime" GNU/Linux install. It's also a damned good way for dealing with hardware that otherwise doesn't play friendly with various boot or installation media.

Method 

A Few General Notes and Caveats 

A chroot changes the system root for the chrooted process (your chroot shell) and its children. You're in an environment, not a "new instance" of GNU/Linux — you're running the original system kernel, and have access to resources such as networking, device drivers (kernel modules) and (if you provide mountpoints) removable or fixed media as well. What you do have is a new "effective" top level root directory for the purposes of the install.

Your host environment will provide you much of the support that's difficult to get during a standard install. So while you will be configuring, say, networking and module support for the new install while in the chroot, you won't actually be applying these configurations until after you boot into the chroot (or move the chroot drive to a target system and boot it).

Services are a special concern. Debian likes to start up services after they've been installed. Running a chroot, you may find yourself with two instances of, say, Apache running. Since network ports are external to the chroot (they're a kernel interface), you can run into problems. Use care when setting up services, especially if your host is a production box of some sort.

Getting Started 

Boot whatever your bootable system that works and you're comfortable with.

Transferring The Base Image 

Note: if you are performing a debootstrap install, this section does not apply to you, as debootstrap obtains the base installation system by different means. Please see the Debian Installation Manual for this step

Change to the installation root and unpack: cd /mnt/debinst TRB's tar doesn't handle gzipped archives natively… zcat < /mnt/utility/base2_2.tgz | tar xvf

When you're sure you're done with the image tarball itself, you can delete it. This can happen at any later time.

Configuring The Base System 

Note: deboostrap folks can largely follow the remaining instructions in this article.

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

chroot . bin/bash

OK. You've got a few things to configure that would ordinarily be handled by the installed (dbootstrap):

Partitioning and Filesystems 

You've already dealt with partitioning, no need to revisit this. You need to create /etc/fstab, however. While you don't need mount additional filesystems, this is a good time to do so. You'll probably want to activate swap and the proc filesystem.

You can mount the proc filesystem multiple times and to arbitrary locations, though /proc is customary. It will make certain other tasks easier, so do this now:

mount -t proc proc /proc

Mount any additional filesystems. Note that these filesystems are mounted under the chroot.

Networking 

I'll assume you've got networking handled through your boot system, for the duration of your chroot installation process. This section mostly covers configuring networking for use after installation, when you actually boot your newly installed system.

It's possible that name resolution won't work until /etc/resolv.conf is properly configured. Under Knoppix, this may be symlinked outside the chroot. You'll have to break (delete) the link and create a regular file with your nameserver(s), and (optionally) domain and search directives.

You still likely don't have networking configured to come up on the installed system. This requires hand edits of:

Keyboard, Language, & Timezone: base-config 

Note: Applying these settings will affect both the chroot and host environment, though the configuration files themselves are persistant only in the chroot install.

Basics of system setup are handled by base-config

dpkg-reconfigure base-config
base-config

(You may have to run 'dpkg —install —reinstall base-config' instead to force this).

User Account 

And, if the system hasn't already prompted you, set up a nonpriviledged user account:

adduser <username>        # ...and follow prompts.
passwd <username>
Configure apt sources 

OK, now, munge /etc/apt/sources.list to your preference. You can use apt-setup or edit the file by hand. If you want to run a 'testing' or 'unstable' system, you can make this switch now. After the edits (and setting the $http_proxy environment variable if necessary:

apt-get update
apt-get dist-upgrade
Delete "unconfigured.sh" 
Note
..will update your system.
Not sure this applies in a deboostrap install, but make sure the file isn't present.

The file /sbin/unconfigured.sh will prevent your system from starting up normally if it exists (it is checked for in /etc/init.d/rcS). Delete or rename this file prior to rebooting your system.

Rebooting 

You'll need to umount any filesystems mounted under the chroot manually, before exiting your chroot process. Your chroot mountpoint itself is generally not mounted under the chroot, but under the host system. Remember which environment you're in when running your shutdown or reboot command, particularly if your host is a live install. Bootable CD distros are considerably more tolerant to unclean shutdowns.

Reboot to confirm your settings. If your system doesn't come up, you've got your boot disk (TRB/LNX-BBC) to salvage you. Chroot into the installation, mess with your bootloader, and try again.

Common boot errors include:

Further Configuration and Package Installs 

From here, you can build out the system by:

Applying an existing package list to your new system 
# On other box:
dpkg --get-selections > file
$EDIT file

# Transfer file to your new system (floppy, network, carrier
# pigeon, whatever).

dpkg --set-selections < file

# In theory, the following works, though I had to kick it a few
# times to make it go right:

apt-get dist-upgrade            # This should work.
apt-get dselect-upgrade         # This is what I ended up using.

documented on: 2006.06.20