Installing GNU/Debian Sid in Ubuntu Hardy using debootstrap and chroot
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
INSTALLATION BEGINNING
First of all we create the directory where Debian Sid will be installed.
$ mkdir DebianSidCREATING 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/debianit 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/ptsNOTE: if you wanna share your user application configurations between Ubuntu and Debian you can mount home directory.
$ sudo mount --bind /home DebianSid/homeCopying 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 DebianSidIf we execute:
#cat /etc/issue it 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 updateDialog interface to show messages:
# apt-get install dialogTo obtaing ping utility:
#apt-get install inetutils-pingWe can test the network:
#ping www.google.comInstalling less:
# apt-get install lessSmall vi editor:
# apt-get install vim-tinyapt-file:
#apt-get install apt-file #to search for files and packages.apt-file configuration:
# apt-file update #This will take some time.Installing man to read man pages:
# apt-get install man-dbADDING NEW USERS
# apt-get install adduseradding user foo:
# adduser foobecoming that user:
# su fooINSTALLING AND CONFIGURING LOCALE SUPPORT
installing locales:
# apt-get install localesThe easier way to configure locales is, using dialog interface, executing:
# dpkg-reconfigure localesThe hard way to configure locales is editing some configuration files:
we edit locale.gen file:
# vi /etc/locale.genand uncomment the locale we want to generate:
e.g:
#es_ES.UTF-8 UTF-8 for Spaingenerate locales with:
#locale-genAfter locales have been configured we can execute:
show available locales:
# locale -aselecting a locale: e.g: spanish locale:
# export LANG="es_ES.UTF-8"showing current locale:
# localeWAYS OF LAUNCHING OUR CHROOT ENVIRONMENT
STANDARD WAY
$sudo chroot DebianSid /bin/bashThis 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.
INSTALLING X-WINDOWS
Installing x-windows:
#apt-get install xorgCopying xorg configuration file from Ubuntu:
$ sudo mv /etc/X11/xorg.conf DebianSid/etc/X11/window manager:
# apt-get install ion2starting X:
# startx /usr/bin/ion2 -- :1NOTE: if you cannot start the X server as a normal user change in /etc/X11/Xwrapper.config
allowed_users=console to allowed_users=anybodySHOWING 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:
Installing mplayer:
# apt-get install mplayerINSTALLING GNOME
Installing gnome:
# apt-get install gnomeStarting gdm:
# /etc/init.d/gdm startNOTE: 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/modulesAnd 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.
REFERENCE: http://ubuntuforums.org/showthread.php?t=24575
5 comentarios:
hello,
My DebianSid directory is not a file but a part (/dev/sda6), mounted without loop option (/dev/sda6 on /mnt/system2 type ext3 (rw)).
Howto write the kernel line in menu.lst ?
kernel /boot/vmlinuz-2.6.24-24-generic root=UUID=... loop=/dev/sda6 ro
is it true ?
Hi Matla,
since your Debian Sid directory is in a partition you have to change menu.lst this way:
title kernel 2.6.24-21-generic DebianSid
root (hd0,0)
You have to change (hd0,0) to the one it represents /dev/sda6, may be (hd0,5)
kernel /boot/vmlinuz-2.6.24-21-generic root=/dev/sda6 ro
initrd /boot/initrd.img-2.6.24-21-generic
Hope it helps,
Vicente.
hi,
Thanks for your tutorial, i followed it with success and i have my debian sid chroot in a term.
But i try to start X desktop in chrooted debian Sid, and it doesn't work.
I have nvidia drivers in Ubuntu, and can't use the same drivers to start X desktop in the chroot.
UBUNTU
dpkg -l | egrep '(nvidia|2.6.24-24)'
ii linux-image-2.6.24-24-generic 2.6.24-24.56
ii linux-restricted-modules-2.6.24-24-generic 2.6.24.18-24.1
ii linux-ubuntu-modules-2.6.24-24-generic 2.6.24-24.39
ii nvidia-glx-new 169.12+2.6.24.18-24.1
ii nvidia-kernel-common 20051028+1ubuntu8
CHROOT DEBIAN SID
uname -a
Linux elisaktor 2.6.24-24-generic #1 SMP Tue Jul 7 19:46:39 UTC 2009 i686 GNU/Linux
dpkg -l | grep nvidia
ii nvidia-kernel-common 20080825+1
in debian sid sources (apt-cache), nvidia-kernel is version 2.6.26, and linux-image is version 2.6.30
when i start X , i have this xorg error message :
startx /usr/bin/icewm -- :1
...
(EE) Failed to load module "nvidia" (module does not exist, 0)
(EE) No devices detected.
...
in fact, i don't know if it's possible, but i need direct rendering in the debian sid chroot.
thank you if you know a way that can help me ..
matla
Hi Matla,
not what you asked for, but a quick workaround:
your nvidia driver works fine in ubuntu, so you could start the Xorg server in Ubuntu. e.g:
startx /usr/bin/icewm -- :1
then in your chroot environment
export DISPLAY=:1.0
xterm
The xterminal should appear in :1 display if you shared /tmp dir between chroot and host and followed
"SHOWING X APPLICATIONS IN THE UBUNTU DISPLAY" instructions.
it works now. thank you for your help !
Post a Comment