SubscribeXMLTagsEditHistoryDiscussion

Introduction

I recently bought a virtual dedicated hosting service. Sadly, it doesn't offer the option of running it with a Debian distribution. While I could reinstall everything, I don't want to get into kernel headaches but rather get it working as fast as I can. This guide will explain what I did to get Debian on it.

I will refer to chrooted processes as guest processes and to normal (non-chrooted) processes as host processes, to borrow a terminology common to many virtualization schemes.

Install Debian on /debian

Download the latest release of the debootstrap package and uncompress it:

$ wget http://http.us.debian.org/debian/pool/main/d/debootstrap/debootstrap_0.3.3.2etch1_all.deb $ ar -x debootstrap_0.3.3.2etch1_all.deb

Uncompress its data.tar.gz into some directory:

# mkdir /debian
# cd /debian
# tar xvfz /full/path/data.tar.gz

Run debootstrap:

# ln -s /debian/usr/lib/debootstrap /usr/lib
# ./usr/sbin/debootstrap --arch XXX etch /debian

Start a shell in the Debian machine

We need to start a shell that lives in the Debian machine:

# chroot /debian /bin/sh

Prepare the Debian machine

Edit /debian/etc/fstab and add entries that the host machine uses. You will probably use one for /proc and another one for /dev/pts.

none    /proc           proc    defaults                0       0
devpts  /dev/pts        devpts  rw      0       0

Verify that this has been correctly setup with:

chroot /debian
mount -a
ps aufxw

ps should show processes.

Configure two sshd daemons

We will use two separate sshd processes: we reconfigure the host sshd process to run on a port other than 22 (I choose to use 2222) and we run the guest sshd in the default port. That way, we can connect to the guest by going through port 2222 but regular users will be connecting to the host, using the regular port.

To do this, set the port in /etc/ssh/sshd_config and restart your sshd process.

Now install ssh in the guest machine:

# apt-get install ssh

(Technically you could install just openssh-server.)

Boot your Debian machine

Check to see what your default runlevel is. Edit your /etc/rc$RUNLEVEL.d host directories and remove as much software as possible. We want to run everything *inside* the guest. Don't remove syslogd or things the host does need for its basic functioning.

Once everything is set, edit /etc/rc$RUNLEVEL.d/S99debian for your host's default runlevel and have it boot your Debian machine at its default runlevel (2 in this case):

#!/bin/sh
chroot /debian /etc/init.d/rc 2

Verify the list of processes in your Debian machine and boot it by running the S99debian script.

Last update: 2007-11-11 (Rev 13115)

svnwiki $Rev: 14721 $