1- sudo apt-get install debootstrap schroot
2- Use debootstrap to make a minimal install of karmic into a directory:
sudo mkdir /home/chroot
sudo debootstrap karmic /home/chroot/karmic http://mirror.internode.on.net/pub/ubuntu/ubuntu/
Supply the name of your nearest Ubuntu mirror as the last parameter.
3- Put something like this at the end of /etc/schroot/schroot.conf:
description=Ubuntu 9.10 Karmic Koala
schroot -c karmic
should give you a shell, running as yourself, in the karmic environment. schroot with these settings automatically arranges for your home directory to be shared, so you can get at the same source code from both places. (See /etc/schroot/mount-defaults.)
You won't, by default, have sudo access in that chroot, so you can either edit /home/chroot/karmic/etc/sudoers to allow it, or you can run commands like this from outside of the jail:
schroot -c karmic -u root apt-get install zlib1g-dev
To avoid confusion I like to show the OS version in my zsh prompt, with a line like this in my ~/.zshrc:
RPS1='%B%~ ('"`lsb_release -cs`"')%b'