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

This section explains how to install Debian GNU/Linux from an existing
Unix or Linux system, without using the menu-driven installer as
explained in the rest of the manual. This “cross-install”
HOWTO has been requested by users switching to Debian GNU/Linux from
Red Hat, Mandriva, and SUSE. In this section some familiarity with
entering *nix commands and navigating the file system is assumed. In
this section, $ symbolizes a command to be entered in
the user's current system, while # refers to a
command entered in the Debian chroot.

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. This is therefore a “zero downtime” Debian GNU/Linux
install. It's also a clever way for dealing with hardware that
otherwise doesn't play friendly with various boot or installation
media.

Note

As this is a mostly manual procedure, you should bear in mind that you
will need to do a lot of basic configuration of the system yourself,
which will also require more knowledge of Debian and of Linux in general
than performing a regular installation. You cannot expect this procedure
to result in a system that is identical to a system from a regular
installation. You should also keep in mind that this procedure only
gives the basic steps to set up a system. Additional installation and/or
configuration steps may be needed.

D.3.1. Getting Started

With your current *nix partitioning tools, repartition the hard
drive as needed, creating at least one filesystem plus swap. You
need around 432MB of space available for a console only install,
or about 1521MB if you plan to install X (more if you intend to
install desktop environments like GNOME or KDE).

Next, create file systems on the partitions. For example, to create an
ext3 file system on partition /dev/hda6 (that's
our example root partition):

Mount one partition as /mnt/debinst (the
installation point, to be the root (/) filesystem
on your new system). The mount point name is strictly arbitrary, it is
referenced later below.

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

Note

If you want to have parts of the filesystem (e.g. /usr) mounted on
separate partitions, you will need to create and mount these directories
manually before proceding with the next stage.

D.3.2. Install debootstrap

The utility used by the Debian installer, and 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[23]. Install wget and
ar if they aren't already on your current system,
then download and install debootstrap.

Or, you can use the following procedure to install it
manually. Make a work folder for extracting the .deb into:

# mkdir work
# cd work

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, copy the package to the work folder, and extract the
files from it. You will need to have root privileges to install
the files.

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/mirror/list.

If you have a wheezy Debian GNU/Linux CD mounted at
/cdrom, you could substitute a file URL instead
of the http URL: file:/cdrom/debian/

Substitute one of the following for ARCH
in the debootstrap command:
amd64,
armel,
armhf,
i386,
ia64,
mips,
mipsel,
powerpc,
s390,
s390x, or
sparc.

D.3.4. Configure The Base System

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

# LANG=C.UTF-8 chroot /mnt/debinst /bin/bash

After chrooting you may need to set the terminal definition to be
compatible with the Debian base system, for example:

# export TERM=xterm-color

Depending on the value of TERM, you may have to install the
ncurses-term package to get support for it.

D.3.4.1. Create device files

At this point /dev/ only contains very basic device
files. For the next steps of the installation additional device files may
be needed. There are different ways to go about this and which method you
should use depends on the host system you are using for the installation,
on whether you intend to use a modular kernel or not, and on whether you
intend to use dynamic (e.g. using udev) or static
device files for the new system.

A few of the available options are:

install the makedev package, and create a default set of static device files
using (after chrooting)

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.3. Setting Timezone

Setting the third line of the file /etc/adjtime to
“UTC” or “LOCAL” determines
whether the system will interpret the hardware clock as being set to UTC
respective local time. The following command allows you to set that.

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.5. Configure Apt

Debootstrap will have created a very basic
/etc/apt/sources.list that will allow installing
additional packages. However, you may want to add some additional sources,
for example for source packages and security updates:

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

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 the kernel package of your choice using its package name.

# aptitude install linux-image-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 aptitude inside your Debian chroot to do so.

Note that this assumes that a /dev/hda device file has
been created. There are alternative methods to install grub2,
but those are outside the scope of this appendix.

Check man yaboot.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 yaboot.conf. You could also copy it to
the new system and
edit it there. After you are done editing, call ybin (remember it will
use yaboot.conf relative to the system you call it from).