Running two Linux systems on one machine
11:52pm, 16th August 2003
Here’s a nice trick. Let me explain the context. I’ve just installed Gentoo Linux, and while it’s nice and clean, there’s a lot of stuff on my old Mandrake partition that’s still useful, namely GTK1 apps, and anything that uses the old Gnome libraries. Since I’m not using Gnome on the Gentoo installation, I don’t want it lying around cluttering the place up. And I definitely don’t want GTK2 downgraded to GTK1. What’s the solution then? As always, it’s chroot.
My old Mandrake partition is /dev/hda5, so, as root, I mount that at /MDKROOT:
# mount /dev/hda5 /MDKROOT
Now I bind my home directory to a location within /MDKROOT:
# mount --bind /home/james /MDKROOT/home/james
Now, as the Gentoo user james, not root, I tell X to allow any application running on my machine to connect to it. This is a single user machine, so the security implications here are few.
$ xhost +localhost
Now I can use chroot to get into the old Mandrake system:
# chroot /MDKROOT /bin/bash
Now I set an environment variable telling applications to connect to the X server through TCP sockets rather than UNIX domain sockets, which would require access to the /tmp directory of the Gentoo system, which is inaccessible to the chrooted system:
# DISPLAY=localhost:0
Now I can switch users, and run any application from Mandrake:
# su james
$ gnumeric
Gnumeric is what I really wanted to use, since there is currently no GTK2 port. Now it runs using all the libraries and dependencies on the Mandrake partition, and displays on my shiny new XFCE desktop, and has access to my home directory. Everything is great!
