SbuildLVMHowto

Revision 2 as of 2006-04-08 16:06:51

Clear message

Introduction

This document describes the steps to setup a chroot with schroot on an lvm module, so that you can build packages on an lvm-snapshot. It tries to provide an alternative to PbuilderHowto

The following assume you want to install dapper. If you need a hoary or breezy chroot, then exchange breezy with the appropriate distribtion.

Installing required packages on dapper

You need a very recent version of schroot. I used version 0.2.8-1ubuntu1, which is derived from debians latest schroot.

Once it gets accepted to dapper, just install the following packages:

apt-get install schroot sbuild

creating lvm volumes

in order to create an lvm volume, you first need to prepare one or more partitions (or other block devices) for use as physical volume:

pvcreate /dev/md1

Then you add these physical volumes to a new volume group:

vgcreate data00 /dev/md1

Once this is done, you can now create a new logical volume. The following commands creates a new logical volume 'dapper_chroot' with the size of 5GB in a volumegroup called 'data00':

lvcreate -n dapper_chroot -L 5g data00

you can now create a filesystem on it and mount it:

mkfs -t ext3 /dev/data00/dapper_chroot
mount /dev/data00/dapper_chroot /mnt

bootstrapping a base system

Now you can bootstrap your favorite distribution on that:

debootstrap dapper /mnt http://archive.ubuntu.com

Perhaps you want your /etc/sudoers and sources.list copied into that chroot, so that you can easily become root inside:

sudo cp /etc/sudoers /mnt/etc
sudo cp /etc/apt/sources.list /mnt/etc/apt

configuring schroot

edit '/etc/schroot/schroot.conf' to contain this stanza:

[dapper]
type=lvm-snapshot
description=Ubuntu Dapper
priority=3
groups=sbuild,root,admin
root-groups=root,sbuild,admin
source-groups=sbuild,root,admin
source-root-groups=root,sbuild,admin
device=/dev/data00/dapper_chroot
mount-options=-o noatime
lvm-snapshot-options=--size 1G
run-setup-scripts=true
run-exec-scripts=true

Entering the chroot

If you want to change the 'original' chroot, you can chroot into that with the following command:

schroot -c dapper-source

All changes you make there are persistent. So if you want to upgrade that chroot, use the following commands:

schroot -c dapper-source -u root -- apt-get update
schroot -c dapper-source -u root -- apt-get -y dist-upgrade 
schroot -c dapper-source -u root -- apt-get get install build-essential ubuntu-minimal fakeroot devscripts

To enter the chroot on an lvm snapshot, use this command:

schroot -c dapper

Thanks to the session scripts, some directories, like /home, /proc, /sys and /tmp are mounted for you. You can modify/add session scripts in /etc/schroot/setup.d/*

sbuild

For proper support for schroot, make sure you are in the system group 'sbuild'.

Create a file called '~/.sbuildrc' with the following contents:

# Mail address where logs are sent to (mandatory, no default!)
$mailto = "root";

# Name to use as override in .changes files for the Maintainer: field
# (mandatory, no default!).
$maintainer_name='Reinhard Tartler <siretart@tauware.de>';

# Chroot behaviour; possible values are "split" (apt and dpkg are run
# from the host system) and "schroot" (all package operations are done in
# the chroot with schroot, but the chroot must allow networking)
$chroot_mode = "schroot";

# don't remove this, Perl needs it:
1;

building packages

You can build now packages with the following command on lvm snapshots:

sbuild -d dapper package_1.2.3-4.dsc

If anything goes wrong, use parameters '-v -D' to debug.

Good Luck!