Debootstrap – all steps

Installing Debian GNU/Linux from another Unix/Linux System

This article will show how to install a Debian GNU/Linux on a existing
Linux server which is up and running.

A more detailed information about this stuff you will be able to get
on http://www.debian.org/releases/stable/i386/apds03.html

Following steps should be followed in order.

Getting debootsrap:

cd /root
mkdir tmp
cd tmp
wget http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.26+squeeze1_all.deb
ar -x debootstrap_1.0.26+squeeze1_all.debar -x debootstrap_1.0.26+squeeze1_all.deb
cd /
zcat /root/tmp/data.tar.gz | tar xv

Making the base directory for the chroot enviroment:

mkdir /mnt/debian

Mounting the target partition (we are assuming target partition is a Linux
metadevice):

mount /dev/md1 /mnt/debian/
/usr/sbin/debootstrap --arch amd64 squeeze /mnt/debian/ http://ftp.us.debian.org/debian

Copying the reusable information:

cp /etc/hosts /mnt/debian/etc/
cp /etc/hostname /mnt/debian/etc/
cp /etc/network/intefaces /mnt/debian/etc/network/
cp /etc/fstab /mnt/debian/etc/

/dev/md1 / ext4 defaults 1 1
devpts /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0

cp /etc/mdadm.conf /mnt/debian/etc/

MAILADDR root
AUTO +imsm +1.x -all
DEVICE /dev/sda* /dev/sdb*
ARRAY /dev/md1 devices=/dev/sda1,/dev/sdb1
ARRAY /dev/md3 devices=/dev/sda3,/dev/sdb3

cp /etc/inittab /mnt/debian/etc/

# getty in a serial console:
T0:2345:respawn:/sbin/getty -L ttyS0 57600 vt100

Cheking if serial console port is in seccuretty file:

vim /mnt/debian/etc/securetty
# ttyS0 must be listen into this file

Adjusting the source.list

vim /mnt/debian/etc/apt/sources.list

Mounting needed resources:

mount -t proc proc /mnt/debian/proc
mount -o bind /dev/ /mnt/debian/dev/

Entering in the chroot enviroment:

LANG=C chroot /mnt/debian/ /bin/bash

Mounting extra resources needed

mount /dev/pts/
mount /sys

Changing password. We usually  forget this step and due to this fact then we can
not login into the server.

passwd root

Installing needed packages (kernel, tools, modeules required, bootloader):

apt-get install vim ssh lvm2 mdadm bridge-utils
apt-cache search linux.image
apt-get install linux-image...
apt-get install grub2

Configuring grub

vim /etc/default/grub
# set console output on grub

update-grub

Reviewing all settings:

vim /boot/grub/grub.cfg
vim /etc/inittab
vim /etc/fstab
vim /etc/network/interfaces

Finally, exit to the chroot enviroment and execute the reboot command.

… and Good luck !!!