Re: [vserver] Mount host-fs into running vserver

From: Herbert Poetzl <herbert_at_13thfloor.at>
Date: Wed 23 Apr 2008 - 14:55:06 BST
Message-ID: <20080423135504.GA26960@MAIL.13thfloor.at>

On Wed, Apr 23, 2008 at 03:12:36PM +0200, Wilhelm Meier wrote:
> Am Mittwoch, 23. April 2008 schrieb Herbert Poetzl:
> > On Fri, Apr 11, 2008 at 02:13:45PM +0200, Wilhelm Meier wrote:
> > > Hallo,
> > >
> > > I think, this question was already answered on the list, but I
> > > can't find right answer ..,
> > >
> > > on the host I have a directory /mnt/test and I want to bind-mount
> > > this into a running vserver. I thought I have to use vnamespace
> > > to do this:
> > >
> > > vnamespace -e test mount /mnt/test
> > > /var/lib/vservers/test/mnt/test -o bind,ro
> > >
> > > but the files in /mnt/test don't schow up in the vserver:
> > >
> > > vserver test exec ls -l /mnt/test
> > >
> > > ist empty.
> > >
> > > What am I doing wrong?
> >
> > most likely they are not there (in /mnt/test) after
> > you entered the guest's namespace with vnamespace,
> > thus the bind mount succeeds, but leaves you with
> > the empty mountpoint ...
>
> yes, the bind-mount succeeds but the target is empty. I just don't
> understand why. Is there a possibility to get this done?

it's quite simple actually, here what happens:

                host guest
1 /mnt/test is empy
2 guest is started a copy of the host namespace
                                is created, chroot into guestdir
3 something is mounted
        on /mnt/test /mnt/test is still empty and
                                not visible to the guest, as it
                                is chrooted somewhere else
4 you enter the namespace
        of the guest -> you bind mount the empty
                                /mnt/test into /vserver/name/test

> I made the additional attempt to mark the host-mount-point as
> make-rshared. But this did no do the trick either.

that is an option too, but you have to do that
_before_ the guest clones the namespace

> > instead trying to bind mount a newly on the guest
> > mounted path (I assume /mnt/test is such a thing)
> > simply do the /mnt/test mount inside the guest
> > namespace and preferably to the right location too
>
> If I understand that correct I have to make the device visible
> to the guest. But I don't want to do that.

no, you got that part wrong.

if you do 'vnamespace --enter <xid> -- /bin/bash'
then you will see that you are _outside_ the guest's
dir, but inside the guest's namespace ...

look around, see that /mnt/test is or is not mounted
(depending on shared mounts), and simply do the
original mount like this:

'mount .... /dev/somedevice /vservers/name/test'

best,
Herbert

> > HTC,
> > Herbert
> >
> > > --
> > > Wilhelm
>
>
>
> --
> Wilhelm
Received on Wed Apr 23 14:57:06 2008

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Wed 23 Apr 2008 - 14:57:10 BST by hypermail 2.1.8