Debian Chroot in Ubuntu

- 1 min

In order to develop and package for Debian, a testing environment is required, that’s why I’ve setup a Debian chroot environment in my computer (Ubuntu) using Debootstrap.

Chroot using Debootstrap Simplified Diagram
Chroot using Debootstrap Simplified Diagram

To do this I’ve run the following commands:

$ sudo apt-get install schroot dchroot debootstrap
$ sudo debootstrap sid /sid-root http://httpredir.debian.org/debian/

Then I appended to the file /etc/fstab the following lines:

/home             /sid-root/home                none    bind            0       0
/opt              /sid-root/opt                 none    bind            0       0
/tmp              /sid-root/tmp                 none    bind            0       0
/dev              /sid-root/dev                 none    bind            0       0
proc-chroot       /sid-root/proc                proc    defaults        0       0
devpts-chroot     /sid-root/dev/pts	        devpts  defaults        0       0
binfmt_misc	  /sid-root/proc/sys/fs/binfmt_misc  binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
sysfs		  /sid-root/sys                 sysfs   rw,nosuid,nodev,noexec,relatime  0  0
$ mount -a

To the file /etc/schroot/schroot.conf I appended:

[sid-root]
description=Debian sid
directory=/sid-root
aliases=default
users=mouaad

And finaly :

$ sudo su -c 'echo "stretch /sid-root" > /etc/dchroot.conf'

Now to change to chroot is simply type:

$ dchroot #sudo chroot for root

Now that I am on chroot I’ve run the following commands to setup the environement for packaging:

$ apt-get update
$ apt-get install debconf devscripts gnupg
$ apt-get install locales
$ locale-gen

And finaly, the debian chroot environement is ready !

Sources:

Mouaad Aallam

Mouaad Aallam

Software Engineer

rss facebook twitter bsky github youtube mail spotify instagram linkedin google pinterest medium vimeo mastodon gitlab docker