Joys of schroot
Schroot is good! Try schroot. You have LVM set up and some free
extents in a vg? Try this:
lvcreate -n schroot-sid -L1G YOUR-VG-NAME
mke2fs -j /dev/YOUR-VG-NAME/schroot-sid
mount /dev/YOUR-VG-NAME/schroot-sid /mnt
debootstrap --keyring=/etc/apt/trusted.gpg sid /mnt http://ftp.uk.debian.org/debian
umount /mnt
Then
apt-get install schroot and put this in your
/etc/schroot/schroot.conf:
[sid]
type=lvm-snapshot
device=/dev/YOUR-VG-NAME/schroot-sid
description=Debian sid
priority=5
users=YOUR-USER-NAME
root-users=YOUR-USER-NAME
source-root-users=root
aliases=unstable
lvm-snapshot-options=--size 2G
Now,
schroot -c sid will make a LVM snapshot of
/dev/YOUR-VG-NAME/schroot-sid, mount it, set it up as
a nice working system, and chroot into it running a shell. Have a
look around: resolv.conf is set up, your home directory is bind
mounted, /proc and /sys are mounted.
When you exit the chroot, the LVM snapshot disappears, and
/dev/YOUR-VG-NAME/schroot-sid is unchanged.
If you want to modify
/dev/YOUR-VG-NAME/schroot-sid, you just
schroot
-c sid-source.
In my laptop, I did this:
# schroot -c sid-source
(sid)# echo APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/50enrico
(sid)# apt-get install build-essential, pbuilder, devscripts, fakeroot
(sid)# apt-get clean
At this point, to build a debian package like if I were using
pbuilder, I do this:
pkgdir$ schroot -c sid
(sid)pkgdir$ su -c /usr/lib/pbuilder/pbuilder-satisfydepends
(sid)pkgdir$ debuild -us -uc
You can repeat this whole process with lenny and etch, for
example, and if you are on an amd64 system, you can also do sid32,
lenny32 and etch32.
If you don't want to redownload packages all the time, install
approx and
configure the
-source chroots to use it. This also
allows you to easily switch all systems from one mirror to another
if, for example, you are traveling abroad.
If you want to do the same as
pbuilder update, you
can do this:
# schroot -c sid-source
(sid)# apt-get update
(sid)# apt-get dist-upgrade
(sid)# apt-get autoremove
(sid)# apt-get clean
You can use
schroot -c sid-source for all sorts of
permanent maintenance works.
You can also create persistent named snapshots:
$ schroot -b -c sid -n playground
This will only disappear when you do:
$ schroot -c playground -e
And you can enter the schroot as many time as you want with:
$ schroot -r -c playground
You can also enter a temporary snapshot as many times as you
want, by using the random name that schroot generated for it (you
can see it, for example, when running
df or
mount).
You fear that lvm snapshots are a little fragile and a little
slow at the moment? It's not a problem: your home is bind-mounted
inside the chroot, so you can do all the work in your normal home
filesystem, without stressing the snapshot.
This is good not only to build packages. For example, now that
svk is broken in sid
and lenny, I just did
schroot -b -c etch -n svk,
installed svk on it, and then every time I need svk, I can do
schroot -r -c svk and have it ready.