User:Zeekec/schroot

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a work in progress; treat its contents with caution - zeekec (talk | contribs).

The program schroot allows the user to run a command or a login shell in a chroot environment.

Install dev-util/schroot

Since dev-util/schroot is already in the tree, installing is as simple as:

root #emerge --ask dev-util/schroot

Create chroot

Configuration

FILE /etc/schroot/chroot.d/gentoo32
[gentoo32]
type=directory
directory=/mnt/gentoo32
description=Gentoo 32 bit chroot
users=zeekec,root
root-users=zeekec,root
personality=linux32
preserve-environment=true
profile=gentoo32
aliases=default

[gentoo32-plain]
type=plain
directory=/mnt/gentoo32
description=Gentoo 32 bit chroot
users=zeekec
root-users=zeekec
personality=linux32
preserve-environment=true
FILE /etc/schroot/gentoo32/copyfiles
# Files to copy into the chroot from the host system.
#
# <source and destination>
/etc/resolv.conf
/etc/machine-id
Note
I copied machine-id because there was a symlink to it in /var/lib/dbus, which is bind mounted below. Probably only one of those is needed.
FILE /etc/schroot/gentoo32/fstab
# fstab: static file system information for chroots.
# Note that the mount point will be prefixed by the chroot path
# (CHROOT_PATH)
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/proc                   /proc                   none    rw,bind         0               0
/sys                    /sys                    none    rw,bind         0               0
/dev                    /dev                    none    rw,bind         0               0
/dev/pts                /dev/pts                none    rw,bind         0               0
/tmp                    /tmp                    none    rw,bind         0               0
/lib/modules    /lib/modules    none    rw,bind         0               0
/usr/src                /usr/src                none    rw,bind         0               0
/home                   /home                   none    rw,bind         0               0

# If you use gdm3, uncomment this line to allow Xauth to work
#/var/run/gdm3  /var/run/gdm3   none    rw,bind         0               0
# For PulseAudio and other desktop-related things
/var/lib/dbus   /var/lib/dbus   none    rw,bind         0               0

# It may be desirable to have access to /run, especially if you wish
# to run additional services in the chroot.  However, note that this
# may potentially cause undesirable behaviour on upgrades, such as
# killing services on the host.
/run                    /run                    none    rw,bind         0               0
/run/lock               /run/lock               none    rw,bind         0               0
/dev/shm                /dev/shm                none    rw,bind         0               0
/run/shm                /run/shm                none    rw,bind         0               0
FILE /etc/schroot/gentoo32/nssdatabases
# System databases to copy into the chroot from the host system.
#
# <database name>
passwd
shadow
group
gshadow
services
protocols
networks
hosts