Subject: Re: [vserver] file copying between host and guest
From: Herbert Poetzl <herbert@13thfloor.at>
Date: Thu, 5 Aug 2010 01:09:02 +0200

On Wed, Aug 04, 2010 at 02:24:30PM -0700, Nirmal Guhan wrote:
> On Wed, Aug 4, 2010 at 9:25 AM, Herbert Poetzl <herbert@13thfloor.at> wrote:
> > On Wed, Aug 04, 2010 at 04:20:14PM +0200, raflik-nb wrote:
> >> Hello, I am a new user of vserver (on Debian) and found this in FAQ:
> >
> >> ===
> >> How can I copy anything from host to guest partition, normally
> >>   unvisible on host?
> >   ~~~~~~~~~~~ (should be invisible, but hey :)
> >> You should just change namespace, e.g.:
> >
> >> vnamespace --enter <xid> -- /bin/bash
> >> and then use standard cp or rsync programs.
> >> ===
> >
> >> What I see is the guest filesystem in /var/lib/<vserver>
> >
> > which means it is _visible_ on the host
> >
> >> and I can copy files there which are instantly visible
> >> from the guest.
> >
> > which is expected ...
> >
> >> What issue does that piece of advice actually address?
> >
> > mainly filesystems not mounted on the host, like
> > for example the /tmp (tmpfs) only mounted inside
> > the guest (or other filesystems not shared with
> > the host namespace)
> >
> >> I find it a bit confusing.
> >
> > hope this clarifies,
> > Herbert
> >
> >> Greets,
> >> raflik

> How different is this from doing a "cp <somefile> <rootfs path of
> guest/somedirectory>" from host ?

that it ends up in the host filesystem instead of the 
filesystem mounted in the guest (at the same location)?

example:

 guest at /vservers/guest1

mounts /dev/vg/usr on /vservers/guest1/usr in the guest
configs fstab like this:

/dev/vg/usr /usr ext3 default 0 0

now, when you start the guest, util-vserver will mount
the /usr entry in the guest namespace, still on the host
the /vservers/guest1/usr dir will be empty (the mount
doesn't 'exist' on the host) ...

echo test >/vservers/guest1/usr/test will create a file
on the host filesystem _under_ the /usr mounted inside
the guest, and so the file will not be visible inside
the guest (unless you unmount /usr) and similar
echo test >/usr/test2 (inside the guest) will not be 
visible on the host as /vservers/guest1/usr simply is
not there in the host namespace ...

HTH,
Herbert

> --Nirmal