This article explains how to install GNU/Debian Sid in a previously installed Ubuntu Hardy System. We will use debootstrap and chroot tools to accomplish that. This how-to is not focused on security, it does not tell how to create a restricted chroot environment to improve security.
Ubuntu is a GNU/Debian based distro. Every six months they take GNU/Debian Unstable packages and make a new Ubuntu distribution.
Debian Sid provides more and newer packages. Ubuntu is configured for easiness. Debian has less preconfiguration instead.
chroot runs a command with a special root directory.
chroot comes as part of coreutils package.
$ sudo aptitude install coreutils
debootstrap command bootstraps a basic Debian system (it can also bootstrap other systems).
$ sudo aptitude install debootstrap
$ ls /usr/share/debootstrap/scripts/ #shows which distros and versions you can install with debootstrap:
breezy edgy etch-m68k gutsy hoary lenny sarge sarge.fakechroot warty woody dapper etch feisty hardy hoary.buildd potato sarge.buildd sid warty.buildd woody.buildd
First of all we create the directory where Debian Sid will be installed.
$ mkdir DebianSid
CREATING A LOOPBACK IMAGE TO STORE DEBIAN SID
This step is only necessary if you plan to boot your system from your Debian Sid chroot environment.
$ sudo dd if=/dev/zero of=DebianSidFile bs=1048576 count=10000#We create DebianSidFile with 10 gigabyte capacity.
$ sudo mkfs.ext3 -b 4096 -L DSid DebianSidFile#Ext3 filesystem creation.
$ sudo mount DebianSidFile DebianSid -t ext3 -o loop#mounting it on DebianSid directory.
INSTALLING A MINIMAL SYSTEM
$ sudo debootstrap --variant=minbase --verbose sid DebianSid http://ftp.debian.org/debian
it downloads, unpacks and installs a minimal Debian base system.
MOUNTING IMPORTANT FILESYSTEMS
$ sudo mount --bind /proc DebianSid/proc
$ sudo mount --bind /sys DebianSid/sys
$ sudo mount --bind /tmp DebianSid/tmp
$ sudo mount --bind /dev DebianSid/dev
$ sudo mount --bind /dev/pts DebianSid/dev/pts
NOTE: if you wanna share your user application configurations between Ubuntu and Debian you can mount home directory.
$ sudo mount --bind /home DebianSid/home
Copying the static lookup table for host names:
$ sudo cp /etc/hosts DebianSid/etc/
To resolve dns:
$ sudo cp /etc/resolv.conf DebianSid/etc/
ENTERING INTO THE CHROOT ENVIRONMENT
$ sudo chroot DebianSid
If we execute:
#cat /etc/issueit will show:
Debian GNU/Linux lenny/sid \n \l
so we are in Debian Sid!!
NOTE: Setting the hostname also changes the original system hostname, better not to change it: e.g: #hostname DebianChrootSid
ADDING SEVERAL TOOLS TO OUR SYSTEM
Updating the package system database:
# apt-get update
Dialog interface to show messages:
# apt-get install dialog
To obtaing ping utility:
#apt-get install inetutils-ping
We can test the network:
# apt-get install less
Small vi editor:
# apt-get install vim-tiny
#apt-get install apt-file#to search for files and packages.
# apt-file update#This will take some time.
Installing man to read man pages:
# apt-get install man-db
ADDING NEW USERS
# apt-get install adduser
adding user foo:
# adduser foo
becoming that user:
# su foo
INSTALLING AND CONFIGURING LOCALE SUPPORT
# apt-get install locales
The easier way to configure locales is, using dialog interface, executing:
# dpkg-reconfigure locales
The hard way to configure locales is editing some configuration files:
we edit locale.gen file:
# vi /etc/locale.gen
and uncomment the locale we want to generate:
#es_ES.UTF-8 UTF-8for Spain
generate locales with:
After locales have been configured we can execute:
show available locales:
# locale -a
selecting a locale: e.g: spanish locale:
# export LANG="es_ES.UTF-8"
showing current locale:
WAYS OF LAUNCHING OUR CHROOT ENVIRONMENT
$sudo chroot DebianSid /bin/bash
This method maintains a lot of variables from the original environment, I dont like it.
LOGGING IN WAY
NOTE: To use this method you need to previously create a new user (with adduser) and assign a password to root (with passwd) because is not possible to log in as root user. You will have to login as a standard user and then execute su command to become root.
tty command tells which terminal is standard output attached to: eg: /dev/pts/3
$ sudo chroot DebianSid /sbin/getty 38400 `tty`
after you type sudo password you are offered a login prompt to enter in the chroot environment.
#apt-get install xorg
Copying xorg configuration file from Ubuntu:
$ sudo mv /etc/X11/xorg.conf DebianSid/etc/X11/
# apt-get install ion2
# startx /usr/bin/ion2 -- :1
NOTE: if you cannot start the X server as a normal user change in /etc/X11/Xwrapper.config
SHOWING X APPLICATIONS IN THE UBUNTU DISPLAY
On ubuntu to allow connections from anyone:
$ xhost +
Better open only local connections: (in Ubuntu)
$ hostname#shows the hostname
$ xhost +local:`hostname`
now in the chroot environtment:
$ export DISPLAY=:0.0# X display in Ubuntu.
$ xclock# an x window clock will show on the Ubuntu desktop screen.
this will work because we have shared X11 socket through /tmp dir with Ubuntu.
INSTALLING MPLAYER TO TEST VIDEO AND SOUND
After installing mplayer, video and sound should work fine:
# apt-get install mplayer
# apt-get install gnome
# /etc/init.d/gdm start
NOTE: There is a problem with some gnome-applets because their configuration are shared with Ubuntu.
BOOTING FROM YOUR CHROOT ENVIRONMENT USING GRUB
At booting time you will be able to choose between booting from Ubuntu or from your chrooted Debian Sid.
You will have to add some lines to /boot/grub/menu.lst file to boot from your chroot environment.
Best idea is copying the lines at /boot/grub/menu.lst which ubuntu uses to boot Ubuntu and adapt them.
These are from my system. You will have to change 2.6.24-21 to your linux kernel version, loop=/usr/local/DebianSidFile to your DebianSidFile location, and your root device identifier.
title kernel 2.6.24-21-generic DebianSid Loop root (hd0,0) kernel /boot/vmlinuz-2.6.24-21-generic root=UUID=a31628c8-5402-4319-b9cd-6a6183d43bc5 loop=/usr/local/DebianSidFile ro initrd /boot/initrd.img-2.6.24-21-generic quiet
NOTE: You have to use an ubuntu initrd.img file in order to understand the loop option.
Copy the necessary kernel modules into our chroot environment:
$ sudo cp -a /lib/modules/2.6.24-21-generic DebianSid/lib/modules
And reinstall grub:
$ sudo grub-install /dev/sda#supposing master boot record is in /dev/sda device.
Now you can reboot your system into your chroot environment.