Send As SMS

Tuesday, December 05, 2006

Maintaining other Debain releases in chroots

This question came up on the mvpmc-users list in response to my throwaway comment:
The VLC in Debian Sarge (0.8.2) doesn't appear to be able to do this. Instead I fished whatever version happened to be in sid yesterday (0.8.6).
My reply:
On Tue, 2006-12-05 at 14:12 +0100, Marc wrote:

Roland --

On Wed, 29 Nov 2006 19:13:21 +0000, "Roland Turner (mvpmc-users)" wrote:

> I maintain a number of chroot environments (one each for woody, sarge,
> etch and sid) on my machine:
>
> - created with debootstrap
>
> - some cleverness with bind mounting /tmp and /home, plus some tweaking
> of /etc/passwd, provides an equivalent-to-host environment
>
> - accessed with dchroot

Would you mind sharing that bit with the cleverness? I currently run a server with sarge,
for peace of mind. I experimented with VLC on my laptop and enjoy it a lot, but I'd prefer
to run it on the server.

Was googling around a bit with debootstrap and dchroot as my keywords, but no result...

The following is from memory. I suggest that you peruse the relevant documentation (man pages, etc.) at each step to verify (a) that you understand what you're doing and (b) that I haven't goofed.

# apt-get install debootstrap dchroot
# mkdir -p /chroot/sid
# debootstrap sid /chroot/sid
# echo 'sid /chroot/sid' >>/etc/dchroot.conf
# cat /etc/debian_version
# dchroot -c sid
# cat /etc/debian_version

Note (check!) that the Debian version changed.

At this point, you've got the basics up and running. You still have a superuser shell, but you're inside a chroot with a copy of sid in it.

# vi /etc/apt/sources.list

Set up relevant sources for sid and save

# apt-get update
# apt-get install vlc
# vipw

Place a copy of your personal account from your "real" /etc/passwd. In particular, be careful to preserve your UID.

# vigr

Put your personal username into whatever groups you require.

# ^D
# cat /etc/debian_version

Verify that you're back in the real root.

# vi /etc/fstab

Add:

/home /chroot/sid/home none bind 0 2
/tmp /chroot/sid/tmp none bind 0 2
/var/local /chroot/sid/var/local none bind 0 2
proc /chroot/sid/proc proc defaults 0 0

N.B.:

/home will mean that your normal non-root-user environment continues to work; this is the reason for preserving your UID.

/tmp gives you access to the local X server at /tmp/.X11-unix/X0

/var/local may not be of interest to you; I keep all kinds of useful stuff there.

# mount -a

$ dchroot -d -c sid
$ vlc somefile.mpeg

Voila!


- Raz