The major penalty of multilib is that it's sort of a mess or at least can easily create a mess. While it's a nice comfortable solution, it's still a bit "hackish and messy" (might be a bit hard to say it that plain in this case).
For virtual machines it's just performance (mainly memory, although cpu and especially any sort of acceleration like graphics, sse, ...) and convenience. Two separated computers are just not comfortable, no matter how much integration guest additions might provide.
The
chroot solution pretty much overcomes those downsides. It's still a little less convenient than multilib and possibly not the easiest solution to setup.
EDIT:
That's how you setup a
chroot system:
The easiest way is to just install another Salix system from an installation cd without installing lilo. There are other methods which don't even require booting from the installation cd nor rebooting at all, but you lack all the (auto)configuration done by the installation cd.
Once you have setup that partition mount it and any other partitions you might want somewhere in your tree. Then you can use this script (change the variables in the beginning and comment DISTCC_HOSTS if you don't use distcc it):
Code: Select all
#!/bin/sh
CHROOT_USER=shador
CHROOT_PATH=/media/salix32
CHROOT_NAME=salix32
CHROOT_ARCH=i486
DISTCC_HOSTS="localhost nix:45932 ker:45932"
usage() {
cat <<EOF
Usage: `basename $0` [OPTIONS] [-- COMMAND]
Switch to the same directory where we're being called from inside the
chroot environment ('$CHROOT_PATH') and by default launch an
interactive shell. The architecture is modified to pretend $CHROOT_ARCH.
If the directory doesn't exist in the chroot the root is used.
Inside the chroot environment two variables are set:
CHROOT: true
CHROOT_NAME: $CHROOT_NAME (name of the chroot)
OPTIONS:
-u, --user=USER switch to USER (only root, default: '$CHROOT_USER')
-c, --command=COMMAND execute COMMAND instead of a shell
-h, --help print this message and exit
EOF
}
argument() {
opt=$1
shift
if test $# -eq 0; then
echo "Error: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
quote() {
for i in "$@"; do
echo -n "'$i' "
done
}
# Check the arguments.
while test $# -gt 0
do
option=$1
shift
case "$option" in
-u | --user)
user=`argument $option "$@"`; shift
;;
--user=*)
user=`echo "$option" | sed 's/--output=//'`
;;
-c | --command)
command=`argument $option "$@"`; shift
command=`quote $command`
;;
--command=*)
command=`echo "$option" | sed 's/--command=//'`
command=`quote $command`
;;
-h | --help)
usage
exit
;;
--)
command=`quote "$@"`
break
;;
*)
echo "Error: Unrecognized option '$option'" 1>&2
usage
exit 1
;;
esac
done
if ! [ -d $CHROOT_PATH ] || ! [ -f $CHROOT_PATH/bin/bash ]; then
echo "Error: check if chroot path is mounted -- '$CHROOT_PATH'" 1>&2
exit 1
fi
if [ "x$user" != "x" ]; then
if [ "x$UID" == "x0" ]; then
CHROOT_USER=$user
else
echo "Error: Not allowed to change the user to su to" 1>&2
echo "Warning: Falling back to the default: '$CHROOT_USER'" 1>&2
fi
fi
if [ "x$UID" != "x0" ]; then
exec sudo "$0" -u $CHROOT_USER -- $command
fi
startdir="$PWD"
if ! [ -d $CHROOT_PATH/$startdir ]; then
startdir=/
fi
if [ "x$command" != "x" ]; then
bashcmd="/bin/bash -c \\\"`echo $command`\\\""
else
bashcmd="/bin/bash -i"
fi
cd $CHROOT_PATH
# prepare the chroot environment
mount -t proc proc proc/ >/dev/null 2>&1 && PROC=true
mount -t sysfs sysfs sys/ >/dev/null 2>&1 && SYS=true
mount -t devpts devpts dev/pts/ >/dev/null 2>&1 && DEVPTS=true
cp -L /etc/resolv.conf etc/resolv.conf
setarch $CHROOT_ARCH \
chroot $CHROOT_PATH /bin/sh -c " \
grep -v rootfs /proc/mounts > /etc/mtab; \
su $CHROOT_USER -s /bin/sh -c \"cd $startdir; \
[ -f /etc/profile ] && . /etc/profile; \
[ -f ~/.bash_profile ] && . ~/.bash_profile; \
[ -f ~/.bash_login ] && . ~/.bash_login; \
[ -f ~/.profile ] && . ~/.profile; \
[ -f ~/.bashrc ] && . ~/.bashrc; \
DISTCC_HOSTS='$DISTCC_HOSTS' \
CHROOT=true CHROOT_NAME='$CHROOT_NAME' \
PS1=\\\"($CHROOT_NAME) \\\$PS1\\\" \
$bashcmd \"" || exit 1
cd $CHROOT_PATH
[ "x$PROC" = "xtrue" ] && umount proc/
[ "x$SYS" = "xtrue" ] && umount sys/
[ "x$DEVPTS" = "xtrue" ] && umount dev/pts/
You should also add the script to your sudoers file, e.g. like this:
Code: Select all
%users ALL = (root) NOPASSWD:/usr/local/bin/switch32
In the
chroot environment you should consider adding this to the .bashrc of all users or some global file (it does no harm in the host bashrc either):
Code: Select all
if [ "$CHROOT" == "true" ]; then
if [ -z "$CHROOT_NAME" ]; then
CHROOT_NAME=chroot
fi
PS1="($CHROOT_NAME) $PS1"
fi
I also recommend at least binding your /home partition to the
chroot like this:
Code: Select all
mount --bind /home /media/salix32/home
or like this for fstab:
Code: Select all
/home /media/salix32/home none bind 0 0
The script tries to change to the same directory in the
chroot from where it was invoked from. That means when launched with PWD=/home/shador/projects/salix/ the result is when viewed from the host environment /media/salix32/home/shador/projects/salix/ or from within the
chroot /home/shador/projects/salix/. This might of course not always be possible so the default is to fallback to /media/salix32/ (or depending on your pov /).
If you don't do this some additional setup with X is possibly needed as the magic cookie needed to connect to the Xserver is not available in the
chroot. Have a look at man Xsecurity in this case. To make it short two possible solutions are coping .Xauthority or allowing at least connections from localhost with xauth.