Sunday, April 10, 2016

Creating a chroot Environment for Mageia

Mageia documents (link below) tell us how to set up a chroot environment in their Wiki.

We'll set up both a 32-bit and a 64-bit environment for the current release as well as the development branch, Cauldron, and eventually use them with schroot, a tool that makes managing chrooted environments much, much easier.

To summarize the steps to create a chroot using urpmi as follows:

Create a Mount Point
To create the mountpoint for the chroot environment for either or both 32- and 64-bit environments as well as Cauldron:
# mkdir -p /mnt/chroot/mageia32
# mkdir -p /mnr/chroot/mageia64
# mkdir -p /mnt/chroot/cauldron32
# mkdir -p /mnt/chroot/cauldron64

Mageia can use either package set with your native urpmi application to install packages in the chrooted environment.

32-bit chroot
For the 32-bit environment:

Add the repositories.
$ sudo urpmi.addmedia --distrib --urpmi-root /mnt/chroot/mageia32  --mirrorlist 'http://mirrors.mageia.org/api/mageia.5.i586.list' 

$ sudo urpmi.addmedia --distrib --urpmi-root /mnt/chroot/cauldron32  --mirrorlist 'http://mirrors.mageia.org/api/mageia.cauldron.i586.list' 

Install the base system:
$ sudo urpmi --urpmi-root /mnt/chroot/mageia32 basesystem urpmi locales-en mc wget openssh-server

$ sudo urpmi --urpmi-root /mnt/chroot/cauldron32 basesystem urpmi locales-en mc wget openssh-server

64-bit chroot
For a 64-bit environment:

Add the repositories.
$ sudo urpmi.addmedia --distrib --urpmi-root /mnt/chroot/mageia64  --mirrorlist 'http://mirrors.mageia.org/api/mageia.5.x86_64.list'

$ sudo urpmi.addmedia --distrib --urpmi-root /mnt/chroot/cauldron64  --mirrorlist 'http://mirrors.mageia.org/api/mageia.cauldron.x86_64.list'

Install the base system:
$ sudo urpmi --urpmi-root /mnt/chroot/mageia64 basesystem urpmi locales-en mc wget openssh-server 

$ sudo urpmi --urpmi-root /mnt/chroot/cauldron64 basesystem urpmi locales-en mc wget openssh-server 

Make the Environments Usable
These next few steps are not needed if you will be using schroot. If not using schroot, you need to make these environments usable by providing DNS information so networking can be used by copying /etc/resolve.conf to the appropriate location in the chroot.

You also need to have a working /proc filesystem.
# mount -o bind /proc /mnt/chroot/mageia [cauldron][32][64]/proc

You would also use this technique to access your host filesystem from within the chrooted environment by mounting it inside the chroot.

Using the chroot Environment
The Mageia wiki for chroot (link below) offers straightforward instructions as to how to ssh into your chroot environment and won't be repeated here. It also offers advice on launching X clients from the chrooted environment.

schroot
At this point, it is worth exploring the advantages that schroot offers for managing and manipulating your chrooted environments. To Be Continued . . .

RESOURCES

Mageia Wiki for chroot

Mageia QA procedure for evaluating schroot

Magiea URPMI Wiki Entry

Debian Wiki Schroot HOWTO

Schroot Build Environment Setup

Schroot Mageia Configuration



No comments: