How To: Installing Debian Etch From a running Debian based system

This How To will show how you can install Debian Etch and basically any Debian based distribution from a chroot environment. This way you don't need to download the (net)install CD, neither to burn it.

This is as well a good training in order to understand how a debian system works.

1.Introduction
It's a long time since I ran debian on my system, I'm kind of missing it and decided to use the 5G I got left on my hard disk to install Debian Etch.

I wanted to install it directly from my Ubuntu Dapper environment. It used to be quite easy in the past as you could use the base-config which would guide you through the installation process, but recently (2 month actually), Debian Installer Etch beta 2 was released, here is an excerpt of Debian News March 15th, 2006:
March 15th, 2006

The Debian Installer team is proud to announce the second beta release of the installer for Debian GNU/Linux Etch.

Improvements in this release of the installer include:

Well, the debian installer is now run while on the install cd and base-config was removed from the repository, this means that I will have to do the job done by base-config, basically, setting up locale, console-data, timezone, network and fstab.

2. Preparing your system

The first thing you need to do is to prepare a partition to host your new system. Your filesystem might be more or less complex (having separate /boot, /usr, /var ...), in my case, as I don't have much space left, I will create a / partition on sda11 of type ext3 and a separate /home partition (the one I'm already using on my Ubuntu Dapper system) which is located on partition /dev/sda5 and is of type reiserfs. The swap partition will be the one I use on my running system, namely: sda9.
So here we go, we have to format /, mount / on our file system and prepare our future debian filesystem using debootstrap which is a tool to bootstraps a basic Debian system.

Let's go to it, open a terminal and type:

root@laptop:/#mkfs.ext3 /dev/sda11
root@laptop:/# mkdir /mnt/debian
root@laptop:/#mount /dev/sda11 /mnt/debian/

now, the filesystem is prepare and we have mounted our system on /mnt/debian, now, we install a basic system with debootstrap:

root@laptop:/#debootstrap etch /mnt/debian/   ftp://ftp.de.debian.org/debian/
I: Retrieving Release
I: Retrieving Packages
I: Validating Packages
I: Resolving dependencies of required packages...
I: Resolving dependencies of base packages...
I: Found additional base dependencies: libdb4.2 libgnutls12 libreadline5 libsigc ++-2.0-0c2aopenbsd-inetd readline-common
...
...
I: Configuring netbase...
I: Configuring openbsd-inetd...
I: Base system installed successfully.

Done! Now we are going to chroot (a tool provided by the package coreutils), chroot runs command or interactive shell with a special root directory, in order to let our new system being informed of what is in the system, we need to mount /proc filesystem:

root@laptop:/#mount -t proc none /mnt/debian/proc
root@laptop:/#chroot  /mnt/debian/

Let's carry on with the configuration.

Carry on with page 2.


How To: Installing Debian Etch From a running Debian based system -- page 2

3. Installing utils package and Configuring your new system

Now, we need to install some more packages (such as the kernel :D), configure the timezone, partition, your hostname create your main user, define a new password for root ...

root@laptop:/# apt-get install locales console-data console-common
root@laptop:/# dpkg-reconfigure locales console-data

Enter the appropriate value for your system. Install the kernel:

root@laptop:/#apt-get install initrd-tools
root@laptop:/#apt-get install linux-headers-2.6-686 linux-image-2.6.15-1-686

Linux headers might not be required for most users, but because I will need to compile a kernel module in order to use my wireless network card, I do need the kernel headers.

You might need a set of usefull packages, here is a good set:

root@laptop:/#apt-get install usbutils pciutils bzip2 sysfsutils wireless-tools dhcp3-client resolvconf cpufreqd cpufrequtils acpid acpi

Now we are going to configure the system. We start with the file /etc/hosts, edit it and write:

# /etc/hosts
127.0.0.1       localhost

, set the hostname in /etc/hostname and add your host name. You might want to configure /etc/network/interfaces, to get automatic configuration of your network interfaces, here in a sample:

iface lo inet loopback
iface eth0 inet dhcp
wireless-essid XXXXXX
auto eth0

We are done with the network bit, let's configure the time zone:

ln -sf /usr/share/zoneinfo/Zone/Town /etc/localtime

and the file system, edit /etc/fstab and add:

proc            /proc           proc    defaults        0       0
/dev/sda11      /               ext3    defaults,errors=remount-ro 0       1
/dev/sda5       /home           reiserfs defaults        0       2
/dev/sda9       none            swap    sw              0       0
/dev/hda        /media/cdrom0   iso9660 ro,user,noauto  0       0

Replace sdaX with the appropriate value for your system.

Important Notice: You need to set a default root password or you won't be able to login, type:

root@laptop:/#passwd

and define your new password.

4. Installing the boot loader (GRUB)

In my case, I'm going to use the bootloader from my running system. Edit /boot/grub/menu.lst and add at the end of the file:

title           Debian Etch, kernel 2.6.15-1-686 (on /dev/sda11)
root            (hd0,10)
kernel          /boot/vmlinuz-2.6.15-1-686 root=/dev/sda11 ro quiet splash
initrd          /boot/initrd.img-2.6.15-1-686
savedefault
boot

Same here, change sdaX according to your system.

You can now exit your chrooted environment reboot on your new system and boot it. We still require to install and configure Xorg.

root@laptop:/#exit
root@laptop:~#umount /mnt/debian/proc
root@laptop:~#umount /mnt/debian
root@laptop:~#reboot

End of the installation on page 3.


How To: Installing Debian Etch From a running Debian based system -- page 3

5. Install and Configure Xorg

During your system reboot, you should watch out for any errors and warning message, they might turn out to be usefull :).

Let's install xserver and xclient:

root@laptop:~#apt-get install  xserver-common xserver-xorg
root@laptop:~#apt-get install x-window-system-core x-window-system
root@laptop:~#apt-get install gdm gnome-session

plus whichever package you might want.

Open /etc/X11/xorg.conf and check that the driver is appropriate to your video card, verify the keyboard layout setting and try X.

root@laptop:~#X

If this goes wrong, google will be your best friend :).

Suppose X is working fine, you need to create your normal user's account. On my /home partition, the uid and gid is 1000, therefore I need to create my group user and user with uid and gid 1000:

root@laptop:~#addgroup --gid 1000 myuser
root@laptop:~#adduser --id 1000 --gid 1000 myuser

start gdm, and login with your normal user account ;).

That's it, you will still need to install loads of other package (xmms, mplayer, gaim...), but your system is running.

Hope you liked the trip.