The venerable chroot virtualisation method is often overlooked though. chroot is a much simpler inbuilt mechanism to unix which can be used when the parallel environments can share the same kernel. Personally I use the chroot method to run an ubuntu (5.10) environment inside my fedora (4) system. I use it for various things, but mainly for developing debian packages on fedora.
Note I have a shared /home partition between fedora core 4 and ubuntu 5.10. This allows the two environments to share the same settings and data, whether they're running in a dual boot configuration, or running in parallel in a chroot configuration which this page discusses. It also allows me to upgrade or add new distributions independently of my data and settings. Since both environment's apps use the same settings from the shared /home partition, they need to be compatible. I haven't found this to be a problem, even with gnome versions 2.10 and 2.12 on redhat and fedora respectively.
The scenario I detail below is booting the system into fedora, and starting ubuntu in a separate partition in the chroot environment. I've also documented the additional possibility of having the chroot image on the same partition. To distinguish the commands used in both systems, I use green for fedora, and gray for ubuntu.
[Update Jan 2011: I noticed a good post on higher level chroot tools like rinse and debootstrap.]
setting up an ubuntu text console
In an xterm (gnome-terminal) on fedora I do the following to create an ubuntu chroot.sudo cp /etc/resolv.conf /ubuntu/etc/ #Make DNS available to ubuntu sudo /usr/sbin/chroot /ubuntu #chroot to ubuntu root partition mount /proc #make /proc virtual filesystem available mount /sys #make /sys virtual filesystem available mount /home #shared home partition between ubuntu and fedora su - padraig #Change user from root to me . /etc/environment && export LANG #need to explicitly set localeFor completeness going the other direction and starting a fedora chroot from ubuntu is done using
sudo cp /etc/resolv.conf /fedora/etc/ #Make DNS available to fedora sudo chroot /fedora #chroot to fedora root partition mount /proc #make /proc virtual filesystem available mount /sys #make /sys virtual filesystem available start_udev #make devices available in /dev mount /home #shared home partition between ubuntu and fedora su - padraig #Change user from root to meA shell is usually all I use, but sometimes I would like to run X applications from within the chroot, which is discussed in the remaining sections.
starting ubuntu X applications on the fedora X server
To get ubuntu X apps to connect to fedora server one needs to enable TCP access to the fedora server. The handiest way to do that is to get ssh to setup the appropriate authorization and connections by doing the following on the fedora systemssh -Y localhostIn the resulting shell, you can get the appropriate $DISPLAY variable to set in the ubuntu terminal by running the echo $DISPLAY command, and you set that in the ubuntu terminal as follows:
export DISPLAY=localhost:10.0Any subsequent ubuntu X applications started, will display on fedora's X session.
Note to enable TCP access to the X server always, negating the need for the ssh session above, you can run the following and restart X
GDM_CONF=`find /etc -name gdm.conf 2>/dev/null` sudo sed -i 's/#DisallowTCP=true/DisallowTCP=false/' $GDM_CONF
starting a separate ubuntu X server
Note I don't do this and I wouldn't really advise it due to the problems mentioned below, but I'm presenting this info anyway for completeness.To start a completely new X session (on a new Virtual Terminal), use startx -- :1 &. Note to be able to do that from an xterm (the existing fedora X session) one needs to run on the ubuntu system:
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.configstartx will allocate a new VT and start the X session on it. To switch between the original X session and the new one use CtrlAltF7 and CtrlAltF8 respectively. I noticed some problems with this though:
- startx doesn't deallocate the VT, hence subsequent runs will be on CtrlAltF9,F10,... The error is "Couldnt get a file descriptor referring to the console", "Exit 71 (EPROTO)". If one subsequently runs `deallocvt 8` you get the error "VT_DISALLOCATE: Device or resource busy"
- HAL does not start in the new gnome session and gnome-terminal spins the CPU on startup. Most other things seem to work fine though. The error is "Failed to initialise HAL!"
- Note the correct way to start multiple gnome sessions in parallel is by using the command gdmflexiserver -l. However I'm not sure if this can be used from the ubuntu session. I tried setting $DISPLAY to the fedora X server and running it, but got the error "Could not access GDM configuration file". Perhaps this is because of the differing locations of gdm.conf in /etc/ between ubuntu and fedora?
startx /usr/X11R6/bin/twm -- :1&Some very quick twm usage notes:
- Click the desktop to start an xterm from which you can start other programs
- Click the desktop to select the "delete" option for apps that don't have means to exit (like fslint-gui)
- Note gnome-terminal works fine under twm