Setting up Debootstrap Environment

By | August 22, 2012

So, here is how you install a debootstrap sandbox on your linux box. First step is to install debootstrap. On debian or ubuntu you can install it using apt-get.

apt-get install debootstrap

Now, create a folder where you need sandbox.

mkdir /home/sandbox/debian

Now, use the following command to create your sandbox. Im creating sarge sandbox so I am specifying as sarge. If you need Lenny or squeeze sandbox then you have specify it.

debootstrap sarge /home/sandbox/debian

If you are using proxy use the following command.

http_proxy = “proxyurl:proxyport” debootstrap sarge /home/sandbox/debian

You should now see something like this…

I: Retrieving Release
I: Retrieving Packages
I: Validating Packages
I: Resolving dependencies of required packages…
I: Resolving dependencies of base packages…

Once its done, do the following to make it a perfect sandbox to work.

mount -t proc proc /home/sandbox/debian/proc/
cp /etc/resolv.conf /home/sandbox/debian/etc
cp /etc/hosts /home/sandbox/debian/etc

Now, chroot and work with your sandbox.

chroot /home/sandbox/debian

To identify different sandboxes, you can do the following.

Inside sandbox after using chroot, create the following file.

touch /etc/debian_chroot

Add the name of your sandbox inside that file. I have added the name as my-sbox

cat /etc/debian_chroot
my-sbox

Now, edit the /root/.bashrc file inside the sandbox and add the following.

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z “$debian_chroot” ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, overwrite the one in /etc/profile)
PS1=’${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ‘

umask 022

If you like this article, then please consider sharing it. Sharing really inspires us to do things much better!!

Leave a Reply

Your email address will not be published. Required fields are marked *