[Buildd-tools-devel] schroot question

Roger Leigh rleigh at codelibre.net
Sun Jan 11 14:43:36 UTC 2009


On Sat, Jan 10, 2009 at 10:37:25AM -0500, Steven Hirsch wrote:
> On Sat, 10 Jan 2009, Steven Hirsch wrote:
> 
> > On Sat, 10 Jan 2009, Philipp Kern wrote:
> >
> >> On Fri, Jan 09, 2009 at 06:02:30PM -0500, Steven Hirsch wrote:
> >>> My home directory is mounted from NFS using autofs, and normally shows up
> >>> as /net/home/hirsch in the root environment.  Problem is, no matter what I
> >>> have tried I cannot get this to appear in the chroot tree.  The
> >>> conventional bind mount that works so well for the local filesystem
> >>> objects doesn't seem able to present the autofs directory - all I see is
> >>> an empty directory.
> >>
> >> Without deeper knowledge of schroot: maybe this is a problem with the use
> >> of --bind instead of --rbind (which propagates sub-mounts)?
> >
> > I've tried both.  Nothing, but nothing appears to work.
> >
> > Worse yet, I tried starting a second automount daemon during chroot
> > initialization and THAT didn't even work!  It fails with a message that it
> > cannot place automount on /net and bails.
> 
> More information:
> 
> The reason that a second automount daemon failed was that the chroot has 
> not occurred at the point were exec.d commands get run (???)  I thought 
> this was the entire point behind that directory!

exec.d runs a command prior to *every command* you run in the chroot
(from the perspective of --run-session).  If you don't create a
persistent session, this will only happen once.  You probably don't want
this; it's really not used much at present, mainly because there isn't
currently a good use-case for it since the initial reason for its creation
went away.

However, the chroot is set up.  Note that the script runs on the host
system, not inside the chroot.

> Can anyone explain how I can get an arbitrary sequence of commands to 
> execute as root user _after_ the session and the new root location has 
> been established?

You do this in the chroot setup sequence in setup.d.  The early scripts
do the chroot creation and then mount filesystems, then do any tweaking
needed to set up the environment.  You can add extra scripts here to do
whatever you like.  I would suggest for your usage a script after 10mount
such as 11autofs would be appropriate.  This will be run just the once
when the session is created, and again at the session end.

Seeing as you are mounting things, I suggest copying 10mount and copying
what you see there.  See 00check for a complete list of environment
variables you can use, as well as the sbuild-setup(5) manual page.  Note
that 10mount /might/ automatically clean up for you; but I'm not
personally familiar with autofs so you might need to manually umount
and/or stop the autofs service.  As for exec scripts, these run on the
host, so you'll need to chroot(8) to start a daemon inside the chroot
and/or use the environment provided to get the path to the chroot.

Seeing that autofs is a kernel filesystem, it might not allow more than
once instance, but it might be as simple as mounting it on /net.  This
is also why you can't bind/rbind mount it, but you might try binding
/net directly, rather than its submounts.


I am interested in what you find.  If you find a working solution, I'm
sure we can put this into a setup script provided with schroot, so long
as it's not system-specific.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.



More information about the Buildd-tools-devel mailing list